Created
January 20, 2016 22:53
-
-
Save mwilliammyers/1dfb20ad63b3aae3c24f 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 ?= target | |
LIBS = -lm | |
CC = gcc | |
CFLAGS = -g -Wall | |
.PHONY: default all test clean | |
default: $(TARGET) | |
all: default test | |
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 $@ | |
test: | |
./$(TARGET) | |
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