Start sharing parts of the linux build system.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2017-11-26 22:10:17 +00:00
parent f50c83ad36
commit 11062607e6
6 changed files with 114 additions and 32 deletions

23
Makefile Normal file
View File

@ -0,0 +1,23 @@
.PHONY: all
all: opt
opt:
$(MAKE) -C src opt
$(MAKE) -C Z80/src opt
$(MAKE) -C Z80/test opt
debug:
$(MAKE) -C src debug
$(MAKE) -C Z80/src debug
$(MAKE) -C Z80/test debug
coverage:
$(MAKE) -C src coverage
$(MAKE) -C Z80/src coverage
$(MAKE) -C Z80/test coverage
.PHONY: clean
clean:
$(MAKE) -C src clean
$(MAKE) -C Z80/src clean
$(MAKE) -C Z80/test clean

7
Z80/src/Makefile Normal file
View File

@ -0,0 +1,7 @@
LIB = libz80.a
CXXFLAGS = -I ../inc -I ../../inc
CXXFILES = Disassembler.cpp Profiler.cpp Z80.cpp
include ../../lib_build.mk

9
Z80/test/Makefile Normal file
View File

@ -0,0 +1,9 @@
EXE = test_z80
CXXFLAGS = -I ../inc -I ../../inc
CXXFILES = Board.cpp Configuration.cpp test.cpp
LDFLAGS = -L ../src -L ../../src -lz80 -leightbit
include ../../exe_build.mk

37
exe_build.mk Normal file
View File

@ -0,0 +1,37 @@
CXXFLAGS += -g -Wall -std=c++14 -pipe
CXXOBJECTS = $(CXXFILES:.cpp=.o)
SOURCES = $(CXXFILES)
OBJECTS = $(CXXOBJECTS)
PCH = stdafx.h.gch
.PHONY: all
all: opt
.PHONY: opt
opt: CXXFLAGS += -DNDEBUG -march=native -O3 -flto
opt: $(EXE)
.PHONY: debug
debug: CXXFLAGS += -D_DEBUG
debug: $(EXE)
.PHONY: coverage
coverage: CXXFLAGS += -D_DEBUG -fprofile-arcs -ftest-coverage
coverage: LDFLAGS += -lgcov
coverage: $(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

36
lib_build.mk Normal file
View File

@ -0,0 +1,36 @@
CXXFLAGS += -g -Wall -std=c++14 -pipe
CXXOBJECTS = $(CXXFILES:.cpp=.o)
SOURCES = $(CXXFILES)
OBJECTS = $(CXXOBJECTS)
PCH = stdafx.h.gch
.PHONY: all
all: opt
.PHONY: opt
opt: CXXFLAGS += -DNDEBUG -march=native -O3 -flto
opt: $(LIB)
.PHONY: debug
debug: CXXFLAGS += -D_DEBUG
debug: $(LIB)
.PHONY: coverage
coverage: CXXFLAGS += -D_DEBUG -fprofile-arcs -ftest-coverage
coverage: $(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)

View File

@ -1,37 +1,7 @@
LIB = libeightbit.a
CXXFLAGS = -Wall -std=c++14 -pipe -I ../inc
CXXFLAGS = -I ../inc
CXXFILES = Bus.cpp EventArgs.cpp InputOutput.cpp IntelProcessor.cpp Memory.cpp Processor.cpp
CXXOBJECTS = $(CXXFILES:.cpp=.o)
SOURCES = $(CXXFILES)
OBJECTS = $(CXXOBJECTS)
PCH = stdafx.h.gch
all: opt
opt: CXXFLAGS += -DNDEBUG -march=native -O3 -flto
opt: $(LIB)
debug: CXXFLAGS += -g -D_DEBUG
debug: $(LIB)
coverage: CXXFLAGS += -g -D_DEBUG -fprofile-arcs -ftest-coverage
coverage: $(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)
include ../lib_build.mk