rewrite memhandlers (write)
[pcsx_rearmed.git] / Makefile
1 #CROSS_COMPILE=
2 AS = $(CROSS_COMPILE)as
3 CC = $(CROSS_COMPILE)gcc
4 LD = $(CROSS_COMPILE)ld
5
6 ARM926 ?= 0
7 ARM_CORTEXA8 ?= 1
8 PLATFORM ?= pandora
9 USE_OSS ?= 1
10 #USE_ALSA = 1
11 #DRC_DBG = 1
12 #PCNT = 1
13 TARGET = pcsx
14
15 -include Makefile.local
16
17 ARCH = $(shell $(CC) -v 2>&1 | grep -i 'target:' | awk '{print $$2}' | awk -F '-' '{print $$1}')
18
19 CFLAGS += -Wall -ggdb -Ifrontend -ffast-math
20 LDFLAGS += -lz -lpthread -ldl -lpng
21 ifndef DEBUG
22 CFLAGS += -O2 -DNDEBUG
23 endif
24 CFLAGS += $(EXTRA_CFLAGS)
25
26 ifeq "$(ARCH)" "arm"
27 ifeq "$(ARM_CORTEXA8)" "1"
28 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
29 ASFLAGS += -mcpu=cortex-a8 -mfpu=neon
30 endif
31 ifeq "$(ARM926)" "1"
32 CFLAGS += -mcpu=arm926ej-s -mtune=arm926ej-s
33 ASFLAGS += -mcpu=arm926ej-s
34 endif
35 endif
36
37 # detect armv7 and NEON from the specified CPU
38 HAVE_NEON = $(shell $(CC) -E -dD $(CFLAGS) frontend/config.h | grep -q '__ARM_NEON__ 1' && echo 1)
39 HAVE_ARMV7 = $(shell $(CC) -E -dD $(CFLAGS) frontend/config.h | grep -q '__ARM_ARCH_7A__ 1' && echo 1)
40
41 all: $(TARGET)
42
43 # core
44 OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/debug.o \
45         libpcsxcore/decode_xa.o libpcsxcore/disr3000a.o libpcsxcore/mdec.o \
46         libpcsxcore/misc.o libpcsxcore/plugins.o libpcsxcore/ppf.o libpcsxcore/psxbios.o \
47         libpcsxcore/psxcommon.o libpcsxcore/psxcounters.o libpcsxcore/psxdma.o libpcsxcore/psxhle.o \
48         libpcsxcore/psxhw.o libpcsxcore/psxinterpreter.o libpcsxcore/psxmem.o libpcsxcore/r3000a.o \
49         libpcsxcore/sio.o libpcsxcore/socket.o libpcsxcore/spu.o
50 OBJS += libpcsxcore/gte.o libpcsxcore/gte_nf.o libpcsxcore/gte_divider.o
51 ifeq "$(ARCH)" "arm"
52 OBJS += libpcsxcore/gte_arm.o
53 endif
54 ifeq "$(HAVE_NEON)" "1"
55 OBJS += libpcsxcore/gte_neon.o
56 endif
57 libpcsxcore/cdrom.o libpcsxcore/misc.o: CFLAGS += -Wno-pointer-sign
58 libpcsxcore/misc.o libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
59
60 # dynarec
61 ifndef NO_NEW_DRC
62 OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o
63 OBJS += libpcsxcore/new_dynarec/pcsxmem.o
64 endif
65 OBJS += libpcsxcore/new_dynarec/emu_if.o
66 libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c \
67         libpcsxcore/new_dynarec/pcsxmem_inline.c
68 libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -Wno-all -Wno-pointer-sign
69 ifdef DRC_DBG
70 libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
71 CFLAGS += -DDRC_DBG
72 endif
73
74 # spu
75 OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
76         plugins/dfsound/registers.o plugins/dfsound/spu.o
77 plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
78         plugins/dfsound/xa.c
79 ifeq "$(HAVE_NEON)" "1"
80 OBJS += plugins/dfsound/arm_utils.o
81 endif
82 ifeq "$(USE_OSS)" "1"
83 plugins/dfsound/%.o: CFLAGS += -DUSEOSS
84 OBJS += plugins/dfsound/oss.o
85 endif
86 ifeq "$(USE_ALSA)" "1"
87 plugins/dfsound/%.o: CFLAGS += -DUSEALSA
88 OBJS += plugins/dfsound/alsa.o
89 LDFLAGS += -lasound
90 endif
91
92 # gpu
93 # note: code is not safe for strict-aliasing? (Castlevania problems)
94 plugins/dfxvideo/%.o: CFLAGS += -fno-strict-aliasing
95 OBJS += plugins/dfxvideo/gpu.o
96 plugins/dfxvideo/gpu.o: plugins/dfxvideo/fps.c plugins/dfxvideo/prim.c \
97         plugins/dfxvideo/gpu.c plugins/dfxvideo/soft.c
98 ifdef X11
99 LDFLAGS += -lX11 -lXv
100 OBJS += plugins/dfxvideo/draw.o
101 else
102 OBJS += plugins/dfxvideo/draw_fb.o
103 endif
104
105 # cdrcimg
106 OBJS += plugins/cdrcimg/cdrcimg.o
107
108 # dfinput
109 OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
110
111 # gui
112 OBJS += frontend/main.o frontend/plugin.o
113 OBJS += frontend/plugin_lib.o frontend/common/readpng.o
114 OBJS += frontend/common/fonts.o frontend/linux/plat.o
115 ifeq "$(USE_GTK)" "1"
116 OBJS += maemo/hildon.o maemo/main.o
117 maemo/%.o: maemo/%.c
118 else
119 OBJS += frontend/menu.o frontend/linux/in_evdev.o
120 OBJS += frontend/common/input.o frontend/linux/oshide.o
121
122 ifeq "$(PLATFORM)" "pandora"
123 frontend/%.o: CFLAGS += -DVOUT_FBDEV
124 OBJS += frontend/linux/fbdev.o
125 OBJS += frontend/plat_omap.o
126 OBJS += frontend/plat_pandora.o
127 else
128 ifeq "$(PLATFORM)" "caanoo"
129 OBJS += frontend/plat_pollux.o
130 OBJS += frontend/warm/warm.o
131 else
132 OBJS += frontend/plat_dummy.o
133 endif
134 endif
135
136 endif # !USE_GTK
137
138 ifeq "$(HAVE_NEON)" "1"
139 OBJS += frontend/cspace_neon.o
140 else
141 OBJS += frontend/cspace.o
142 endif
143 ifdef X11
144 frontend/%.o: CFLAGS += -DX11
145 OBJS += frontend/xkb.o
146 endif
147 ifdef PCNT
148 CFLAGS += -DPCNT
149 endif
150 ifndef NO_TSLIB
151 frontend/%.o: CFLAGS += -DHAVE_TSLIB
152 OBJS += frontend/pl_gun_ts.o
153 endif
154 %.o: ASFLAGS += --defsym HAVE_ARMV7=$(HAVE_ARMV7)
155 frontend/%.o: CFLAGS += -DIN_EVDEV
156 frontend/menu.o: frontend/revision.h
157
158 libpcsxcore/gte_nf.o: libpcsxcore/gte.c
159         $(CC) -c -o $@ $^ $(CFLAGS) -DFLAGLESS
160
161 frontend/revision.h: FORCE
162         @(git describe || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
163         @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
164         @rm $@_
165 .PHONY: FORCE
166
167
168 $(TARGET): $(OBJS)
169         $(CC) -o $@ $^ $(LDFLAGS) -Wl,-Map=$@.map
170
171 PLUGINS ?= plugins/spunull/spunull.so plugins/gpu_unai/gpuPCSX4ALL.so \
172         plugins/gpu-gles/gpuGLES.so plugins/gpu_neon/gpu_neon.so
173
174 $(PLUGINS):
175         make -C $(dir $@)
176
177 clean:
178         $(RM) $(TARGET) $(OBJS) $(TARGET).map
179
180 clean_plugins:
181         for dir in $(PLUGINS) ; do \
182                 $(MAKE) -C $$(dirname $$dir) clean; done
183
184 # ----------- release -----------
185
186 PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
187
188 VER ?= $(shell git describe master)
189
190 rel: pcsx $(PLUGINS) \
191                 pandora/pcsx.sh pandora/pcsx.pxml.templ pandora/pcsx.png \
192                 pandora/picorestore pandora/readme.txt pandora/skin COPYING
193         rm -rf out
194         mkdir -p out/plugins
195         cp -r $^ out/
196         sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
197         rm out/pcsx.pxml.templ
198         mv out/*.so out/plugins/
199         mv out/plugins/gpu_neon.so out/plugins/gpuPEOPS2.so
200         $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i pandora/pcsx.png -c