Last active
July 8, 2017 18:54
-
-
Save fmela/9061088 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 *.cxx) | |
HEADERS = $(wildcard *.hxx) | |
OBJECTS = $(SOURCES:%.cxx=%.o) | |
PROGRAM = $(shell basename `pwd`) | |
CC := $(shell which clang || which gcc) | |
CFLAGS = -Wall -W -O -fno-exceptions -fno-rtti | |
LIBS = stdc++ m | |
LDFLAGS = $(LIBS:%=-l%) | |
$(PROGRAM) : $(OBJECTS) | |
$(CC) $(LDFLAGS) -o $@ $< | |
%.o : %.cxx $(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