* Libtool reminder about shlibs' usefulness problems: - why need PIC - tools used to build shlibs vs. static libs - gcc can use gld or native ld, ditto for g/as - shlibs points to anywhere on system, what if previous vers. installed => need to dyn. link against correct shlib but that's different than what's actually installed ** ldd: finding what shlibs a binary is linked with? $ ldd /bin/ls libtermcap.so.2 => /lib/libtermcap.so.2 (0x4002c000) libc.so.6 => /lib/libc.so.6 (0x40030000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) AIX ) alias ldd="dump -H" ;; IRIX* ) alias ldd="elfdump -L" ;; HP* ) alias ldd="chatr" ;; OSF1 ) alias ldd="odump -D" ;; # odump -Dl gives brief info libtool to the rescue! ** SRCDIR/configure.in add AC_PROG_LIBTOOL after AC_PROG_CC comment out AC_CANONICAL_HOST (dup use) (See section 4.8 of Autoconf manual) add AC_CONFIG_COMMANDS_PRE( [LTLIBOBJS=`echo $LIBOBJS | sed 's/\.o/\.lo/g'` AC_SUBST(LTLIBOBJS)]) will be run right before AC_OUTPUT is run why? b/c autoconf builds $LIBOBJS while it runs, listing .o files that it needs to build, but libtool wants this list of .o files to be in LTLIBOBJS, and it wants them to have a different extension: .lo, so it can distinguish b/t static and dynamic object files. ** in all Makefile.am's libskey.a -> libskey.la libskey_a -> libskey_la LIBRARIES -> LTLIBRARIES ** SRCDIR/lib/Makefile.am lib_LTLIBRARIES = libskey.la libskey_la_SOURCES = skeylogin.c skeysubr.c md4.c put.c ** SRCDIR/tools/Makefile.am LDADD = ../lib/libskey.la ** next, bootstrapping - rerun bootstrap - automake will copy ltmain.sh script => main driver script for libtool, no need to touch, edit, etc. script gets distributed automatically for you 4984 lines long! ** configure ./configure --{enable,disable}-{static,shared} both enabled so, to build only shared ./configure --disable-static ** running make in BUILDDIR/lib instead of: gcc -c foo.c /bin/sh ../libtool --mode=compile gcc -c foo.c => gcc -c foo.c -fPIC -DPIC -o foo.lo builds libskey.la: wrapper around real shlib .libs/libskey.so ** make in BUILDDIR/tools also uses libtool driver script to dynamically link builds tools/skey as a special wrapper shell script tools/.lib/skey is binary ready to be installed points to shlib that's NOT yet installed won't run directly out of BUILDDIR/tools/.lib - if run "make install", will install shlib + real skey binary, so it'll point to where the shlib is now installed - if run BUILDDIR/tools/skey wrapper script, will execute specially built skey binary in BUILDDIR/tools/.libs/skey, which'll use the shlib just built in SRCDIR/lib/.libs/; will relink a new binary called BUILDDIR/tools/.libs/lt-skey which is shlib-linked to point not to final target of shlib ($INSTALLDIR/lib) but BUILDDIR/lib/.libs. summary: configure, make, and make install "just work magically" * Testing and regression suites Section 16.1 in online Automake manual * SRCDIR/tools/Makefile.am TESTS = test1.sh EXTRA_DIST = $(TESTS) XFAIL_TESTS = test2.sh ... exit 0 to indicate success exit 1 to indicate failure exit 77 to indicate test is not applicable on this system * SRCDIR/tools/test1.sh $ chmod a+rx test1.sh $ cat test1.sh #!/bin/sh # run s/key with sequence 88, key ka9q2, and passphrase "foobar" msg=`echo foobar | ./skey 88 ka9q2 | tail -1` if test "$msg" != "WORN MUD CORK DARK MONT HAP" then exit 1 else exit 0 fi * running test $ make check > PASS: test1.sh > ================== > All 1 tests passed > ================== - runs all tests - reports no. of tests that succeeded, failed, or ignore * misc posted grading criteria for project last one is version 6 (minor changes and clarifications) handout #10: sample final exam course/TA eval forms will be around until midnight, then post list of submissions. register for demo w/ TA demo in which room? grades within 48 hours 48 more hours for any questions/disputes final exam Thu 12/20, 5-7:30pm, ESS-001 * new macro: checking for externals AC_DEFUN(AC_CHECK_EXTERN, [ # store variable name for external definition exname=`echo $1 | tr 'a-z 'A-Z` tmp=HAVE_EXTERN_$exname # this pattern assumes that the complete external definition is on one line pattern="(extern)?.*[[^a-zA-Z0-9_]]$1[[^a-zA-Z0-9_]]?.*\(.*\).*;" AC_EGREP_CPP(${pattern}, [ # include # include ], AC_DEFINE_UNQUOTED($tmp)) ]) * writing new macros - add to acinclude.m4 - rerun aclocal * reaching the limits of capability, limited by C detect the type of an argument: foo(int arg) foo(unsigned int arg) foo(long arg) can detect such things w/ gcc -Wall -Werror, but only works for gcc can do fancy parsing of headers, but need full C parser for this ugly, but works: case $host_os in linux ) AC_DEFINE_UNQUOTED(FOO_FXN_TYPE, "int") ;; * ) # all others AC_DEFINE_UNQUOTED(FOO_FXN_TYPE, "long") ;; esac