Last active
December 5, 2016 05:03
-
-
Save jocke-l/8c0217c6257bd3a7b6a5 to your computer and use it in GitHub Desktop.
Makefile
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
# This Makefile uses gcc's -MM-flag to scan your source tree for dependencies | |
# Other compilers may or may not have this feature. Adjust the DEPS | |
# definition accordingly. | |
CC := gcc | |
RM := rm | |
CFLAGS := -pedantic -Wall -Wextra -g | |
LIBS := | |
BIN := | |
SRCS := $(wildcard *.c) | |
OBJS := $(patsubst %.c, %.o, $(SRCS)) | |
CLEAN_TARGETS := $(addprefix __clean__, $(OBJS) $(BIN)) | |
# Haxx for making dynamic targets for dependencies | |
DEPS := $(shell $(CC) -MM $(SRCS)) | |
.PHONY: all clean $(CLEAN_TARGETS) | |
.SILENT: all $(CLEAN_TARGETS) $(OBJS) | |
all: $(OBJS) | |
echo -e 'CC\t$(BIN)' | |
$(CC) $(OBJS) -o $(BIN) $(LIBS) | |
clean: $(CLEAN_TARGETS) | |
$(CLEAN_TARGETS): __clean__%: | |
echo -e 'RM\t$*' | |
$(RM) -f $* | |
%.o: | |
echo -e 'CC\t$@' | |
$(CC) -c $(CFLAGS) $*.c | |
# Dependencies | |
$(DEPS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment