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