5720bab5d4bb594c614d3bddb0795f1b4832eddf
[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)" "sdl"
83 OBJS += plugins/dfsound/sdl.o
84 endif
85 ifeq "$(SOUND_DRIVER)" "none"
86 OBJS += plugins/dfsound/nullsnd.o
87 endif
88
89 # builtin gpu
90 OBJS += plugins/gpulib/gpu.o plugins/gpulib/vout_pl.o
91 ifeq "$(HAVE_NEON)" "1"
92 OBJS += plugins/gpulib/cspace_neon.o
93 else
94 OBJS += plugins/gpulib/cspace.o
95 endif
96 ifeq "$(BUILTIN_GPU)" "neon"
97 OBJS += plugins/gpu_neon/psx_gpu_if.o plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o
98 plugins/gpu_neon/psx_gpu_if.o: CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP
99 plugins/gpu_neon/psx_gpu_if.o: plugins/gpu_neon/psx_gpu/*.c
100 endif
101 ifeq "$(BUILTIN_GPU)" "peops"
102 # note: code is not safe for strict-aliasing? (Castlevania problems)
103 plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
104 plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
105 OBJS += plugins/dfxvideo/gpulib_if.o
106 endif
107 ifeq "$(BUILTIN_GPU)" "unai"
108 OBJS += plugins/gpulib/cspace.o
109 OBJS += plugins/gpu_unai/gpulib_if.o
110 ifeq "$(ARCH)" "arm"
111 OBJS += plugins/gpu_unai/gpu_arm.o
112 endif
113 plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED
114 CC_LINK = $(CXX)
115 endif
116
117 # cdrcimg
118 OBJS += plugins/cdrcimg/cdrcimg.o
119
120 # dfinput
121 OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
122
123 # gui
124 OBJS += frontend/main.o frontend/plugin.o
125 OBJS += frontend/common/readpng.o frontend/common/fonts.o
126 OBJS += frontend/linux/plat.o
127
128 ifeq "$(PLATFORM)" "generic"
129 OBJS += frontend/plat_sdl.o frontend/common/in_sdl.o
130 USE_FRONTEND = 1
131 endif
132 ifeq "$(PLATFORM)" "pandora"
133 OBJS += frontend/linux/fbdev.o
134 OBJS += frontend/plat_omap.o frontend/linux/xenv.o
135 OBJS += frontend/plat_pandora.o
136 USE_FRONTEND = 1
137 endif
138 ifeq "$(PLATFORM)" "caanoo"
139 OBJS += frontend/plat_pollux.o frontend/in_tsbutton.o frontend/blit320.o
140 OBJS += frontend/gp2x/in_gp2x.o frontend/warm/warm.o
141 USE_FRONTEND = 1
142 endif
143 ifeq "$(PLATFORM)" "maemo"
144 OBJS += maemo/hildon.o maemo/main.o
145 maemo/%.o: maemo/%.c
146 OBJS += frontend/plugin_lib.o
147 endif
148 ifeq "$(PLATFORM)" "libretro"
149 OBJS += frontend/libretro.o
150 endif
151 ifeq "$(USE_FRONTEND)" "1"
152 OBJS += frontend/menu.o frontend/linux/in_evdev.o
153 OBJS += frontend/common/input.o
154 OBJS += frontend/plugin_lib.o
155 ifeq "$(HAVE_TSLIB)" "1"
156 frontend/%.o: CFLAGS += -DHAVE_TSLIB
157 OBJS += frontend/pl_gun_ts.o
158 endif
159 else
160 CFLAGS += -DNO_FRONTEND
161 endif
162
163 ifdef X11
164 frontend/%.o: CFLAGS += -DX11
165 OBJS += frontend/xkb.o
166 endif
167 ifdef PCNT
168 CFLAGS += -DPCNT
169 endif
170 frontend/%.o: CFLAGS += -DIN_EVDEV
171 frontend/menu.o frontend/main.o frontend/plat_sdl.o: frontend/revision.h
172
173 libpcsxcore/gte_nf.o: libpcsxcore/gte.c
174         $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
175
176 frontend/revision.h: FORCE
177         @(git describe || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
178         @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
179         @rm $@_
180 .PHONY: FORCE
181
182 %.o: %.S
183         $(CC) $(CFLAGS) -c $^ -o $@
184
185 target_: $(TARGET)
186
187 $(TARGET): $(OBJS)
188         $(CC_LINK) -o $@ $^ $(LDFLAGS) $(LDLIBS) -Wl,-Map=$@.map
189
190 clean: $(PLAT_CLEAN) clean_plugins
191         $(RM) $(TARGET) $(OBJS) $(TARGET).map
192
193 ifneq ($(PLUGINS),)
194 plugins_: $(PLUGINS)
195
196 $(PLUGINS):
197         make -C $(dir $@)
198
199 clean_plugins:
200         make -C plugins/gpulib/ clean
201         for dir in $(PLUGINS) ; do \
202                 $(MAKE) -C $$(dirname $$dir) clean; done
203 else
204 plugins_:
205 clean_plugins:
206 endif
207
208 # ----------- release -----------
209
210 VER ?= $(shell git describe master)
211
212 ifeq "$(PLATFORM)" "generic"
213 OUT = pcsx_rearmed_$(VER)
214
215 rel: pcsx $(PLUGINS) \
216                 frontend/pandora/skin readme.txt COPYING
217         rm -rf $(OUT)
218         mkdir -p $(OUT)/plugins
219         mkdir -p $(OUT)/bios
220         cp -r $^ $(OUT)/
221         mv $(OUT)/*.so* $(OUT)/plugins/
222         zip -9 -r $(OUT).zip $(OUT)
223 endif
224
225 ifeq "$(PLATFORM)" "pandora"
226 PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
227
228 rel: pcsx $(PLUGINS) \
229                 frontend/pandora/pcsx.sh frontend/pandora/pcsx.pxml.templ frontend/pandora/pcsx.png \
230                 frontend/pandora/picorestore frontend/pandora/skin readme.txt COPYING
231         rm -rf out
232         mkdir -p out/plugins
233         cp -r $^ out/
234         sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
235         rm out/pcsx.pxml.templ
236         mv out/*.so out/plugins/
237         mv out/plugins/gpu_unai.so out/plugins/gpuPCSX4ALL.so
238         mv out/plugins/gpu_gles.so out/plugins/gpuGLES.so
239         mv out/plugins/gpu_peops.so out/plugins/gpuPEOPS.so
240         $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i frontend/pandora/pcsx.png -c
241 endif
242
243 ifeq "$(PLATFORM)" "caanoo"
244 PLAT_CLEAN = caanoo_clean
245
246 caanoo_clean:
247         $(RM) frontend/320240/pollux_set
248
249 rel: pcsx $(PLUGINS) \
250                 frontend/320240/caanoo.gpe frontend/320240/pcsx26.png \
251                 frontend/320240/pcsxb.png frontend/320240/skin \
252                 frontend/warm/bin/warm_2.6.24.ko frontend/320240/pollux_set \
253                 frontend/320240/pcsx_rearmed.ini frontend/320240/haptic_w.cfg \
254                 frontend/320240/haptic_s.cfg \
255                 readme.txt COPYING
256         rm -rf out
257         mkdir -p out/pcsx_rearmed/plugins
258         cp -r $^ out/pcsx_rearmed/
259         mv out/pcsx_rearmed/gpu_unai.so out/pcsx_rearmed/gpuPCSX4ALL.so
260         mv out/pcsx_rearmed/gpu_gles.so out/pcsx_rearmed/gpuGLES.so
261         mv out/pcsx_rearmed/*.so out/pcsx_rearmed/plugins/
262         mv out/pcsx_rearmed/caanoo.gpe out/pcsx_rearmed/pcsx.gpe
263         mv out/pcsx_rearmed/pcsx_rearmed.ini out/
264         mkdir out/pcsx_rearmed/lib/
265         cp ./lib/libbz2.so.1 out/pcsx_rearmed/lib/
266         mkdir out/pcsx_rearmed/bios/
267         cd out && zip -9 -r ../pcsx_rearmed_$(VER)_caanoo.zip *
268 endif