Makefile 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. #OBJS += align.o
  44. # default settings
  45. ifeq "$(ARCH)" "arm"
  46. use_cyclone ?= 1
  47. use_drz80 ?= 1
  48. use_sh2drc ?= 1
  49. use_svpdrc ?= 1
  50. asm_memory ?= 1
  51. asm_render ?= 1
  52. asm_ym2612 ?= 1
  53. asm_misc ?= 1
  54. asm_cdmemory ?= 1
  55. asm_mix ?= 1
  56. asm_32xdraw ?= 1
  57. asm_32xmemory ?= 1
  58. else
  59. use_fame ?= 1
  60. use_cz80 ?= 1
  61. ifneq (,$(filter x86% i386% mips% aarch% riscv% powerpc% ppc%, $(ARCH)))
  62. use_sh2drc ?= 1
  63. endif
  64. endif
  65. -include Makefile.local
  66. ifeq "$(PLATFORM)" "opendingux"
  67. opk: $(TARGET).opk
  68. $(TARGET).opk: $(TARGET)
  69. $(RM) -rf .opk_data
  70. cp -r platform/opendingux/data .opk_data
  71. cp $< .opk_data/PicoDrive
  72. $(STRIP) .opk_data/PicoDrive
  73. mksquashfs .opk_data $@ -all-root -noappend -no-exports -no-xattrs
  74. OBJS += platform/opendingux/inputmap.o
  75. # OpenDingux is a generic platform, really.
  76. PLATFORM := generic
  77. endif
  78. ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","rpi1" "rpi2"))
  79. CFLAGS += -DHAVE_GLES -DRASPBERRY
  80. CFLAGS += -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads/ -I/opt/vc/include/interface/vmcs_host/linux/
  81. LDFLAGS += -ldl -lbcm_host -L/opt/vc/lib
  82. # Stupid renaming occured in latest raspbian...
  83. ifneq (,$(wildcard /opt/vc/lib/libbrcmGLESv2.so))
  84. LDFLAGS += -lbrcmEGL -lbrcmGLESv2
  85. else
  86. LDFLAGS += -lEGL -lGLESv2
  87. endif
  88. OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
  89. OBJS += platform/common/plat_sdl.o
  90. OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
  91. OBJS += platform/libpicofe/plat_dummy.o
  92. OBJS += platform/libpicofe/gl.o
  93. OBJS += platform/libpicofe/gl_platform.o
  94. USE_FRONTEND = 1
  95. endif
  96. ifeq "$(PLATFORM)" "generic"
  97. CFLAGS += -DSDL_OVERLAY_2X
  98. OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
  99. OBJS += platform/common/plat_sdl.o
  100. OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
  101. OBJS += platform/libpicofe/plat_dummy.o
  102. USE_FRONTEND = 1
  103. endif
  104. ifeq "$(PLATFORM)" "pandora"
  105. platform/common/menu_pico.o: CFLAGS += -DPANDORA
  106. platform/libpicofe/linux/plat.o: CFLAGS += -DPANDORA
  107. OBJS += platform/pandora/plat.o
  108. OBJS += platform/pandora/asm_utils.o
  109. OBJS += platform/common/arm_utils.o
  110. OBJS += platform/libpicofe/linux/fbdev.o
  111. OBJS += platform/libpicofe/linux/xenv.o
  112. OBJS += platform/libpicofe/pandora/plat.o
  113. USE_FRONTEND = 1
  114. endif
  115. ifeq "$(PLATFORM)" "gp2x"
  116. OBJS += platform/common/arm_utils.o
  117. OBJS += platform/libpicofe/gp2x/in_gp2x.o
  118. OBJS += platform/libpicofe/gp2x/soc.o
  119. OBJS += platform/libpicofe/gp2x/soc_mmsp2.o
  120. OBJS += platform/libpicofe/gp2x/soc_pollux.o
  121. OBJS += platform/libpicofe/gp2x/plat.o
  122. OBJS += platform/libpicofe/gp2x/pollux_set.o
  123. OBJS += platform/gp2x/940ctl.o
  124. OBJS += platform/gp2x/plat.o
  125. OBJS += platform/gp2x/emu.o
  126. OBJS += platform/gp2x/vid_mmsp2.o
  127. OBJS += platform/gp2x/vid_pollux.o
  128. OBJS += platform/gp2x/warm.o
  129. USE_FRONTEND = 1
  130. PLATFORM_MP3 = 1
  131. PLATFORM_ZLIB = 1
  132. HAVE_ARMv6 = 0
  133. endif
  134. ifeq "$(PLATFORM)" "libretro"
  135. OBJS += platform/libretro/libretro.o
  136. PLATFORM_ZLIB = 1
  137. endif
  138. ifeq "$(USE_FRONTEND)" "1"
  139. # common
  140. OBJS += platform/common/main.o platform/common/emu.o \
  141. platform/common/menu_pico.o platform/common/config_file.o
  142. # libpicofe
  143. OBJS += platform/libpicofe/input.o platform/libpicofe/readpng.o \
  144. platform/libpicofe/fonts.o platform/libpicofe/linux/in_evdev.o \
  145. platform/libpicofe/linux/plat.o
  146. # libpicofe - sound
  147. OBJS += platform/libpicofe/sndout.o
  148. ifneq ($(findstring oss,$(SOUND_DRIVERS)),)
  149. platform/libpicofe/sndout.o: CFLAGS += -DHAVE_OSS
  150. OBJS += platform/libpicofe/linux/sndout_oss.o
  151. endif
  152. ifneq ($(findstring alsa,$(SOUND_DRIVERS)),)
  153. platform/libpicofe/sndout.o: CFLAGS += -DHAVE_ALSA
  154. OBJS += platform/libpicofe/linux/sndout_alsa.o
  155. endif
  156. ifneq ($(findstring sdl,$(SOUND_DRIVERS)),)
  157. platform/libpicofe/sndout.o: CFLAGS += -DHAVE_SDL
  158. OBJS += platform/libpicofe/sndout_sdl.o
  159. endif
  160. ifeq "$(ARCH)" "arm"
  161. OBJS += platform/libpicofe/arm_linux.o
  162. endif
  163. endif # USE_FRONTEND
  164. OBJS += platform/common/mp3.o platform/common/mp3_sync.o
  165. ifeq "$(PLATFORM_MP3)" "1"
  166. platform/common/mp3_helix.o: CFLAGS += -Iplatform/libpicofe
  167. OBJS += platform/common/mp3_helix.o
  168. else ifeq "$(HAVE_LIBAVCODEC)" "1"
  169. OBJS += platform/common/mp3_libavcodec.o
  170. else
  171. OBJS += platform/common/mp3_dummy.o
  172. endif
  173. ifeq "$(PLATFORM_ZLIB)" "1"
  174. # zlib
  175. OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \
  176. zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o zlib/uncompr.o
  177. CFLAGS += -Izlib
  178. endif
  179. # unzip
  180. OBJS += unzip/unzip.o
  181. include platform/common/common.mak
  182. OBJS += $(OBJS_COMMON)
  183. CFLAGS += $(addprefix -D,$(DEFINES))
  184. ifneq ($(findstring gcc,$(CC)),)
  185. LDFLAGS += -Wl,-Map=$(TARGET).map
  186. endif
  187. target_: $(TARGET)
  188. clean:
  189. $(RM) $(TARGET) $(OBJS) pico/pico_int_offs.h
  190. $(RM) -r .opk_data
  191. $(TARGET): $(OBJS)
  192. ifeq ($(STATIC_LINKING), 1)
  193. $(AR) rcs $@ $^
  194. else
  195. $(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) $(LDLIBS)
  196. endif
  197. pprof: platform/linux/pprof.c
  198. $(CC) $(CFLAGS) -O2 -ggdb -DPPROF -DPPROF_TOOL -I../../ -I. $^ -o $@ $(LDFLAGS) $(LDLIBS)
  199. pico/pico_int_offs.h: tools/mkoffsets.sh
  200. make -C tools/ XCC="$(CC)" XCFLAGS="$(CFLAGS)" XPLATFORM="$(platform)"
  201. .s.o:
  202. $(CC) $(CFLAGS) -c $< -o $@
  203. .S.o:
  204. $(CC) $(CFLAGS) -c $< -o $@
  205. # special flags - perhaps fix this someday instead?
  206. pico/draw.o: CFLAGS += -fno-strict-aliasing
  207. pico/draw2.o: CFLAGS += -fno-strict-aliasing
  208. pico/mode4.o: CFLAGS += -fno-strict-aliasing
  209. pico/cd/memory.o: CFLAGS += -fno-strict-aliasing
  210. pico/cd/cd_file.o: CFLAGS += -fno-strict-aliasing
  211. pico/cd/pcm.o: CFLAGS += -fno-strict-aliasing
  212. pico/cd/LC89510.o: CFLAGS += -fno-strict-aliasing
  213. pico/cd/gfx_cd.o: CFLAGS += -fno-strict-aliasing
  214. ifeq (1,$(use_sh2drc))
  215. ifneq (,$(findstring -flto,$(CFLAGS)))
  216. # if using the DRC, memory and sh2soc directly use the DRC register for SH2 SR
  217. # to avoid saving and reloading it. However, this collides with the use of LTO.
  218. pico/32x/memory.o: CFLAGS += -fno-lto
  219. pico/32x/sh2soc.o: CFLAGS += -fno-lto
  220. endif
  221. endif
  222. # fame needs ~2GB of RAM to compile on gcc 4.8
  223. # on x86, this is reduced by ~300MB when debug info is off (but not on ARM)
  224. # not using O3 and -fno-expensive-optimizations seems to also help, but you may
  225. # want to remove this stuff for better performance if your compiler can handle it
  226. ifeq "$(DEBUG)" "0"
  227. cpu/fame/famec.o: CFLAGS += -g0 -O2 -fno-expensive-optimizations
  228. endif
  229. pico/carthw_cfg.c: pico/carthw.cfg
  230. tools/make_carthw_c $< $@
  231. # preprocessed asm files most probably include the offsets file
  232. $(filter %.S,$(SRCS_COMMON)): pico/pico_int_offs.h
  233. # random deps
  234. pico/carthw/svp/compiler.o : cpu/drc/emit_arm.c
  235. cpu/sh2/compiler.o : cpu/drc/emit_arm.c cpu/drc/emit_arm64.c cpu/drc/emit_ppc.c
  236. cpu/sh2/compiler.o : cpu/drc/emit_x86.c cpu/drc/emit_mips.c cpu/drc/emit_riscv.c
  237. cpu/sh2/mame/sh2pico.o : cpu/sh2/mame/sh2.c
  238. pico/pico.o pico/cd/mcd.o pico/32x/32x.o : pico/pico_cmn.c pico/pico_int.h
  239. pico/memory.o pico/cd/memory.o pico/32x/memory.o : pico/pico_int.h pico/memory.h
  240. # pico/cart.o : pico/carthw_cfg.c
  241. cpu/fame/famec.o: cpu/fame/famec.c cpu/fame/famec_opcodes.h