Repository navigation
Expand file tree
/
Copy pathcommon.mk
More file actions
71 lines (57 loc) · 2.07 KB
/
Copy pathcommon.mk
File metadata and controls
71 lines (57 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# common.mk — shared Make fragment for SSW's non-GUI module Makefiles.
#
# Included (via `include ../../common.mk`) by:
# - the six non-GUI src module Makefiles: src/core, src/strategic,
# src/ships, src/weapons, src/defenses, src/tactical
# - the four simple test-lib Makefiles: tests/core, tests/weapons,
# tests/strategic, tests/ships
#
# Each including Makefile must still define, after the `include` line:
# - TARGET (the .a library name)
# - SRCS / OBJS / DEPS (from $(wildcard *.cpp), or the
# filter-out test_template.cpp glob for
# the test-lib Makefiles)
# - the `all $(TARGET): $(COVERAGE_PREP) $(OBJS)` -> `ar rcs` rule
# - `-include $(DEPS)` at the end of the file
# - any module-specific CXXFLAGS/LIBS additions via `+=` AFTER the
# include (e.g. `` `wx-config --cxxflags` `` and -lcppunit for the
# test-lib Makefiles, or -D<MODULE>_TEST_REPO_ROOT defines)
ifeq ($(COVERAGE),1)
COVERAGE_FLAGS = -fprofile-arcs -ftest-coverage
COVERAGE_PREP = coverage-clean
else
COVERAGE_FLAGS =
COVERAGE_PREP =
endif
.DEFAULT_GOAL := all
CXXFLAGS = -I../../include -g -Wall -Woverloaded-virtual -DLINUX -std=c++17 $(COVERAGE_FLAGS)
DEPFLAGS = -MMD -MP
PICFLAGS = -fPIC -DPIC
#################### the implicit rules #############################
# NB: we use the old style suffix rules (.c.o) and not the GNU make
# implicit rules (%.o: %.c) because they are more portable, in
# particular the BSD make understands the former but not the
# latter
.SUFFIXES: .o .c .cpp .cxx .rsrc .r
.c.o:
$(CC) -c $(CFLAGS) $(PICFLAGS) -o $@ $<
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(DEPFLAGS) $(PICFLAGS) -o $@ $<
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(PICFLAGS) -o $@ $<
.rsrc.r:
$(DEREZ) $^ Carbon.r -useDF > $@
############################# Shared targets #########################
objs: $(OBJS)
rm -f *.gcda
rm -f *.gcov
rm -f *.gcno
.PHONY: coverage-clean
coverage-clean:
rm -f $(OBJS) $(DEPS)
rm -f *.gcda
rm -f *.gcov
rm -f *.gcno
clean:
rm -f $(OBJS) $(DEPS)
rm -f $(TARGET)