BUILD/MEDIUM: rebuild everything when an include file is changed

Some users tend to get caught by incorrect builds when they try patches
that modify some include file after they forget to run "make clean".
While we can't blame users who are not developers, forcing developers
to rely on a painful autodepend is not nice either and will cause them
to test their changes less often. Here we propose a reasonable tradeoff.
This patch introduces a new "INCLUDES" variable which enumerates all
the ".h" files and sets them as a build dependency for all ".o" files.
This list is then copied into a "DEP" variable which can safely be
overridden if desired. This way by default all .c files are rebuilt if
any include file changes. This is the safe method for all users. And
developers can simply add "DEP=" to their quick build scripts to keep
the old fast and efficient behaviour.
This commit is contained in:
Willy Tarreau 2016-05-30 13:39:32 +02:00
parent 6fc340ff07
commit b26835db3b
1 changed files with 8 additions and 3 deletions

View File

@ -49,6 +49,7 @@
# ARCH may be useful to force build of 32-bit binary on 64-bit systems
# CFLAGS is automatically set for the specified CPU and may be overridden.
# LDFLAGS is automatically set to -g and may be overridden.
# DEP may be cleared to ignore changes to include files during development
# SMALL_OPTS may be used to specify some options to shrink memory usage.
# DEBUG may be used to set some internal debugging options.
# ADDINC may be used to complete the include path in the form -Ipath.
@ -767,6 +768,10 @@ WRAPPER_OBJS = src/haproxy-systemd-wrapper.o
# Not used right now
LIB_EBTREE = $(EBTREE_DIR)/libebtree.a
# Used only for forced dependency checking. May be cleared during development.
INCLUDES = $(wildcard include/*/*.h ebtree/*.h)
DEP = $(INCLUDES)
haproxy: $(OBJS) $(OPTIONS_OBJS) $(EBTREE_OBJS)
$(LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
@ -779,13 +784,13 @@ $(LIB_EBTREE): $(EBTREE_OBJS)
objsize: haproxy
@objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
%.o: %.c
%.o: %.c $(DEP)
$(CC) $(COPTS) -c -o $@ $<
src/trace.o: src/trace.c
src/trace.o: src/trace.c $(DEP)
$(CC) $(TRACE_COPTS) -c -o $@ $<
src/haproxy.o: src/haproxy.c
src/haproxy.o: src/haproxy.c $(DEP)
$(CC) $(COPTS) \
-DBUILD_TARGET='"$(strip $(TARGET))"' \
-DBUILD_ARCH='"$(strip $(ARCH))"' \