Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. MAKEFLAGS = -R -r
  2. prefix := $(CURDIR)/gnu
  3. bindir := $(prefix)/bin
  4. tooldir = gnusrc
  5. binutils = $(tooldir)/binutils
  6. all_config = --prefix=$(prefix)
  7. z80_config = $(all_config) --target=z80-none-elf
  8. all: gnu
  9. include ../riscv-opts.mk
  10. export riscv_target_flags
  11. multilibs= rv32imc-ilp32--zicsr;rv32im-ilp32--zicsr;rv32i-ilp32--zicsr;rv32imc_zbb-ilp32--zicsr
  12. riscv_tuple=riscv32-unknown-elf
  13. riscv_config = $(all_config) \
  14. --target=riscv32-unknown-elf \
  15. --enable-languages=c,c++ \
  16. --with-arch=rv32imc_zicsr --with-abi=ilp32 \
  17. --with-newlib \
  18. --with-sysroot=$(prefix)/$(riscv_tuple) \
  19. --disable-shared --disable-threads \
  20. --disable-libmudflap --disable-libssp \
  21. --disable-libquadmath --disable-libgomp --disable-nls \
  22. --disable-tm-clone-registry \
  23. --enable-multilib --with-multilib-generator=$(multilibs)
  24. export riscv_config
  25. riscv_binutils_configargs := \
  26. --disable-gold --disable-gprof --disable-sim
  27. export riscv_binutils_configargs
  28. pathify = PATH='$(bindir):$(PATH)'
  29. # -R -r fails, and one can't disable it, so strip all of MAKEFLAGS
  30. # except any job-related options. Sigh.
  31. gnu_makeflags = MAKEFLAGS=' $(filter -j% --job%,$(MAKEFLAGS))'
  32. rsetup = $(pathify) $(gnu_makeflags)
  33. RMAKE = $(rsetup) $(MAKE)
  34. riscv_newlib_configargs := \
  35. --disable-newlib-fseek-optimization \
  36. --disable-newlib-fvwrite-in-streamio \
  37. --disable-newlib-mb \
  38. --disable-newlib-multithread \
  39. --disable-newlib-reent-check-verify \
  40. --disable-newlib-register-fini \
  41. --disable-newlib-supplied-syscalls \
  42. --disable-newlib-unbuf-stream-opt \
  43. --disable-newlib-wide-orient \
  44. --enable-lite-exit \
  45. --enable-newlib-global-atexit \
  46. --enable-newlib-nano-formatted-io \
  47. --enable-newlib-io-c99-formats \
  48. --enable-newlib-nano-malloc \
  49. --enable-newlib-reent-small
  50. export riscv_newlib_configargs
  51. clean:
  52. rm -rf *.build *~ *.bak \#* .\#* *.deps *.stamp
  53. spotless: clean
  54. rm -rf gnu
  55. .PHONY: gnu.src
  56. gnu.src:
  57. if [ -f ../.gitmodules ] && \
  58. git submodule status --recursive | grep -q '^[+-]'; then \
  59. git submodule update --init --recursive ; \
  60. rm -rf gnu gnu.*.stamp ; \
  61. fi
  62. .PHONY: gnu
  63. gnu:
  64. $(MAKE) gnu.src
  65. $(MAKE) autotools
  66. $(MAKE) gnu.bin
  67. .PHONY: gnu.bin
  68. gnu.bin: gnu.riscv.build gnu.z80.build.stamp
  69. # At least binutils is really picky about which version of autoconf
  70. # and aclocal (automake) it uses, so build it explicitly
  71. autoconf-ver = 2.69
  72. automake-ver = 1.15.1
  73. # Don't require these tools for autotools
  74. # autoconf seems picky about the makeinfo version (and we don't need to
  75. # build an emacs .el), but binutils breaks trying to build without
  76. # makeinfo. Sigh.
  77. autotools-disable = EMACS=no MAKEINFO=no TEXI2ANY=no TEXI2DVI=no TEXI2PDF=no
  78. .PHONY: autotools
  79. autotools: gnu.autoconf.build.stamp gnu.automake.build.stamp
  80. gnu.automake.build.stamp: gnu.autoconf.build.stamp
  81. .PHONY: gnu.auto%.build
  82. gnu.auto%.build: gnusrc/auto%
  83. mkdir -p $@
  84. cd $@ && $(rsetup) $(autotools-disable) ../$</configure $(all_config)
  85. $(RMAKE) -C $@
  86. $(RMAKE) -C $@ install
  87. : >$@.stamp
  88. # Note: the riscv-gnu-toolchain repo has bugs when building in
  89. # parallel, so spoon feed it a sequence to avoid dependency problems.
  90. %.build.stamp:
  91. $(MAKE) $*.build
  92. .PHONY: gnu.riscv.build
  93. gnu.riscv.build: autotools
  94. $(rsetup) MAKE='$(MAKE)' ./riscvbuild.sh
  95. .PHONY: gnu.z80.build
  96. gnu.z80.build: autotools
  97. mkdir -p $@
  98. cd $@ && $(rsetup) ../$(binutils)/configure $(z80_config)
  99. $(RMAKE) -C $@
  100. $(RMAKE) -C $@ install
  101. : >$@.stamp