revive GP2X build, update
[picodrive.git] / Makefile
1 TARGET ?= PicoDrive
2 CFLAGS += -Wall -ggdb -falign-functions=2
3 CFLAGS += -I.
4 ifndef DEBUG
5 CFLAGS += -O2 -DNDEBUG
6 endif
7 #CFLAGS += -DEVT_LOG
8 #CFLAGS += -DDRC_CMP
9 #cpu_cmp = 1
10 #drc_debug = 7
11 #profile = 1
12
13
14 all: config.mak target_
15
16 ifndef NO_CONFIG_MAK
17 ifneq ($(wildcard config.mak),)
18 config.mak: ./configure
19         @echo $@ is out-of-date, running configure
20         @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
21 include config.mak
22 else
23 config.mak:
24         @echo "Please run ./configure before running make!"
25         @exit 1
26 endif
27 else # NO_CONFIG_MAK
28 config.mak:
29 endif
30
31 # default settings
32 ifeq "$(ARCH)" "arm"
33 use_cyclone ?= 1
34 use_drz80 ?= 1
35 use_sh2drc ?= 1
36 use_svpdrc ?= 1
37
38 asm_memory ?= 1
39 asm_render ?= 1
40 asm_ym2612 ?= 1
41 asm_misc ?= 1
42 asm_cdpico ?= 1
43 asm_cdmemory ?= 1
44 asm_mix ?= 1
45 else # if not arm
46 use_fame ?= 1
47 use_cz80 ?= 1
48 use_sh2mame ?= 1
49 endif
50
51 -include Makefile.local
52
53 ifneq "$(use_cyclone)" "1"
54 # due to CPU stop flag access
55 asm_cdpico = 0
56 asm_cdmemory = 0
57 endif
58
59 # frontend
60 ifeq "$(PLATFORM)" "generic"
61 OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
62 OBJS += platform/common/plat_sdl.o
63 OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
64 OBJS += platform/libpicofe/plat_dummy.o
65 USE_FRONTEND = 1
66 endif
67 ifeq "$(PLATFORM)" "pandora"
68 platform/common/menu_pico.o: CFLAGS += -DPANDORA
69 OBJS += platform/pandora/plat.o
70 OBJS += platform/pandora/asm_utils.o
71 OBJS += platform/common/arm_utils.o 
72 OBJS += platform/libpicofe/linux/fbdev.o 
73 OBJS += platform/libpicofe/linux/xenv.o
74 OBJS += platform/libpicofe/pandora/plat.o
75 USE_FRONTEND = 1
76 endif
77 ifeq "$(PLATFORM)" "gp2x"
78 OBJS += platform/common/arm_utils.o 
79 OBJS += platform/libpicofe/gp2x/in_gp2x.o
80 OBJS += platform/libpicofe/gp2x/soc.o 
81 OBJS += platform/libpicofe/gp2x/soc_mmsp2.o 
82 OBJS += platform/libpicofe/gp2x/soc_pollux.o 
83 OBJS += platform/libpicofe/gp2x/plat.o 
84 OBJS += platform/libpicofe/gp2x/pollux_set.o 
85 OBJS += platform/gp2x/940ctl.o 
86 OBJS += platform/gp2x/plat.o 
87 OBJS += platform/gp2x/emu.o 
88 OBJS += platform/gp2x/vid_mmsp2.o 
89 OBJS += platform/gp2x/vid_pollux.o 
90 OBJS += platform/gp2x/warm.o 
91 USE_FRONTEND = 1
92 PLATFORM_MP3 = 1
93 endif
94 ifeq "$(PLATFORM)" "libretro"
95 OBJS += platform/libretro.o 
96 endif
97
98 ifeq "$(USE_FRONTEND)" "1"
99
100 # common
101 OBJS += platform/common/main.o platform/common/emu.o \
102         platform/common/menu_pico.o platform/common/config_file.o
103
104 # libpicofe
105 OBJS += platform/libpicofe/input.o platform/libpicofe/readpng.o \
106         platform/libpicofe/fonts.o platform/libpicofe/linux/in_evdev.o \
107         platform/libpicofe/linux/plat.o
108
109 # libpicofe - sound
110 OBJS += platform/libpicofe/sndout.o
111 ifneq ($(findstring oss,$(SOUND_DRIVERS)),)
112 platform/libpicofe/sndout.o: CFLAGS += -DHAVE_OSS
113 OBJS += platform/libpicofe/linux/sndout_oss.o
114 endif
115 ifneq ($(findstring alsa,$(SOUND_DRIVERS)),)
116 platform/libpicofe/sndout.o: CFLAGS += -DHAVE_ALSA
117 OBJS += platform/libpicofe/linux/sndout_alsa.o
118 endif
119 ifneq ($(findstring sdl,$(SOUND_DRIVERS)),)
120 platform/libpicofe/sndout.o: CFLAGS += -DHAVE_SDL
121 OBJS += platform/libpicofe/sndout_sdl.o
122 endif
123
124 ifeq "$(ARCH)" "arm"
125 OBJS += platform/libpicofe/arm_linux.o
126 endif
127
128 endif # USE_FRONTEND
129
130 OBJS += platform/common/mp3.o
131 ifeq "$(PLATFORM_MP3)" "1"
132 else ifeq "$(HAVE_LIBAVCODEC)" "1"
133 OBJS += platform/common/mp3_libavcodec.o
134 else
135 OBJS += platform/common/mp3_dummy.o
136 endif
137
138 # zlib
139 OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \
140         zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o zlib/uncompr.o
141 # unzip
142 OBJS += unzip/unzip.o unzip/unzip_stream.o
143
144
145 include platform/common/common.mak
146
147 OBJS += $(OBJS_COMMON)
148 CFLAGS += $(addprefix -D,$(DEFINES))
149
150 ifneq ($(findstring gcc,$(CC)),)
151 LDFLAGS += -Wl,-Map=$(TARGET).map
152 endif
153
154
155 target_: $(TARGET)
156
157 clean:
158         $(RM) $(TARGET) $(OBJS)
159
160 $(TARGET): $(OBJS)
161         $(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) $(LDLIBS)
162
163 pprof: platform/linux/pprof.c
164         $(CC) -O2 -ggdb -DPPROF -DPPROF_TOOL -I../../ -I. $^ -o $@
165
166 tools/textfilter: tools/textfilter.c
167         make -C tools/ textfilter
168
169 .s.o:
170         $(CC) $(CFLAGS) -c $< -o $@
171
172 # special flags - perhaps fix this someday instead?
173 pico/draw.o: CFLAGS += -fno-strict-aliasing
174 pico/draw2.o: CFLAGS += -fno-strict-aliasing
175 pico/mode4.o: CFLAGS += -fno-strict-aliasing
176 pico/cd/memory.o: CFLAGS += -fno-strict-aliasing
177 pico/cd/cd_file.o: CFLAGS += -fno-strict-aliasing
178 pico/cd/pcm.o: CFLAGS += -fno-strict-aliasing
179 pico/cd/LC89510.o: CFLAGS += -fno-strict-aliasing
180 pico/cd/gfx_cd.o: CFLAGS += -fno-strict-aliasing
181
182 # random deps
183 pico/carthw/svp/compiler.o : cpu/drc/emit_$(ARCH).c
184 cpu/sh2/compiler.o : cpu/drc/emit_$(ARCH).c
185 cpu/sh2/mame/sh2pico.o : cpu/sh2/mame/sh2.c
186 pico/pico.o pico/cd/pico.o pico/32x/32x.o : pico/pico_cmn.c pico/pico_int.h
187 pico/memory.o pico/cd/memory.o : pico/pico_int.h pico/memory.h
188 cpu/fame/famec.o: cpu/fame/famec.c cpu/fame/famec_opcodes.h
189
190 # ----------- release -----------
191
192 VER ?= $(shell head -n 1 platform/common/version.h | \
193         sed 's/.*"\(.*\)\.\(.*\)".*/\1\2/g')
194
195 ifeq "$(PLATFORM)" "pandora"
196
197 PND_MAKE ?= $(HOME)/dev/pnd/src/pandora-libraries/testdata/scripts/pnd_make.sh
198
199 /tmp/readme.txt: tools/textfilter platform/base_readme.txt
200         tools/textfilter platform/base_readme.txt $@ PANDORA
201
202 /tmp/PicoDrive.pxml: platform/pandora/PicoDrive.pxml.template
203         platform/pandora/make_pxml.sh $^ $@
204
205 rel: PicoDrive platform/pandora/PicoDrive.run platform/pandora/picorestore \
206         pico/carthw.cfg /tmp/readme.txt platform/pandora/skin \
207         platform/pandora/PicoDrive.png platform/pandora/PicoDrive_p.png \
208         /tmp/PicoDrive.pxml
209         rm -rf out
210         mkdir out
211         cp -r $^ out/
212         $(PND_MAKE) -p PicoDrive_$(VER).pnd -d out -x out/PicoDrive.pxml -i out/PicoDrive.png -c
213
214 endif