fix maemo build
[pcsx_rearmed.git] / Makefile
1 # Makefile for PCSX ReARMed
2
3 # default stuff goes here, so that config can override
4 TARGET = pcsx
5 CFLAGS += -Wall -ggdb -Ifrontend -ffast-math
6 LDLIBS += -lpthread -ldl -lpng -lz -lm
7 ifndef DEBUG
8 CFLAGS += -O2 -DNDEBUG
9 endif
10 CXXFLAGS += $(CFLAGS)
11 #DRC_DBG = 1
12 #PCNT = 1
13
14 all: config.mak target_ plugins_
15
16 ifneq ($(wildcard config.mak),)
17 config.mak: ./configure
18         @echo $@ is out-of-date, running configure
19         @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
20 include config.mak
21 else
22 config.mak:
23         @echo "Please run ./configure before running make!"
24         @exit 1
25 endif
26 -include Makefile.local
27
28 CC_LINK = $(CC)
29
30 # core
31 OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/debug.o \
32         libpcsxcore/decode_xa.o libpcsxcore/disr3000a.o libpcsxcore/mdec.o \
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
37 OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
38 ifeq "$(ARCH)" "arm"
39 OBJS += libpcsxcore/gte_arm.o
40 endif
41 ifeq "$(HAVE_NEON)" "1"
42 OBJS += libpcsxcore/gte_neon.o
43 endif
44 libpcsxcore/gte.o libpcsxcore/gte_nf.o: CFLAGS += -fno-strict-aliasing
45 libpcsxcore/cdrom.o libpcsxcore/misc.o: CFLAGS += -Wno-pointer-sign
46 libpcsxcore/misc.o libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
47
48 # dynarec
49 ifeq "$(USE_DYNAREC)" "1"
50 OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o
51 OBJS += libpcsxcore/new_dynarec/pcsxmem.o
52 endif
53 OBJS += libpcsxcore/new_dynarec/emu_if.o
54 libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c \
55         libpcsxcore/new_dynarec/pcsxmem_inline.c
56 libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -Wno-all -Wno-pointer-sign
57 ifdef DRC_DBG
58 libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
59 CFLAGS += -DDRC_DBG
60 endif
61 ifeq "$(DRC_CACHE_BASE)" "1"
62 libpcsxcore/new_dynarec/%.o: CFLAGS += -DBASE_ADDR_FIXED=1
63 endif
64
65 # spu
66 OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
67         plugins/dfsound/registers.o plugins/dfsound/spu.o
68 plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
69         plugins/dfsound/xa.c
70 ifeq "$(ARCH)" "arm"
71 OBJS += plugins/dfsound/arm_utils.o
72 endif
73 ifeq "$(SOUND_DRIVER)" "oss"
74 plugins/dfsound/%.o: CFLAGS += -DUSEOSS
75 OBJS += plugins/dfsound/oss.o
76 endif
77 ifeq "$(SOUND_DRIVER)" "alsa"
78 plugins/dfsound/%.o: CFLAGS += -DUSEALSA
79 OBJS += plugins/dfsound/alsa.o
80 LDLIBS += -lasound
81 endif
82 ifeq "$(SOUND_DRIVER)" "none"
83 OBJS += plugins/dfsound/nullsnd.o
84 endif
85
86 # builtin gpu
87 OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
88 ifeq "$(HAVE_NEON)" "1"
89 OBJS += plugins/gpulib/cspace_neon.o
90 else
91 OBJS += plugins/gpulib/cspace.o
92 endif
93 ifeq "$(BUILTIN_GPU)" "neon"
94 OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
95 plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
96 plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
97 endif
98 ifeq "$(BUILTIN_GPU)" "peops"
99 # note: code is not safe for strict-aliasing? (Castlevania problems)
100 plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
101 plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
102 OBJS += plugins/dfxvideo/gpulib_if.o
103 endif
104 ifeq "$(BUILTIN_GPU)" "unai"
105 OBJS += plugins/gpulib/cspace.o
106 OBJS += plugins/gpu_unai/gpulib_if.o
107 ifeq "$(ARCH)" "arm"
108 OBJS += plugins/gpu_unai/gpu_arm.o
109 endif
110 plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED
111 CC_LINK = $(CXX)
112 endif
113
114 # cdrcimg
115 OBJS += plugins/cdrcimg/cdrcimg.o
116
117 # dfinput
118 OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
119
120 # gui
121 OBJS += frontend/main.o frontend/plugin.o
122 OBJS += frontend/common/readpng.o frontend/common/fonts.o
123 OBJS += frontend/linux/plat.o
124
125 ifeq "$(PLATFORM)" "generic"
126 OBJS += frontend/plat_sdl.o frontend/common/in_sdl.o
127 USE_FRONTEND = 1
128 endif
129 ifeq "$(PLATFORM)" "pandora"
130 OBJS += frontend/linux/fbdev.o
131 OBJS += frontend/plat_omap.o frontend/linux/xenv.o
132 OBJS += frontend/plat_pandora.o
133 USE_FRONTEND = 1
134 endif
135 ifeq "$(PLATFORM)" "caanoo"
136 OBJS += frontend/plat_pollux.o frontend/in_tsbutton.o frontend/blit320.o
137 OBJS += frontend/gp2x/in_gp2x.o frontend/warm/warm.o
138 USE_FRONTEND = 1
139 endif
140 ifeq "$(PLATFORM)" "maemo"
141 OBJS += maemo/hildon.o maemo/main.o
142 maemo/%.o: maemo/%.c
143 OBJS += frontend/plugin_lib.o
144 endif
145 ifeq "$(PLATFORM)" "libretro"
146 OBJS += frontend/libretro.o
147 endif
148 ifeq "$(USE_FRONTEND)" "1"
149 OBJS += frontend/menu.o frontend/linux/in_evdev.o
150 OBJS += frontend/common/input.o
151 OBJS += frontend/plugin_lib.o
152 ifeq "$(HAVE_TSLIB)" "1"
153 frontend/%.o: CFLAGS += -DHAVE_TSLIB
154 OBJS += frontend/pl_gun_ts.o
155 endif
156 else
157 CFLAGS += -DNO_FRONTEND
158 endif
159
160 ifdef X11
161 frontend/%.o: CFLAGS += -DX11
162 OBJS += frontend/xkb.o
163 endif
164 ifdef PCNT
165 CFLAGS += -DPCNT
166 endif
167 frontend/%.o: CFLAGS += -DIN_EVDEV
168 frontend/menu.o frontend/main.o frontend/plat_sdl.o: frontend/revision.h
169
170 libpcsxcore/gte_nf.o: libpcsxcore/gte.c
171         $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
172
173 frontend/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
179 %.o: %.S
180         $(CC) $(CFLAGS) -c $^ -o $@
181
182 target_: $(TARGET)
183
184 $(TARGET): $(OBJS)
185         $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) -Wl,-Map=$@.map
186
187 clean: $(PLAT_CLEAN) clean_plugins
188         $(RM) $(TARGET) $(OBJS) $(TARGET).map
189
190 ifneq ($(PLUGINS),)
191 plugins_: $(PLUGINS)
192
193 $(PLUGINS):
194         make -C $(dir $@)
195
196 clean_plugins:
197         make -C plugins/gpulib/ clean
198         for dir in $(PLUGINS) ; do \
199                 $(MAKE) -C $$(dirname $$dir) clean; done
200 else
201 plugins_:
202 clean_plugins:
203 endif
204
205 # ----------- release -----------
206
207 VER ?= $(shell git describe master)
208
209 ifeq "$(PLATFORM)" "generic"
210 OUT = pcsx_rearmed_$(VER)
211
212 rel: 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)
220 endif
221
222 ifeq "$(PLATFORM)" "pandora"
223 PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
224
225 rel: pcsx $(PLUGINS) \
226                 frontend/pandora/pcsx.sh frontend/pandora/pcsx.pxml.templ frontend/pandora/pcsx.png \
227                 frontend/pandora/picorestore frontend/pandora/skin readme.txt COPYING
228         rm -rf out
229         mkdir -p out/plugins
230         cp -r $^ out/
231         sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
232         rm out/pcsx.pxml.templ
233         mv out/*.so out/plugins/
234         mv out/plugins/gpu_unai.so out/plugins/gpuPCSX4ALL.so
235         mv out/plugins/gpu_gles.so out/plugins/gpuGLES.so
236         mv out/plugins/gpu_peops.so out/plugins/gpuPEOPS.so
237         $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i frontend/pandora/pcsx.png -c
238 endif
239
240 ifeq "$(PLATFORM)" "caanoo"
241 PLAT_CLEAN = caanoo_clean
242
243 caanoo_clean:
244         $(RM) frontend/320240/pollux_set
245
246 rel: 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 *
265 endif