123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- MAKEFLAGS = -R -r
- prefix := $(CURDIR)/gnu
- bindir := $(prefix)/bin
- tooldir = gnusrc
- binutils = $(tooldir)/binutils
- all_config = --prefix=$(prefix)
- z80_config = $(all_config) --target=z80-none-elf
- all: gnu
- include ../riscv-opts.mk
- export riscv_target_flags
- multilibs= rv32imc-ilp32--zicsr;rv32im-ilp32--zicsr;rv32i-ilp32--zicsr;rv32imc_zbb-ilp32--zicsr
- riscv_tuple=riscv32-unknown-elf
- riscv_config = $(all_config) \
- --target=riscv32-unknown-elf \
- --enable-languages=c,c++ \
- --with-arch=rv32imc_zicsr --with-abi=ilp32 \
- --with-newlib \
- --with-sysroot=$(prefix)/$(riscv_tuple) \
- --disable-shared --disable-threads \
- --disable-libmudflap --disable-libssp \
- --disable-libquadmath --disable-libgomp --disable-nls \
- --disable-tm-clone-registry \
- --enable-multilib --with-multilib-generator=$(multilibs)
- export riscv_config
- riscv_binutils_configargs := \
- --disable-gold --disable-gprof --disable-sim
- export riscv_binutils_configargs
- pathify = PATH='$(bindir):$(PATH)'
- # -R -r fails, and one can't disable it, so strip all of MAKEFLAGS
- # except any job-related options. Sigh.
- gnu_makeflags = MAKEFLAGS=' $(filter -j% --job%,$(MAKEFLAGS))'
- rsetup = $(pathify) $(gnu_makeflags)
- RMAKE = $(rsetup) $(MAKE)
- riscv_newlib_configargs := \
- --disable-newlib-fseek-optimization \
- --disable-newlib-fvwrite-in-streamio \
- --disable-newlib-mb \
- --disable-newlib-multithread \
- --disable-newlib-reent-check-verify \
- --disable-newlib-register-fini \
- --disable-newlib-supplied-syscalls \
- --disable-newlib-unbuf-stream-opt \
- --disable-newlib-wide-orient \
- --enable-lite-exit \
- --enable-newlib-global-atexit \
- --enable-newlib-nano-formatted-io \
- --enable-newlib-io-c99-formats \
- --enable-newlib-nano-malloc \
- --enable-newlib-reent-small
- export riscv_newlib_configargs
- clean:
- rm -rf *.build *~ *.bak \#* .\#* *.deps *.stamp
- spotless: clean
- rm -rf gnu
- .PHONY: gnu.src
- gnu.src:
- if [ -f ../.gitmodules ] && \
- git submodule status --recursive | grep -q '^[+-]'; then \
- git submodule update --init --recursive ; \
- rm -rf gnu gnu.*.stamp ; \
- fi
- .PHONY: gnu
- gnu:
- $(MAKE) gnu.src
- $(MAKE) autotools
- $(MAKE) gnu.bin
- .PHONY: gnu.bin
- gnu.bin: gnu.riscv.build gnu.z80.build.stamp
- # At least binutils is really picky about which version of autoconf
- # and aclocal (automake) it uses, so build it explicitly
- autoconf-ver := 2.69
- automake-ver := 1.15.1
- autoconf = autoconf-$(autoconf-ver)
- automake = automake-$(automake-ver)
- # Don't require these tools for autotools
- autotools-disable = EMACS=no GIT=no MAKEINFO=:
- .PHONY: autotools
- autotools: gnu.autotools.build.stamp
- .PHONY: gnu.autotools.build
- gnu.autotools.build:
- mkdir -p $@
- cd $@ && tar xvvf ../gnusrc/$(autoconf).tar.xz
- cd $@/$(autoconf) && \
- $(rsetup) $(autotools-disable) ./configure $(all_config)
- $(RMAKE) -C $@/$(autoconf)
- $(RMAKE) -C $@/$(autoconf) install
- cd $@ && tar xvvf ../gnusrc/$(automake).tar.xz
- cd $@/$(automake) && \
- $(rsetup) $(autotools-disable) ./configure $(all_config)
- $(RMAKE) -C $@/$(automake)
- $(RMAKE) -C $@/$(automake) install
- : >$@.stamp
- # Note: the riscv-gnu-toolchain repo has bugs when building in
- # parallel, so spoon feed it a sequence to avoid dependency problems.
- %.build.stamp:
- $(MAKE) $*.build
- .PHONY: gnu.riscv.build
- gnu.riscv.build: autotools
- $(rsetup) MAKE='$(MAKE)' ./riscvbuild.sh
- .PHONY: gnu.z80.build
- gnu.z80.build: autotools
- mkdir -p $@
- cd $@ && $(rsetup) ../$(binutils)/configure $(z80_config)
- $(RMAKE) -C $@
- $(RMAKE) -C $@ install
- : >$@.stamp
|