handle bad cd images better
[pcsx_rearmed.git] / Makefile
... / ...
CommitLineData
1# Makefile for PCSX ReARMed
2
3# default stuff goes here, so that config can override
4TARGET = pcsx
5CFLAGS += -Wall -ggdb -Ifrontend -ffast-math
6LDLIBS += -lpthread
7ifndef DEBUG
8CFLAGS += -O2 -DNDEBUG
9endif
10CXXFLAGS += $(CFLAGS)
11#DRC_DBG = 1
12#PCNT = 1
13
14all: config.mak target_ plugins_
15
16ifneq ($(wildcard config.mak),)
17config.mak: ./configure
18 @echo $@ is out-of-date, running configure
19 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
20include config.mak
21else
22config.mak:
23 @echo "Please run ./configure before running make!"
24 @exit 1
25endif
26-include Makefile.local
27
28CC_LINK = $(CC)
29LDLIBS += $(MAIN_LDLIBS)
30
31# core
32OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/debug.o \
33 libpcsxcore/decode_xa.o libpcsxcore/disr3000a.o libpcsxcore/mdec.o \
34 libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
35 libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o libpcsxcore/psxhle.o \
36 libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o libpcsxcore/r3000a.o \
37 libpcsxcore/sio.o libpcsxcore/socket.o libpcsxcore/spu.o
38OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
39ifeq "$(ARCH)" "arm"
40OBJS += libpcsxcore/gte_arm.o
41endif
42ifeq "$(HAVE_NEON)" "1"
43OBJS += libpcsxcore/gte_neon.o
44endif
45libpcsxcore/gte.o libpcsxcore/gte_nf.o: CFLAGS += -fno-strict-aliasing
46libpcsxcore/cdrom.o libpcsxcore/misc.o: CFLAGS += -Wno-pointer-sign
47libpcsxcore/misc.o libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
48
49# dynarec
50ifeq "$(USE_DYNAREC)" "1"
51OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o
52OBJS += libpcsxcore/new_dynarec/pcsxmem.o
53endif
54OBJS += libpcsxcore/new_dynarec/emu_if.o
55libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c \
56 libpcsxcore/new_dynarec/pcsxmem_inline.c
57libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -Wno-all -Wno-pointer-sign
58ifdef DRC_DBG
59libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
60CFLAGS += -DDRC_DBG
61endif
62ifeq "$(DRC_CACHE_BASE)" "1"
63libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_FIXED=1
64endif
65
66# spu
67OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
68 plugins/dfsound/registers.o plugins/dfsound/spu.o \
69 plugins/dfsound/out.o plugins/dfsound/nullsnd.o
70plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
71 plugins/dfsound/xa.c
72ifeq "$(ARCH)" "arm"
73OBJS += plugins/dfsound/arm_utils.o
74endif
75ifneq ($(findstring oss,$(SOUND_DRIVERS)),)
76plugins/dfsound/out.o: CFLAGS += -DHAVE_OSS
77OBJS += plugins/dfsound/oss.o
78endif
79ifneq ($(findstring alsa,$(SOUND_DRIVERS)),)
80plugins/dfsound/out.o: CFLAGS += -DHAVE_ALSA
81OBJS += plugins/dfsound/alsa.o
82LDLIBS += -lasound
83endif
84ifneq ($(findstring sdl,$(SOUND_DRIVERS)),)
85plugins/dfsound/out.o: CFLAGS += -DHAVE_SDL
86OBJS += plugins/dfsound/sdl.o
87endif
88ifneq ($(findstring pulseaudio,$(SOUND_DRIVERS)),)
89plugins/dfsound/out.o: CFLAGS += -DHAVE_PULSE
90OBJS += plugins/dfsound/pulseaudio.o
91endif
92ifneq ($(findstring libretro,$(SOUND_DRIVERS)),)
93plugins/dfsound/out.o: CFLAGS += -DHAVE_LIBRETRO
94endif
95
96# builtin gpu
97OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
98ifeq "$(HAVE_NEON)" "1"
99OBJS += plugins/gpulib/cspace_neon.o
100else
101OBJS += plugins/gpulib/cspace.o
102endif
103ifeq "$(BUILTIN_GPU)" "neon"
104OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
105plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
106plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
107endif
108ifeq "$(BUILTIN_GPU)" "peops"
109# note: code is not safe for strict-aliasing? (Castlevania problems)
110plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
111plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
112OBJS += plugins/dfxvideo/gpulib_if.o
113endif
114ifeq "$(BUILTIN_GPU)" "unai"
115OBJS += plugins/gpulib/cspace.o
116OBJS += plugins/gpu_unai/gpulib_if.o
117ifeq "$(ARCH)" "arm"
118OBJS += plugins/gpu_unai/gpu_arm.o
119endif
120plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -O3
121CC_LINK = $(CXX)
122endif
123
124# cdrcimg
125OBJS += plugins/cdrcimg/cdrcimg.o
126
127# dfinput
128OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
129
130# misc
131ifeq "$(HAVE_NEON)" "1"
132OBJS += frontend/libpicofe/arm/neon_scale2x.o
133OBJS += frontend/libpicofe/arm/neon_eagle2x.o
134frontend/libpicofe/arm/neon_scale2x.o: CFLAGS += -DDO_BGR_TO_RGB
135frontend/libpicofe/arm/neon_eagle2x.o: CFLAGS += -DDO_BGR_TO_RGB
136endif
137
138# gui
139OBJS += frontend/main.o frontend/plugin.o
140OBJS += frontend/common/readpng.o frontend/common/fonts.o
141OBJS += frontend/linux/plat.o
142
143ifeq "$(PLATFORM)" "generic"
144OBJS += frontend/plat_sdl.o frontend/common/in_sdl.o
145USE_FRONTEND = 1
146endif
147ifeq "$(PLATFORM)" "pandora"
148OBJS += frontend/linux/fbdev.o
149OBJS += frontend/plat_omap.o frontend/linux/xenv.o
150OBJS += frontend/plat_pandora.o
151USE_FRONTEND = 1
152endif
153ifeq "$(PLATFORM)" "caanoo"
154OBJS += frontend/plat_pollux.o frontend/in_tsbutton.o frontend/blit320.o
155OBJS += frontend/gp2x/in_gp2x.o frontend/warm/warm.o
156libpcsxcore/new_dynarec/pcsxmem.o: CFLAGS += -DCUSTOM_MEMMAPS
157USE_FRONTEND = 1
158endif
159ifeq "$(PLATFORM)" "maemo"
160OBJS += maemo/hildon.o maemo/main.o
161maemo/%.o: maemo/%.c
162OBJS += frontend/plugin_lib.o
163endif
164ifeq "$(PLATFORM)" "libretro"
165OBJS += frontend/libretro.o
166endif
167ifeq "$(USE_FRONTEND)" "1"
168OBJS += frontend/menu.o frontend/linux/in_evdev.o
169OBJS += frontend/common/input.o
170OBJS += frontend/plugin_lib.o
171ifeq "$(HAVE_TSLIB)" "1"
172frontend/%.o: CFLAGS += -DHAVE_TSLIB
173OBJS += frontend/pl_gun_ts.o
174endif
175else
176CFLAGS += -DNO_FRONTEND
177endif
178
179ifdef X11
180frontend/%.o: CFLAGS += -DX11
181OBJS += frontend/xkb.o
182endif
183ifdef PCNT
184CFLAGS += -DPCNT
185endif
186frontend/%.o: CFLAGS += -DIN_EVDEV
187frontend/menu.o frontend/main.o frontend/plat_sdl.o: frontend/revision.h
188
189frontend/libpicofe/arm/neon_scale2x.S frontend/libpicofe/menu.c:
190 @echo "libpicofe module is missing, please run:"
191 @echo "git submodule init && git submodule update"
192 @exit 1
193
194
195libpcsxcore/gte_nf.o: libpcsxcore/gte.c
196 $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
197
198frontend/revision.h: FORCE
199 @(git describe || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
200 @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
201 @rm $@_
202
203%.o: %.S
204 $(CC) $(CFLAGS) -c $^ -o $@
205
206target_: $(TARGET)
207
208$(TARGET): $(OBJS)
209 $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) -Wl,-Map=$@.map
210
211clean: $(PLAT_CLEAN) clean_plugins
212 $(RM) $(TARGET) $(OBJS) $(TARGET).map
213
214ifneq ($(PLUGINS),)
215plugins_: $(PLUGINS)
216
217$(PLUGINS):
218 make -C $(dir $@)
219
220clean_plugins:
221 make -C plugins/gpulib/ clean
222 for dir in $(PLUGINS) ; do \
223 $(MAKE) -C $$(dirname $$dir) clean; done
224else
225plugins_:
226clean_plugins:
227endif
228
229.PHONY: all clean target_ plugins_ clean_plugins FORCE
230
231# ----------- release -----------
232
233VER ?= $(shell git describe HEAD)
234
235ifeq "$(PLATFORM)" "generic"
236OUT = pcsx_rearmed_$(VER)
237
238rel: pcsx $(PLUGINS) \
239 frontend/pandora/skin readme.txt COPYING
240 rm -rf $(OUT)
241 mkdir -p $(OUT)/plugins
242 mkdir -p $(OUT)/bios
243 cp -r $^ $(OUT)/
244 mv $(OUT)/*.so* $(OUT)/plugins/
245 zip -9 -r $(OUT).zip $(OUT)
246endif
247
248ifeq "$(PLATFORM)" "pandora"
249PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
250
251rel: pcsx $(PLUGINS) \
252 frontend/pandora/pcsx.sh frontend/pandora/pcsx.pxml.templ frontend/pandora/pcsx.png \
253 frontend/pandora/picorestore frontend/pandora/skin readme.txt COPYING
254 rm -rf out
255 mkdir -p out/plugins
256 cp -r $^ out/
257 sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
258 rm out/pcsx.pxml.templ
259 mv out/*.so out/plugins/
260 $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i frontend/pandora/pcsx.png -c
261endif
262
263ifeq "$(PLATFORM)" "caanoo"
264PLAT_CLEAN = caanoo_clean
265
266caanoo_clean:
267 $(RM) frontend/320240/pollux_set
268
269rel: pcsx $(PLUGINS) \
270 frontend/320240/caanoo.gpe frontend/320240/pcsx26.png \
271 frontend/320240/pcsxb.png frontend/320240/skin \
272 frontend/warm/bin/warm_2.6.24.ko frontend/320240/pollux_set \
273 frontend/320240/pcsx_rearmed.ini frontend/320240/haptic_w.cfg \
274 frontend/320240/haptic_s.cfg \
275 readme.txt COPYING
276 rm -rf out
277 mkdir -p out/pcsx_rearmed/plugins
278 cp -r $^ out/pcsx_rearmed/
279 mv out/pcsx_rearmed/*.so out/pcsx_rearmed/plugins/
280 mv out/pcsx_rearmed/caanoo.gpe out/pcsx_rearmed/pcsx.gpe
281 mv out/pcsx_rearmed/pcsx_rearmed.ini out/
282 mkdir out/pcsx_rearmed/lib/
283 cp ./lib/libbz2.so.1 out/pcsx_rearmed/lib/
284 mkdir out/pcsx_rearmed/bios/
285 cd out && zip -9 -r ../pcsx_rearmed_$(VER)_caanoo.zip *
286endif