Skip to content

Instantly share code, notes, and snippets.

@JayKickliter
Last active May 7, 2017 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayKickliter/3119fce6eee578990e8686aa98aee639 to your computer and use it in GitHub Desktop.
Save JayKickliter/3119fce6eee578990e8686aa98aee639 to your computer and use it in GitHub Desktop.
GNU Make: force recompile when flags change
# Make OBJS depend on CPP/C/CXX/LD flags
$(OBJS): $(BUILDDIR)/flags.txt
# Creates a new flags.txt file when flags change
# make will detect this change and force a rebuild of
# all the sources
.PHONY: flags
$(BUILDDIR)/flags.txt: flags
$(Q){ \
TMP=`mktemp`; \
echo 'CPPFLAGS: $(CPPFLAGS)' >> $$TMP; \
echo 'CFLAGS: $(CFLAGS)' >> $$TMP; \
echo 'CXXFLAGS: $(CXXFLAGS)' >> $$TMP; \
echo 'LDFLAGS: $(LDFLAGS)' >> $$TMP; \
cmp -s $$TMP $@ || mv -f $$TMP $@; \
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment