Re: [A-a-p-user] (tutorial) Changing the type of a program
Brought to you by:
vimboss
From: Bram M. <Br...@mo...> - 2003-07-29 18:33:57
|
Adriaan de Groot wrote: > [What with all of Bram's help, I've discovered some nice aap tidbits > that it'd be nice to see in the tutorial. So here's a stab at some > text.] Thanks. Do you also see the spot where this fits best? > The final build action will link hello against these libraries and all is > well. However, not all libraries are either static or shared. Many libraries > are also available as libtool libraries (identified by their .la extensions) > and the standard linker does not know how to deal with them. The following > recipe will fail: > > LIBS=libmyltlib.la > :program hello : hello.c To avoid people using $LIBS in a wrong way (when they skip reading the text), I would suggest adding a comment: "# This doesn't work!". Following text then explains how to make it work. But the $LIBS variable is supposed to only contain "-lname" arguments, nothing else. Copied from the docs: $LIBS user Arguments for linking, after the object files. Convention: Always use "-lname", the tools will translate it into the flags that the linker actually uses. I suggest you use another variable to specify the arguments for libtool. $LIBTOOLLIBS is a bit long. $LTLIBS? Despite your well written explanation, we can make the default behavior simpler: When the user assigns something to $LIBTOOLLIBS the default link argument can use $LIBTOOL instead of $LD: LIBTOOL ?= libtool --silent --mode=link --tag=CXX :action build default [...] @if _no.get("LIBTOOLLIBS"): :sys $LIBTOOL $ld -o $target $source $?LIBS $LIBTOOLLIBS @else: :sys $ld $LDFLAGS `cflags_normal()` $flags -o $target $source $?LIBS Well, something like that. Would that do what people expect? > [Note that in my testing, this recipe (similar to the solaris one): > > :action build solarisexe default > :do build { filetype=default } $source > :sys brandelf -f 6 $target > > :program t { filetype=solarisexe } : t.c > > doesn't quite work as expected, since brandelf is invoked twice, like so: > > Aap: cc -MM -MG t.c > build-FreeBSD4_8_STABLE/t.c.aap > Aap: cc -O2 -c -o build-FreeBSD4_8_STABLE/t.o t.c > Aap: cc -O2 -o t build-FreeBSD4_8_STABLE/t.o > Aap: brandelf -f 6 t > Aap: brandelf -f 6 t You need to put the different "filetype" attribute on the target, not on the action name: :action build solarisexe default :do build {target = $+target {filetype=default}} $source :sys brandelf -f 6 $target Strange that it doesn't happen recursively though... > The aap -v output, BTW, doesn't seem to report the names of the build rules > used properly, since I get > > Aap: Using default for build from object > Aap: Do build default > > even when I can see that it's using the non-default rule.] Well, you specified the "default" filetype is to be used! OK, so mentioning the target filetype is also useful. I'll try making the message clearer. -- Contrary to popular belief, it's often your clothing that gets promoted, not you. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html /// |