diff options
authorSeebs <seebs@seebs.net>2017-02-03 12:31:40 -0600
committerSeebs <seebs@seebs.net>2017-02-03 12:31:40 -0600
commit1192126f1852dfc13432f0807e577da30ef6f228 (patch)
parentfb3a0eeb7def32aaf2288e1b73573eb2f1862acf (diff)
Makefile.in: Stop rebuilding binaries so much.
Currently, the Makefile rebuilds the binary at every invokation of the command make: $ make cc -pipe -std=gnu99 -Wall -W -Wextra -fPIC -D_LARGEFILE64_SOURCE -D_ATFILE_SOURCE -m64 -DPSEUDO_PREFIX='"/opt"' -DPSEUDO_SUFFIX='""' -DPSEUDO_BINDIR='"bin"' -DPSEUDO_LIBDIR='"lib64"' -DPSEUDO_LOCALSTATEDIR='"var/pseudo"' -DPSEUDO_VERSION='"1.8.1"' -DUSE_MEMORY_DB -DPSEUDO_PASSWD_FALLBACK='""' -DPSEUDO_XATTR_SUPPORT -O2 -g -o bin/pseudo \ pseudo.o pseudo_server.o pseudo_client.o pseudo_ipc.o \ pseudo_db.o pseudo_tables.o pseudo_util.o -lsqlite3 -lpthread -ldl -lpthread cc -pipe -std=gnu99 -Wall -W -Wextra -fPIC -D_LARGEFILE64_SOURCE -D_ATFILE_SOURCE -m64 -DPSEUDO_PREFIX='"/opt"' -DPSEUDO_SUFFIX='""' -DPSEUDO_BINDIR='"bin"' -DPSEUDO_LIBDIR='"lib64"' -DPSEUDO_LOCALSTATEDIR='"var/pseudo"' -DPSEUDO_VERSION='"1.8.1"' -DUSE_MEMORY_DB -DPSEUDO_PASSWD_FALLBACK='""' -DPSEUDO_XATTR_SUPPORT -O2 -g -o bin/pseudodb pseudodb.o \ pseudo_db.o pseudo_tables.o pseudo_util.o pseudo_ipc.o -lsqlite3 -lpthread -ldl -lpthread The fault comes from the $(BIN) directory prerequesite. According to the documention of GNU make(*), directory prerequesites normally go to <order-only-prerequisites>: targets: normal-prerequisites | order-only-prerequisites > Consider an example where your targets are to be placed in a separate > directory, and that directory might not exist before make is run. In > this situation, you want the directory to be created before any > targets are placed into it but, because the timestamps on directories > change whenever a file is added, removed, or renamed, we certainly > don’t want to rebuild all the targets whenever the directory’s > timestamp changes. One way to manage this is with order-only > prerequisites: make the directory an order-only prerequisite on all > the targets. > > OBJDIR := objdir > OBJS := $(addprefix $(OBJDIR)/,foo.o bar.o baz.o) > > $(OBJDIR)/%.o : %.c > $(COMPILE.c) $(OUTPUT_OPTION) $< > > all: $(OBJS) > > $(OBJS): | $(OBJDIR) > > $(OBJDIR): > mkdir $(OBJDIR) > > Now the rule to create the objdir directory will be run, if needed, > before any ‘.o’ is built, but no ‘.o’ will be built because the > objdir directory timestamp changed. This patch fixes this behavior. No binaries are rebuilt when the command make is re-run: $ make make: Nothing to be done for 'all'. *: https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com> Signed-off-by: Seebs <seebs@seebs.net>
2 files changed, 9 insertions, 6 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 0191a8e..ae2a6e9 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,6 @@
+ * (gportay) contributed fix to Makefile (fix binaries rebuild).
* (seebs) handle xattr deletion slightly more carefully.
* (seebs) tag this as 1.8.2
diff --git a/Makefile.in b/Makefile.in
index 0c271b5..76d0518 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -84,7 +84,7 @@ TABLES=table_templates/pseudo_tables.c table_templates/pseudo_tables.h
-test: all $(BIN) $(LIB) $(LOCALSTATE)
+test: all | $(BIN) $(LIB) $(LOCALSTATE)
@./run_tests.sh -v
install-lib: $(LIBPSEUDO)
@@ -106,26 +106,26 @@ $(BIN) $(LIB) $(LOCALSTATE):
pseudo: $(PSEUDO)
-$(PSEUDO): $(BIN) pseudo.o $(SHOBJS) $(DBOBJS) pseudo_client.o pseudo_server.o pseudo_ipc.o
+$(PSEUDO): pseudo.o $(SHOBJS) $(DBOBJS) pseudo_client.o pseudo_server.o pseudo_ipc.o | $(BIN)
pseudo.o pseudo_server.o pseudo_client.o pseudo_ipc.o \
pseudolog: $(PSEUDOLOG)
-$(PSEUDOLOG): $(BIN) pseudolog.o $(SHOBJS) $(DBOBJS) pseudo_client.o pseudo_ipc.o
+$(PSEUDOLOG): pseudolog.o $(SHOBJS) $(DBOBJS) pseudo_client.o pseudo_ipc.o | $(BIN)
$(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -o $(PSEUDOLOG) pseudolog.o pseudo_client.o pseudo_ipc.o \
pseudodb: $(PSEUDODB)
-$(PSEUDODB): $(BIN) pseudodb.o $(SHOBJS) $(DBOBJS) pseudo_ipc.o
+$(PSEUDODB): pseudodb.o $(SHOBJS) $(DBOBJS) pseudo_ipc.o | $(BIN)
$(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -o $(PSEUDODB) pseudodb.o \
libpseudo: $(LIBPSEUDO)
-$(LIBPSEUDO): $(LIB) $(WRAPOBJS) pseudo_client.o pseudo_ipc.o $(SHOBJS)
+$(LIBPSEUDO): $(WRAPOBJS) pseudo_client.o pseudo_ipc.o $(SHOBJS) | $(LIB)
$(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -shared -o $(LIBPSEUDO) \
pseudo_client.o pseudo_ipc.o \
@@ -168,7 +168,7 @@ offsets32:
$(CC) -m64 -o offsets64 offsets.c
-$(PSEUDO_PROFILE): $(BIN) pseudo_profile
+$(PSEUDO_PROFILE): pseudo_profile | $(BIN)
cp pseudo_profile $(BIN)
pseudo_profile: Makefile pseudo_profile.c tables wrappers