From 26d694fe4f485e06aeb7207e88c463c8b1a65964 Mon Sep 17 00:00:00 2001 From: Glenn McGrath Date: Mon, 13 Jun 2011 17:31:57 -0400 Subject: [PATCH] Use libtool to build dynamic library --- configure.ac | 6 +++--- lib/Makefile.in | 55 +++++++++++++++++++++++++++++++++--------------------- libtar/Makefile.in | 20 ++++++++++++-------- 3 files changed, 49 insertions(+), 32 deletions(-) diff --git a/configure.ac b/configure.ac index f2d5ca1..087e19c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl ### Normal initialization. ###################################### AC_INIT([libtar], [1.2.11]) -AC_PREREQ([2.57]) +AC_PREREQ([2.61]) AC_CONFIG_AUX_DIR([autoconf]) AC_CONFIG_HEADERS([config.h]) AC_COPYRIGHT([[ @@ -28,15 +28,15 @@ AC_SUBST([MKDIR]) dnl ### Check for compiler et al. ################################### +AC_USE_SYSTEM_EXTENSIONS AC_PROG_CC -AC_PROG_RANLIB +AC_PROG_LIBTOOL AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET dnl ### Compiler characteristics. ################################## -AC_AIX AC_C_CONST diff --git a/lib/Makefile.in b/lib/Makefile.in index 969fcf5..3509c7a 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -3,6 +3,7 @@ ### Path settings srcdir = @srcdir@ top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ @@ -15,6 +16,8 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ @ENCAP_DEFS@ +SHELL = @SHELL@ + ### Installation programs and flags INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ -s @@ -24,6 +27,7 @@ MKDIR = @MKDIR@ ### Compiler and link options CC = @CC@ +LIBTOOL = @LIBTOOL@ CPPFLAGS = -I. \ -I.. \ -I${srcdir} \ @@ -33,7 +37,7 @@ CPPFLAGS = -I. \ CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ -LIBOBJS = @LIBOBJS@ +LTLIBOBJS = @LTLIBOBJS@ RANLIB = @RANLIB@ @SET_MAKE@ VPATH = @srcdir@:@top_srcdir@/compat:../listhash @@ -41,24 +45,26 @@ VPATH = @srcdir@:@top_srcdir@/compat:../listhash ### Makefile rules - no user-servicable parts below -LIBTAR_OBJS = append.o \ - block.o \ - decode.o \ - encode.o \ - extract.o \ - handle.o \ - libtar_hash.o \ - libtar_list.o \ - output.o \ - util.o \ - wrapper.o +LIBTAR_OBJS = append.lo \ + block.lo \ + decode.lo \ + encode.lo \ + extract.lo \ + handle.lo \ + libtar_hash.lo \ + libtar_list.lo \ + output.lo \ + util.lo \ + wrapper.lo LIBTAR_HDRS = ../config.h \ ${top_srcdir}/compat/compat.h \ ${srcdir}/libtar.h \ ${srcdir}/internal.h \ ../listhash/libtar_listhash.h -LIBTAR_LIBS = ./libtar.a -ALL = libtar.a +LIBTAR_LIBS = ./libtar.la +ALL = libtar.la +LDFLAGS = @LDFLAGS@ +CFLAGS = @CFLAGS@ DISTCLEANFILES = ../listhash/libtar_listhash.h \ ../listhash/libtar_list.c \ @@ -69,24 +75,31 @@ all: ${ALL} .PHONY: clean distclean install -libtar.a: ${LIBTAR_OBJS} ${LIBOBJS} - ${AR} rc libtar.a ${LIBTAR_OBJS} ${LIBOBJS} - ${RANLIB} libtar.a +libtar.la: ${LIBTAR_OBJS} ${LTLIBOBJS} + $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o libtar.la $(LIBTAR_OBJS) $(LTLIBOBJS) -rpath $(libdir) +# ${AR} rc libtar.a ${LIBTAR_OBJS} ${LIBOBJS} +# ${RANLIB} libtar.a ${LIBTAR_OBJS}: ${LIBTAR_HDRS} -.c.o: - ${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $< +%.lo: $(srcdir)/%.c + $(LIBTOOL) --mode=compile ${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $< + +%.lo: listhash/%.c + $(LIBTOOL) --mode=compile ${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $< + +%.lo: compat/%.c + $(LIBTOOL) --mode=compile ${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $< clean: - rm -f *~ *.o ${ALL} core + rm -rf *~ *.o $(LIBTAR_OBJS) ${ALL} core .libs $(LTLIBOBJS) distclean: clean rm -f Makefile ${DISTCLEANFILES} install: ${ALL} ${MKDIR} ${DESTDIR}${libdir} - ${INSTALL_DATA} libtar.a ${DESTDIR}${libdir} + $(LIBTOOL) --mode=install ${INSTALL_DATA} libtar.la ${DESTDIR}${libdir} ${MKDIR} ${DESTDIR}${includedir} ${INSTALL_DATA} ${srcdir}/libtar.h ${DESTDIR}${includedir} ${INSTALL_DATA} ../listhash/libtar_listhash.h ${DESTDIR}${includedir} diff --git a/libtar/Makefile.in b/libtar/Makefile.in index 00de44e..7c6f1bc 100644 --- a/libtar/Makefile.in +++ b/libtar/Makefile.in @@ -3,6 +3,7 @@ ### Path settings srcdir = @srcdir@ top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ @@ -15,6 +16,8 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ @ENCAP_DEFS@ +SHELL = @SHELL@ + ### Installation programs and flags INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ -s @@ -24,6 +27,7 @@ MKDIR = @MKDIR@ ### Compiler and link options CC = @CC@ +LIBTOOL = @LIBTOOL@ CPPFLAGS = -I.. \ -I../lib \ -I../listhash \ @@ -32,7 +36,7 @@ CPPFLAGS = -I.. \ @CPPFLAGS@ CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ +LIBS = @LIBS@ -ltar LIBOBJS = @LIBOBJS@ RANLIB = @RANLIB@ @SET_MAKE@ @@ -41,12 +45,12 @@ VPATH = @srcdir@ ### Makefile rules - no user-servicable parts below -LIBTAR_OBJS = libtar.o +LIBTAR_OBJS = libtar.lo LIBTAR_HDRS = ../config.h \ ${top_srcdir}/compat/compat.h \ ${top_srcdir}/lib/libtar.h \ ../listhash/libtar_listhash.h -LIBTAR_LIBS = ../lib/libtar.a +LIBTAR_LIBS = $(top_builddir)/lib ALL = libtar @@ -55,20 +59,20 @@ all: ${ALL} .PHONY: clean distclean install libtar: ${LIBTAR_OBJS} ${LIBTAR_LIBS} ${LIBTAR_HDRS} - ${CC} ${CFLAGS} ${LDFLAGS} -o libtar libtar.o ${LIBTAR_LIBS} ${LIBS} + $(LIBTOOL) --mode=link ${CC} ${CFLAGS} ${LDFLAGS} -o libtar $(LIBTAR_OBJS) -L${LIBTAR_LIBS} ${LIBS} ${LIBTAR_OBJS}: ${LIBTAR_HDRS} -.c.o: - ${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $< +%.lo: %.c + $(LIBTOOL) --mode=compile ${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $< clean: - rm -f *~ *.o ${ALL} core + rm -rf *~ *.o ${ALL} $(LIBTAR_OBJS) core .libs distclean: clean rm -f Makefile install: ${ALL} ${MKDIR} ${DESTDIR}${bindir} - ${INSTALL_PROGRAM} libtar ${DESTDIR}${bindir} + $(LIBTOOL) --mode=install ${INSTALL_PROGRAM} libtar ${DESTDIR}${bindir} -- 2.11.4.GIT