Created
February 17, 2014 23:04
-
-
Save fmela/9061043 to your computer and use it in GitHub Desktop.
C program makefile boilerplate
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
SOURCES = $(wildcard *.c) | |
HEADERS = $(wildcard *.h) | |
OBJECTS = $(SOURCES:%.c=%.o) | |
PROGRAM = $(shell basename `pwd`) | |
CC := $(shell which clang || which gcc) | |
CFLAGS = -Wall -W -O | |
LIBS = | |
LDFLAGS = $(LIBS:%=-l%) | |
$(PROGRAM) : $(OBJECTS) | |
$(CC) $(LDFLAGS) -o $@ $< | |
%.o : %.c $(HEADERS) | |
$(CC) $(CFLAGS) -c -o $@ $< | |
.PHONY : clean | |
clean : | |
rm -f $(PROGRAM) $(OBJECTS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment