-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile.orig
307 lines (249 loc) · 7.42 KB
/
makefile.orig
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
# set this to mame, mess or the destination you want to build
# TARGET = mame
# TARGET = mess
# TARGET = mmsnd
# example for a tiny compile
# TARGET = tiny
ifeq ($(TARGET),)
TARGET = mame
endif
# uncomment next line to include the debugger
# DEBUG = 1
# uncomment next line to include the symbols for symify
# SYMBOLS = 1
# uncomment next line to generate a link map for exception handling in windows
# MAP = 1
# uncomment next line to use DRC MIPS3 engine
X86_MIPS3_DRC = 1
# uncomment next line to use the new multiwindow debugger
NEW_DEBUGGER = 1
# uncomment next line to use cygwin compiler
# COMPILESYSTEM_CYGWIN = 1
# uncomment next line to build expat as part of MAME build
BUILD_EXPAT = 1
# uncomment next line to build zlib as part of MAME build
BUILD_ZLIB = 1
# set this the operating system you're building for
# MAMEOS = msdos
# MAMEOS = windows
ifeq ($(MAMEOS),)
MAMEOS = windows
endif
# extension for executables
EXE = .exe
# CPU core include paths
VPATH=src $(wildcard src/cpu/*)
# compiler, linker and utilities
AR = @ar
CC = @gcc
LD = @gcc
ASM = @nasm
ASMFLAGS = -f coff
MD = -mkdir.exe
RM = @rm -f
#PERL = @perl -w
ifeq ($(MAMEOS),msdos)
PREFIX = d
else
PREFIX =
endif
ifdef DEBUG
NAME = $(PREFIX)$(TARGET)$(SUFFIX)d
else
ifdef ATHLON
NAME = $(PREFIX)$(TARGET)$(SUFFIX)at
ARCH = -march=athlon
else
ifdef K6
NAME = $(PREFIX)$(TARGET)$(SUFFIX)k6
ARCH = -march=k6
else
ifdef I686
NAME = $(PREFIX)$(TARGET)$(SUFFIX)pp
ARCH = -march=pentiumpro
else
ifdef P4
NAME = $(PREFIX)$(TARGET)$(SUFFIX)p4
ARCH = -march=pentium4
else
NAME = $(PREFIX)$(TARGET)$(SUFFIX)
ARCH = -march=pentium
endif
endif
endif
endif
endif
# build the targets in different object dirs, since mess changes
# some structures and thus they can't be linked against each other.
OBJ = obj/$(NAME)
EMULATOR = $(NAME)$(EXE)
DEFS = -DX86_ASM -DLSB_FIRST -DINLINE="static __inline__" -Dasm=__asm__ -DCRLF=3
ifdef NEW_DEBUGGER
DEFS += -DNEW_DEBUGGER
endif
CFLAGS = -std=gnu99 -Isrc -Isrc/includes -Isrc/debug -Isrc/$(MAMEOS) -I$(OBJ)/cpu/m68000 -Isrc/cpu/m68000
ifdef SYMBOLS
CFLAGS += -O0 -Wall -Wno-unused -g
else
CFLAGS += -DNDEBUG \
$(ARCH) -O3 -fomit-frame-pointer -fno-strict-aliasing \
-Werror -Wall -Wno-sign-compare -Wunused -Wno-unused-functions \
-Wpointer-arith -Wbad-function-cast -Wcast-align \
-Wstrict-prototypes -Wundef \
-Wformat-security -Wwrite-strings \
-Wdisabled-optimization \
# -Wredundant-decls
# -Wfloat-equal
# -Wunreachable-code -Wpadded
# -W had to remove because of the "missing initializer" warning
# -Wlarger-than-262144 \
# -Wcast-qual \
# -Wwrite-strings \
# -Wconversion \
# -Wmissing-prototypes \
# -Wmissing-declarations
endif
# extra options needed *only* for the osd files
CFLAGSOSDEPEND = $(CFLAGS)
# the windows osd code at least cannot be compiled with -pedantic
CFLAGSPEDANTIC = $(CFLAGS) -pedantic
ifdef SYMBOLS
LDFLAGS =
else
#LDFLAGS = -s -Wl,--warn-common
LDFLAGS = -s
endif
ifdef MAP
MAPFLAGS = -Wl,-Map,$(NAME).map
else
MAPFLAGS =
endif
OBJDIRS = obj $(OBJ) $(OBJ)/cpu $(OBJ)/sound $(OBJ)/$(MAMEOS) \
$(OBJ)/drivers $(OBJ)/machine $(OBJ)/vidhrdw $(OBJ)/sndhrdw $(OBJ)/debug
ifdef MESS
OBJDIRS += $(OBJ)/mess $(OBJ)/mess/systems $(OBJ)/mess/machine \
$(OBJ)/mess/vidhrdw $(OBJ)/mess/sndhrdw $(OBJ)/mess/tools
endif
ifeq ($(TARGET),mmsnd)
OBJDIRS += $(OBJ)/mmsnd $(OBJ)/mmsnd/machine $(OBJ)/mmsnd/drivers $(OBJ)/mmsnd/sndhrdw
endif
# start with an empty set of libs
LIBS =
ifdef BUILD_EXPAT
CFLAGS += -Isrc/expat
OBJDIRS += $(OBJ)/expat
EXPAT = $(OBJ)/libexpat.a
else
LIBS += -lexpat
EXPAT =
endif
ifdef BUILD_ZLIB
CFLAGS += -Isrc/zlib
OBJDIRS += $(OBJ)/zlib
ZLIB = $(OBJ)/libz.a
else
LIBS += -lz
ZLIB =
endif
all: maketree $(EMULATOR) extra
# include the various .mak files
include src/core.mak
include src/$(TARGET).mak
include src/rules.mak
include src/$(MAMEOS)/$(MAMEOS).mak
ifdef DEBUG
DBGDEFS = -DMAME_DEBUG
else
DBGDEFS =
DBGOBJS =
endif
ifdef COMPILESYSTEM_CYGWIN
CFLAGS += -mno-cygwin
LDFLAGS += -mno-cygwin
endif
extra: $(TOOLS) $(TEXTS)
# combine the various definitions to one
CDEFS = $(DEFS) $(COREDEFS) $(CPUDEFS) $(SOUNDDEFS) $(ASMDEFS) $(DBGDEFS)
# primary target
$(EMULATOR): $(OBJS) $(COREOBJS) $(OSOBJS) $(DRVLIBS) $(EXPAT) $(ZLIB)
# always recompile the version string
$(CC) $(CDEFS) $(CFLAGSPEDANTIC) -c src/version.c -o $(OBJ)/version.o
@echo Linking $@...
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@ $(MAPFLAGS)
romcmp$(EXE): $(OBJ)/romcmp.o $(OBJ)/unzip.o $(ZLIB)
@echo Linking $@...
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@
chdman$(EXE): $(OBJ)/chdman.o $(OBJ)/chd.o $(OBJ)/chdcd.o $(OBJ)/cdrom.o $(OBJ)/md5.o $(OBJ)/sha1.o $(OBJ)/version.o $(ZLIB)
@echo Linking $@...
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@
xml2info$(EXE): $(OBJ)/xml2info.o $(EXPAT)
@echo Linking $@...
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@
# secondary libraries
$(OBJ)/libexpat.a: $(OBJ)/expat/xmlparse.o $(OBJ)/expat/xmlrole.o $(OBJ)/expat/xmltok.o
$(OBJ)/libz.a: $(OBJ)/zlib/adler32.o $(OBJ)/zlib/compress.o $(OBJ)/zlib/crc32.o $(OBJ)/zlib/deflate.o \
$(OBJ)/zlib/gzio.o $(OBJ)/zlib/inffast.o $(OBJ)/zlib/inflate.o $(OBJ)/zlib/infback.o \
$(OBJ)/zlib/inftrees.o $(OBJ)/zlib/trees.o $(OBJ)/zlib/uncompr.o $(OBJ)/zlib/zutil.o
ifdef PERL
$(OBJ)/cpuintrf.o: src/cpuintrf.c rules.mak
$(PERL) src/makelist.pl
@echo Compiling $<...
$(CC) $(CDEFS) $(CFLAGSPEDANTIC) -c $< -o $@
endif
$(OBJ)/$(MAMEOS)/%.o: src/$(MAMEOS)/%.c
@echo Compiling $<...
$(CC) $(CDEFS) $(CFLAGSOSDEPEND) -c $< -o $@
$(OBJ)/%.o: src/%.c
@echo Compiling $<...
$(CC) $(CDEFS) $(CFLAGS) -c $< -o $@
# compile generated C files for the 68000 emulator
$(M68000_GENERATED_OBJS): $(OBJ)/cpu/m68000/m68kmake$(EXE)
@echo Compiling $(subst .o,.c,$@)...
$(CC) $(CDEFS) $(CFLAGSPEDANTIC) -c $*.c -o $@
# 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 $<...
$(CC) $(CDEFS) $(CFLAGSPEDANTIC) -DDOS -o $(OBJ)/cpu/m68000/m68kmake$(EXE) $<
@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 $<...
$(CC) $(CDEFS) $(CFLAGSPEDANTIC) -O0 -DDOS -o $(OBJ)/cpu/m68000/make68k$(EXE) $<
@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) $(CFLAGSPEDANTIC) -O0 -DDOS -o $(OBJ)/cpu/m68000/make68k$(EXE) $<
@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) $@
$(AR) cr $@ $^
$(sort $(OBJDIRS)):
$(MD) $@
maketree: $(sort $(OBJDIRS))
clean:
@echo Deleting object tree $(OBJ)...
$(RM) -r $(OBJ)
@echo Deleting $(EMULATOR)...
$(RM) $(EMULATOR)
clean68k:
@echo Deleting 68k files...
$(RM) -r $(OBJ)/cpuintrf.o
$(RM) -r $(OBJ)/drivers/cps2.o
$(RM) -r $(OBJ)/cpu/m68000
check: $(EMULATOR) xml2info$(EXE)
./$(EMULATOR) -listxml > $(NAME).xml
./xml2info < $(NAME).xml > $(NAME).lst
./xmllint --valid --noout $(NAME).xml