Unlink static libraries before rebuilding them.
authorNoah Misch
Sun, 1 Mar 2015 18:05:23 +0000 (13:05 -0500)
committerNoah Misch
Sun, 1 Mar 2015 18:06:39 +0000 (13:06 -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 ac095374295fdd16694b064a3ddfd120d33d2f05..4ca894a29328738845233fb8e8713008c8f47abf 100644 (file)
@@ -316,6 +316,7 @@ all-shared-lib: $(shlib)
 
 ifndef haslibarule
 $(stlib): $(OBJS) | $(SHLIB_PREREQS)
+   rm -f $@
    $(LINK.static) $@ $^
    $(RANLIB) $@
 endif #haslibarule
@@ -357,6 +358,7 @@ else # PORTNAME == aix
 
 # AIX case
 $(shlib) $(stlib): $(OBJS) | $(SHLIB_PREREQS)
+   rm -f $(stlib)
    $(LINK.static) $(stlib) $^
    $(RANLIB) $(stlib)
    $(MKLDEXPORT) $(stlib) >$(exports_file)
@@ -377,6 +379,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 b5889f7380f7a035cbe73b3a641ab70b8216a210..e8fb1ec86bbf3ac8de1d779f5cc1c4ecad2aac39 100644 (file)
@@ -42,6 +42,7 @@ uninstall:
    rm -f '$(DESTDIR)$(libdir)/libpgcommon.a'
 
 libpgcommon.a: $(OBJS_FRONTEND)
+   rm -f $@
    $(AR) $(AROPT) $@ $^
 
 #
@@ -49,6 +50,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 a032acca1c26be025aef180e9f52911790dc2fbc..3a26006b7c1a2031fc374259d5db1b856825ecee 100644 (file)
@@ -52,6 +52,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)
@@ -62,6 +63,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