Makefile 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. $(LD) ?= $(CC)
  2. TARGET ?= PicoDrive
  3. DEBUG ?= 0
  4. CFLAGS += -I.
  5. CYCLONE_CC ?= gcc
  6. CYCLONE_CXX ?= g++
  7. all: config.mak target_
  8. ifndef NO_CONFIG_MAK
  9. ifneq ($(wildcard config.mak),)
  10. config.mak: ./configure
  11. @echo $@ is out-of-date, running configure
  12. @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
  13. include config.mak
  14. else
  15. config.mak:
  16. @echo "Please run ./configure before running make!"
  17. @exit 1
  18. endif
  19. else # NO_CONFIG_MAK
  20. config.mak:
  21. endif
  22. # This is actually needed, believe me.
  23. # If you really have to disable this, set NO_ALIGN_FUNCTIONS elsewhere.
  24. ifndef NO_ALIGN_FUNCTIONS
  25. CFLAGS += -falign-functions=2
  26. endif
  27. # profiling
  28. pprof ?= 0
  29. gperf ?= 0
  30. ifneq ("$(PLATFORM)", "libretro")
  31. CFLAGS += -Wall -g
  32. ifneq ($(findstring gcc,$(CC)),)
  33. CFLAGS += -ffunction-sections -fdata-sections
  34. LDFLAGS += -Wl,--gc-sections
  35. endif
  36. ifeq "$(DEBUG)" "0"
  37. CFLAGS += -O3 -DNDEBUG
  38. endif
  39. LD = $(CC)
  40. OBJOUT ?= -o
  41. LINKOUT ?= -o
  42. endif
  43. ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","gp2x" "opendingux" "rpi1"))
  44. # very small caches, avoid optimization options making the binary much bigger
  45. CFLAGS += -finline-limit=42 -fno-unroll-loops -fno-ipa-cp -ffast-math
  46. # this gets you about 20% better execution speed on 32bit arm/mips
  47. CFLAGS += -fno-common -fno-stack-protector -fno-guess-branch-probability -fno-caller-saves -fno-tree-loop-if-convert -fno-regmove
  48. endif
  49. # default settings
  50. ifeq "$(ARCH)" "arm"
  51. use_cyclone ?= 1
  52. use_drz80 ?= 1
  53. use_sh2drc ?= 1
  54. use_svpdrc ?= 1
  55. asm_memory ?= 1
  56. asm_render ?= 1
  57. asm_ym2612 ?= 1
  58. asm_misc ?= 1
  59. asm_cdmemory ?= 1
  60. asm_mix ?= 1
  61. asm_32xdraw ?= 1
  62. asm_32xmemory ?= 1
  63. else
  64. use_fame ?= 1
  65. use_cz80 ?= 1
  66. ifneq (,$(filter x86% i386% mips% aarch% riscv% powerpc% ppc%, $(ARCH)))
  67. use_sh2drc ?= 1
  68. endif
  69. endif
  70. -include Makefile.local
  71. ifeq "$(PLATFORM)" "opendingux"
  72. opk: $(TARGET).opk
  73. $(TARGET).opk: $(TARGET)
  74. $(RM) -rf .opk_data
  75. cp -r platform/opendingux/data .opk_data
  76. cp $< .opk_data/PicoDrive
  77. $(STRIP) .opk_data/PicoDrive
  78. mksquashfs .opk_data $@ -all-root -noappend -no-exports -no-xattrs
  79. all: opk
  80. OBJS += platform/opendingux/inputmap.o
  81. ifneq (,$(filter %__GCW0__ %__RG350__, $(CFLAGS)))
  82. CFLAGS += -DMIPS_USE_SYNCI # clear_cache uses SYNCI instead of a syscall
  83. endif
  84. # OpenDingux is a generic platform, really.
  85. PLATFORM := generic
  86. endif
  87. ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","rpi1" "rpi2"))
  88. CFLAGS += -DHAVE_GLES -DRASPBERRY
  89. CFLAGS += -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads/ -I/opt/vc/include/interface/vmcs_host/linux/
  90. LDFLAGS += -ldl -lbcm_host -L/opt/vc/lib
  91. # Stupid renaming occured in latest raspbian...
  92. ifneq (,$(wildcard /opt/vc/lib/libbrcmGLESv2.so))
  93. LDFLAGS += -lbrcmEGL -lbrcmGLESv2
  94. else
  95. LDFLAGS += -lEGL -lGLESv2
  96. endif
  97. OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
  98. OBJS += platform/common/plat_sdl.o
  99. OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
  100. OBJS += platform/libpicofe/plat_dummy.o
  101. OBJS += platform/libpicofe/gl.o
  102. OBJS += platform/libpicofe/gl_platform.o
  103. USE_FRONTEND = 1
  104. endif
  105. ifeq "$(PLATFORM)" "generic"
  106. CFLAGS += -DSDL_OVERLAY_2X -DSDL_BUFFER_3X
  107. OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
  108. OBJS += platform/common/plat_sdl.o
  109. OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
  110. OBJS += platform/libpicofe/plat_dummy.o
  111. USE_FRONTEND = 1
  112. endif
  113. ifeq "$(PLATFORM)" "pandora"
  114. platform/common/menu_pico.o: CFLAGS += -DPANDORA
  115. platform/libpicofe/linux/plat.o: CFLAGS += -DPANDORA
  116. OBJS += platform/pandora/plat.o
  117. OBJS += platform/pandora/asm_utils.o
  118. OBJS += platform/common/arm_utils.o
  119. OBJS += platform/libpicofe/linux/in_evdev.o
  120. OBJS += platform/libpicofe/linux/fbdev.o
  121. OBJS += platform/libpicofe/linux/xenv.o
  122. OBJS += platform/libpicofe/pandora/plat.o
  123. USE_FRONTEND = 1
  124. endif
  125. ifeq "$(PLATFORM)" "gp2x"
  126. OBJS += platform/common/arm_utils.o
  127. OBJS += platform/libpicofe/linux/in_evdev.o
  128. OBJS += platform/libpicofe/gp2x/in_gp2x.o
  129. OBJS += platform/libpicofe/gp2x/soc.o
  130. OBJS += platform/libpicofe/gp2x/soc_mmsp2.o
  131. OBJS += platform/libpicofe/gp2x/soc_pollux.o
  132. OBJS += platform/libpicofe/gp2x/plat.o
  133. OBJS += platform/libpicofe/gp2x/pollux_set.o
  134. OBJS += platform/gp2x/940ctl.o
  135. OBJS += platform/gp2x/plat.o
  136. OBJS += platform/gp2x/emu.o
  137. OBJS += platform/gp2x/vid_mmsp2.o
  138. OBJS += platform/gp2x/vid_pollux.o
  139. OBJS += platform/gp2x/warm.o
  140. USE_FRONTEND = 1
  141. PLATFORM_MP3 = 1
  142. PLATFORM_ZLIB = 1
  143. HAVE_ARMv6 = 0
  144. endif
  145. ifeq "$(PLATFORM)" "libretro"
  146. OBJS += platform/libretro/libretro.o
  147. ifeq "$(USE_LIBRETRO_VFS)" "1"
  148. OBJS += platform/libretro/libretro-common/compat/compat_posix_string.o
  149. OBJS += platform/libretro/libretro-common/compat/compat_strl.o
  150. OBJS += platform/libretro/libretro-common/compat/fopen_utf8.o
  151. OBJS += platform/libretro/libretro-common/encodings/encoding_utf.o
  152. OBJS += platform/libretro/libretro-common/streams/file_stream.o
  153. OBJS += platform/libretro/libretro-common/streams/file_stream_transforms.o
  154. OBJS += platform/libretro/libretro-common/vfs/vfs_implementation.o
  155. endif
  156. PLATFORM_ZLIB = 1
  157. endif
  158. ifeq "$(USE_FRONTEND)" "1"
  159. # common
  160. OBJS += platform/common/main.o platform/common/emu.o \
  161. platform/common/menu_pico.o platform/common/config_file.o
  162. # libpicofe
  163. OBJS += platform/libpicofe/input.o platform/libpicofe/readpng.o \
  164. platform/libpicofe/fonts.o platform/libpicofe/linux/plat.o
  165. # libpicofe - sound
  166. OBJS += platform/libpicofe/sndout.o
  167. ifneq ($(findstring oss,$(SOUND_DRIVERS)),)
  168. platform/libpicofe/sndout.o: CFLAGS += -DHAVE_OSS
  169. OBJS += platform/libpicofe/linux/sndout_oss.o
  170. endif
  171. ifneq ($(findstring alsa,$(SOUND_DRIVERS)),)
  172. platform/libpicofe/sndout.o: CFLAGS += -DHAVE_ALSA
  173. OBJS += platform/libpicofe/linux/sndout_alsa.o
  174. endif
  175. ifneq ($(findstring sdl,$(SOUND_DRIVERS)),)
  176. platform/libpicofe/sndout.o: CFLAGS += -DHAVE_SDL
  177. OBJS += platform/libpicofe/sndout_sdl.o
  178. endif
  179. ifeq "$(ARCH)" "arm"
  180. OBJS += platform/libpicofe/arm_linux.o
  181. endif
  182. endif # USE_FRONTEND
  183. OBJS += platform/common/mp3.o platform/common/mp3_sync.o
  184. ifeq "$(PLATFORM_MP3)" "1"
  185. platform/common/mp3_helix.o: CFLAGS += -Iplatform/libpicofe
  186. OBJS += platform/common/mp3_helix.o
  187. else ifeq "$(HAVE_LIBAVCODEC)" "1"
  188. OBJS += platform/common/mp3_libavcodec.o
  189. else
  190. OBJS += platform/common/mp3_dummy.o
  191. endif
  192. ifeq "$(PLATFORM_ZLIB)" "1"
  193. # zlib
  194. OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \
  195. zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o zlib/uncompr.o
  196. CFLAGS += -Izlib
  197. endif
  198. # unzip
  199. OBJS += unzip/unzip.o
  200. include platform/common/common.mak
  201. OBJS += $(OBJS_COMMON)
  202. CFLAGS += $(addprefix -D,$(DEFINES))
  203. ifneq (,$(findstring sdl,$(OBJS)))
  204. CFLAGS += -DUSE_SDL
  205. endif
  206. ifneq ($(findstring gcc,$(CC)),)
  207. ifneq ($(findstring SunOS,$(shell uname -a)),SunOS)
  208. LDFLAGS += -Wl,-Map=$(TARGET).map
  209. endif
  210. endif
  211. target_: $(TARGET)
  212. clean:
  213. $(RM) $(TARGET) $(OBJS) pico/pico_int_offs.h
  214. $(RM) -r .opk_data
  215. $(TARGET): $(OBJS)
  216. ifeq ($(STATIC_LINKING), 1)
  217. $(AR) rcs $@ $^
  218. else
  219. $(LD) $(LINKOUT)$@ $^ $(LDFLAGS) $(LDLIBS)
  220. endif
  221. pprof: platform/linux/pprof.c
  222. $(CC) $(CFLAGS) -O2 -ggdb -DPPROF -DPPROF_TOOL -I../../ -I. $^ -o $@ $(LDFLAGS) $(LDLIBS)
  223. pico/pico_int_offs.h: tools/mkoffsets.sh
  224. make -C tools/ XCC="$(CC)" XCFLAGS="$(CFLAGS)" XPLATFORM="$(platform)"
  225. %.o: %.c
  226. $(CC) -c $(OBJOUT)$@ $< $(CFLAGS)
  227. .s.o:
  228. $(CC) $(CFLAGS) -c $< -o $@
  229. .S.o:
  230. $(CC) $(CFLAGS) -c $< -o $@
  231. # special flags - perhaps fix this someday instead?
  232. pico/draw.o: CFLAGS += -fno-strict-aliasing
  233. pico/draw2.o: CFLAGS += -fno-strict-aliasing
  234. pico/mode4.o: CFLAGS += -fno-strict-aliasing
  235. pico/cd/memory.o: CFLAGS += -fno-strict-aliasing
  236. pico/cd/cd_file.o: CFLAGS += -fno-strict-aliasing
  237. pico/cd/pcm.o: CFLAGS += -fno-strict-aliasing
  238. pico/cd/LC89510.o: CFLAGS += -fno-strict-aliasing
  239. pico/cd/gfx_cd.o: CFLAGS += -fno-strict-aliasing
  240. ifeq (1,$(use_sh2drc))
  241. ifneq (,$(findstring -flto,$(CFLAGS)))
  242. # if using the DRC, memory and sh2soc directly use the DRC register for SH2 SR
  243. # to avoid saving and reloading it. However, this collides with the use of LTO.
  244. pico/32x/memory.o: CFLAGS += -fno-lto
  245. pico/32x/sh2soc.o: CFLAGS += -fno-lto
  246. endif
  247. endif
  248. # fame needs ~2GB of RAM to compile on gcc 4.8
  249. # on x86, this is reduced by ~300MB when debug info is off (but not on ARM)
  250. # not using O3 and -fno-expensive-optimizations seems to also help, but you may
  251. # want to remove this stuff for better performance if your compiler can handle it
  252. ifeq "$(DEBUG)" "0"
  253. ifeq (,$(findstring msvc,$(platform)))
  254. cpu/fame/famec.o: CFLAGS += -g0 -O2 -fno-expensive-optimizations
  255. else
  256. cpu/fame/famec.o: CFLAGS += -Od
  257. endif
  258. endif
  259. pico/carthw_cfg.c: pico/carthw.cfg
  260. tools/make_carthw_c $< $@
  261. # preprocessed asm files most probably include the offsets file
  262. $(filter %.S,$(SRCS_COMMON)): pico/pico_int_offs.h
  263. # random deps
  264. pico/carthw/svp/compiler.o : cpu/drc/emit_arm.c
  265. cpu/sh2/compiler.o : cpu/drc/emit_arm.c cpu/drc/emit_arm64.c cpu/drc/emit_ppc.c
  266. cpu/sh2/compiler.o : cpu/drc/emit_x86.c cpu/drc/emit_mips.c cpu/drc/emit_riscv.c
  267. cpu/sh2/mame/sh2pico.o : cpu/sh2/mame/sh2.c
  268. pico/pico.o pico/cd/mcd.o pico/32x/32x.o : pico/pico_cmn.c pico/pico_int.h
  269. pico/memory.o pico/cd/memory.o pico/32x/memory.o : pico/pico_int.h pico/memory.h
  270. # pico/cart.o : pico/carthw_cfg.c
  271. cpu/fame/famec.o: cpu/fame/famec.c cpu/fame/famec_opcodes.h