Advertisement
Guest User

GCC7 32X Makefile

a guest
Aug 21st, 2017
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 6.16 KB | None | 0 0
  1. # SEGA MD/CD/32X toolchain makefile by Chilly Willy
  2. # adapted from Jim Ursetto' makefile for the DC
  3. # adapted from Stalin's build script version 0.3
  4. #
  5. # Interesting parameters:
  6. # erase=0|1                     Erase build directories on the fly to save space
  7. # thread_model=posix|single     Set gcc threading model
  8. # verbose=0|1                   Display
  9. #
  10. # Interesting targets (you can 'make' any of these):
  11. # all: build
  12. # build: build-sh2 build-m68k
  13. # build-sh2: build-sh2-binutils build-sh2-gcc
  14. # build-m68k: build-m68k-binutils build-m68k-gcc
  15. # build-sh2-gcc: build-sh2-gcc-pass1 build-sh2-newlib build-sh2-gcc-pass2
  16. # build-m68k-gcc: build-m68k-gcc-pass1 build-m68k-newlib build-m68k-gcc-pass2
  17. # build-sh2-newlib: build-sh2-newlib-only
  18. # build-m68k-newlib: build-m68k-newlib-only
  19.  
  20. # User configuration
  21. sh_target=sh-elf
  22. m68k_target=m68k-elf
  23. sh_prefix  := /opt/toolchains/sega/$(sh_target)
  24. m68k_prefix := /opt/toolchains/sega/$(m68k_target)
  25. binutils_ver=2.28
  26. gcc_ver=7.1.0
  27. newlib_ver=2.5.0
  28. thread_model=single
  29. erase=0
  30. verbose=1
  31. # Set the languages to build for pass 2 of building gcc. The default
  32. # here is to build C, C++, Objective C, and Objective C++. You may want to take
  33. # out the latter two if you're not worried about them and/or you're short on
  34. # hard drive space.
  35. pass2_languages=c,c++,objc,obj-c++
  36.  
  37. # build variables
  38. install=$(prefix)/bin
  39. pwd := $(shell pwd)
  40. logdir := $(pwd)/logs
  41. PATH := $(sh_prefix)/bin:$(m68k_prefix)/bin:$(PATH)
  42. binutils_dir=binutils-$(binutils_ver)
  43. gcc_dir=gcc-$(gcc_ver)
  44. newlib_dir=newlib-$(newlib_ver)
  45.  
  46. all: build
  47.  
  48. # ---- build {{{
  49.  
  50. build: build-sh2 build-m68k
  51. build-sh2: build-sh2-binutils build-sh2-gcc
  52. build-m68k: build-m68k-binutils build-m68k-gcc
  53. build-sh2-gcc: build-sh2-gcc-pass1 build-sh2-newlib build-sh2-gcc-pass2
  54. build-m68k-gcc: build-m68k-gcc-pass1 build-m68k-newlib build-m68k-gcc-pass2
  55. build-sh2-newlib: build-sh2-newlib-only
  56. build-m68k-newlib: build-m68k-newlib-only
  57.  
  58. # Ensure that, no matter where we enter, prefix and target are set correctly.
  59. build_sh2_targets=build-sh2-binutils build-sh2-gcc build-sh2-gcc-pass1 build-sh2-newlib build-sh2-newlib-only build-sh2-gcc-pass2
  60. build_m68k_targets=build-m68k-binutils build-m68k-gcc build-m68k-gcc-pass1 build-m68k-newlib build-m68k-newlib-only build-m68k-gcc-pass2
  61. $(build_sh2_targets): prefix = $(sh_prefix)
  62. $(build_sh2_targets): target = $(sh_target)
  63. $(build_sh2_targets): extra_configure_args = --with-endian=big --with-cpu=m2 --disable-werror --disable-multilib
  64. $(build_m68k_targets): prefix = $(m68k_prefix)
  65. $(build_m68k_targets): target = $(m68k_target)
  66. $(build_m68k_targets): extra_configure_args = --with-cpu=m68000 --disable-werror --disable-multilib
  67.  
  68. # To avoid code repetition, we use the same commands for both
  69. # architectures.  But we can't create a single target called
  70. # build-binutils for both sh2 and m68k, because phony targets
  71. # can't be run multiple times.  So we create multiple targets.
  72. build_binutils     = build-sh2-binutils  build-m68k-binutils
  73. build_gcc_pass1    = build-sh2-gcc-pass1 build-m68k-gcc-pass1
  74. build_newlib       = build-sh2-newlib-only build-m68k-newlib-only
  75. build_gcc_pass2    = build-sh2-gcc-pass2 build-m68k-gcc-pass2
  76.  
  77. # Here we use the essentially same code for multiple targets,
  78. # differing only by the current state of the variables below.
  79. $(build_binutils): build = build-binutils-$(target)-$(binutils_ver)
  80. $(build_binutils): src_dir = binutils-$(binutils_ver)
  81. $(build_binutils): log = $(logdir)/$(build).log
  82. $(build_binutils): logdir
  83.     @echo "+++ Building $(src_dir) to $(build)..."
  84.     -mkdir -p $(build)
  85.     > $(log)
  86.     cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) --disable-werror --enable-install-libbfd $(extra_configure_args) $(to_log)
  87.     make -C $(build) all install DESTDIR=$(DESTDIR) $(to_log)
  88.     $(clean_up)
  89.  
  90. $(build_gcc_pass1) $(build_gcc_pass2): build = build-gcc-$(target)-$(gcc_ver)
  91. $(build_gcc_pass1) $(build_gcc_pass2): src_dir = gcc-$(gcc_ver)
  92. $(build_gcc_pass1): log = $(logdir)/$(build)-pass1.log
  93. $(build_gcc_pass1): logdir
  94.     @echo "+++ Building $(src_dir) to $(build) (pass 1)..."
  95.     -mkdir -p $(build)
  96.     > $(log)
  97.     cd $(build);  ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) --without-headers --with-newlib --enable-languages=c --disable-libssp --disable-tls $(extra_configure_args) $(to_log)
  98.     make -C $(build) all-gcc install-gcc DESTDIR=$(DESTDIR) $(to_log)
  99.  
  100. $(build_newlib): build = build-newlib-$(target)-$(newlib_ver)
  101. $(build_newlib): src_dir = newlib-$(newlib_ver)
  102. $(build_newlib): log = $(logdir)/$(build).log
  103. $(build_newlib): logdir
  104.     @echo "+++ Building $(src_dir) to $(build)..."
  105.     -mkdir -p $(build)
  106.     > $(log)
  107.     cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) $(extra_configure_args) $(to_log)
  108.     make -C $(build) all install DESTDIR=$(DESTDIR) $(to_log)
  109.     $(clean_up)
  110.  
  111. $(build_gcc_pass2): log = $(logdir)/$(build)-pass2.log
  112. $(build_gcc_pass2): logdir
  113.     @echo "+++ Building $(src_dir) to $(build) (pass 2)..."
  114.     -mkdir -p $(build)
  115.     > $(log)
  116.     cd $(build);  ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) --with-newlib --disable-libssp --disable-tls \
  117.         --enable-threads=$(thread_model) --enable-languages=$(pass2_languages) $(extra_configure_args) $(to_log)
  118.     make -C $(build) all install DESTDIR=$(DESTDIR) $(to_log)
  119.     $(clean_up)
  120.  
  121. # ---- }}}}
  122.  
  123.  
  124. # ---- support {{{
  125.  
  126. clean:
  127.     -rm -rf build-newlib-$(sh_target)-$(newlib_ver)
  128.     -rm -rf build-newlib-$(m68k_target)-$(newlib_ver)
  129.     -rm -rf build-gcc-$(sh_target)-$(gcc_ver)
  130.     -rm -rf build-gcc-$(m68k_target)-$(gcc_ver)
  131.     -rm -rf build-binutils-$(sh_target)-$(binutils_ver)
  132.     -rm -rf build-binutils-$(m68k_target)-$(binutils_ver)
  133.  
  134. logdir:
  135.     @mkdir -p $(logdir)
  136.  
  137. # If erase=1, erase build directories on the fly.
  138. ifeq (1,$(erase))
  139.     define clean_up
  140.     @echo "+++ Cleaning up $(build)..."
  141.     -rm -rf $(build)
  142.     endef
  143. endif
  144.  
  145. # If verbose=1, display output to screen as well as log files
  146. ifeq (1,$(verbose))
  147.     to_log = 2>&1 | tee -a $(log)
  148. else
  149.     to_log = >> $(log) 2>&1
  150. endif
  151.  
  152. # ---- }}}
  153.  
  154. # ---- phony targets {{{
  155.  
  156. .PHONY: all build build-sh2 build-m68k $(build_sh2_targets) $(build_m68k_targets) clean
  157. .PHONY: build-binutils build-newlib build-gcc-pass1 build-gcc-pass2
  158.  
  159. # ---- }}}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement