Created
November 21, 2017 20:19
-
-
Save fresc81/db578991c91129703cb166f20db533ed to your computer and use it in GitHub Desktop.
Generic C++ Makefile with support for multiple executables
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 characters
APPS := nmdbg bla | |
nmdbg_OBJS := blubb.o | |
nmdbg_LIBS := -lboost_regex | |
bla_OBJS := blubb.o | |
CXX := g++-6 | |
CXXFLAGS := -I3rdparty/json/src -Iinclude -Isrc | |
LD := g++-6 | |
LDFLAGS := -Llib | |
LIBS := -lboost_filesystem -lboost_system | |
.PHONY: all clean | |
all:: bin/ build/ $(addprefix bin/,$(APPS)) | |
@printf '\033[32mbuilt all\033[0m\n' | |
clean: | |
@printf '\033[31mcleaning\033[0m\n' | |
rm -rf bin build | |
bin/: | |
@printf '\033[36mcreating $@\033[0m\n' | |
mkdir bin | |
build/: | |
@printf '\033[36mcreating $@\033[0m\n' | |
mkdir build | |
build/%.o: src/%.cpp | |
@printf '\033[33mcompiling $@ from $^\033[0m\n' | |
$(CXX) -std=c++11 $(CXXFLAGS) -c $< -o $@ | |
.SECONDEXPANSION: | |
.SECONDARY: build/%.o | |
.PRECIOUS: build/%.o bin/% | |
bin/%: build/%.o $$(addprefix build/,$$($$*_OBJS)) | |
@printf '\033[1;35mlinking $@ from $^\033[0m\n' | |
$(LD) -std=c++11 $(LDFLAGS) $^ $($*_LIBS) $(LIBS) -o $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment