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