# libtool module for the A-A-P build system. # # Written by Adriaan de Groot. Copyright is assigned to # Bram Moolenaar and Stichting NlNet Labs. Released under # the GPL, version 2. There should be a file named COPYING # in the main A-A-P directory with the complete text of # this license. # Last Change: 2005 Dec 27 _top.LTSUF = .la _top.LTPRE = lib _top.LTOBJSUF = .lo # Spend some time searching for the libtool program. # This is very shellscript-ish, since I don't know # any better. I expect libtool is posix-specific. # "libtool15" is used on FreeBSD. @if not _top.get("top_srcdir"): _top.top_srcdir = . @libtool_locations = [ _no.get("LIBTOOL"), os.environ.get("LIBTOOL"), "libtool", os.path.join(_top.get("top_srcdir"), "libtool") ] @libtool_locations.append( "/usr/local/gnu-autotools/bin/libtool" ) @for libtool in libtool_locations : @if libtool: @try: :syseval $libtool --version 2>&1 | :assign libtool_ver @if not libtool_ver: @continue @libtool_ver = re.sub("^[^)]*\) *", "", libtool_ver) @libtool_ver = re.sub("[^0-9.].*", "", libtool_ver) @if libtool_ver >= "1.5": @break @else: :log $libtool -- bad version libtool_ver= @except: libtool_ver= @if not libtool_ver: :error Cannot find a proper libtool version (>= 1.5) LIBTOOL = $libtool # Initially, there is nothing to install. _top.INSTALL_LTLIB = "" # Declare a filetype to indicate that a program can be # built with libtool. :filetype declare ltprogram # Define the compile actions :python define_action("compile", 1, """ @if not _no.get("target"): target = `src2obj(fname)` :attr {buildaction = cxx_build} $target # Need to build with $CXX @if DEFER_ACTION_NAME: :do $DEFER_ACTION_NAME {target = $target} $source @else: :buildcheck $OPTIMIZE $?DEBUG :sys $LIBTOOL --mode=compile --tag=CXX $CXX $CPPFLAGS $?DEFINE $?INCLUDE `cflags_normal()` $CXXFLAGS -c -o $target $source """, outtypes = ["ltobject"], intypes = ["cpp"], defer_var_names = ["CXX_COMPILE_ACTION", "COMPILE_ACTION"]) # :route cpp ltobject {buildaction = cxx_build} # compile :python define_action("compile", 1, """ @if not _no.get("target"): target = `src2obj(fname)` @if DEFER_ACTION_NAME: :do $DEFER_ACTION_NAME {target = $target} $source @else: :buildcheck $OPTIMIZE $?DEBUG :sys $LIBTOOL --mode=compile --tag=C $CC $CPPFLAGS $?DEFINE $?INCLUDE `cflags_normal()` $CFLAGS -c -o $target $source """, outtypes = ["ltobject"], intypes = ["c"], defer_var_names = ["C_COMPILE_ACTION", "COMPILE_ACTION"]) # :route c ltobject # compile # It may be useful to use { filetype= } in :ltlib commands, # so that buildltlib can use the correct tag. :python define_action("buildltlib", 1, """ :sys $LIBTOOL --mode=link --tag=CXX $CXX $?LDFLAGS $?LTLIBS $?LIBS -o $target $source """, outtypes = ["default"], intypes = ["ltobject", "default"]) # This rule is still here so you can use the { filetype= } # attribute to select to build a program with libtool or without. :action build ltprogram default :sys $LIBTOOL --mode=link --tag=CXX g++ -o $target $source $LDFLAGS $?LTLIBS $?LIBS # :do installtlib :action installltlib default @for i in var2dictlist(source): @if i.has_key("installvar") and not i.get("installvar"): @continue destltlib = $DESTDIR/$PREFIX/$DLLDIR @if i.has_key("installdir") and i.has_key("keepdir"): :error Library $i has both {installdir} and {keepdir} set. @if i.has_key("installdir"): @destltlib = os.path.join(destltlib, i["installdir"]) @destltlib = os.path.abspath(destltlib) @try: @os.makedirs(destltlib) @except OSError: :log $destltlib already exists @if i.has_key("keepdir"): @destltlib = os.path.join(destltlib, i["name"]) @else: @destltlib = os.path.join(destltlib, os.path.basename(i["name"])) @destltlib = os.path.abspath(destltlib) :sys $LIBTOOL --mode=install /usr/bin/install `i["name"]` $destltlib :action ltbuild default # $LTLIBS is set, use libtool for linking :sys $LIBTOOL --mode=link --tag=C $CC $LDFLAGS `cflags_normal()` -o $target $source $?LTLIBS $?LIBS :action ltbuild_cxx default # $LTLIBS is set, use libtool for linking :sys $LIBTOOL --mode=link --tag=CXX $CXX $LDFLAGS `cflags_normal()` -o $target $source $?LTLIBS $?LIBS :action installexec ltprogram @for i in var2dictlist(source): @if i.has_key("installvar") and not i.get("installvar"): @continue destltlib = $DESTDIR/$PREFIX/$EXECDIR @if i.has_key("installdir") and i.has_key("keepdir"): :error Application $i has both {installdir} and {keepdir} set. @if i.has_key("installdir"): @destltlib = os.path.join(destltlib, i["installdir"]) @destltlib = os.path.abspath(destltlib) @try: @os.makedirs(destltlib) @except OSError: :log $destltlib already exists @if i.has_key("keepdir"): @destltlib = os.path.join(destltlib, i["name"]) @else: @destltlib = os.path.join(destltlib, os.path.basename(i["name"])) @destltlib = os.path.abspath(destltlib) :sys $LIBTOOL --mode=install /usr/bin/install `i["name"]` $destltlib :rule %.lo : .libs/%.o # vim: set sw=4 sts=4 tw=79 et :