Last active
August 21, 2017 12:35
-
-
Save polyfloyd/72b297fc88ad5bbb1cc14069eb3130fc to your computer and use it in GitHub Desktop.
Revisions
-
polyfloyd renamed this gist
Aug 21, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
polyfloyd created this gist
Nov 18, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,150 @@ # Environment checks {{{ ifdef VERBOSE Q := E := @true else Q := @ E := @echo # Output coloring {{{ ifndef NOCOLOR COLOR_COMPILE := \x1b[32;1m COLOR_LINK := \x1b[36;1m COLOR_DEP := \x1b[33;1m COLOR_LOCALE := \x1b[34;1m COLOR_TOOL := \x1b[35;1m COLOR_RESET := \x1b[0m E := @/bin/echo -e endif # }}} endif # }}} # Package metadata {{{ PACKAGE_NAME := myproject PACKAGE_VERSION := $(shell git describe --always --dirty) ifndef PACKAGE_VERSION PACKAGE_VERSION := 9999 endif # }}} # Directories {{{ SRCDIR := src OBJDIR := obj BINDIR := bin DEPDIR := dep # }}} # Output files {{{ BINFILE := $(BINDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION) # }}} # Toolkit selection {{{ CXX := clang++ # }}} # Compiler flags {{{ LIBS := CXXWARNINGS := \ -Wall \ -Wextra \ -Wpointer-arith \ -Wwrite-strings \ -Wmissing-declarations \ -Wno-long-long \ -Wuninitialized \ -Wno-unused-parameter CXXINCLUDES := \ $(SRCDIR) COMMONFLAGS := -Wfatal-errors CXXFLAGS := \ $(shell pkg-config --cflags $(LIBS)) \ -std=c++0x LDFLAGS := \ $(shell pkg-config --libs $(LIBS)) ifdef RELEASE COMMONFLAGS := -g0 -O2 $(COMMONFLAGS) CXXFLAGS := -D_RELEASE $(CXXFLAGS) else COMMONFLAGS := -g3 -O0 $(COMMONFLAGS) endif CXXFLAGS := $(COMMONFLAGS) $(CXXWARNINGS) $(CXXFLAGS) $(addprefix -I, $(CXXINCLUDES)) # }}} # Code input and output files {{{ CXXFILES := $(shell find $(SRCDIR) -name *.cc) DEPFILES := $(CXXFILES:$(SRCDIR)/%.cc=$(DEPDIR)/%.d) OBJNAMES := $(CXXFILES:$(SRCDIR)/%.cc=%) OBJFILES := $(OBJNAMES:%=$(OBJDIR)/%.o) # }}} -include Makefile.local # Make targets {{{ .PHONY: all test dep doc clean # Phony {{{ all: $(BINFILE) test: $(BINFILE) ./$(BINFILE) dep: $(DEPFILES) doc: $(CXXFILES) doxygen.conf $(Q)doxygen doxygen.conf 1>/dev/null clean: $(Q)rm -rf $(OBJDIR) $(BINDIR) $(LIBDIR) $(DEPDIR) # Include generated dependencies if we're compiling or linking ifeq (,$(filter $(MAKECMDGOALS),dep doc clean)) -include $(CXXFILES:$(SRCDIR)/%.cc=$(DEPDIR)/%.d) endif # }}} # Output files {{{ $(BINFILE): $(OBJFILES) $(E)" [$(COLOR_LINK)LD $(COLOR_RESET)] $@" $(Q)mkdir -p `dirname $@` $(Q)$(CXX) $(LDFLAGS) -o $@ $(OBJFILES) $(Q)ln -sf $(PACKAGE_NAME)-$(PACKAGE_VERSION) $(BINDIR)/$(PACKAGE_NAME) # }}} # Dependency generation {{{ $(DEPDIR)/%.d: $(SRCDIR)/%.cc $(E)" [$(COLOR_DEP)DEP$(COLOR_RESET)] $@" $(Q)mkdir -p `dirname $@` $(Q)$(CXX) $(CXXFLAGS) -MM -MT $(<:$(SRCDIR)/%.cc=$(OBJDIR)/%.o) -o $@ $< # }}} # Code compilation {{{ $(OBJDIR)/%.o: $(SRCDIR)/%.cc $(E)" [$(COLOR_COMPILE)CXX$(COLOR_RESET)] $<" $(Q)mkdir -p `dirname $@` $(Q)$(CXX) -o $@ -c $< $(CXXFLAGS) # }}} # }}}