Created
March 17, 2016 08:14
-
-
Save waveacme/e45914e53e7499a43be5 to your computer and use it in GitHub Desktop.
general Makefile
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
CC=gcc | |
CFLAGS=-Wall -IDIR | |
LDFLAGS=-LDIR -lfoo | |
TARGET= a.out | |
#SOURCES=bar.c | |
SOURCES=$(wildcard *.c) | |
OBJECTS=$(SOURCES:.c=.o) | |
all: $(TARGET) | |
$(TARGET): $(OBJECTS) | |
$(CC) $^ -o $@ $(LDFLAGS) | |
clean: | |
-rm $(TARGET) *.o *.d *.d.* | |
.PHONY: clean | |
-include $(SOURCES:.c=.d) | |
%.d: %.c | |
@set -e; rm -f $@; \ | |
$(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \ | |
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