release r23
[pcsx_rearmed.git] / Makefile
CommitLineData
4132e8ca 1# Makefile for PCSX ReARMed
a80ae4a0 2
61bc6d40 3# default stuff goes here, so that config can override
9aff1963 4TARGET ?= pcsx
da710571 5CFLAGS += -Wall -ggdb -Iinclude -ffast-math
f95a77f7 6ifndef DEBUG
cfbd3c6e 7CFLAGS += -O2 -DNDEBUG
b60f2812 8endif
61bc6d40 9CXXFLAGS += $(CFLAGS)
4132e8ca 10#DRC_DBG = 1
11#PCNT = 1
80c2304e 12
38c2028e 13all: config.mak target_ plugins_
de38f20e 14
9aff1963 15ifndef NO_CONFIG_MAK
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
9aff1963 26else # NO_CONFIG_MAK
27config.mak:
28endif
29
4132e8ca 30-include Makefile.local
80c2304e 31
9aff1963 32CC_LINK ?= $(CC)
33CC_AS ?= $(CC)
22fa3f2b 34LDFLAGS += $(MAIN_LDFLAGS)
9aff1963 35EXTRA_LDFLAGS ?= -Wl,-Map=$@.map
07c13dfd 36LDLIBS += $(MAIN_LDLIBS)
e0aec5ee 37ifdef PCNT
38CFLAGS += -DPCNT
39endif
61bc6d40 40
80c2304e 41# core
7d7672a5 42OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/database.o \
43 libpcsxcore/decode_xa.o libpcsxcore/mdec.o \
80c2304e 44 libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
45 libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o libpcsxcore/psxhle.o \
46 libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o libpcsxcore/r3000a.o \
7d7672a5 47 libpcsxcore/sio.o libpcsxcore/spu.o
59774ed0 48OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
7d7672a5 49#OBJS += libpcsxcore/debug.o libpcsxcore/socket.o libpcsxcore/disr3000a.o
59774ed0 50ifeq "$(ARCH)" "arm"
51OBJS += libpcsxcore/gte_arm.o
52endif
a80ae4a0 53ifeq "$(HAVE_NEON)" "1"
8cfbda97 54OBJS += libpcsxcore/gte_neon.o
55endif
305c8c93 56libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
ab948f7e 57
f95a77f7 58# dynarec
4132e8ca 59ifeq "$(USE_DYNAREC)" "1"
be516ebe 60OBJS += libpcsxcore/new_dynarec/new_dynarec.o
7e605697 61OBJS += libpcsxcore/new_dynarec/pcsxmem.o
be516ebe 62 ifeq "$(ARCH)" "arm"
63 OBJS += libpcsxcore/new_dynarec/linkage_arm.o
687b4580 64 libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c
be516ebe 65 else ifeq "$(ARCH)" "aarch64"
66 OBJS += libpcsxcore/new_dynarec/linkage_arm64.o
687b4580 67 libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm64.c
be516ebe 68 else
69 $(error no dynarec support for architecture $(ARCH))
70 endif
448bbcae 71else
41e82ad4 72CFLAGS += -DDRC_DISABLE
7139f3c8 73endif
74OBJS += libpcsxcore/new_dynarec/emu_if.o
687b4580 75libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/pcsxmem_inline.c
3eb78778 76ifdef DRC_DBG
77libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
78CFLAGS += -DDRC_DBG
79endif
2a014d73 80ifeq "$(BASE_ADDR_DYNAMIC)" "1"
81libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_DYNAMIC=1
a327ad27 82endif
f95a77f7 83
e906c010 84# spu
ee849648 85OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
07c13dfd 86 plugins/dfsound/registers.o plugins/dfsound/spu.o \
87 plugins/dfsound/out.o plugins/dfsound/nullsnd.o
6d866bb7 88plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
89 plugins/dfsound/xa.c
3a721c1f 90ifeq "$(ARCH)" "arm"
b17618c0 91OBJS += plugins/dfsound/arm_utils.o
92endif
5514a050 93ifeq "$(HAVE_C64_TOOLS)" "1"
94plugins/dfsound/spu.o: CFLAGS += -DC64X_DSP
95plugins/dfsound/spu.o: plugins/dfsound/spu_c64x.c
8886a808 96frontend/menu.o: CFLAGS += -DC64X_DSP
5514a050 97endif
07c13dfd 98ifneq ($(findstring oss,$(SOUND_DRIVERS)),)
99plugins/dfsound/out.o: CFLAGS += -DHAVE_OSS
de38f20e 100OBJS += plugins/dfsound/oss.o
101endif
07c13dfd 102ifneq ($(findstring alsa,$(SOUND_DRIVERS)),)
103plugins/dfsound/out.o: CFLAGS += -DHAVE_ALSA
de38f20e 104OBJS += plugins/dfsound/alsa.o
4132e8ca 105LDLIBS += -lasound
106endif
07c13dfd 107ifneq ($(findstring sdl,$(SOUND_DRIVERS)),)
108plugins/dfsound/out.o: CFLAGS += -DHAVE_SDL
d8a2f79b 109OBJS += plugins/dfsound/sdl.o
110endif
07c13dfd 111ifneq ($(findstring pulseaudio,$(SOUND_DRIVERS)),)
112plugins/dfsound/out.o: CFLAGS += -DHAVE_PULSE
113OBJS += plugins/dfsound/pulseaudio.o
114endif
115ifneq ($(findstring libretro,$(SOUND_DRIVERS)),)
116plugins/dfsound/out.o: CFLAGS += -DHAVE_LIBRETRO
de38f20e 117endif
118
61bc6d40 119# builtin gpu
120OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
61bc6d40 121ifeq "$(BUILTIN_GPU)" "neon"
90ca4913 122OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
123plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
124plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
61bc6d40 125endif
126ifeq "$(BUILTIN_GPU)" "peops"
2ef486ee 127# note: code is not safe for strict-aliasing? (Castlevania problems)
62d7fa95 128plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
129plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
130OBJS += plugins/dfxvideo/gpulib_if.o
90ca4913 131endif
61bc6d40 132ifeq "$(BUILTIN_GPU)" "unai"
61bc6d40 133OBJS += plugins/gpu_unai/gpulib_if.o
134ifeq "$(ARCH)" "arm"
135OBJS += plugins/gpu_unai/gpu_arm.o
136endif
46aa5b98 137plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -O3
61bc6d40 138CC_LINK = $(CXX)
b60f2812 139endif
e0c692d9 140
0bfe8d59 141ifeq "$(BUILTIN_GPU)" "senquack"
142OBJS += plugins/gpu_senquack/gpulib_if.o
143ifeq "$(ARCH)" "arm"
144OBJS += plugins/gpu_senquack/gpu_arm.o
145endif
146plugins/gpu_senquack/gpulib_if.o: CFLAGS += -DREARMED -O3
147CC_LINK = $(CXX)
148endif
149
47bf65ab 150# cdrcimg
47bf65ab 151OBJS += plugins/cdrcimg/cdrcimg.o
68e7d409 152#ifeq "$(CHD_SUPPORT)" "1"
00f0670c 153OBJS += libchdr/src/libchdr_bitstream.o
154OBJS += libchdr/src/libchdr_cdrom.o
155OBJS += libchdr/src/libchdr_chd.o
156OBJS += libchdr/src/libchdr_flac.o
157OBJS += libchdr/src/libchdr_huffman.o
158OBJS += libchdr/deps/lzma-19.00/src/Alloc.o libchdr/deps/lzma-19.00/src/Bra86.o libchdr/deps/lzma-19.00/src/BraIA64.o libchdr/deps/lzma-19.00/src/CpuArch.o libchdr/deps/lzma-19.00/src/Delta.o
159OBJS += libchdr/deps/lzma-19.00/src/LzFind.o libchdr/deps/lzma-19.00/src/Lzma86Dec.o libchdr/deps/lzma-19.00/src/LzmaDec.o libchdr/deps/lzma-19.00/src/LzmaEnc.o libchdr/deps/lzma-19.00/src/Sort.o
68e7d409 160CFLAGS += -DHAVE_CHD -Ilibchdr/include
161libpcsxcore/cdriso.o: CFLAGS += -Wno-unused-function
162libchdr/src/%.o: CFLAGS += -Wno-unused -Ilibchdr/deps/lzma-19.00/include
163libchdr/deps/lzma-19.00/src/%.o: CFLAGS += -Wno-unused -D_7ZIP_ST -Ilibchdr/deps/lzma-19.00/include
164#endif
e906c010 165
384f5f43 166# dfinput
4c08b9e7 167OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
384f5f43 168
cc56203b 169# frontend/gui
c82f907a 170OBJS += frontend/cspace.o
171ifeq "$(HAVE_NEON)" "1"
172OBJS += frontend/cspace_neon.o
d57557c0 173else
174ifeq "$(ARCH)" "arm"
175OBJS += frontend/cspace_arm.o
176endif
c82f907a 177endif
178
4132e8ca 179ifeq "$(PLATFORM)" "generic"
5b9aa749 180OBJS += frontend/libpicofe/in_sdl.o
181OBJS += frontend/libpicofe/plat_sdl.o
cc56203b 182OBJS += frontend/libpicofe/plat_dummy.o
183OBJS += frontend/libpicofe/linux/in_evdev.o
5b9aa749 184OBJS += frontend/plat_sdl.o
185ifeq "$(HAVE_GLES)" "1"
2c616080 186OBJS += frontend/libpicofe/gl.o frontend/libpicofe/gl_platform.o
5b9aa749 187LDLIBS += $(LDLIBS_GLES)
188frontend/libpicofe/plat_sdl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
2c616080 189frontend/libpicofe/gl_platform.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
5b9aa749 190frontend/libpicofe/gl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
191frontend/plat_sdl.o: CFLAGS += -DHAVE_GLES $(CFLAGS_GLES)
192endif
cc56203b 193USE_PLUGIN_LIB = 1
38c2028e 194USE_FRONTEND = 1
4132e8ca 195endif
55b0eeea 196ifeq "$(PLATFORM)" "pandora"
cc56203b 197OBJS += frontend/libpicofe/pandora/plat.o
198OBJS += frontend/libpicofe/linux/fbdev.o frontend/libpicofe/linux/xenv.o
199OBJS += frontend/libpicofe/linux/in_evdev.o
200OBJS += frontend/plat_pandora.o frontend/plat_omap.o
da710571 201frontend/main.o frontend/menu.o: CFLAGS += -include frontend/pandora/ui_feat.h
3aba4185 202frontend/libpicofe/linux/plat.o: CFLAGS += -DPANDORA
cc56203b 203USE_PLUGIN_LIB = 1
38c2028e 204USE_FRONTEND = 1
4132e8ca 205endif
55b0eeea 206ifeq "$(PLATFORM)" "caanoo"
cc56203b 207OBJS += frontend/libpicofe/gp2x/in_gp2x.o frontend/warm/warm.o
208OBJS += frontend/libpicofe/gp2x/soc_pollux.o
209OBJS += frontend/libpicofe/linux/in_evdev.o
faf2b2aa 210OBJS += frontend/plat_pollux.o frontend/in_tsbutton.o frontend/blit320.o
da710571 211frontend/main.o frontend/menu.o: CFLAGS += -include frontend/320240/ui_gp2x.h
cc56203b 212USE_PLUGIN_LIB = 1
38c2028e 213USE_FRONTEND = 1
214endif
215ifeq "$(PLATFORM)" "maemo"
baaef67b 216OBJS += maemo/hildon.o maemo/main.o maemo/maemo_xkb.o frontend/pl_gun_ts.o
38c2028e 217maemo/%.o: maemo/%.c
cc56203b 218USE_PLUGIN_LIB = 1
a76fd953 219LDFLAGS += $(shell pkg-config --libs hildon-1 libpulse)
7010034e 220CFLAGS += $(shell pkg-config --cflags hildon-1) -DHAVE_TSLIB
a76fd953
PI
221CFLAGS += `pkg-config --cflags glib-2.0 libosso dbus-1 hildon-fm-2`
222LDFLAGS += `pkg-config --libs glib-2.0 libosso dbus-1 hildon-fm-2`
38c2028e 223endif
224ifeq "$(PLATFORM)" "libretro"
225OBJS += frontend/libretro.o
46aa5b98 226CFLAGS += -DFRONTEND_SUPPORTS_RGB565
ce0e7ac9 227
228ifeq ($(MMAP_WIN32),1)
229OBJS += libpcsxcore/memmap_win32.o
230endif
38c2028e 231endif
cc56203b 232
233ifeq "$(USE_PLUGIN_LIB)" "1"
38c2028e 234OBJS += frontend/plugin_lib.o
cc56203b 235OBJS += frontend/libpicofe/linux/plat.o
236OBJS += frontend/libpicofe/readpng.o frontend/libpicofe/fonts.o
a4da039c 237frontend/libpicofe/linux/plat.o: CFLAGS += -DNO_HOME_DIR
cc56203b 238ifeq "$(HAVE_NEON)" "1"
239OBJS += frontend/libpicofe/arm/neon_scale2x.o
240OBJS += frontend/libpicofe/arm/neon_eagle2x.o
241frontend/libpicofe/arm/neon_scale2x.o: CFLAGS += -DDO_BGR_TO_RGB
242frontend/libpicofe/arm/neon_eagle2x.o: CFLAGS += -DDO_BGR_TO_RGB
243endif
244endif
245ifeq "$(USE_FRONTEND)" "1"
246OBJS += frontend/menu.o
247OBJS += frontend/libpicofe/input.o
248frontend/menu.o: frontend/libpicofe/menu.c
38c2028e 249ifeq "$(HAVE_TSLIB)" "1"
250frontend/%.o: CFLAGS += -DHAVE_TSLIB
251OBJS += frontend/pl_gun_ts.o
252endif
253else
254CFLAGS += -DNO_FRONTEND
55b0eeea 255endif
a80ae4a0 256
cc56203b 257# misc
258OBJS += frontend/main.o frontend/plugin.o
259
e0aec5ee 260
a1a232ad 261frontend/menu.o frontend/main.o: frontend/revision.h
262frontend/plat_sdl.o frontend/libretro.o: frontend/revision.h
3c70c47b 263
cc56203b 264frontend/libpicofe/%.c:
fa56d360 265 @echo "libpicofe module is missing, please run:"
266 @echo "git submodule init && git submodule update"
267 @exit 1
268
59774ed0 269libpcsxcore/gte_nf.o: libpcsxcore/gte.c
270 $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
271
3c70c47b 272frontend/revision.h: FORCE
4527b1fd 273 @(git describe --always || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
3c70c47b 274 @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
275 @rm $@_
3c70c47b 276
90ca4913 277%.o: %.S
9aff1963 278 $(CC_AS) $(CFLAGS) -c $^ -o $@
80c2304e 279
e0aec5ee 280
38c2028e 281target_: $(TARGET)
282
80c2304e 283$(TARGET): $(OBJS)
9aff1963 284 $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(EXTRA_LDFLAGS)
80c2304e 285
dd4d5a35 286clean: $(PLAT_CLEAN) clean_plugins
a1a232ad 287 $(RM) $(TARGET) $(OBJS) $(TARGET).map frontend/revision.h
0d464c77 288
4132e8ca 289ifneq ($(PLUGINS),)
dd4d5a35 290plugins_: $(PLUGINS)
291
ee78346e 292$(PLUGINS):
293 make -C $(dir $@)
f932e54b 294
ee78346e 295clean_plugins:
ea1f6f2f 296 make -C plugins/gpulib/ clean
ee78346e 297 for dir in $(PLUGINS) ; do \
298 $(MAKE) -C $$(dirname $$dir) clean; done
dd4d5a35 299else
300plugins_:
301clean_plugins:
4132e8ca 302endif
80c2304e 303
fa56d360 304.PHONY: all clean target_ plugins_ clean_plugins FORCE
305
857275a9 306ifneq "$(PLATFORM)" "pandora"
307ifdef CPATH
308$(warning warning: CPATH is defined)
309endif
310endif
311
303ee308 312# ----------- release -----------
313
4527b1fd 314VER ?= $(shell git describe --always HEAD)
4132e8ca 315
dd4d5a35 316ifeq "$(PLATFORM)" "generic"
317OUT = pcsx_rearmed_$(VER)
318
319rel: pcsx $(PLUGINS) \
320 frontend/pandora/skin readme.txt COPYING
321 rm -rf $(OUT)
322 mkdir -p $(OUT)/plugins
323 mkdir -p $(OUT)/bios
324 cp -r $^ $(OUT)/
325 mv $(OUT)/*.so* $(OUT)/plugins/
326 zip -9 -r $(OUT).zip $(OUT)
327endif
328
4132e8ca 329ifeq "$(PLATFORM)" "pandora"
303ee308 330PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
331
8886a808 332rel: pcsx plugins/dfsound/pcsxr_spu_area3.out $(PLUGINS) \
9e0630ab 333 frontend/pandora/pcsx.sh frontend/pandora/pcsx.pxml.templ frontend/pandora/pcsx.png \
334 frontend/pandora/picorestore frontend/pandora/skin readme.txt COPYING
303ee308 335 rm -rf out
bbd837c6 336 mkdir -p out/plugins
303ee308 337 cp -r $^ out/
3938f69a 338 sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
339 rm out/pcsx.pxml.templ
bbd837c6 340 mv out/*.so out/plugins/
9e0630ab 341 $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i frontend/pandora/pcsx.png -c
4132e8ca 342endif
343
344ifeq "$(PLATFORM)" "caanoo"
345PLAT_CLEAN = caanoo_clean
346
347caanoo_clean:
348 $(RM) frontend/320240/pollux_set
349
4132e8ca 350rel: pcsx $(PLUGINS) \
351 frontend/320240/caanoo.gpe frontend/320240/pcsx26.png \
352 frontend/320240/pcsxb.png frontend/320240/skin \
353 frontend/warm/bin/warm_2.6.24.ko frontend/320240/pollux_set \
354 frontend/320240/pcsx_rearmed.ini frontend/320240/haptic_w.cfg \
355 frontend/320240/haptic_s.cfg \
356 readme.txt COPYING
357 rm -rf out
358 mkdir -p out/pcsx_rearmed/plugins
359 cp -r $^ out/pcsx_rearmed/
4132e8ca 360 mv out/pcsx_rearmed/*.so out/pcsx_rearmed/plugins/
361 mv out/pcsx_rearmed/caanoo.gpe out/pcsx_rearmed/pcsx.gpe
362 mv out/pcsx_rearmed/pcsx_rearmed.ini out/
363 mkdir out/pcsx_rearmed/lib/
364 cp ./lib/libbz2.so.1 out/pcsx_rearmed/lib/
365 mkdir out/pcsx_rearmed/bios/
366 cd out && zip -9 -r ../pcsx_rearmed_$(VER)_caanoo.zip *
367endif