From: Willy Tarreau Date: Mon, 30 May 2016 13:16:10 +0000 (+0200) Subject: BUILD/MEDIUM: force a full rebuild if some build options change X-Git-Tag: v1.7-dev4~81 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8225bb45779e4cc1bc64169d3a1ab2ff3d2b6af8;p=thirdparty%2Fhaproxy.git BUILD/MEDIUM: force a full rebuild if some build options change 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. --- diff --git a/Makefile b/Makefile index f25d08d656..08d6108d31 100644 --- 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