bf364c70c178deffba513b75b56dea7cf15e6f37
[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/gte.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 ifeq "$(HAVE_NEON)" "1"
51 OBJS += libpcsxcore/gte_neon.o
52 endif
53 libpcsxcore/cdrom.o libpcsxcore/misc.o: CFLAGS += -Wno-pointer-sign
54 libpcsxcore/misc.o libpcsxcore/psxbios.o: CFLAGS += -Wno-nonnull
55
56 # dynarec
57 ifndef NO_NEW_DRC
58 libpcsxcore/new_dynarec/linkage_arm.o: ASFLAGS += --defsym HAVE_ARMV7=$(HAVE_ARMV7)
59 OBJS += libpcsxcore/new_dynarec/new_dynarec.o libpcsxcore/new_dynarec/linkage_arm.o
60 OBJS += libpcsxcore/new_dynarec/pcsxmem.o
61 endif
62 OBJS += libpcsxcore/new_dynarec/emu_if.o
63 libpcsxcore/new_dynarec/new_dynarec.o: libpcsxcore/new_dynarec/assem_arm.c \
64         libpcsxcore/new_dynarec/pcsxmem_inline.c
65 libpcsxcore/new_dynarec/new_dynarec.o: CFLAGS += -Wno-all -Wno-pointer-sign
66 ifdef DRC_DBG
67 libpcsxcore/new_dynarec/emu_if.o: CFLAGS += -D_FILE_OFFSET_BITS=64
68 CFLAGS += -DDRC_DBG
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/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
75         plugins/dfsound/xa.c
76 ifeq "$(HAVE_NEON)" "1"
77 OBJS += plugins/dfsound/arm_utils.o
78 endif
79 ifeq "$(USE_OSS)" "1"
80 plugins/dfsound/%.o: CFLAGS += -DUSEOSS
81 OBJS += plugins/dfsound/oss.o
82 endif
83 ifeq "$(USE_ALSA)" "1"
84 plugins/dfsound/%.o: CFLAGS += -DUSEALSA
85 OBJS += plugins/dfsound/alsa.o
86 LDFLAGS += -lasound
87 endif
88
89 # gpu
90 # note: code is not safe for strict-aliasing? (Castlevania problems)
91 plugins/dfxvideo/%.o: CFLAGS += -fno-strict-aliasing
92 OBJS += plugins/dfxvideo/gpu.o
93 plugins/dfxvideo/gpu.o: plugins/dfxvideo/fps.c plugins/dfxvideo/prim.c \
94         plugins/dfxvideo/gpu.c plugins/dfxvideo/soft.c
95 ifdef X11
96 LDFLAGS += -lX11 -lXv
97 OBJS += plugins/dfxvideo/draw.o
98 else
99 OBJS += plugins/dfxvideo/draw_fb.o
100 endif
101
102 # cdrcimg
103 OBJS += plugins/cdrcimg/cdrcimg.o
104
105 # dfinput
106 OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
107
108 # gui
109 OBJS += frontend/main.o frontend/plugin.o
110 OBJS += frontend/plugin_lib.o frontend/common/readpng.o
111 OBJS += frontend/common/fonts.o frontend/linux/plat.o
112 ifeq "$(USE_GTK)" "1"
113 OBJS += maemo/hildon.o maemo/main.o
114 maemo/%.o: maemo/%.c
115 else
116 OBJS += frontend/menu.o frontend/linux/in_evdev.o
117 OBJS += frontend/common/input.o frontend/linux/oshide.o
118
119 ifeq "$(PLATFORM)" "pandora"
120 frontend/%.o: CFLAGS += -DVOUT_FBDEV
121 OBJS += frontend/linux/fbdev.o
122 OBJS += frontend/plat_omap.o
123 OBJS += frontend/plat_pandora.o
124 else
125 ifeq "$(PLATFORM)" "caanoo"
126 OBJS += frontend/plat_pollux.o
127 OBJS += frontend/warm/warm.o
128 else
129 OBJS += frontend/plat_dummy.o
130 endif
131 endif
132
133 endif # !USE_GTK
134
135 ifeq "$(HAVE_NEON)" "1"
136 OBJS += frontend/cspace_neon.o
137 else
138 OBJS += frontend/cspace.o
139 endif
140 ifdef X11
141 frontend/%.o: CFLAGS += -DX11
142 OBJS += frontend/xkb.o
143 endif
144 ifdef PCNT
145 CFLAGS += -DPCNT
146 endif
147 ifndef NO_TSLIB
148 frontend/%.o: CFLAGS += -DHAVE_TSLIB
149 OBJS += frontend/pl_gun_ts.o
150 endif
151 frontend/%.o: CFLAGS += -DIN_EVDEV
152 frontend/menu.o: frontend/revision.h
153
154 frontend/revision.h: FORCE
155         @(git describe || echo) | sed -e 's/.*/#define REV "\0"/' > $@_
156         @diff -q $@_ $@ > /dev/null 2>&1 || cp $@_ $@
157         @rm $@_
158 .PHONY: FORCE
159
160
161 $(TARGET): $(OBJS)
162         $(CC) -o $@ $^ $(LDFLAGS) -Wl,-Map=$@.map
163
164 PLUGINS ?= plugins/spunull/spunull.so plugins/gpu_unai/gpuPCSX4ALL.so \
165         plugins/gpu-gles/gpuGLES.so plugins/gpu_neon/gpu_neon.so
166
167 $(PLUGINS):
168         make -C $(dir $@)
169
170 clean:
171         $(RM) $(TARGET) $(OBJS) $(TARGET).map
172
173 clean_plugins:
174         for dir in $(PLUGINS) ; do \
175                 $(MAKE) -C $$(dirname $$dir) clean; done
176
177 # ----------- release -----------
178
179 PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
180
181 VER ?= $(shell git describe master)
182
183 rel: pcsx $(PLUGINS) \
184                 pandora/pcsx.sh pandora/pcsx.pxml.templ pandora/pcsx.png \
185                 pandora/picorestore pandora/readme.txt pandora/skin COPYING
186         rm -rf out
187         mkdir -p out/plugins
188         cp -r $^ out/
189         sed -e 's/%PR%/$(VER)/g' out/pcsx.pxml.templ > out/pcsx.pxml
190         rm out/pcsx.pxml.templ
191         mv out/*.so out/plugins/
192         mv out/plugins/gpu_neon.so out/plugins/gpuPEOPS2.so
193         $(PND_MAKE) -p pcsx_rearmed_$(VER).pnd -d out -x out/pcsx.pxml -i pandora/pcsx.png -c