fdf3724c12fe415c8f2d822c58c11008fcff37c2
[pcsx_rearmed.git] / Makefile
1 #CROSS_COMPILE=
2 AS  = $(CROSS_COMPILE)as
3 GCC = $(CROSS_COMPILE)gcc
4 CC  = $(CROSS_COMPILE)gcc
5 LD  = $(CROSS_COMPILE)ld
6 ifdef CC_OVERRIDE
7 CC = $(CC_OVERRIDE)
8 endif
9
10 ARM926 ?= 0
11 ARM_CORTEXA8 ?= 1
12 PLATFORM ?= pandora
13 USE_OSS ?= 1
14 #USE_ALSA = 1
15 #DRC_DBG = 1
16 #PCNT = 1
17 TARGET = pcsx
18
19 -include Makefile.local
20
21 ARCH = $(shell $(GCC) -v 2>&1 | grep -i 'target:' | awk '{print $$2}' | awk -F '-' '{print $$1}')
22
23 CFLAGS += -Wall -ggdb -Ifrontend -ffast-math
24 LDFLAGS += -lz -lpthread -ldl -lpng
25 ifndef DEBUG
26 CFLAGS += -O2 -DNDEBUG
27 endif
28 CFLAGS += $(EXTRA_CFLAGS)
29
30 ifeq "$(ARCH)" "arm"
31 ifeq "$(ARM_CORTEXA8)" "1"
32 GCC_CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
33 ASFLAGS += -mcpu=cortex-a8 -mfpu=neon
34 endif
35 ifeq "$(ARM926)" "1"
36 GCC_CFLAGS += -mcpu=arm926ej-s -mtune=arm926ej-s
37 ASFLAGS += -mcpu=arm926ej-s
38 endif
39 endif
40 CFLAGS += $(GCC_CFLAGS)
41
42 # detect armv7 and NEON from the specified CPU
43 HAVE_NEON = $(shell $(GCC) -E -dD $(GCC_CFLAGS) frontend/config.h | grep -q '__ARM_NEON__ 1' && echo 1)
44 HAVE_ARMV7 = $(shell $(GCC) -E -dD $(GCC_CFLAGS) frontend/config.h | grep -q '__ARM_ARCH_7A__ 1' && echo 1)
45
46 all: $(TARGET)
47
48 # core
49 OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/debug.o \
50         libpcsxcore/decode_xa.o libpcsxcore/disr3000a.o libpcsxcore/mdec.o \
51         libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
52         libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o libpcsxcore/psxhle.o \
53         libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o libpcsxcore/r3000a.o \
54         libpcsxcore/sio.o libpcsxcore/socket.o libpcsxcore/spu.o
55 OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
56 ifeq "$(ARCH)" "arm"
57 OBJS += libpcsxcore/gte_arm.o
58 endif
59 ifeq "$(HAVE_NEON)" "1"
60 OBJS += libpcsxcore/gte_neon.o
61 endif
62 libpcsxcore/cdrom.o libpcsxcore/misc.o: CFLAGS += -Wno-pointer-sign
63 libpcsxcore/misc.o libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
64
65 # dynarec
66 ifndef NO_NEW_DRC
67 OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o
68 OBJS += libpcsxcore/new_dynarec/pcsxmem.o
69 endif
70 OBJS += libpcsxcore/new_dynarec/emu_if.o
71 libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c
72 libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -Wno-all -Wno-pointer-sign
73 ifdef DRC_DBG
74 libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
75 CFLAGS += -DDRC_DBG
76 endif
77
78 # spu
79 OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
80         plugins/dfsound/registers.o plugins/dfsound/spu.o
81 plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
82         plugins/dfsound/xa.c
83 ifeq "$(HAVE_NEON)" "1"
84 OBJS += plugins/dfsound/arm_utils.o
85 endif
86 ifeq "$(USE_OSS)" "1"
87 plugins/dfsound/%.o: CFLAGS += -DUSEOSS
88 OBJS += plugins/dfsound/oss.o
89 endif
90 ifeq "$(USE_ALSA)" "1"
91 plugins/dfsound/%.o: CFLAGS += -DUSEALSA
92 OBJS += plugins/dfsound/alsa.o
93 LDFLAGS += -lasound
94 endif
95
96 # gpu
97 # note: code is not safe for strict-aliasing? (Castlevania problems)
98 plugins/dfxvideo/%.o: CFLAGS += -fno-strict-aliasing
99 OBJS += plugins/dfxvideo/gpu.o
100 plugins/dfxvideo/gpu.o: plugins/dfxvideo/fps.c plugins/dfxvideo/prim.c \
101         plugins/dfxvideo/gpu.c plugins/dfxvideo/soft.c
102 ifdef X11
103 LDFLAGS += -lX11 -lXv
104 OBJS += plugins/dfxvideo/draw.o
105 else
106 OBJS += plugins/dfxvideo/draw_fb.o
107 endif
108
109 # cdrcimg
110 OBJS += plugins/cdrcimg/cdrcimg.o
111
112 # dfinput
113 OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
114
115 # gui
116 OBJS += frontend/main.o frontend/plugin.o
117 OBJS += frontend/plugin_lib.o frontend/common/readpng.o
118 OBJS += frontend/common/fonts.o frontend/linux/plat.o
119 ifeq "$(USE_GTK)" "1"
120 OBJS += maemo/hildon.o maemo/main.o
121 maemo/%.o: maemo/%.c
122 else
123 OBJS += frontend/menu.o frontend/linux/in_evdev.o
124 OBJS += frontend/common/input.o frontend/linux/oshide.o
125
126 ifeq "$(PLATFORM)" "pandora"
127 frontend/%.o: CFLAGS += -DVOUT_FBDEV
128 OBJS += frontend/linux/fbdev.o
129 OBJS += frontend/plat_omap.o
130 OBJS += frontend/plat_pandora.o
131 else
132 ifeq "$(PLATFORM)" "caanoo"
133 OBJS += frontend/plat_pollux.o
134 OBJS += frontend/warm/warm.o
135 else
136 OBJS += frontend/plat_dummy.o
137 endif
138 endif
139
140 endif # !USE_GTK
141
142 ifeq "$(HAVE_NEON)" "1"
143 OBJS += frontend/cspace_neon.o
144 else
145 OBJS += frontend/cspace.o
146 endif
147 ifdef X11
148 frontend/%.o: CFLAGS += -DX11
149 OBJS += frontend/xkb.o
150 endif
151 ifdef PCNT
152 CFLAGS += -DPCNT
153 endif
154 ifndef NO_TSLIB
155 frontend/%.o: CFLAGS += -DHAVE_TSLIB
156 OBJS += frontend/pl_gun_ts.o
157 endif
158 %.o: ASFLAGS += --defsym HAVE_ARMV7=$(HAVE_ARMV7)
159 frontend/%.o: CFLAGS += -DIN_EVDEV
160 frontend/menu.o: frontend/revision.h
161
162 libpcsxcore/gte_nf.o: libpcsxcore/gte.c
163         $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
164
165 frontend/revision.h: FORCE
166         @(git describe || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
167         @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
168         @rm $@_
169 .PHONY: FORCE
170
171
172 $(TARGET): $(OBJS)
173         $(CC) -o $@ $^ $(LDFLAGS) -Wl,-Map=$@.map
174
175 PLUGINS ?= plugins/spunull/spunull.so plugins/gpu_unai/gpuPCSX4ALL.so \
176         plugins/gpu-gles/gpuGLES.so plugins/gpu_neon/gpu_neon.so
177
178 $(PLUGINS):
179         make -C $(dir $@)
180
181 clean:
182         $(RM) $(TARGET) $(OBJS) $(TARGET).map
183
184 clean_plugins:
185         for dir in $(PLUGINS) ; do \
186                 $(MAKE) -C $$(dirname $$dir) clean; done
187
188 # ----------- release -----------
189
190 PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
191
192 VER ?= $(shell git describe master)
193
194 rel: pcsx $(PLUGINS) \
195                 pandora/pcsx.sh pandora/pcsx.pxml.templ pandora/pcsx.png \
196                 pandora/picorestore pandora/readme.txt pandora/skin COPYING
197         rm -rf out
198         mkdir -p out/plugins
199         cp -r $^ out/
200         sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
201         rm out/pcsx.pxml.templ
202         mv out/*.so out/plugins/
203         mv out/plugins/gpu_neon.so out/plugins/gpuPEOPS2.so
204         $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i pandora/pcsx.png -c