Unlink static libraries before rebuilding them.
authorNoah Misch <noah@leadboat.com>
Sun, 1 Mar 2015 18:05:23 +0000 (13:05 -0500)
committerNoah Misch <noah@leadboat.com>
Sun, 1 Mar 2015 18:05:23 +0000 (13:05 -0500)
When the library already exists in the build directory, "ar" preserves
members not named on its command line.  This mattered when, for example,
a "configure" rerun dropped a file from $(LIBOBJS).  libpgport carried
the obsolete member until "make clean".  Back-patch to 9.0 (all
supported versions).

src/Makefile.shlib
src/common/Makefile
src/port/Makefile

index 739033f78e83609a952b21696ba96c96b65f3338..f96c7092d8a34464cd7217c3d6220462e01a049b 100644 (file)
@@ -296,6 +296,7 @@ all-shared-lib: $(shlib)
 
 ifndef haslibarule
 $(stlib): $(OBJS) | $(SHLIB_PREREQS)
+   rm -f $@
    $(LINK.static) $@ $^
    $(RANLIB) $@
 endif #haslibarule
@@ -337,6 +338,7 @@ else # PORTNAME == aix
 
 # AIX case
 $(shlib) $(stlib): $(OBJS) | $(SHLIB_PREREQS)
+   rm -f $(stlib)
    $(LINK.static) $(stlib) $^
    $(RANLIB) $(stlib)
    $(MKLDEXPORT) $(stlib) >$(exports_file)
@@ -356,6 +358,7 @@ $(shlib): $(OBJS) | $(SHLIB_PREREQS)
    $(CC) $(CFLAGS)  -shared -o $@  $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) $(LDAP_LIBS_BE)
 
 $(stlib): $(OBJS) | $(SHLIB_PREREQS)
+   rm -f $@
    $(LINK.static) $@ $^
    $(RANLIB) $@
 
index 372a21b99dce4b3e172cea61fe5ab0a94d97287d..c71415ef17d86fada36bcc0d51d56c18e758bdb7 100644 (file)
@@ -43,6 +43,7 @@ uninstall:
    rm -f '$(DESTDIR)$(libdir)/libpgcommon.a'
 
 libpgcommon.a: $(OBJS_FRONTEND)
+   rm -f $@
    $(AR) $(AROPT) $@ $^
 
 #
@@ -50,6 +51,7 @@ libpgcommon.a: $(OBJS_FRONTEND)
 #
 
 libpgcommon_srv.a: $(OBJS_SRV)
+   rm -f $@
    $(AR) $(AROPT) $@ $^
 
 # Because this uses its own compilation rule, it doesn't use the
index a0908bf5e3d45a82ca2b4b60f23bad978cdbf7f4..a862d5186c6ebdc2ecd330441a6a90bcc4e187ec 100644 (file)
@@ -51,6 +51,7 @@ uninstall:
    rm -f '$(DESTDIR)$(libdir)/libpgport.a'
 
 libpgport.a: $(OBJS)
+   rm -f $@
    $(AR) $(AROPT) $@ $^
 
 # thread.o needs PTHREAD_CFLAGS (but thread_srv.o does not)
@@ -61,6 +62,7 @@ thread.o: CFLAGS+=$(PTHREAD_CFLAGS)
 #
 
 libpgport_srv.a: $(OBJS_SRV)
+   rm -f $@
    $(AR) $(AROPT) $@ $^
 
 # Because this uses its own compilation rule, it doesn't use the