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