fix various fPIC issues
[pcsx_rearmed.git] / Makefile
CommitLineData
4132e8ca 1# Makefile for PCSX ReARMed
a80ae4a0 2
61bc6d40 3# default stuff goes here, so that config can override
4132e8ca 4TARGET = pcsx
a80ae4a0 5CFLAGS += -Wall -ggdb -Ifrontend -ffast-math
4132e8ca 6LDLIBS += -lpthread -ldl -lpng -lz -lm
f95a77f7 7ifndef DEBUG
cfbd3c6e 8CFLAGS += -O2 -DNDEBUG
b60f2812 9endif
61bc6d40 10CXXFLAGS += $(CFLAGS)
4132e8ca 11#DRC_DBG = 1
12#PCNT = 1
80c2304e 13
38c2028e 14all: config.mak target_ plugins_
de38f20e 15
4132e8ca 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
80c2304e 27
61bc6d40 28CC_LINK = $(CC)
29
80c2304e 30# core
31OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/debug.o \
3ebefe71 32 libpcsxcore/decode_xa.o libpcsxcore/disr3000a.o libpcsxcore/mdec.o \
80c2304e 33 libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
34 libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o libpcsxcore/psxhle.o \
35 libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o libpcsxcore/r3000a.o \
36 libpcsxcore/sio.o libpcsxcore/socket.o libpcsxcore/spu.o
59774ed0 37OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
38ifeq "$(ARCH)" "arm"
39OBJS += libpcsxcore/gte_arm.o
40endif
a80ae4a0 41ifeq "$(HAVE_NEON)" "1"
8cfbda97 42OBJS += libpcsxcore/gte_neon.o
43endif
ac6575cd 44libpcsxcore/gte.o libpcsxcore/gte_nf.o: CFLAGS += -fno-strict-aliasing
ab948f7e 45libpcsxcore/cdrom.o libpcsxcore/misc.o: CFLAGS += -Wno-pointer-sign
46libpcsxcore/misc.o libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
47
f95a77f7 48# dynarec
4132e8ca 49ifeq "$(USE_DYNAREC)" "1"
7139f3c8 50OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o
7e605697 51OBJS += libpcsxcore/new_dynarec/pcsxmem.o
7139f3c8 52endif
53OBJS += libpcsxcore/new_dynarec/emu_if.o
b1be1eee 54libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c \
55 libpcsxcore/new_dynarec/pcsxmem_inline.c
ab948f7e 56libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -Wno-all -Wno-pointer-sign
3eb78778 57ifdef DRC_DBG
58libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
59CFLAGS += -DDRC_DBG
60endif
4132e8ca 61ifeq "$(DRC_CACHE_BASE)" "1"
62libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_FIXED=1
a327ad27 63endif
f95a77f7 64
e906c010 65# spu
ee849648 66OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
67 plugins/dfsound/registers.o plugins/dfsound/spu.o
6d866bb7 68plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
69 plugins/dfsound/xa.c
3a721c1f 70ifeq "$(ARCH)" "arm"
b17618c0 71OBJS += plugins/dfsound/arm_utils.o
72endif
61bc6d40 73ifeq "$(SOUND_DRIVER)" "oss"
de38f20e 74plugins/dfsound/%.o: CFLAGS += -DUSEOSS
75OBJS += plugins/dfsound/oss.o
76endif
61bc6d40 77ifeq "$(SOUND_DRIVER)" "alsa"
de38f20e 78plugins/dfsound/%.o: CFLAGS += -DUSEALSA
79OBJS += plugins/dfsound/alsa.o
4132e8ca 80LDLIBS += -lasound
81endif
61bc6d40 82ifeq "$(SOUND_DRIVER)" "none"
4132e8ca 83OBJS += plugins/dfsound/nullsnd.o
de38f20e 84endif
85
61bc6d40 86# builtin gpu
87OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
90ca4913 88ifeq "$(HAVE_NEON)" "1"
62d7fa95 89OBJS += plugins/gpulib/cspace_neon.o
61bc6d40 90else
91OBJS += plugins/gpulib/cspace.o
92endif
93ifeq "$(BUILTIN_GPU)" "neon"
90ca4913 94OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
95plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
96plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
61bc6d40 97endif
98ifeq "$(BUILTIN_GPU)" "peops"
2ef486ee 99# note: code is not safe for strict-aliasing? (Castlevania problems)
62d7fa95 100plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
101plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
102OBJS += plugins/dfxvideo/gpulib_if.o
90ca4913 103endif
61bc6d40 104ifeq "$(BUILTIN_GPU)" "unai"
105OBJS += plugins/gpulib/cspace.o
106OBJS += plugins/gpu_unai/gpulib_if.o
107ifeq "$(ARCH)" "arm"
108OBJS += plugins/gpu_unai/gpu_arm.o
109endif
110plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED
111CC_LINK = $(CXX)
b60f2812 112endif
e0c692d9 113
47bf65ab 114# cdrcimg
47bf65ab 115OBJS += plugins/cdrcimg/cdrcimg.o
e906c010 116
384f5f43 117# dfinput
4c08b9e7 118OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
384f5f43 119
80c2304e 120# gui
29a8c4f3 121OBJS += frontend/main.o frontend/plugin.o
38c2028e 122OBJS += frontend/common/readpng.o frontend/common/fonts.o
123OBJS += frontend/linux/plat.o
55b0eeea 124
4132e8ca 125ifeq "$(PLATFORM)" "generic"
7badc935 126OBJS += frontend/plat_sdl.o frontend/common/in_sdl.o
38c2028e 127USE_FRONTEND = 1
4132e8ca 128endif
55b0eeea 129ifeq "$(PLATFORM)" "pandora"
55b0eeea 130OBJS += frontend/linux/fbdev.o
dd4d5a35 131OBJS += frontend/plat_omap.o frontend/linux/xenv.o
55b0eeea 132OBJS += frontend/plat_pandora.o
38c2028e 133USE_FRONTEND = 1
4132e8ca 134endif
55b0eeea 135ifeq "$(PLATFORM)" "caanoo"
faf2b2aa 136OBJS += frontend/plat_pollux.o frontend/in_tsbutton.o frontend/blit320.o
221be40d 137OBJS += frontend/gp2x/in_gp2x.o frontend/warm/warm.o
38c2028e 138USE_FRONTEND = 1
139endif
140ifeq "$(PLATFORM)" "maemo"
141OBJS += maemo/hildon.o maemo/main.o
142maemo/%.o: maemo/%.c
143OBJS += frontend/plugin_lib.o
144endif
145ifeq "$(PLATFORM)" "libretro"
146OBJS += frontend/libretro.o
147endif
148ifeq "$(USE_FRONTEND)" "1"
149OBJS += frontend/menu.o frontend/linux/in_evdev.o
150OBJS += frontend/common/input.o
151OBJS += frontend/plugin_lib.o
152ifeq "$(HAVE_TSLIB)" "1"
153frontend/%.o: CFLAGS += -DHAVE_TSLIB
154OBJS += frontend/pl_gun_ts.o
155endif
156else
157CFLAGS += -DNO_FRONTEND
55b0eeea 158endif
a80ae4a0 159
447783f8 160ifdef X11
161frontend/%.o: CFLAGS += -DX11
162OBJS += frontend/xkb.o
163endif
72228559 164ifdef PCNT
165CFLAGS += -DPCNT
166endif
ab948f7e 167frontend/%.o: CFLAGS += -DIN_EVDEV
38c2028e 168frontend/menu.o frontend/main.o frontend/plat_sdl.o: frontend/revision.h
3c70c47b 169
59774ed0 170libpcsxcore/gte_nf.o: libpcsxcore/gte.c
171 $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
172
3c70c47b 173frontend/revision.h: FORCE
174 @(git describe || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
175 @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
176 @rm $@_
177.PHONY: FORCE
178
90ca4913 179%.o: %.S
180 $(CC) $(CFLAGS) -c $^ -o $@
80c2304e 181
38c2028e 182target_: $(TARGET)
183
80c2304e 184$(TARGET): $(OBJS)
61bc6d40 185 $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) -Wl,-Map=$@.map
80c2304e 186
dd4d5a35 187clean: $(PLAT_CLEAN) clean_plugins
4132e8ca 188 $(RM) $(TARGET) $(OBJS) $(TARGET).map
0d464c77 189
4132e8ca 190ifneq ($(PLUGINS),)
dd4d5a35 191plugins_: $(PLUGINS)
192
ee78346e 193$(PLUGINS):
194 make -C $(dir $@)
f932e54b 195
ee78346e 196clean_plugins:
ea1f6f2f 197 make -C plugins/gpulib/ clean
ee78346e 198 for dir in $(PLUGINS) ; do \
199 $(MAKE) -C $$(dirname $$dir) clean; done
dd4d5a35 200else
201plugins_:
202clean_plugins:
4132e8ca 203endif
80c2304e 204
303ee308 205# ----------- release -----------
206
4132e8ca 207VER ?= $(shell git describe master)
208
dd4d5a35 209ifeq "$(PLATFORM)" "generic"
210OUT = pcsx_rearmed_$(VER)
211
212rel: pcsx $(PLUGINS) \
213 frontend/pandora/skin readme.txt COPYING
214 rm -rf $(OUT)
215 mkdir -p $(OUT)/plugins
216 mkdir -p $(OUT)/bios
217 cp -r $^ $(OUT)/
218 mv $(OUT)/*.so* $(OUT)/plugins/
219 zip -9 -r $(OUT).zip $(OUT)
220endif
221
4132e8ca 222ifeq "$(PLATFORM)" "pandora"
303ee308 223PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
224
ee78346e 225rel: pcsx $(PLUGINS) \
9e0630ab 226 frontend/pandora/pcsx.sh frontend/pandora/pcsx.pxml.templ frontend/pandora/pcsx.png \
227 frontend/pandora/picorestore frontend/pandora/skin readme.txt COPYING
303ee308 228 rm -rf out
bbd837c6 229 mkdir -p out/plugins
303ee308 230 cp -r $^ out/
3938f69a 231 sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
232 rm out/pcsx.pxml.templ
bbd837c6 233 mv out/*.so out/plugins/
59f1c85c 234 mv out/plugins/gpu_unai.so out/plugins/gpuPCSX4ALL.so
ea1f6f2f 235 mv out/plugins/gpu_gles.so out/plugins/gpuGLES.so
59f1c85c 236 mv out/plugins/gpu_peops.so out/plugins/gpuPEOPS.so
9e0630ab 237 $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i frontend/pandora/pcsx.png -c
4132e8ca 238endif
239
240ifeq "$(PLATFORM)" "caanoo"
241PLAT_CLEAN = caanoo_clean
242
243caanoo_clean:
244 $(RM) frontend/320240/pollux_set
245
4132e8ca 246rel: pcsx $(PLUGINS) \
247 frontend/320240/caanoo.gpe frontend/320240/pcsx26.png \
248 frontend/320240/pcsxb.png frontend/320240/skin \
249 frontend/warm/bin/warm_2.6.24.ko frontend/320240/pollux_set \
250 frontend/320240/pcsx_rearmed.ini frontend/320240/haptic_w.cfg \
251 frontend/320240/haptic_s.cfg \
252 readme.txt COPYING
253 rm -rf out
254 mkdir -p out/pcsx_rearmed/plugins
255 cp -r $^ out/pcsx_rearmed/
256 mv out/pcsx_rearmed/gpu_unai.so out/pcsx_rearmed/gpuPCSX4ALL.so
257 mv out/pcsx_rearmed/gpu_gles.so out/pcsx_rearmed/gpuGLES.so
258 mv out/pcsx_rearmed/*.so out/pcsx_rearmed/plugins/
259 mv out/pcsx_rearmed/caanoo.gpe out/pcsx_rearmed/pcsx.gpe
260 mv out/pcsx_rearmed/pcsx_rearmed.ini out/
261 mkdir out/pcsx_rearmed/lib/
262 cp ./lib/libbz2.so.1 out/pcsx_rearmed/lib/
263 mkdir out/pcsx_rearmed/bios/
264 cd out && zip -9 -r ../pcsx_rearmed_$(VER)_caanoo.zip *
265endif