From 8225bb45779e4cc1bc64169d3a1ab2ff3d2b6af8 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 30 May 2016 15:16:10 +0200 Subject: [PATCH] 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. --- Makefile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f25d08d65..08d6108d3 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