-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
88 lines (68 loc) · 2.61 KB
/
Makefile
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Originally written by @Muffindrake
PREFIX ?= /usr/local
.PHONY: release debug profile all clean install
OPTLEVEL ?= -O3
LIBS += sdl2 libpng libjpeg gl glew openal mad pangocairo
CXXFLAGS += -std=c++11 -Wall
CXXFLAGS += $(shell pkg-config $(LIBS) --cflags)
LDFLAGS += $(shell pkg-config $(LIBS) --libs) -lpthread -lfontconfig
PROG = endless-sky
PROG_DEBUG = $(PROG)-debug
PROG_PROF = $(PROG)-profile
DIR_SRC = source
DIR_BUILD = build
DIR_RELEASE = $(DIR_BUILD)/release
DIR_DEBUG = $(DIR_BUILD)/debug
DIR_PROF = $(DIR_BUILD)/profile
SRCS = $(wildcard $(DIR_SRC)/*.cpp)
OBJS = $(patsubst $(DIR_SRC)/%.cpp,$(DIR_RELEASE)/%.o,$(SRCS))
DEPS = $(patsubst $(DIR_SRC)/%.cpp,$(DIR_RELEASE)/%.d,$(SRCS))
OBJS_DEBUG = $(patsubst $(DIR_SRC)/%.cpp,$(DIR_DEBUG)/%.o,$(SRCS))
DEPS_DEBUG = $(patsubst $(DIR_SRC)/%.cpp,$(DIR_DEBUG)/%.d,$(SRCS))
OBJS_PROF = $(patsubst $(DIR_SRC)/%.cpp,$(DIR_PROF)/%.o,$(SRCS))
DEPS_PROF = $(patsubst $(DIR_SRC)/%.cpp,$(DIR_PROF)/%.d,$(SRCS))
$(info mkdir -p $(DIR_RELEASE) $(DIR_DEBUG) $(DIR_PROF))
$(shell mkdir -p $(DIR_RELEASE) $(DIR_DEBUG) $(DIR_PROF))
$(DIR_RELEASE)/%.o: $(DIR_SRC)/%.cpp
$(CXX) $(OPTLEVEL) $(CXXFLAGS) -o $@ -c -MMD $<
$(PROG): $(OBJS)
$(CXX) $(OPTLEVEL) $(CXXFLAGS) -o $(PROG) $^ $(LDFLAGS)
release: $(PROG)
$(DIR_DEBUG)/%.o: $(DIR_SRC)/%.cpp
$(CXX) $(CXXFLAGS) -g -o $@ -c -MMD $<
$(PROG_DEBUG): $(OBJS_DEBUG)
$(CXX) $(CXXFLAGS) -g -o $(PROG_DEBUG) $^ $(LDFLAGS)
debug: $(PROG_DEBUG)
$(DIR_PROF)/%.o: $(DIR_SRC)/%.cpp
$(CXX) $(CXXFLAGS) -pg -o $@ -c -MMD $<
$(PROG_PROF): $(OBJS_PROF)
$(CXX) $(CXXFLAGS) -pg -o $(PROG_PROF) $^ $(LDFLAGS)
profile: $(PROG_PROF)
.DEFAULT: all
all: release
DESTINATION = $(DESTDIR)$(PREFIX)
PREFIX_DATA = $(DESTINATION)/share/games/$(PROG)
PREFIX_BIN = $(DESTINATION)/bin
ICON = icons/icon_
ICONS = 16x16 22x22 24x24 32x32 48x48 256x256
install: release
mkdir -p $(PREFIX_BIN)
install -m 0755 $(PROG) $(PREFIX_BIN)
mkdir -p $(PREFIX_DATA)
cp -R --no-preserve=ownership data $(PREFIX_DATA)
cp -R --no-preserve=ownership images $(PREFIX_DATA)
cp -R --no-preserve=ownership sounds $(PREFIX_DATA)
cp --no-preserve=ownership credits.txt $(PREFIX_DATA)
cp --no-preserve=ownership keys.txt $(PREFIX_DATA)
mkdir -p $(DESTINATION)/share/man/man6/
gzip -c $(PROG).6 > $(DESTINATION)/share/man/man6/$(PROG).6.gz
for icon in $(ICONS); do \
mkdir -p $(DESTINATION)/share/icons/hicolor/$$icon/apps; \
cp --no-preserve=ownership $(ICON)$$icon.png $(DESTINATION)/share/icons/hicolor/$$icon/apps/$(PROG).png; \
done
clean:
$(RM) $(PROG) $(PROG_DEBUG) $(PROG_PROF)
$(RM) -r $(DIR_RELEASE) $(DIR_DEBUG) $(DIR_PROF)
-include $(DEPS)
-include $(DEPS_DEBUG)
-include $(DEPS_PROF)