-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmakefile.wce
449 lines (368 loc) · 9.37 KB
/
makefile.wce
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# set this to mame, mess or the destination you want to build
# TARGET = mame
TARGET = mess
# TARGET = neomame
# TARGET = tiny
# TARGET=tinyms
# uncomment next line to make a debug version
# DEBUG = 1
# build with browser information for debugging
BSCMAKE = @-bscmake.exe
# command to invoke UPX (Ultimate Packer for eXecutables)
# UPX = upx.exe -9 --compress-icons=0
# uncomment next line to use Assembler 68000 engine
# X86_ASM_68000 = 1
# uncomment next line to use Assembler 68020 engine
# X86_ASM_68020 = 1
# set this the operating system you're building for
# MAMEOS = windows
MAMEOS = wince
# if MAME_NET is defined, network support will be compiled in
# MAME_NET = -DMAME_NET
# uncomment next line to generate help files
# HELP = 1
# extension for executables
EXE = .exe
# CPU core include paths
VPATH=src $(wildcard src/cpu/*)
# Windows CE version
WINCE_VERSION = wce300
# Windows CE platform (x86em | arm | mips | sh3)
ifeq "$(TARGETCPU)" "ARM"
WCEPLAT = arm
endif
ifeq "$(TARGETCPU)" "THUMB"
WCEPLAT = thumb
endif
ifeq "$(TARGETCPU)" "SH3"
WCEPLAT = sh3
endif
ifeq "$(TARGETCPU)" "R4100"
WCEPLAT = mips
endif
ifndef WCEPLAT
WCEPLAT = x86em
endif
# compiler, linker and utilities
AR = @lib
#CC =
CCL = gcc
LD = link
RC = rc
ASM = @nasmw
ASMFLAGS = -f win32
RM = rm
RMDIR = rd /S /Q
MD = -mkdir
ifeq "$(TARGET)" "mess"
MESS = 1
endif
ifeq "$(TARGET)" "tinyms"
MESS = 1
endif
ifeq "$(MAMEOS)" "wince"
ifeq "$(WCEPLAT)" "x86em"
WINDOWS_PROGRAM = -subsystem:windows -windowsce:emulation
else
WINDOWS_PROGRAM = -subsystem:windowsce,3.00
endif
else
WINDOWS_PROGRAM = -subsystem:windows
endif
CONSOLE_PROGRAM = -subsystem:console
ifdef DEBUG
NAME = $(TARGET)ced_$(WCEPLAT)
else
NAME = $(TARGET)ce_$(WCEPLAT)
endif
# build the targets in different object dirs, since mess changes
# some structures and thus they can't be linked against each other.
# cleantiny isn't needed anymore, because the tiny build has its
# own object directory too.
OBJ = obj/$(NAME)
EMULATOR = $(NAME)$(EXE)
#####################################################################
# compiler
#
# Preprocessor Definitions
#
DEFS = \
-DWIN32 \
-D_WINDOWS \
-DM_PI=3.1415926534 \
-DPI=3.1415926534 \
-DINLINE='static __inline' \
-Dinline=__inline \
-D__inline__=__inline \
-Dalloca=_alloca \
-DPNG_SAVE_SUPPORT \
-DMAME_AVI \
-DHAS_CPUS \
-DHAS_SOUND \
-DLSB_FIRST=1 \
$(MAME_VERSION) \
$(MAME_NET) \
ifeq "$(MAMEOS)" "wince"
DEFS += \
-DUNICODE \
-D_UNICODE \
-DUNDER_CE=300 \
-D_WIN32_WCE=0300 \
-DSTRICT \
-Dstricmp=_stricmp \
-Dstrnicmp=_strnicmp \
-DCLIB_DECL=_cdecl \
-DDECL_SPEC=_cdecl \
-DZEXPORT=
ifeq "$(WCEPLAT)" "x86em"
DEFS += -DX86 -Dx86 -D_X86_
ifeq "$(PLATFORM)" "ms pocket pc"
DEFS += -D_WIN32_WCE_EMULATION
endif
endif
ifeq "$(WCEPLAT)" "arm"
DEFS += -DARM -D_ARM_
endif
ifeq "$(WCEPLAT)" "sh3"
DEFS += -DSHx -D_SHx_
endif
ifeq "$(WCEPLAT)" "mips"
DEFS += -DMIPS -D_MIPS_
endif
endif
ifdef DEBUG
DEFS += -DDEBUG
else
DEFS += -DNDEBUG
endif
ifdef MESS
DEFS += -DMESS=1 -DMAME32NAME='"MESS"' -DMAMENAME='"MESS"'
endif
INCLUDES = \
-Isrc/wince/crt \
-Isrc/wince \
-Isrc \
-Isrc/includes \
-Isrc/windows \
-Isrc/ui \
-Isrc/cpu/m68000 \
-I$(OBJ)/cpu/m68000
ifdef MESS
INCLUDES += \
-Imess \
-Imess/includes \
-Imess/wince \
-Imess/windows
endif
ifdef DX_INCPATH
INCLUDES += -I$(DX_INCPATH)
endif
ifdef ZLIB_INCPATH
INCLUDES += -I$(subst \,\\,$(ZLIB_INCPATH))
endif
ifdef GX_PATH
INCLUDES += -I$(subst \,\\,$(GX_PATH))\\inc
endif
#
# C Compiler flags
#
CFLAGS = -W1 -nologo $(INCLUDES) -Gz
ifdef DEBUG
CFLAGS += -Zi -Od
else
CFLAGS += -Ox -Ob2
endif
#####################################################################
# Resources
RCDEFS = $(MAME_NET) $(MAME_MMX) -DNDEBUG $(MAME_VERSION)
RCFLAGS = -l 0x409 $(DBGDEFS) -Isrc/wince -Isrc/ui/res -Imess/windows
ifdef MESS
RCFLAGS += -DMESS -Imess/ui/res
endif
#####################################################################
# Linker
LIBS = \
coredll.lib \
corelibc.lib \
aygshell.lib \
commctrl.lib \
uuid.lib
ifdef DX_LIBPATH
LDFLAGS += -LIBPATH:$(subst \,\\,$(DX_LIBPATH))
endif
ifdef ZLIB_LIBPATH
LDFLAGS += -LIBPATH:$(subst \,\\,$(ZLIB_LIBPATH))
endif
ifdef GX_PATH
LDFLAGS += -LIBPATH:$(subst \,\\,$(GX_PATH))\\$(WCEPLAT)
endif
ifeq "$(MAMEOS)" "wince"
LDFLAGS += -nodefaultlib
ifeq "$(WCEPLAT)" "x86em"
LDFLAGS += -machine:ix86
endif
ifeq "$(WCEPLAT)" "arm"
LDFLAGS += -machine:arm
endif
ifeq "$(WCEPLAT)" "sh3"
LDFLAGS += -machine:sh3
endif
ifeq "$(WCEPLAT)" "mips"
LDFLAGS += -machine:mips
endif
endif
ifdef DEBUG
LDFLAGS += -debug:full
else
LDFLAGS += -release -incremental:no -map
endif
ifdef BSCMAKE
BSCDEFS = -FR$(@:%.o=%.sbr)
endif
#####################################################################
OBJDIRS = \
obj \
$(OBJ) \
$(OBJ)/cpu \
$(OBJ)/sound \
$(OBJ)/drivers \
$(OBJ)/machine \
$(OBJ)/vidhrdw \
$(OBJ)/sndhrdw \
$(OBJ)/windows \
$(OBJ)/wince \
$(OBJ)/ui \
$(OBJ)/zlib
ifdef MESS
# MESS object directories
OBJDIRS += \
$(OBJ)/mess \
$(OBJ)/mess/cpu \
$(OBJ)/mess/sound \
$(OBJ)/mess/systems \
$(OBJ)/mess/machine \
$(OBJ)/mess/vidhrdw \
$(OBJ)/mess/sndhrdw \
$(OBJ)/mess/tools \
$(OBJ)/mess/tools/dat2html \
$(OBJ)/mess/tools/imgtool \
$(OBJ)/mess/tools/mkhdimg \
$(OBJ)/mess/tools/messroms \
$(OBJ)/mess/tools/mkimage \
$(OBJ)/mess/formats \
$(OBJ)/mess/devices \
$(OBJ)/mess/windows \
$(OBJ)/mess/ui
endif
#####################################################################
all: maketree $(EMULATOR)
# include the various .mak files
include src/core.mak
ifdef MESS
include mess/$(TARGET).mak
else
include src/$(TARGET).mak
endif
include src/rules.mak
include src/$(MAMEOS)/$(MAMEOS).mak
ifdef MESS
include mess/rules_ms.mak
endif
#ifdef DEBUG
DBGDEFS = -DMAME_DEBUG
#else
#DBGDEFS =
#DBGOBJS =
#endif
extra: romcmp$(EXE) $(TOOLS) $(HELPFILES)
# combine the various definitions to one
CDEFS = $(DEFS) $(COREDEFS) $(CPUDEFS) $(SOUNDDEFS) $(ASMDEFS) $(DBGDEFS) $(BSCDEFS)
$(EMULATOR): $(OBJS) $(COREOBJS) $(OSOBJS) $(DRVLIBS) $(RES)
# always recompile the version string
$(CC) $(CDEFS) $(CFLAGS) -FR$(OBJ)/version.sbr -Fo$(OBJ)/version.o -c src/version.c
@echo Linking $@...
$(LD) $(LDFLAGS) $(WINDOWS_PROGRAM) -out:$(EMULATOR) $(LIBS) $(COREOBJS) $(OBJS) $(OSOBJS) $(DRVLIBS) $(RES)
ifdef BSCMAKE
$(BSCMAKE) -nologo -o$(EMULATOR:%.exe=%.bsc) $(OBJS:%.o=%.sbr) $(COREOBJS:%.o=%.sbr) $(OSOBJS:%.o=%.sbr)
endif
ifndef DEBUG
ifdef UPX
$(UPX) $@
endif
endif
romcmp$(EXE): $(OBJ)/romcmp.o $(OBJ)/unzip.o
@echo Linking $@...
$(LD) $(LDFLAGS) $(CONSOLE_PROGRAM) $(LIBS) $(OBJ)/Win32/dirent.o -out:$@ $^
ifdef PERL
$(OBJ)/cpuintrf.o: src/cpuintrf.c rules.mak
$(PERL) src/makelist.pl
@echo Compiling $<...
$(CC) $(CDEFS) $(CFLAGS) -c $< -o $@
endif
$(OBJ)/%.o: src/%.asm
$(ASM) -o $@ $(ASMFLAGS) $(ASMDEFS) $<
$(OBJ)/%.o: src/%.c
$(CC) $(CDEFS) $(CFLAGS) -Fo$@ -c $<
$(OBJ)/wince/%.o: src/wince/%.cpp
$(CC) $(CDEFS) $(CFLAGS) -Fo$@ -c $<
$(OBJ)/zlib/%.o: zlib/%.c
$(CC) $(CDEFS) $(CFLAGS) -Fo$@ -c $<
$(OBJ)/mess/%.o: mess/%.c
@echo [MESS] Compiling $<...
$(CC) $(CDEFS) $(CFLAGS) -Fo$@ -c $<
$(OBJ)/wince/%.res: src/wince/%.rc
@echo Compiling resources $<...
$(RC) $(RCDEFS) $(RCFLAGS) -Fo$@ $<
$(OBJ)/windowsui/%.res: windowsui/%.rc
@echo Compiling resources $<...
$(RC) $(RCDEFS) $(RCFLAGS) -Fo$@ $<
$(OBJ)/mess/windows/%.res: mess/windows/%.rc
@echo Compiling resources $<...
$(RC) $(RCDEFS) $(RCFLAGS) -Fo$@ $<
$(OBJ)/mess/windowsui/%.res: mess/windowsui/%.rc
@echo Compiling resources $<...
$(RC) $(RCDEFS) $(RCFLAGS) -Fo$@ $<
# compile generated C files for the 68000 emulator
$(M68000_GENERATED_OBJS): $(OBJ)/cpu/m68000/m68kmake$(EXE)
@echo Compiling $(subst .o,.c,$@)...
$(CC) $(CDEFS) $(CFLAGS) -Fo$@ -c $*.c
# additional rule, because m68kcpu.c includes the generated m68kops.h :-/
$(OBJ)/cpu/m68000/m68kcpu.o: $(OBJ)/cpu/m68000/m68kmake$(EXE)
# generate C source files for the 68000 emulator
$(OBJ)/cpu/m68000/m68kmake$(EXE): src/cpu/m68000/m68kmake.c
@echo M68K make $<...
$(CCL) -o $@ $<
@echo Generating M68K source files...
$(OBJ)/cpu/m68000/m68kmake$(EXE) $(OBJ)/cpu/m68000 src/cpu/m68000/m68k_in.c
# generate asm source files for the 68000/68020 emulators
$(OBJ)/cpu/m68000/68000.asm: src/cpu/m68000/make68k.c
@echo Compiling $<...
$(CCL) $(CDEFS) $(CFLAGS) -Fe$(OBJ)/cpu/m68000/make68k$(EXE) -Fo$(OBJ)/cpu/m68000/ $<
@echo Generating $@...
$(OBJ)/cpu/m68000/make68k$(EXE) $@ $(OBJ)/cpu/m68000/68000tab.asm 00
$(OBJ)/cpu/m68000/68020.asm: src/cpu/m68000/make68k.c
@echo Compiling $<...
$(CC) $(CDEFS) $(CFLAGS) -Fe$(OBJ)/cpu/m68000/make68k$(EXE) -Fo$(OBJ)/cpu/m68000/ $<
@echo Generating $@...
$(OBJ)/cpu/m68000/make68k$(EXE) $@ $(OBJ)/cpu/m68000/68020tab.asm 20
# generated asm files for the 68000 emulator
$(OBJ)/cpu/m68000/68000.o: $(OBJ)/cpu/m68000/68000.asm
@echo Assembling $<...
$(ASM) -o $@ $(ASMFLAGS) $(subst -D,-d,$(ASMDEFS)) $<
$(OBJ)/cpu/m68000/68020.o: $(OBJ)/cpu/m68000/68020.asm
@echo Assembling $<...
$(ASM) -o $@ $(ASMFLAGS) $(subst -D,-d,$(ASMDEFS)) $<
$(OBJ)/%.a:
@echo Archiving $@...
@-$(RM) $(subst /,\\,$@)
$(AR) -nologo -out:$@ $^
makedir:
@echo make makedir is no longer necessary, just type make
$(sort $(OBJDIRS)):
$(MD) $(subst /,\\,$@)
maketree: $(sort $(OBJDIRS))
clean:
@echo Deleting object tree $(OBJ)...
@-$(RM) -r $(OBJ)
@echo Deleting $(EMULATOR)...
@-$(RM) $(EMULATOR)