Makefile 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. TARGET ?= PicoDrive
  2. DEBUG ?= 0
  3. CFLAGS += -Wall -ggdb -ffunction-sections -fdata-sections
  4. CFLAGS += -I.
  5. ifeq "$(DEBUG)" "0"
  6. CFLAGS += -O3 -DNDEBUG
  7. endif
  8. # This is actually needed, believe me.
  9. # If you really have to disable this, set NO_ALIGN_FUNCTIONS elsewhere.
  10. ifndef NO_ALIGN_FUNCTIONS
  11. CFLAGS += -falign-functions=2
  12. endif
  13. LDFLAGS += -Wl,--gc-sections
  14. # profiling
  15. pprof ?= 0
  16. gperf ?= 0
  17. all: config.mak target_
  18. ifndef NO_CONFIG_MAK
  19. ifneq ($(wildcard config.mak),)
  20. config.mak: ./configure
  21. @echo $@ is out-of-date, running configure
  22. @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
  23. include config.mak
  24. else
  25. config.mak:
  26. @echo "Please run ./configure before running make!"
  27. @exit 1
  28. endif
  29. else # NO_CONFIG_MAK
  30. config.mak:
  31. endif
  32. ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","gp2x" "opendingux" "rpi1"))
  33. # very small caches, avoid optimization options making the binary much bigger
  34. CFLAGS += -finline-limit=42 -fno-unroll-loops -fno-ipa-cp -ffast-math
  35. # this gets you about 20% better execution speed on 32bit arm/mips
  36. CFLAGS += -fno-common -fno-stack-protector -fno-guess-branch-probability -fno-caller-saves -fno-tree-loop-if-convert -fno-regmove
  37. endif
  38. #OBJS += align.o
  39. # default settings
  40. ifeq "$(ARCH)" "arm"
  41. use_cyclone ?= 1
  42. use_drz80 ?= 1
  43. use_sh2drc ?= 1
  44. use_svpdrc ?= 1
  45. asm_memory ?= 1
  46. asm_render ?= 1
  47. asm_ym2612 ?= 1
  48. asm_misc ?= 1
  49. asm_cdmemory ?= 1
  50. asm_mix ?= 1
  51. asm_32xdraw ?= 1
  52. asm_32xmemory ?= 1
  53. else ifneq (,$(findstring 86,$(ARCH)))
  54. use_fame ?= 1
  55. use_cz80 ?= 1
  56. use_sh2drc ?= 1
  57. else ifneq (,$(findstring mips,$(ARCH)))
  58. use_fame ?= 1
  59. use_cz80 ?= 1
  60. use_sh2drc ?= 1
  61. else ifneq (,$(findstring aarch64,$(ARCH)))
  62. use_fame ?= 1
  63. use_cz80 ?= 1
  64. use_sh2drc ?= 1
  65. else ifneq (,$(findstring riscv,$(ARCH)))
  66. use_fame ?= 1
  67. use_cz80 ?= 1
  68. use_sh2drc ?= 1
  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. OBJS += platform/opendingux/inputmap.o
  80. # OpenDingux is a generic platform, really.
  81. PLATFORM := generic
  82. endif
  83. ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","rpi1" "rpi2"))
  84. CFLAGS += -DHAVE_GLES -DRASPBERRY
  85. CFLAGS += -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads/ -I/opt/vc/include/interface/vmcs_host/linux/
  86. LDFLAGS += -ldl -lbcm_host -L/opt/vc/lib
  87. # Stupid renaming occured in latest raspbian...
  88. ifneq (,$(wildcard /opt/vc/lib/libbrcmGLESv2.so))
  89. LDFLAGS += -lbrcmEGL -lbrcmGLESv2
  90. else
  91. LDFLAGS += -lEGL -lGLESv2
  92. endif
  93. OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
  94. OBJS += platform/common/plat_sdl.o
  95. OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
  96. OBJS += platform/libpicofe/plat_dummy.o
  97. OBJS += platform/libpicofe/gl.o
  98. OBJS += platform/libpicofe/gl_platform.o
  99. USE_FRONTEND = 1
  100. endif
  101. ifeq "$(PLATFORM)" "generic"
  102. OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
  103. OBJS += platform/common/plat_sdl.o
  104. OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
  105. OBJS += platform/libpicofe/plat_dummy.o
  106. USE_FRONTEND = 1
  107. endif
  108. ifeq "$(PLATFORM)" "pandora"
  109. platform/common/menu_pico.o: CFLAGS += -DPANDORA
  110. platform/libpicofe/linux/plat.o: CFLAGS += -DPANDORA
  111. OBJS += platform/pandora/plat.o
  112. OBJS += platform/pandora/asm_utils.o
  113. OBJS += platform/common/arm_utils.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/gp2x/in_gp2x.o
  122. OBJS += platform/libpicofe/gp2x/soc.o
  123. OBJS += platform/libpicofe/gp2x/soc_mmsp2.o
  124. OBJS += platform/libpicofe/gp2x/soc_pollux.o
  125. OBJS += platform/libpicofe/gp2x/plat.o
  126. OBJS += platform/libpicofe/gp2x/pollux_set.o
  127. OBJS += platform/gp2x/940ctl.o
  128. OBJS += platform/gp2x/plat.o
  129. OBJS += platform/gp2x/emu.o
  130. OBJS += platform/gp2x/vid_mmsp2.o
  131. OBJS += platform/gp2x/vid_pollux.o
  132. OBJS += platform/gp2x/warm.o
  133. USE_FRONTEND = 1
  134. PLATFORM_MP3 = 1
  135. PLATFORM_ZLIB = 1
  136. HAVE_ARMv6 = 0
  137. endif
  138. ifeq "$(PLATFORM)" "libretro"
  139. OBJS += platform/libretro/libretro.o
  140. PLATFORM_ZLIB = 1
  141. endif
  142. ifeq "$(USE_FRONTEND)" "1"
  143. # common
  144. OBJS += platform/common/main.o platform/common/emu.o \
  145. platform/common/menu_pico.o platform/common/config_file.o
  146. # libpicofe
  147. OBJS += platform/libpicofe/input.o platform/libpicofe/readpng.o \
  148. platform/libpicofe/fonts.o platform/libpicofe/linux/in_evdev.o \
  149. 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 gcc,$(CC)),)
  189. LDFLAGS += -Wl,-Map=$(TARGET).map
  190. endif
  191. target_: pico/pico_int_offs.h $(TARGET)
  192. clean:
  193. $(RM) $(TARGET) $(OBJS) pico/pico_int_offs.h
  194. $(RM) -r .opk_data
  195. $(TARGET): $(OBJS)
  196. ifeq ($(STATIC_LINKING), 1)
  197. $(AR) rcs $@ $^
  198. else
  199. $(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) $(LDLIBS)
  200. endif
  201. pprof: platform/linux/pprof.c
  202. $(CC) $(CFLAGS) -O2 -ggdb -DPPROF -DPPROF_TOOL -I../../ -I. $^ -o $@ $(LDFLAGS) $(LDLIBS)
  203. pico/pico_int_offs.h: tools/mkoffsets.sh
  204. make -C tools/ XCC="$(CC)" XCFLAGS="$(CFLAGS)"
  205. .s.o:
  206. $(CC) $(CFLAGS) -c $< -o $@
  207. .S.o:
  208. $(CC) $(CFLAGS) -c $< -o $@
  209. # special flags - perhaps fix this someday instead?
  210. pico/draw.o: CFLAGS += -fno-strict-aliasing
  211. pico/draw2.o: CFLAGS += -fno-strict-aliasing
  212. pico/mode4.o: CFLAGS += -fno-strict-aliasing
  213. pico/cd/memory.o: CFLAGS += -fno-strict-aliasing
  214. pico/cd/cd_file.o: CFLAGS += -fno-strict-aliasing
  215. pico/cd/pcm.o: CFLAGS += -fno-strict-aliasing
  216. pico/cd/LC89510.o: CFLAGS += -fno-strict-aliasing
  217. pico/cd/gfx_cd.o: CFLAGS += -fno-strict-aliasing
  218. ifeq (1,$(use_sh2drc))
  219. ifneq (,$(findstring -flto,$(CFLAGS)))
  220. # if using the DRC, memory and sh2soc directly use the DRC register for SH2 SR
  221. # to avoid saving and reloading it. However, this collides with the use of LTO.
  222. pico/32x/memory.o: CFLAGS += -fno-lto
  223. pico/32x/sh2soc.o: CFLAGS += -fno-lto
  224. endif
  225. endif
  226. # fame needs ~2GB of RAM to compile on gcc 4.8
  227. # on x86, this is reduced by ~300MB when debug info is off (but not on ARM)
  228. # not using O3 and -fno-expensive-optimizations seems to also help, but you may
  229. # want to remove this stuff for better performance if your compiler can handle it
  230. ifeq "$(DEBUG)" "0"
  231. cpu/fame/famec.o: CFLAGS += -g0 -O2 -fno-expensive-optimizations
  232. endif
  233. pico/carthw_cfg.c: pico/carthw.cfg
  234. tools/make_carthw_c $< $@
  235. # random deps
  236. pico/carthw/svp/compiler.o : cpu/drc/emit_arm.c
  237. cpu/sh2/compiler.o : cpu/drc/emit_arm.c cpu/drc/emit_arm64.c
  238. cpu/sh2/compiler.o : cpu/drc/emit_x86.c cpu/drc/emit_mips.c cpu/drc/emit_riscv.c
  239. cpu/sh2/mame/sh2pico.o : cpu/sh2/mame/sh2.c
  240. pico/pico.o pico/cd/mcd.o pico/32x/32x.o : pico/pico_cmn.c pico/pico_int.h
  241. pico/memory.o pico/cd/memory.o pico/32x/memory.o : pico/pico_int.h pico/memory.h
  242. # pico/cart.o : pico/carthw_cfg.c
  243. cpu/fame/famec.o: cpu/fame/famec.c cpu/fame/famec_opcodes.h