libtool module

Adriaan de Groot <adridg-FlD2LfDziEhmR6Xm/[email protected]>
Newsgroups gmane.comp.tools.aap.devel
Message-ID <[email protected]>
here's the last (before the deadline!) version of the libtool module. i 
haven't adjusted the name of the did_import variable since yesterday - it 
probably needs a little tweak to work with today's cvs. I'll post the diff to 
default.aap in a moment.

-- 
pub  1024D/FEA2A3FE 2002-06-18 Adriaan de Groot <[email protected]>
            If the door is ajar, can we fill it with door-jamb?
libtoolmod.aap (text/plain, 3.9 KB)
# 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.

@if not _top.get("did_install_libtoolmod"):
  _top.LTLIBSUF=.la
  _top.LTLIBPRE=lib
  _top.LTLIBOBJSUF=.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.

  :print Checking for libtool ...
  @if not _top.get("top_srcdir"):
      _top.top_srcdir=.
  @for libtool in [ os.environ.get("LIBTOOL"), "libtool", _top.get("top_srcdir")+"/libtool", "/bin/false" ] :
      @if libtool:
          @try:
	      :syseval $libtool --version | :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:
		  :print $libtool -- bad version
		  libtool_ver=
          @except:
	      libtool_ver=
  @if not libtool_ver:
      :print Cannot find a proper libtool version (>= 1.5)
      @raise UserError, "bad 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 ltexe
  
  # Bram's version of the compile actions
  :action compile ltobject cpp
    @if not _no.get("target"):
	target = `src2obj(fname)`
    :attr {buildaction = cxx_build} $target	# Need to build with $CXX
    act = $?CXX_COMPILE_ACTION
    @if not act:
	act = $?COMPILE_ACTION	    # be backwards compatible
    @if act:
	:do $act {target = $target} $source
    @else:
	:buildcheck $OPTIMIZE $?DEBUG
	:sys $LIBTOOL --mode=compile --tag=CXX
		  $CXX $CPPFLAGS $?DEFINE $?INCLUDE `cflags_normal()` $CXXFLAGS 
							  -c -o $target $source

  :route cpp ltobject
      compile
  
  :action compile ltobject c
    @if not _no.get("target"):
	target = `src2obj(fname)`
    :attr {buildaction = c_build} $target	# Need to build with $CXX
    act = $?C_COMPILE_ACTION
    @if not act:
	act = $?COMPILE_ACTION	    # be backwards compatible
    @if act:
	:do $act {target = $target} $source
    @else:
	:buildcheck $OPTIMIZE $?DEBUG
	:sys $LIBTOOL --mode=compile --tag=C
		  $CC $CPPFLAGS $?DEFINE $?INCLUDE `cflags_normal()` $CFLAGS 
							  -c -o $target $source
  :route c ltobject
      compile

  # It may be useful to use { filetype= } in :ltlib commands,
  # so that buildltlib can use the correct tag.
  :action buildltlib default
      :sys $libtool --silent --mode=link --tag=CXX
          $CXX $?LDFLAGS $?LTLIBS $?LIBS -o $target $source
  
  
  # This rule is still here so you can use the { filetype= }
  # attribute to select to build a program with libtool or without.
  :action build ltexe default
      :sys $libtool --silent --mode=link --tag=CXX g++ -o $target 
          $source $LDFLAGS $LIBS $LTLIBS
  
  
  
  # :do installtlib
  :action installltlib default
    @for i in var2dictlist(source):
	destltlib = $DESTDIR/$PREFIX/$DLLDIR
	@if i.has_key("installdir"):
	    @destltlib += "/" + i["installdir"] + "/"
	@destltlib = os.path.abspath(destltlib)
	@try:
	    @os.makedirs(destltlib)
	@except OSError:
	    :print $destltlib already exists
	@destltlib = destltlib + "/" + 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
		$ld $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
		$ld $LDFLAGS `cflags_normal()` -o $target $source
		$?LTLIBS $?LIBS

  _top.did_import_libtoolmod=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.