$NetBSD: patch-av,v 1.5 2004/11/19 14:54:55 jlam Exp $ --- modules/pam_tally/Makefile.orig 2001-06-27 02:20:43.000000000 -0400 +++ modules/pam_tally/Makefile @@ -20,6 +20,7 @@ LIBSRC = $(TITLE).c LIBOBJ = $(TITLE).o LIBOBJD = $(addprefix dynamic/,$(LIBOBJ)) LIBOBJS = $(addprefix static/,$(LIBOBJ)) +LIBOBJLA = $(LIBOBJ:.o=.lo) APPSRC = $(TITLE)_app.c APPOBJ = $(TITLE)_app.o @@ -32,6 +33,8 @@ dynamic/%.o : %.c static/%.o : %.c $(CC) $(CFLAGS) $(STATIC) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ +%.lo : %.c + $(SHLIBTOOL) --mode=compile $(CC) $(CFLAGS) $(LTCFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< ifdef DYNAMIC LIBSHARED = $(TITLE).so @@ -41,12 +44,26 @@ ifdef STATIC LIBSTATIC = lib$(TITLE).o endif +ifdef LIBTOOL +LIBLIBTOOL = $(TITLE).la +endif + APPLICATION = $(TITLE) APPMODE = 755 ####################### don't edit below ####################### -all: dirs $(LIBSHARED) $(LIBSTATIC) register $(APPLICATION) +ifdef DYNAMIC +MODULES_TO_BUILD+= $(LIBSHARED) +endif +ifdef STATIC +MODULES_TO_BUILD+= $(LIBSTATIC) +endif +ifdef LIBTOOL +MODULES_TO_BUILD+= $(LIBLIBTOOL) +endif + +all: dirs $(MODULES_TO_BUILD) register $(APPLICATION) dirs: ifdef DYNAMIC @@ -55,6 +72,9 @@ endif ifdef STATIC $(MKDIR) ./static endif +ifdef LIBTOOL + $(MKDIR) ./static +endif register: ifdef STATIC @@ -82,22 +102,38 @@ $(APPLICATION): $(APPOBJS) $(TITLE).c $(CC) $(CFLAGS) -o $@ $(APPOBJS) $(LOADLIBES) endif +ifdef LIBTOOL +$(LIBOBJLA): $(LIBSRC) + +$(LIBLIBTOOL): $(LIBOBJLA) + $(SHLIBTOOL) --mode=link $(CC) $(LDFLAGS) $(LIBOBJLA) -o $@ -module -avoid-version -rpath $(FAKEROOT)$(SECUREDIR) + +$(APPLICATION): $(APPOBJS) $(TITLE).c + $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS) -o $@ $(APPOBJS) $(LOADLIBES) +endif + install: all $(MKDIR) $(FAKEROOT)$(SECUREDIR) ifdef DYNAMIC $(INSTALL) -m $(SHLIBMODE) $(LIBSHARED) $(FAKEROOT)$(SECUREDIR) endif +ifdef LIBTOOL + $(SHLIBTOOL) --mode=install $(INSTALL) $(LIBLIBTOOL) $(FAKEROOT)$(SECUREDIR) +endif $(MKDIR) $(FAKEROOT)$(SUPLEMENTED) $(INSTALL) -m $(APPMODE) $(APPLICATION) $(FAKEROOT)$(SUPLEMENTED) remove: rm -f $(FAKEROOT)$(SECUREDIR)/$(TITLE).so +ifdef LIBTOOL + $(SHLIBTOOL) --mode=uninstall rm $(FAKEROOT)$(SECUREDIR)/$(TITLE).la +endif rm -f $(FAKEROOT)$(SUPLEMENTED)/$(TITLE) clean: - rm -f $(LIBOBJD) $(LIBOBJS) $(APPOBJD) $(APPOBJS) core *~ - rm -f *.a *.o *.so *.bak dynamic/* static/* $(APPLICATION) - rm -rf dynamic static + rm -f $(LIBOBJD) $(LIBOBJS) $(LIBOBJLA) $(APPOBJD) $(APPOBJS) core *~ + rm -f *.a *.la *.lo *.o *.so *.bak dynamic/* static/* $(APPLICATION) + rm -rf dynamic static .libs .c.o: $(CC) $(CFLAGS) -c $<