Simplify Linux build configurations.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2017-12-25 23:45:55 +00:00
parent c05a236f1d
commit df1f47fb36
3 changed files with 21 additions and 48 deletions

View File

@ -6,3 +6,24 @@ CXXFLAGS_COVERAGE = $(CXXFLAGS_DEBUG) -fprofile-arcs -ftest-coverage
CXXFLAGS_PROFILE = $(CXXFLAGS_OPT) -fprofile-generate
CXXFLAGS_PROFILED = $(CXXFLAGS_OPT) -fprofile-use
CXXOBJECTS = $(CXXFILES:.cpp=.o)
SOURCES = $(CXXFILES)
OBJECTS = $(CXXOBJECTS)
PCH = stdafx.h.gch
all: opt
opt: CXXFLAGS += $(CXXFLAGS_OPT)
debug: CXXFLAGS += $(CXXFLAGS_DEBUG)
coverage: CXXFLAGS += $(CXXFLAGS_COVERAGE)
profile: CXXFLAGS += $(CXXFLAGS_PROFILE)
profiled: CXXFLAGS += $(CXXFLAGS_PROFILED)
$(PCH): stdafx.h
$(CXX) $(CXXFLAGS) -x c++-header $<
%.o: %.cpp $(PCH)
$(CXX) $(CXXFLAGS) $< -c -o $@

View File

@ -1,40 +1,16 @@
CXXOBJECTS = $(CXXFILES:.cpp=.o)
LDFLAGS += -g
SOURCES = $(CXXFILES)
OBJECTS = $(CXXOBJECTS)
PCH = stdafx.h.gch
all: opt
opt: CXXFLAGS += $(CXXFLAGS_OPT)
opt: $(EXE)
debug: CXXFLAGS += $(CXXFLAGS_DEBUG)
debug: $(EXE)
coverage: CXXFLAGS += $(CXXFLAGS_COVERAGE)
coverage: LDFLAGS += -lgcov
coverage: $(EXE)
profile: CXXFLAGS += $(CXXFLAGS_PROFILE)
profile: LDFLAGS += -lgcov
profile: $(EXE)
profiled: CXXFLAGS += $(CXXFLAGS_PROFILED)
profiled: $(EXE)
$(PCH): stdafx.h
$(CXX) $(CXXFLAGS) -x c++-header $<
$(EXE): $(OBJECTS)
$(CXX) $(OBJECTS) -o $(EXE) $(LDFLAGS)
%.o: %.cpp $(PCH)
$(CXX) $(CXXFLAGS) $< -c -o $@
.PHONY: clean
clean:
-rm -f $(EXE) $(OBJECTS) $(PCH) *.gcov *.gcda *.gcno

View File

@ -1,36 +1,12 @@
CXXOBJECTS = $(CXXFILES:.cpp=.o)
SOURCES = $(CXXFILES)
OBJECTS = $(CXXOBJECTS)
PCH = stdafx.h.gch
all: opt
opt: CXXFLAGS += $(CXXFLAGS_OPT)
opt: $(LIB)
debug: CXXFLAGS += $(CXXFLAGS_DEBUG)
debug: $(LIB)
coverage: CXXFLAGS += $(CXXFLAGS_COVERAGE)
coverage: $(LIB)
profile: CXXFLAGS += $(CXXFLAGS_PROFILE)
profile: $(LIB)
profiled: CXXFLAGS += $(CXXFLAGS_PROFILED)
profiled: $(LIB)
$(PCH): stdafx.h
$(CXX) $(CXXFLAGS) -x c++-header $<
$(LIB): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIB) $(OBJECTS)
%.o: %.cpp $(PCH)
$(CXX) $(CXXFLAGS) $< -c -o $@
.PHONY: clean
clean:
-rm -f $(LIB) $(OBJECTS) $(PCH)