Makefile 7.3 KB

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