-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.inc
More file actions
230 lines (182 loc) · 5.3 KB
/
Makefile.inc
File metadata and controls
230 lines (182 loc) · 5.3 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# vim: ft=make noexpandtab
ifeq ($(MAUG_ROOT),)
MAUG_ROOT := maug
endif
INCLUDES_GCC += -I$(MAUG_ROOT)/src
INCLUDES_WATCOM += -i=$(MAUG_ROOT)/src
INCLUDES_VS += /I $(MAUG_ROOT)/src
ifeq ("$(RETROFLAT_OPENGL)","1")
DEFINES_GCC += -DRETROFLAT_OPENGL -DRETROFLAT_3D
DEFINES_WATCOM += -DRETROFLAT_OPENGL -DRETROFLAT_3D
endif
ifeq ("$(RETROFLAT_SMALL3DL)","1")
DEFINES_GCC += -DRETROFLAT_SMALL3DL -DRETROFLAT_3D
DEFINES_WATCOM += -DRETROFLAT_SMALL3DL -DRETROFLAT_3D
endif
ifneq ("$(RETROFLAT_SOUND)","1")
DEFINES_GCC += -DRETROFLAT_NO_SOUND
DEFINES_WATCOM += -DRETROFLAT_NO_SOUND
endif
MAUG_UNIX := $(shell uname -s -m | tr ' ' '_')
GLOBAL_DEFINES += -DRETROFLAT_COMMIT_HASH="\"$(shell git -C $(MAUG_ROOT) rev-parse HEAD)\"" -DMAUG_UNIX="\"$(MAUG_UNIX)\""
CFLAGS_GCC := $(GLOBAL_DEFINES) $(INCLUDES_GCC) $(DEFINES_GCC)
CFLAGS_GCC64 := $(GLOBAL_DEFINES) $(INCLUDES_GCC) $(DEFINES_GCC)
CFLAGS_WATCOM := $(GLOBAL_DEFINES) $(INCLUDES_WATCOM) $(DEFINES_WATCOM)
CFLAGS_WATCOM386 := $(GLOBAL_DEFINES) $(INCLUDES_WATCOM) $(DEFINES_WATCOM)
CFLAGS_EMCC := $(GLOBAL_DEFINES) $(DEFINES_GCC) $(INCLUDES_GCC)
LDFLAGS_GCC := $(LIBS_GCC)
LDFLAGS_GCC64 := $(LIBS_GCC)
LDFLAGS_WATCOM := $(LIBS_WATCOM)
LDFLAGS_WATCOM386 := $(LIBS_WATCOM)
CLEAN_TARGETS := obj *.err
#DEFINES_GLOBAL = -DLOG_TO_FILE -DLOG_FILE_NAME=\"out.log\"
ifeq ($(DEBUG_THRESHOLD),)
DEBUG_THRESHOLD := 1
endif
ifeq ("$(FORCE_OPT)", "1")
CFLAGS_WATCOM += -ot
CFLAGS_WATCOM386 += -ot
CFLAGS_GCC += -O2
CFLAGS_GCC64 += -O2
CFLAGS_CECL += /O2
endif
# Build debug unless release specified.
ifeq ("$(BUILD)","RELEASE")
CFLAGS_WATCOM += -ot
CFLAGS_WATCOM386 += -ot
CFLAGS_GCC += -O2
CFLAGS_GCC64 += -O2
CFLAGS_CECL += /O2 /D "NDEBUG" /W1 /ML
else
CFLAGS_GCC_WARN := -Wall -Wno-sign-compare -Wno-strict-aliasing
CFLAGS_WATCOM += -DDEBUG_LOG -DDEBUG -DDEBUG_THRESHOLD=$(DEBUG_THRESHOLD)
CFLAGS_WATCOM386 += -d3 -db -DDEBUG_LOG -DDEBUG -DDEBUG_THRESHOLD=$(DEBUG_THRESHOLD)
CFLAGS_GCC += -DDEBUG -Wall $(CFLAGS_GCC_WARN) -g -pg
CFLAGS_GCC64 += -DDEBUG $(CFLAGS_GCC_WARN) -g -pg
LDFLAGS_GCC += -g -pg
LDFLAGS_GCC64 += -g -pg
CFLAGS_EMCC += -g -DDEBUG -DDEBUG_LOG -DDEBUG_THRESHOLD=$(DEBUG_THRESHOLD) -Wall
LDFLAGS_EMCC += -g --profiling-functions
LDFLAGS_WATCOM386 += debug all
CFLAGS_CECL += /W1 /MLd
endif
ifeq ("$(FORCEOPT)","1")
CFLAGS_WATCOM += -ot
CFLAGS_WATCOM386 += -ot
CFLAGS_GCC += -O2
CFLAGS_GCC64 += -O2
CFLAGS_CECL += /O2
CFLAGS_EMCC += -O2
endif
ifeq ("$(PEDANTIC)","1")
CFLAGS_GCC += -Wpedantic
CFLAGS_GCC64 += -Wpedantic
endif
ifeq ("$(WERROR)","1")
CFLAGS_GCC += -Werror -Wno-sign-compare -Wno-strict-aliasing -Wno-unused-value -Wno-unused-but-set-variable
CFLAGS_GCC64 += -Werror -Wno-sign-compare -Wno-strict-aliasing -Wno-unused-value -Wno-unused-but-set-variable
CFLAGS_WATCOM += -we
CFLAGS_WATCOM386 += -we
endif
ifeq ("$(C89)","1")
CFLAGS_GCC += -std=c89
CFLAGS_GCC64 += -std=c89
endif
# Default compiler specs.
ifeq ("$(CC_GCC)","")
CC_GCC := gcc
endif
ifeq ("$(CC_WATCOM)","")
CC_WATCOM := wcc
endif
ifeq ("$(LD_WATCOM)","")
LD_WATCOM := wlink
endif
ifeq ("$(CC_WATCOM386)","")
CC_WATCOM386 := wcc386
endif
ifeq ("$(LD_WATCOM386)","")
LD_WATCOM386 := wlink
endif
ifeq ("$(EMCC)","")
EMCC := emcc
endif
MD := mkdir -p
include maug/make/Maketpl.inc
include maug/make/Makevfs.inc
include maug/make/Makexpm.inc
include maug/make/Makeunix.inc
include maug/make/Makewin.inc
include maug/make/Makece.inc
include maug/make/Makewasm.inc
include maug/make/Makedos.inc
include maug/make/Makends.inc
include maug/make/Makewii.inc
include maug/make/Makenx.inc
include maug/make/Makeos2.inc
include maug/make/Makemac.inc
include maug/make/Makepsx.inc
include maug/make/Makeplug.inc
# ---
define TGTISO
# Easier to understand error messages.
ifeq ("$$(shell which mkisofs 2>/dev/null)","")
$$(error could not find mkisofs!)
endif
$(1)_iso.dst: $(2)
mkdir -v -p $$@
for f in $$^; do \
mkdir -v -p "$$@/`dirname $$$$f`"; \
cp -v -R $$$$f "$$@/$$$$f"; \
done
$(1).iso: $(1)_iso.dst
mkisofs -J -o $$@ $$<
CLEAN_TARGETS += $(1)_iso.dst $(1).iso
endef
# ---
define TGTSER
obj/mserdefs/serial: $(MAUG_ROOT)/tools/serial.c
mkdir -v -p "`dirname $$@`"
gcc -Isrc -o $$@ $$<
obj/mserdefs/mserdef.c: $(1) | obj/mserdefs/serial
echo "#include <maug.h>" > $$@
echo "#include \"../../src/msercust.h\"" >> $$@
./obj/mserdefs/serial $$^ >> $$@
echo "#ifndef MSERDEF_H" > $$(subst .c,.h,$$@)
echo "#define MSERDEF_H" >> $$(subst .c,.h,$$@)
./obj/mserdefs/serial -p $$^ >> $$(subst .c,.h,$$@)
echo "#endif /* MSERDEF_H */" >> $$(subst .c,.h,$$@)
C_FILES := obj/mserdefs/mserdef.c $(C_FILES)
endef
# ---
define TGTZIP
# Easier to understand error messages.
ifeq ("$$(shell which zip 2>/dev/null)","")
$$(error could not find zip!)
endif
$(1)_zip.dst: $(2)
mkdir -v -p $$@
for f in $$^; do \
mkdir -v -p "$$@/`dirname $$$$f`"; \
cp -v -R $$$$f "$$@/$$$$f"; \
done
$(1).zip: $(1)_zip.dst
zip -r $$@ $$<
CLEAN_TARGETS += $(1)_zip.dst $(1).zip
endef
# ---
define TGTTGZ
# Easier to understand error messages.
ifeq ("$$(shell which tar 2>/dev/null)","")
$$(error could not find tar!)
endif
$(1)_tgz.$$(MAUG_UNIX).dst: $(2)
mkdir -v -p $$@
for f in $$^; do \
mkdir -v -p "$$@/`dirname $$$$f`"; \
cp -v -R $$$$f "$$@/$$$$f"; \
done
$(1).$$(MAUG_UNIX).tgz: $(1)_tgz.$$(MAUG_UNIX).dst
tar -cvzf $$@ $$<
CLEAN_TARGETS += $(1)_tgz.$$(MAUG_UNIX).dst $(1).$$(MAUG_UNIX).tgz
endef