Last active
December 15, 2017 01:50
-
-
Save tisyang/74f349a8db718caf794e8f9c0681c6c6 to your computer and use it in GitHub Desktop.
Simple makefile template
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
TARGET = prog | |
LIBS = -lm | |
CC = gcc | |
CFLAGS = -g -Wall | |
.PHONY: default all clean | |
default: $(TARGET) | |
all: default | |
OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c)) | |
HEADERS = $(wildcard *.h) | |
%.o: %.c $(HEADERS) | |
$(CC) $(CFLAGS) -c $< -o $@ | |
.PRECIOUS: $(TARGET) $(OBJECTS) | |
$(TARGET): $(OBJECTS) | |
$(CC) $(OBJECTS) -Wall $(LIBS) -o $@ | |
clean: | |
-rm -f *.o | |
-rm -f $(TARGET) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment