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:07:00 +0000 (13:07 -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/port/Makefile

index 21ae9b37a11778f1250054e15f9871eaf89b07f6..e728801f5fc858ad5a6a5368da6dc373be062d65 100644 (file)
@@ -318,6 +318,7 @@ all-shared-lib: $(shlib)
 
 ifndef haslibarule
 $(stlib): $(OBJS) | $(SHLIB_PREREQS)
+   rm -f $@
    $(LINK.static) $@ $^
    $(RANLIB) $@
 endif #haslibarule
@@ -360,6 +361,7 @@ else # PORTNAME == aix
 
 # AIX case
 $(shlib) $(stlib): $(OBJS) | $(SHLIB_PREREQS)
+   rm -f $(stlib)
    $(LINK.static) $(stlib) $^
    $(RANLIB) $(stlib)
    $(MKLDEXPORT) $(stlib) >$(exports_file)
@@ -380,6 +382,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 bace576d80356da0a1077b5c82303ff36cc530b1..67677ae8937c5ccd28633b402c6ec7d8435c2a6e 100644 (file)
@@ -50,6 +50,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)
@@ -60,6 +61,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