Skip to content

Instantly share code, notes, and snippets.

@fmela
Last active July 8, 2017 18:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmela/9061088 to your computer and use it in GitHub Desktop.
Save fmela/9061088 to your computer and use it in GitHub Desktop.
C++ program makefile boilerplate
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