-
Notifications
You must be signed in to change notification settings - Fork 115
/
Makefile
136 lines (100 loc) · 2.76 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
.DEFAULT_GOAL := all
PKGCONFIG = pkg-config
STRIP ?= strip
STATIC ?= 0
DEBUG ?= 1
VERBOSE ?= 0
PROFILE ?= 0
GAME_NAME ?= SonicMania
GAME_SUFFIX ?= .so
GAME_ALLC ?= 1
GAME_CFLAGS =
GAME_LDFLAGS = -shared
GAME_LIBS =
GAME_PREBUILD =
GAME_PRELINK =
GAME_POSTLINK =
DEFINES =
RETRO_REVISION ?= 3
RSDK_REVISION ?= $(RETRO_REVISION)
# =============================================================================
# Detect default platform if not explicitly specified
# =============================================================================
ifeq ($(OS),Windows_NT)
PLATFORM ?= Windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
PLATFORM ?= Linux
endif
ifeq ($(UNAME_S),Darwin)
PLATFORM ?= macOS
endif
endif
PLATFORM ?= Unknown
# =============================================================================
ifneq ("$(wildcard makefiles/$(PLATFORM).cfg)","")
include makefiles/$(PLATFORM).cfg
endif
OUTDIR = bin/$(PLATFORM)
GAME_OBJDIR = bin/obj/$(PLATFORM)/$(GAME_NAME)
# =============================================================================
CFLAGS ?= $(CXXFLAGS)
DEFINES += -DBASE_PATH='"$(BASE_PATH)"'
ifeq ($(DEBUG),1)
CXXFLAGS += -g
CFLAGS += -g
STRIP = :
else
CXXFLAGS += -O3
CFLAGS += -O3
endif
ifeq ($(STATIC),1)
CXXFLAGS += -static
CFLAGS += -static
endif
ifeq ($(PROFILE),1)
CXXFLAGS += -pg -g -fno-inline-functions -fno-inline-functions-called-once -fno-optimize-sibling-calls -fno-default-inline
CFLAGS += -pg -g -fno-inline-functions -fno-inline-functions-called-once -fno-optimize-sibling-calls -fno-default-inline
endif
ifeq ($(VERBOSE),0)
CC := @$(CC)
CXX := @$(CXX)
endif
DEFINES += -DRETRO_STANDALONE=1
DEFINES += -DRETRO_REVISION=$(RSDK_REVISION)
CFLAGS_ALL += $(CFLAGS) \
-fsigned-char
CXXFLAGS_ALL += $(CXXFLAGS) \
-std=c++17 \
-fsigned-char \
-fpermissive
LDFLAGS_ALL = $(LDFLAGS)
GAME_INCLUDES = \
-I./$(GAME_NAME)/ \
-I./$(GAME_NAME)/Objects/
GAME_SOURCES = \
$(GAME_NAME)/Game
ifeq ($(GAME_ALLC),1)
GAME_SOURCES += $(GAME_NAME)/Objects/All
else
# execute Game/objectmake.py?
include $(GAME_NAME)/Objects.cfg
endif
$(shell mkdir -p $(OUTDIR))
GAME_OBJECTS += $(addprefix $(GAME_OBJDIR)/, $(addsuffix .o, $(GAME_SOURCES)))
GAME_PATH = $(OUTDIR)/$(GAME_NAME)$(GAME_SUFFIX)
$(shell mkdir -p $(GAME_OBJDIR))
$(GAME_OBJDIR)/%.o: $(GAME_PREBUILD) %.c
@mkdir -p $(@D)
@echo compiling $<...
$(CC) -c -fPIC $(CFLAGS_ALL) $(GAME_FLAGS) $(GAME_INCLUDES) $(DEFINES) $< -o $@
@echo done $<
$(GAME_PATH): $(GAME_PRELINK) $(GAME_OBJECTS)
@echo linking game...
$(CXX) $(CXXFLAGS_ALL) $(LDFLAGS_ALL) $(GAME_LDFLAGS) $(GAME_OBJECTS) $(GAME_LIBS) -o $@
$(STRIP) $@
@echo done linking game
all: $(GAME_POSTLINK) $(GAME_PATH)
clean:
rm -rf $(GAME_OBJDIR) && rm -rf $(GAME_PATH)