Makefile 8.1 KB

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