diff --git a/.gitignore b/.gitignore index 31eb7b656c..31ac33df19 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,9 @@ *.orig *.rej *.o +*.lo *.a +*.la *.so *.sl *.so.* @@ -49,6 +51,7 @@ config.log /cscope.out /include /lib +/libtool /autom4te.cache /ID /TAGS diff --git a/Makefile.in b/Makefile.in index f46d149905..5095faa5a8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -829,6 +829,7 @@ distclean: clean src/comerr/test/Makefile \ src/config/Makefile \ src/config/Makefile.config \ + src/config/Makefile.libtool \ src/config/Makefile.lwp \ src/config/Makefile.pthread \ src/config/Makefile.shared \ diff --git a/build-tools/.gitignore b/build-tools/.gitignore new file mode 100644 index 0000000000..3443db6c02 --- /dev/null +++ b/build-tools/.gitignore @@ -0,0 +1 @@ +/ltmain.sh diff --git a/configure.ac b/configure.ac index 3eb836fcee..5cbf591562 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,7 @@ AC_PREREQ([2.60]) AC_INIT([OpenAFS], m4_esyscmd([build-tools/git-version .])) AC_CONFIG_AUX_DIR([build-tools]) +AC_CONFIG_MACRO_DIR([src/cf]) AC_CONFIG_SRCDIR([src/config/stds.h]) AM_INIT_AUTOMAKE @@ -24,6 +25,8 @@ AS_IF([test -z "$CFLAGS"], [CFLAGS=" "], []) AC_USE_SYSTEM_EXTENSIONS +LT_INIT + AC_PROG_CC AC_PATH_PROGS([PATH_CPP], [cpp], [${CC-cc} -E], [$PATH:/lib:/usr/ccs/lib]) @@ -148,6 +151,7 @@ src/comerr/Makefile \ src/comerr/test/Makefile \ src/config/Makefile \ src/config/Makefile.config \ +src/config/Makefile.libtool \ src/config/Makefile.lwp \ src/config/Makefile.pthread \ src/config/Makefile.shared \ diff --git a/regen.sh b/regen.sh index c20c4bbb3a..0908683f0d 100755 --- a/regen.sh +++ b/regen.sh @@ -25,6 +25,8 @@ else exit 1 fi +echo "Running libtoolize" +libtoolize -c -f echo "Running autoconf" autoconf echo "Running autoconf for configure-libafs" diff --git a/src/cf/.gitignore b/src/cf/.gitignore new file mode 100644 index 0000000000..94e6f26a7d --- /dev/null +++ b/src/cf/.gitignore @@ -0,0 +1,5 @@ +/libtool.m4 +/ltoptions.m4 +/ltsugar.m4 +/ltversion.m4 +/lt~obsolete.m4 diff --git a/src/config/.gitignore b/src/config/.gitignore index 2bac1d5904..3d3de334de 100644 --- a/src/config/.gitignore +++ b/src/config/.gitignore @@ -5,6 +5,7 @@ /Makefile.*_*[0123456789] /Makefile.*_*[0123456789].in /Makefile.config +/Makefile.libtool /Makefile.lwp /Makefile.shared /Makefile.pthread diff --git a/src/config/Makefile.config.in b/src/config/Makefile.config.in index b8e7ea58b8..99756e9f4b 100644 --- a/src/config/Makefile.config.in +++ b/src/config/Makefile.config.in @@ -25,6 +25,7 @@ prefix=@prefix@ sbindir=@sbindir@ sysconfdir=@sysconfdir@ viceetcdir=@viceetcdir@/ +top_builddir=@top_builddir@ # @@ -62,6 +63,7 @@ LIB_curses = @LIB_curses@ LIB_hcrypto = @LIB_hcrypto@ LIB_roken = @LIB_roken@ LIB_krb5 = @KRB5_LIBS@ +LIBTOOL= @LIBTOOL@ LIBS = @LIBS@ LIB_LIBINTL = @LIB_libintl@ LINUX_KERNEL_PATH = @LINUX_KERNEL_PATH@ @@ -144,7 +146,8 @@ KERNELDIR = ../libafs # COMPILE_ET = ${TOP_OBJDIR}/src/comerr/compile_et RXGEN = ${TOP_OBJDIR}/src/rxgen/rxgen -SHELL = /bin/sh +SHELL = @SHELL@ +LWPTOOL = ${TOP_SRCDIR}/config/lwptool # # "Pretty" build line stuff @@ -225,6 +228,40 @@ SHD_LDFLAGS=$(COMMON_LDFLAGS) $(MODULE_LDFLAGS) $(SHLIB_LDFLAGS) SHD_CCRULE =$(RUN_CC) $(MT_CC) $(SHD_CFLAGS) $(CFLAGS_$(@)) -o $@ -c SHD_CCRULE_NOQ=$(RUN_CC_NOQ) $(MT_CC) $(SHD_CFLAGS) $(CFLAGS_$(@)) -o $@ -c +# Libtool - for objects that are part of pthread-only libraries +LT_CCRULE=$(RUN_CC) $(LIBTOOL) --quiet --mode=compile --tag=CC \ + $(MT_CC) $(PTH_CFLAGS) $(CFLAGS_$(@)) -o $@ -c + +# Libtool - for objects that are built for both pthread and lwp libraries +LTLWP_CCRULE=$(RUN_CC) $(LWPTOOL) --mode compile \ + --lwpcc $(CCOBJ) \ + --mtcc "$(LIBTOOL) --quiet --mode=compile --tag=CC $(MT_CC) $(MT_CFLAGS)" \ + -o $@ \ + -- \ + $(COMMON_CFLAGS) $(MODULE_CFLAGS) $(CFLAGS_$(@)) \ + -c + +LT_LDLIB_lwp=$(RUN_LD) $(LWPTOOL) --mode link \ + --ranlib "$(RANLIB)" \ + --linker "$(AR) crv" \ + -o $@ \ + -- + + +# Use this to link an executable with one or more libtool libraries +LT_LDRULE = $(RUN_LD) $(LIBTOOL) --quiet --mode=link --tag=CC \ + $(MT_CC) $(PTH_LDFLAGS) $(PTH_CFLAGS) \ + $(LDFLAGS_$(@)) -o $@ + +LT_LDRULE_static = $(RUN_LD) $(LIBTOOL) --quiet --mode=link --tag=CC \ + $(MT_CC) -static $(PTH_LDFLAGS) $(PTH_CFLAGS) \ + $(LDFLAGS_$(@)) -o $@ + +LT_INSTALL_DATA=$(LIBTOOL) --quiet --mode=install $(INSTALL_DATA) +LT_INSTALL_PROGRAM=$(LIBTOOL) --quiet --mode=install $(INSTALL_PROGRAM) + +LT_CLEAN=$(RM) -rf .libs *.la *.lo + # Default rules. These will be overriden if the module Makefile specifically # includes a particular type (lwp, pthread, or shared) diff --git a/src/config/Makefile.libtool.in b/src/config/Makefile.libtool.in new file mode 100644 index 0000000000..534809e9d5 --- /dev/null +++ b/src/config/Makefile.libtool.in @@ -0,0 +1,34 @@ +# This Makefile fragment contains rules necessary to build libtool libraries, +# the Makefile rules necessary to use them are all in Makefile.config + +LT_current=0 +LT_revision=0 +LT_age=0 + +# Basic rule to link a shared library. +LT_LDLIB_shlib=$(LIBTOOL) --quiet --mode=link --tag=CC \ + $(MT_CC) -rpath $(libdir) \ + $(PTH_LDFLAGS) $(PTH_CFLAGS) $(LDFLAGS_$(@)) \ + -o $@ \ + -no-undefined \ + -export-symbols $@.sym \ + -version-info=$(LT_current):$(LT_revision):$(LT_age) + + +# Link a static convenience library (contains no PIC code) +LT_LDLIB_static=$(LIBTOOL) --quiet --mode=link --tag=CC \ + $(MT_CC) -static $(LDFLAGS) $(DBG) $(OPTMZ) \ + $(LDFLAGS_$(@)) -o $@ + +# Link a convenience library for use in other libs (contains PIC code) +LT_LDLIB_pic= $(LIBTOOL) --quiet --mode=link --tag=CC \ + $(MT_CC) $(LDFLAGS) $(DBG) $(OPTMZ) \ + $(LDFLAGS_$(@)) -o $@ + +LT_CLEAN=$(RM) -rf .libs *.la *.lo + +.SUFFIXES: .lo + +.m.lo: + $(LT_CCRULE) $< + diff --git a/src/config/Makefile.lwp.in b/src/config/Makefile.lwp.in index 0025968065..0d536d6516 100644 --- a/src/config/Makefile.lwp.in +++ b/src/config/Makefile.lwp.in @@ -3,6 +3,10 @@ AFS_LDFLAGS = $(LWP_LDFLAGS) AFS_CCRULE =$(LWP_CCRULE) AFS_CCRULE_NOQ =$(LWP_CCRULE_NOQ) +.c.lo: + $(LTLWP_CCRULE) $< +%.lo: %.c + $(LTLWP_CCRULE) $< .c.o: $(AFS_CCRULE) $< %.o: %.c diff --git a/src/config/Makefile.pthread.in b/src/config/Makefile.pthread.in index f4af720d7a..471b0d4363 100644 --- a/src/config/Makefile.pthread.in +++ b/src/config/Makefile.pthread.in @@ -10,5 +10,9 @@ AFS_LDRULE_NOQ=$(RUN_LD_NOQ) $(MT_CC) $(AFS_LDFLAGS) $(AFS_CFLAGS) $(LDFLAGS_$(@ $(AFS_CCRULE) $< %.o: %.c $(AFS_CCRULE) $< +.c.lo: + $(LT_CCRULE) $< +%.lo: %.c + $(LT_CCRULE) $< .m.o: $(AFS_CCRULE) $< diff --git a/src/config/lwptool b/src/config/lwptool new file mode 100755 index 0000000000..2cb55e68bd --- /dev/null +++ b/src/config/lwptool @@ -0,0 +1,103 @@ +#!/bin/sh + +# This is a little helper script to build LWP static, and pthread shared and static +# objects from a single source file. We use libtool to do the heavy lifting for +# the pthreaded builds, but build the LWP objects here ourselves. + +lwpcc= +mtcc= +linker= +ranlib= +mode= +object= +done= + +while [ -z "$done" ] && [ $# -gt 0 ] ; do + case "$1" in + --lwpcc) + shift + lwpcc="$1" + shift + ;; + --mtcc) + shift + mtcc="$1" + shift + ;; + --linker) + shift + linker="$1" + shift + ;; + --mode) + shift + mode="$1" + shift + ;; + --ranlib) + shift + ranlib="$1" + shift + ;; + -o) + shift + object="$1" + shift + ;; + --) + shift; + done=yes + ;; + *) + echo "Usage: lwptool --mode compile|link -o --lwpcc --mtcc -- ..." >&2; + exit 1; + ;; + esac +done + +case "$mode" in +compile) + if [ -z "$object" ] || [ -z "$lwpcc" ] || \ + [ -z "$mtcc" ] || [ -z "$mode" ] ; then + echo "Usage: lwptool --mode compile -o " >&2; + echo " --lwpcc " >&2; + echo " --mtcc blah -- ..." >&2; + exit 1 + fi + + lwpobj=`echo $object | sed -e 's/.lo$/.o/'` + lwpobj=".lwp/$lwpobj" + + mkdir .lwp 2>/dev/null + echo $lwpcc -o $lwpobj "$@" + $lwpcc -o $lwpobj "$@" || exit 1 + echo $mtcc -o $object "$@" + $mtcc -o $object "$@" || exit 1 + ;; +link) + if [ -z "$object" ] || [ -z "$linker" ] || \ + [ -z "$ranlib" ] ; then + echo "Usage: l§wptool --mode linker -o " >&2; + echo " --linker " >&2; + echo " --ranlib " >&2; + exit 1 + fi + + # This will go horribly wrong if we ever have objects with shell + # special characters in their names + + objects= + while [ $# -gt 0 ] ; do + arg=$1; + realobject=`echo $arg | sed -e 's/\(.*\).lo/.lwp\/\1.o/'` + objects="$objects $realobject" + shift + done + + rm -f $object 2>/dev/null + echo $linker $object $objects + $linker $object $objects + echo $ranlib $object + $ranlib $object + ;; +esac