Last active
August 8, 2018 06:52
-
-
Save xieyunzi/9666aea9af17eacee3d8c7f1fe1efb35 to your computer and use it in GitHub Desktop.
makefile for c
This file contains hidden or 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
CFLAGS= -I../include | |
# https://stackoverflow.com/questions/22551167/using-a-result-of-shells-find-as-a-target-in-a-makefile | |
sources = $(shell find . -maxdepth 1 -name '*.c') | |
include $(sources:.c=.d) | |
# http://www.microhowto.info/howto/automatically_generate_makefile_dependencies.html | |
# generate dependencies | |
%.d: %.c | |
@set -e; rm -f $@; \ | |
$(CC) -MM $(CFLAGS) $< > $@.$$$$; \ | |
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ | |
rm -f $@.$$$$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment