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