]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD/MEDIUM: force a full rebuild if some build options change
authorWilly Tarreau <w@1wt.eu>
Mon, 30 May 2016 13:16:10 +0000 (15:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 7 Jun 2016 12:45:44 +0000 (14:45 +0200)
We now instrument the makefile to keep a copy of previous build options.
The goal is to ensure that we'll rebuild everything when build options
change. The options that are watched are TARGET, VERBOSE_CFLAGS, and
BUILD_OPTIONS. These ones are copied into a file ".build_opts" and
compared to the new ones upon each build. This file is referenced in
the DEP variable which all .o files depend on, and it depends on the
code which updates it only upon changes. This ensures that a new file
is regenerated and detected upon change and that everything is rebuilt.

Makefile

index f25d08d656b98bccd8e7644393a0ac5656bd63cb..08d6108d3178047ce1db03e13428350a5b61f68a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -770,7 +770,10 @@ 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)
+DEP = $(INCLUDES) .build_opts
+
+# Used only to force a rebuild if some build options change
+.build_opts: $(shell rm -f .build_opts.new; echo \'$(TARGET) $(BUILD_OPTIONS) $(VERBOSE_CFLAGS)\' > .build_opts.new; if cmp -s .build_opts .build_opts.new; then rm -f .build_opts.new; else mv -f .build_opts.new .build_opts; fi)
 
 haproxy: $(OBJS) $(OPTIONS_OBJS) $(EBTREE_OBJS)
        $(LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
@@ -800,12 +803,12 @@ src/haproxy.o:    src/haproxy.c $(DEP)
              -DBUILD_OPTIONS='"$(strip $(BUILD_OPTIONS))"' \
               -c -o $@ $<
 
-src/haproxy-systemd-wrapper.o: src/haproxy-systemd-wrapper.c
+src/haproxy-systemd-wrapper.o: src/haproxy-systemd-wrapper.c $(DEP)
        $(CC) $(COPTS) \
              -DSBINDIR='"$(strip $(SBINDIR))"' \
               -c -o $@ $<
 
-src/dlmalloc.o: $(DLMALLOC_SRC)
+src/dlmalloc.o: $(DLMALLOC_SRC) $(DEP)
        $(CC) $(COPTS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
 
 install-man:
@@ -837,7 +840,7 @@ uninstall:
        rm -f "$(DESTDIR)$(SBINDIR)"/haproxy-systemd-wrapper
 
 clean:
-       rm -f *.[oas] src/*.[oas] ebtree/*.[oas] haproxy test
+       rm -f *.[oas] src/*.[oas] ebtree/*.[oas] haproxy test .build_opts .build_opts.new
        for dir in . src include/* doc ebtree; do rm -f $$dir/*~ $$dir/*.rej $$dir/core; done
        rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz
        rm -f haproxy-$(VERSION) haproxy-$(VERSION)$(SUBVERS) nohup.out gmon.out