Last active
September 7, 2024 21:12
-
-
Save JayKickliter/3119fce6eee578990e8686aa98aee639 to your computer and use it in GitHub Desktop.
GNU Make: force recompile when flags change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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