Skip to content

Instantly share code, notes, and snippets.

@trevorc
Created October 10, 2011 19:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevorc/1276301 to your computer and use it in GitHub Desktop.
Save trevorc/1276301 to your computer and use it in GitHub Desktop.
cpp.mk
CPPFLAGS += -D_BSD_SOURCE -D_XOPEN_SOURCE=600 \
-I/usr/local/include -Isrc
CXXFLAGS += -std=c++98 -fno-rtti -fno-exceptions -pipe \
-Wall -Wextra -Werror -Wcast-align -Wstrict-overflow -Wshadow
LDFLAGS += -L/usr/local/lib
INSTALL ?= install
ifdef pkg_config_libs
CPPFLAGS += $(shell pkg-config --cflags $(pkg_config_libs))
LDFLAGS += $(shell pkg-config --libs-only-L $(pkg_config_libs))
LDLIBS += $(shell pkg-config --libs-only-l $(pkg_config_libs))
endif
ifdef NDEBUG
CPPFLAGS += -DNDEBUG
CXXFLAGS += -O3
else
CXXFLAGS += -g -ggdb
endif
ifdef STATIC
LDFLAGS += -static
endif
objects := $(patsubst src/%.cc,%.o,$(wildcard src/*.cc))
prefix := /usr/local
bindir := $(prefix)/bin
sysconfdir := $(prefix)/etc
localstatedir := $(prefix)/var
vpath %.cc src
$(program): $(objects)
.PHONY: clean
clean:
-rm -f $(program) $(objects)
# example makefile
program := frobulate
pkg_config_libs := libzmq
CXXFLAGS := -Wstrict-aliasing
LDLIBS := -lm
ifeq (Linux,$(shell uname -s))
LDLIBS += -luuid
endif
include cpp.mk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment