aboutsummaryrefslogtreecommitdiff
path: root/source/Makefile
blob: 9bc8f9768088cad03ba5316faa032fae0011bc01 (plain)
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
# Generated automatically from Makefile.in by configure.
#ZSNESFX=1
#ZSNESC4=1
#ASMCPU=1
#SPC700ASM=1
#NETPLAY=1
#UNZIP=1
#GLIDE=1
#OPENGL=1
#AIDO=1
#GUI=0
#THREAD_SOUND=1
#ASMKREED=1
SDD1_DECOMP=1
#SDD1_VERIFY=0

#Fairly good and special-char-safe descriptor of the os being built on.
OS=`uname -s -r -m|sed \"s/ /-/g\"|tr \"[A-Z]\" \"[a-z]\"|tr \"/()\" \"___\"`
BUILDDIR=.
#BUILDDIR=build/$(OS)


ifdef ZSNESFX
FXOBJ=i386/fxemu2b.o i386/fxemu2.o i386/fxemu2c.o i386/fxtable.o i386/sfxproc.o i386/ZSNES.O
FXDEFINES=-DZSNES_FX -DEXECUTE_SUPERFX_PER_LINE
FXDEPENDS=zsnes_fx
FXNO_DEPENDS=c_fx
else
FXOBJ=fxinst.o fxemu.o fxdbg.o
FXDEFINES=-DEXECUTE_SUPERFX_PER_LINE
FXDEPENDS=c_fx
FXNO_DEPENDS=zsnes_fx
endif

ifdef ZSNESC4
C4OBJ=i386/C4.O i386/zsnesc4.o c4.o
C4DEFINES=-DZSNES_C4
C4DEPENDS=zsnes_c4
C4NO_DEPENDS=c_c4
else
C4OBJ=c4.o c4emu.o
C4DEFINES=
C4DEPENDS=c_c4
C4NO_DEPENDS=zsnes_c4
endif

ifdef SPC700ASM
SOUNDOBJ=spctool/spc700.o spctool/dsp.o spctool.o spctool/soundmod.o SPC.O
SOUNDDEFINES=-DSPCTOOL
else
SOUNDOBJ=spc700.o soundux.o apu.o 
SOUNDDEFINES=-DSPC700_C
endif

ifdef ASMCPU
CPUOBJ=i386/cpuops.o i386/cpuexec.o i386/sa1ops.o
else
CPUOBJ=cpuops.o cpuexec.o sa1cpu.o
endif

ifdef ASMKREED
KREEDOBJ=i386/2XSAIMMX.O i386/bilinear.o 2xsai.o
KREEDDEFINES=-DMMX
else
KREEDDEFINES=
# KREEDOBJ=2xsai.o
endif

ifdef SDD1_DECOMP
SDD1OBJ=sdd1emu.o
ifdef SDD1_VERIFY
SDD1DEFINES=-DSDD1_DECOMP -DSDD1_VERIFY
else
SDD1DEFINES=-DSDD1_DECOMP
endif
else
SDD1DEFINES=
SDD1OBJ=
endif

SPC7110OBJ=spc7110.o
OBC1OBJ=obc1.o
SETAOBJ=seta.o seta010.o seta011.o seta018.o

OBJECTS=$(CPUOBJ) $(SOUNDOBJ) apudebug.o $(FXOBJ) $(C4OBJ) \
	cpu.o sa1.o debug.o sdd1.o tile.o srtc.o \
	gfx.o memmap.o snaporig.o clip.o dsp1.o \
	movie.o \
	ppu.o dma.o snes9x.o snapshot.o screenshot.o \
        cheats.o cheats2.o data.o unix/unix.o unix/config.o globals.o \
	$(SPC7110OBJ) $(OBC1OBJ) $(SETAOBJ) $(KREEDOBJ) $(SDD1OBJ)

#OBJECTS += ../zlib/libz.a

#FIXME: The gui is bitrotted if it ever worked at all. Remove?
ifdef GUI
GUIOBJS = unix/snes9x_gui.o unix/moc_snes9x_gui.o
GUILIBS = -L$(QTDIR)/lib -lqt
GUIDEFINES = -I$(QTDIR)/include
endif

ifdef NETPLAY
OBJECTS += netplay.o server.o
NETPLAYDEFINES=-DNETPLAY_SUPPORT
SERVER_OBJECTS=server.o
endif

ifdef UNZIP
OBJECTS += loadzip.o unzip/unzip.o unzip/explode.o unzip/unreduce.o unzip/unshrink.o
UNZIPDEFINES=-DUNZIP_SUPPORT
endif

ifdef THREAD_SOUND
CPUDEFINES += -DUSE_THREADS
EXTRALIBS += -lpthread
endif

ifdef GLIDE
GLIDEOBJS = unix/glide.o
GLIDEDEFINES = -DUSE_GLIDE -I/usr/include/glide
GLIDELIBS = -lglide2x
endif

ifdef OPENGL
OPENGLOBJS = unix/opengl.o
OPENGLDEFINES = -DUSE_OPENGL
OPENGLLIBS = -lGL -lGLU -ldl
endif

ifdef AIDO
AIDOOBJS = unix/aido.o
AIDODEFINES = -DUSE_AIDO
endif

JOYDEFINES = 

MOC = $(QTDIR)/bin/moc
CCC = c++  -fno-rtti
GASM = c++
CC = gcc
NASM = /usr/bin/nasm

#INCLUDES = -I../zlib -INONE
INCLUDES = -INONE

#OPTIMISE =  -mcpu=pentiumpro -O6 -fomit-frame-pointer -fno-exceptions -Wall -W -pedantic -Wno-unused-parameter -pipe
OPTIMISE =  -O6 -fomit-frame-pointer -fno-exceptions -Wall -W -pedantic -Wno-unused-parameter -pipe

#OPTIMISE=-g -fno-exceptions

CCFLAGS = $(OPTIMISE) -DMITSHM \
 -I. \
-Iunzip \
-DVAR_CYCLES \
-DCPU_SHUTDOWN \
-DSPC700_SHUTDOWN \
$(FXDEFINES) \
$(C4DEFINES) \
$(CPUDEFINES) \
$(SOUNDDEFINES) \
$(NETPLAYDEFINES) \
$(UNZIPDEFINES) \
$(GLIDEDEFINES) \
$(OPENGLDEFINES) \
$(AIDODEFINES) \
$(GUIDEFINES) \
$(KREEDDEFINES) \
$(SDD1DEFINES) \
$(JOYDEFINES) \
-DNO_INLINE_SET_GET  -DNOASM -DHAVE_MKSTEMP '-DACCEPT_SIZE_T=size_t'

#-DOLD_COLOUR_BLENDING
#-DSOUND
#-DDEBUGGER
#-DNO_INLINE_SET_GET
#-DVAR_CYCLES
#-DCPU_SHUTDOWN
#-DSPC700_SHUTDOWN

CFLAGS=$(CCFLAGS)

.SUFFIXES: .o .cpp .c .cc .h .m .i .S .asm .obj .O .CPP .C .ASM
#FIXME: Why is this set statically?
#LDLIBS = -L/usr/X11R6/lib
# -L../zlib

ifdef GLIDE
all: Makefile configure offsets gsnes9x
else
ifdef OPENGL
all: Makefile configure offsets osnes9x
else
# all: Makefile configure offsets snes9x
all: Makefile configure snes9x  
endif
endif

Makefile: configure Makefile.in
	@echo "Makefile is older than configure or in-file. Run configure or touch Makefile."
	exit 1

configure: configure.in
	@echo "configure is older than in-file. Run autoconf or touch configure."
	exit 1

#ssnes9x
#ggisnes9x
#xf86snes9x

# offsets: offsets.o
# 	$(CCC) $(INCLUDES) -o $@ offsets.o
# 	./offsets >i386/offsets.h

#../zlib/libz.a:
#	cd ../zlib && sh ./configure && make

snes9x: $(OBJECTS) $(AIDOOBJS) $(GUIOBJS)
	$(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(AIDOOBJS) $(GLIDEOBJS) $(OPENGLOBJS) $(GUIOBJS) $(LDLIBS) $(GLIDELIBS) $(OPENGLLIBS) $(GUILIBS)  -lnsl  -lXext -lX11 $(EXTRALIBS) -lm

ssnes9x: $(OBJECTS) unix/svga.o 
	$(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(GLIDEOBJS) unix/svga.o $(LDLIBS) $(GLIDELIBS) -lvga -lvgagl $(EXTRALIBS) -lm

gsnes9x: $(OBJECTS) $(GLIDEOBJS)
	$(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(GLIDEOBJS) $(LDLIBS) -lglide $(EXTRALIBS) -lm

ggisnes9x: $(OBJECTS) unix/ggi.o
	$(CCC) $(INCLUDES) -o $@ $(OBJECTS) unix/ggi.o $(LDLIBS) -lggi $(EXTRALIBS) -lm

osnes9x: $(OBJECTS) $(OPENGLOBJS)
	$(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(OPENGLOBJS) $(LDLIBS) $(OPENGLLIBS)  -lnsl  -lXext -lX11 $(EXTRALIBS) -lm

s9xserver: $(SERVER_OBJECTS)
	$(CCC) $(INCLUDES) -o $@ $(SERVER_OBJECTS) 

.cpp.o:
	$(CCC) $(INCLUDES) -c $(CCFLAGS) $*.cpp -o $@

.c.o:
	$(CC) $(INCLUDES) -c $(CCFLAGS) $*.c -o $@

.cpp.S:
	$(GASM) $(INCLUDES) -S $(CCFLAGS) $*.cpp -o $@

.cpp.i:
	$(GASM) $(INCLUDES) -E $(CCFLAGS) $*.cpp -o $@

.S.o:
	$(GASM) $(INCLUDES) -c $(CCFLAGS) $*.S -o $@

.S.i:
	$(GASM) $(INCLUDES) -c -E $(CCFLAGS) $*.S -o $@

.asm.o:
	$(NASM) -f elf $(FXDEFINES) -i. -ii386 -o $@ $*.asm

.obj.o:
	cp $*.obj $*.o

.CPP.O:
	$(CCC) $(INCLUDES) -c $(CCFLAGS) -x c++ $*.CPP -o $@

.C.O:
	$(CC) $(INCLUDES) -c $(CCFLAGS) $*.C -o $@

.ASM.O:
	$(NASM) -f elf $(FXDEFINES) -i . -i i386 $*.ASM -o $@

unix/moc_snes9x_gui.cpp: unix/snes9x_gui.h
	$(MOC) unix/snes9x_gui.h -o $@

clean:
	rm -f $(OBJECTS) offsets.o unix/svga.o unix/aido.o unix/ggi.o unix/xf86.o unix/glide.o

#release: CCFLAGS += -DNO_DEBUGGER

_bin-package:
	RELNR=`grep "#define VERSION" snes9x.h | sed -e 's/"//g' | awk '{ print $$3 }'` && \
	echo $$RELNR && \
	RELNAME=snes9x-$${RELNR} && export RELNAME && \
	test \! -f $${RELNAME}.tar.gz && \
	DISTDIR=disttmp/$${RELNAME}/ && \
	rm -rf disttmp && \
	mkdir disttmp && \
	mkdir $${DISTDIR} && \
	cp snes9x $${DISTDIR} && \
	cp config.info hardware.txt problems.txt changes.txt ../faqs.txt ../readme.txt ../readme.unix $${DISTDIR} && \
	(cd disttmp && tar cvf - $${RELNAME}) | gzip -c > $${RELNAME}.tar.gz &&\
	rm -rf disttmp

#FIXME: Should possibly have clean, but not in xenofarm build
bin-release: snes9x _bin-package

#FIXME: Intelligent messages when bailing out.
#FIXME: See those ls:s? Don't look to closely at the statements...
_src-package:
	RELNR=`grep "#define VERSION" snes9x.h | sed -e 's/"//g' | awk '{ print $$3 }'` && \
	echo $$RELNR && \
	RELNAME=snes9x-$${RELNR}-src && \
	test \! -f $${RELNAME}.tar.gz && \
	test \! `ls *~` && \
	test \! `ls *.o` && \
	test \! -f snes9x && \
	export RELNR && export RELNAME && \
	(cd .. && PWD=`pwd` && SNESDIR=`basename $$PWD` && cd .. && \
	 DISTDIR=disttmp/$${RELNAME} && \
	 rm -rf disttmp && \
	 mkdir disttmp && \
	 cp -r $${SNESDIR} $${DISTDIR} && \
	 rm -f $${DISTDIR}/snes9x/config.* 2>/dev/null && \
	 rm -f $${DISTDIR}/snes9x/conftezt.out.* 2>/dev/null && \
	 rm -rf $${DISTDIR}/snes9x/autom4te.cache 2>/dev/null && \
	 rm $${DISTDIR}/snes9x/Makefile && \
	 find disttmp -name CVS -type f -exec rm "{}" \; && \
	 find disttmp -name CVS -type d -exec rm "{}" \; && \
	 (cd disttmp && tar cvf - $${RELNAME}) | gzip -c > $${RELNAME}.tar.gz  && \
	mv $${RELNAME}.tar.gz $${SNESDIR}/snes9x/ ) && \
	rm -rf disttmp

#Requires:
# 1. Prestine checkout
# 2. `autoconf`
# 3. `./configure`
src-release: depend _src-package

xenofarm:
	./xenofarm.sh
	cd build/xenofarm && tar cf - . > ../../../xenofarm_result.tar
	gzip -f9 ../xenofarm_result.tar

# And now for the impressive testsuite:
verify: snes9x
	./snes9x --selftest

#FIXME: Make a auto-self-reference.
depend:
	$(CC) $(CFLAGS) -MM -MG \
	  `find . '(' -name '*.c' -o -name '*.cpp' -o -name '*.S' ')' -print -o -name msdos -prune` \
	  | sed -e 's@^[^ :]*: *\([^ ]*/\)[^ /]*@\1&@' \
	  >dependencies

include dependencies