Skip to content

Instantly share code, notes, and snippets.

@hlecuanda
Created January 9, 2018 05:05
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 hlecuanda/43672dc37fe6b8f1bf75a6729e5213f1 to your computer and use it in GitHub Desktop.
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
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