2015-08-25 21:32:46 +02:00
|
|
|
|
|
|
|
OUTPUT = $(PWD)/output
|
2015-11-10 02:11:56 +01:00
|
|
|
SOURCES = sources
|
2015-08-25 21:32:46 +02:00
|
|
|
|
|
|
|
BINUTILS_VER = 2.25.1
|
|
|
|
GCC_VER = 5.2.0
|
2015-08-26 00:57:20 +02:00
|
|
|
MUSL_TAG = master
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2015-11-06 07:35:17 +01:00
|
|
|
GNU_SITE = http://ftp.gnu.org/pub/gnu
|
|
|
|
GCC_SITE = $(GNU_SITE)/gcc
|
|
|
|
BINUTILS_SITE = $(GNU_SITE)/binutils
|
|
|
|
|
2015-08-25 21:32:46 +02:00
|
|
|
COMMON_CONFIG = --disable-werror \
|
|
|
|
--target=$(TARGET) --prefix=$(OUTPUT) \
|
|
|
|
--with-sysroot=$(OUTPUT)/$(TARGET)
|
|
|
|
|
|
|
|
BINUTILS_CONFIG = $(COMMON_CONFIG)
|
2015-09-13 10:29:07 +02:00
|
|
|
GCC_CONFIG = $(COMMON_CONFIG) --enable-tls \
|
2015-11-10 01:02:34 +01:00
|
|
|
--disable-libmudflap --disable-libsanitizer
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2015-11-06 01:46:00 +01:00
|
|
|
GCC0_VARS = CFLAGS="-O0 -g0" CXXFLAGS="-O0 -g0"
|
2015-08-25 21:32:46 +02:00
|
|
|
GCC0_CONFIG = $(GCC_CONFIG) \
|
2015-08-25 22:25:43 +02:00
|
|
|
--with-newlib --disable-libssp --disable-threads \
|
2015-08-25 21:32:46 +02:00
|
|
|
--disable-shared --disable-libgomp --disable-libatomic \
|
|
|
|
--disable-libquadmath --disable-decimal-float --disable-nls \
|
2015-11-06 01:46:00 +01:00
|
|
|
--enable-languages=c
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2015-08-27 08:42:32 +02:00
|
|
|
GCC0_BDIR = $(PWD)/gcc-$(GCC_VER)/build0/gcc
|
|
|
|
GCC0_CC = $(GCC0_BDIR)/xgcc -B $(GCC0_BDIR)
|
|
|
|
|
|
|
|
MUSL_CONFIG = CC="$(GCC0_CC)" --prefix=
|
2015-08-25 21:32:46 +02:00
|
|
|
|
|
|
|
-include config.mak
|
|
|
|
|
2015-11-10 01:18:50 +01:00
|
|
|
ifeq ($(TARGET),)
|
|
|
|
$(error TARGET must be set via config.mak or command line)
|
|
|
|
endif
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
all: install_binutils install_musl install_gcc
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2015-08-25 23:28:55 +02:00
|
|
|
clean:
|
|
|
|
rm -rf gcc-$(GCC_VER) binutils-$(BINUTILS_VER) musl
|
|
|
|
|
|
|
|
distclean: clean
|
2015-11-10 02:11:56 +01:00
|
|
|
rm -rf sources
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
.PHONY: extract_binutils extract_gcc clone_musl
|
|
|
|
.PHONY: configure_binutils configure_gcc0 configure_gcc configure_musl
|
|
|
|
.PHONY: build_binutils build_gcc0 build_gcc build_musl
|
|
|
|
.PHONY: install_binutils install_gcc install_musl
|
|
|
|
|
|
|
|
extract_binutils: binutils-$(BINUTILS_VER)/.mcm_extracted
|
|
|
|
extract_gcc: gcc-$(GCC_VER)/.mcm_extracted
|
|
|
|
clone_musl: musl/.mcm_cloned
|
|
|
|
|
|
|
|
configure_binutils: binutils-$(BINUTILS_VER)/.mcm_configured
|
|
|
|
configure_gcc0: gcc-$(GCC_VER)/build0/.mcm_configured
|
|
|
|
configure_gcc: gcc-$(GCC_VER)/build/.mcm_configured
|
|
|
|
configure_musl: musl/.mcm_configured
|
|
|
|
|
|
|
|
build_binutils: binutils-$(BINUTILS_VER)/.mcm_built
|
|
|
|
build_gcc0: gcc-$(GCC_VER)/build0/.mcm_built
|
|
|
|
build_gcc: gcc-$(GCC_VER)/build/.mcm_built
|
|
|
|
build_musl: musl/.mcm_built
|
|
|
|
|
|
|
|
install_binutils: binutils-$(BINUTILS_VER)/.mcm_installed
|
|
|
|
install_gcc: gcc-$(GCC_VER)/build/.mcm_installed
|
|
|
|
install_musl: musl/.mcm_installed
|
|
|
|
|
|
|
|
|
2015-11-10 02:11:56 +01:00
|
|
|
$(SOURCES):
|
|
|
|
mkdir -p $@
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2015-11-10 02:11:56 +01:00
|
|
|
$(SOURCES)/config.sub: | $(SOURCES)
|
2015-08-25 21:32:46 +02:00
|
|
|
wget -O $@ 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'
|
|
|
|
|
2015-11-10 02:11:56 +01:00
|
|
|
$(SOURCES)/binutils-%: | $(SOURCES)
|
2015-11-06 07:35:17 +01:00
|
|
|
wget -c -O $@.part $(BINUTILS_SITE)/$(notdir $@)
|
2015-08-25 21:32:46 +02:00
|
|
|
mv $@.part $@
|
|
|
|
|
2015-11-10 02:11:56 +01:00
|
|
|
$(SOURCES)/gcc-%: | $(SOURCES)
|
2015-11-06 07:35:17 +01:00
|
|
|
wget -c -O $@.part $(GCC_SITE)/$(basename $(basename $(notdir $@)))/$(notdir $@)
|
2015-08-25 21:32:46 +02:00
|
|
|
mv $@.part $@
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-10 02:11:56 +01:00
|
|
|
binutils-$(BINUTILS_VER)/.mcm_extracted: $(SOURCES)/binutils-$(BINUTILS_VER).tar.bz2 $(SOURCES)/config.sub
|
2015-08-25 21:32:46 +02:00
|
|
|
tar jxvf $<
|
|
|
|
cat patches/binutils-$(BINUTILS_VER)/* | ( cd binutils-$(BINUTILS_VER) && patch -p1 )
|
2015-11-10 02:11:56 +01:00
|
|
|
cp $(SOURCES)/config.sub binutils-$(BINUTILS_VER)
|
2015-08-25 21:32:46 +02:00
|
|
|
touch $@
|
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
binutils-$(BINUTILS_VER)/.mcm_configured: binutils-$(BINUTILS_VER)/.mcm_extracted
|
2015-08-25 21:32:46 +02:00
|
|
|
test -e binutils-$(BINUTILS_VER)/config.status || ( cd binutils-$(BINUTILS_VER) && ./configure $(BINUTILS_CONFIG) )
|
|
|
|
touch $@
|
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
binutils-$(BINUTILS_VER)/.mcm_built: binutils-$(BINUTILS_VER)/.mcm_configured
|
2015-08-25 21:32:46 +02:00
|
|
|
cd binutils-$(BINUTILS_VER) && $(MAKE)
|
|
|
|
touch $@
|
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
binutils-$(BINUTILS_VER)/.mcm_installed: binutils-$(BINUTILS_VER)/.mcm_built
|
2015-08-25 21:32:46 +02:00
|
|
|
cd binutils-$(BINUTILS_VER) && $(MAKE) install
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-10 02:11:56 +01:00
|
|
|
gcc-$(GCC_VER)/.mcm_extracted: $(SOURCES)/gcc-$(GCC_VER).tar.bz2 $(SOURCES)/config.sub
|
2015-08-25 21:32:46 +02:00
|
|
|
tar jxvf $<
|
|
|
|
cat patches/gcc-$(GCC_VER)/* | ( cd gcc-$(GCC_VER) && patch -p1 )
|
2015-11-10 02:11:56 +01:00
|
|
|
cp $(SOURCES)/config.sub gcc-$(GCC_VER)
|
2015-08-25 21:32:46 +02:00
|
|
|
touch $@
|
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
gcc-$(GCC_VER)/build0/.mcm_configured: gcc-$(GCC_VER)/.mcm_extracted | binutils-$(BINUTILS_VER)/.mcm_installed
|
2015-08-25 21:32:46 +02:00
|
|
|
mkdir -p gcc-$(GCC_VER)/build0
|
2015-11-06 01:46:00 +01:00
|
|
|
test -e gcc-$(GCC_VER)/build0/config.status || ( cd gcc-$(GCC_VER)/build0 && $(GCC0_VARS) ../configure $(GCC0_CONFIG) )
|
2015-08-25 21:32:46 +02:00
|
|
|
touch $@
|
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
gcc-$(GCC_VER)/build0/.mcm_built: gcc-$(GCC_VER)/build0/.mcm_configured
|
2015-08-25 21:32:46 +02:00
|
|
|
cd gcc-$(GCC_VER)/build0 && $(MAKE)
|
|
|
|
touch $@
|
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
gcc-$(GCC_VER)/build/.mcm_configured: gcc-$(GCC_VER)/.mcm_extracted | binutils-$(BINUTILS_VER)/.mcm_installed musl/.mcm_installed
|
2015-08-25 21:32:46 +02:00
|
|
|
mkdir -p gcc-$(GCC_VER)/build
|
|
|
|
test -e gcc-$(GCC_VER)/build/config.status || ( cd gcc-$(GCC_VER)/build && ../configure $(GCC_CONFIG) )
|
|
|
|
touch $@
|
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
gcc-$(GCC_VER)/build/.mcm_built: gcc-$(GCC_VER)/build/.mcm_configured
|
2015-08-25 21:32:46 +02:00
|
|
|
cd gcc-$(GCC_VER)/build && $(MAKE)
|
|
|
|
touch $@
|
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
gcc-$(GCC_VER)/build/.mcm_installed: gcc-$(GCC_VER)/build/.mcm_built
|
2015-08-25 21:32:46 +02:00
|
|
|
cd gcc-$(GCC_VER)/build && $(MAKE) install
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
musl/.mcm_cloned:
|
2015-08-26 00:57:20 +02:00
|
|
|
test -d musl || git clone -b $(MUSL_TAG) git://git.musl-libc.org/musl musl
|
2015-08-25 21:32:46 +02:00
|
|
|
touch $@
|
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
musl/.mcm_configured: musl/.mcm_cloned gcc-$(GCC_VER)/build0/.mcm_built
|
2015-08-25 21:32:46 +02:00
|
|
|
cd musl && ./configure $(MUSL_CONFIG)
|
|
|
|
touch $@
|
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
musl/.mcm_built: musl/.mcm_configured
|
2016-04-30 00:02:15 +02:00
|
|
|
cd musl && $(MAKE) AR=$(OUTPUT)/bin/$(TARGET)-ar RANLIB=$(OUTPUT)/bin/$(TARGET)-ranlib
|
2015-08-25 21:32:46 +02:00
|
|
|
touch $@
|
|
|
|
|
2015-11-10 00:45:56 +01:00
|
|
|
musl/.mcm_installed: musl/.mcm_built
|
2015-08-25 21:32:46 +02:00
|
|
|
cd musl && $(MAKE) install DESTDIR=$(OUTPUT)/$(TARGET)
|
2015-08-25 22:25:43 +02:00
|
|
|
ln -sfn . $(OUTPUT)/$(TARGET)/usr
|
2015-08-25 21:32:46 +02:00
|
|
|
touch $@
|