Created
January 9, 2018 05:05
-
-
Save hlecuanda/43672dc37fe6b8f1bf75a6729e5213f1 to your computer and use it in GitHub Desktop.
Evermake: aself-regenerating portable makefile that makes itself when new sources are added in order to include them, no coding required
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
LD = gcc | |
SHELL = /bin/sh | |
mainx : Makefile | |
$(LD) -o mainx *.o | |
clean :: | |
-$(RM) mainx | |
Makefile : *.c | |
@sed -e '/^### Do Not edit this line$$/,$$d' Makefile \ | |
> MMM.$$$$ && mv MMM.$$$$ Makefile | |
@echo "### Do Not edit this line" >> Makefile | |
@echo "### Everything below is auto-generated" >> Makefile | |
@for f in *.c ; do echo ===$$f=== 1>&2 ; ff=`basename $$f .c`.o ; \ | |
gcc -MM $$f ; echo ""; echo "mainx : $$ff" ; echo "$$ff : $$f" ; \ | |
echo ' $$(CC) $$(CFLAGS) -c '"$$f" ; echo "" ; echo "clean ::" ; \ | |
echo ' -$$(RM) '"$$ff" ; echo "" ; done >> Makefile | |
@$(MAKE) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment