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
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
CONFIG_SUB_REV = 3d5db9ebe860
|
2015-08-25 21:32:46 +02:00
|
|
|
BINUTILS_VER = 2.25.1
|
2016-05-17 01:17:08 +02:00
|
|
|
GCC_VER = 5.3.0
|
2016-05-01 07:36:28 +02:00
|
|
|
MUSL_VER = 1.1.14
|
|
|
|
GMP_VER = 6.1.0
|
|
|
|
MPC_VER = 1.0.3
|
|
|
|
MPFR_VER = 3.1.4
|
2016-05-14 06:14:52 +02:00
|
|
|
LINUX_VER = 4.4.10
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
GNU_SITE = https://ftp.gnu.org/pub/gnu
|
2015-11-06 07:35:17 +01:00
|
|
|
GCC_SITE = $(GNU_SITE)/gcc
|
|
|
|
BINUTILS_SITE = $(GNU_SITE)/binutils
|
2016-05-01 07:36:28 +02:00
|
|
|
GMP_SITE = $(GNU_SITE)/gmp
|
|
|
|
MPC_SITE = $(GNU_SITE)/mpc
|
|
|
|
MPFR_SITE = $(GNU_SITE)/mpfr
|
2015-11-06 07:35:17 +01:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
MUSL_SITE = https://www.musl-libc.org/releases
|
|
|
|
MUSL_REPO = git://git.musl-libc.org/musl
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-14 06:14:52 +02:00
|
|
|
LINUX_SITE = https://cdn.kernel.org/pub/linux/kernel
|
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
BUILD_DIR = build-$(TARGET)
|
2015-08-25 21:32:46 +02:00
|
|
|
|
|
|
|
-include config.mak
|
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
SRC_DIRS = gcc-$(GCC_VER) binutils-$(BINUTILS_VER) musl-$(MUSL_VER) \
|
|
|
|
$(if $(GMP_VER),gmp-$(GMP_VER)) \
|
|
|
|
$(if $(MPC_VER),mpc-$(MPC_VER)) \
|
2016-05-14 06:14:52 +02:00
|
|
|
$(if $(MPFR_VER),mpfr-$(MPFR_VER)) \
|
|
|
|
$(if $(LINUX_VER),linux-$(LINUX_VER))
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
all:
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2015-08-25 23:28:55 +02:00
|
|
|
clean:
|
2016-05-17 02:07:37 +02:00
|
|
|
rm -rf gcc-* binutils-* musl-* gmp-* mpc-* mpfr-* build-* linux-*
|
2015-08-25 23:28:55 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
# Rules for downloading and verifying sources. Treat an external SOURCES path as
|
|
|
|
# immutable and do not try to download anything into it.
|
2015-11-10 00:45:56 +01:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
ifeq ($(SOURCES),sources)
|
2015-11-10 00:45:56 +01:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/gmp*)): SITE = $(GMP_SITE)
|
|
|
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/mpc*)): SITE = $(MPC_SITE)
|
|
|
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/mpfr*)): SITE = $(MPFR_SITE)
|
|
|
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/binutils*)): SITE = $(BINUTILS_SITE)
|
|
|
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/gcc*)): SITE = $(GCC_SITE)/$(basename $(basename $(notdir $@)))
|
|
|
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/musl*)): SITE = $(MUSL_SITE)
|
2016-05-17 02:05:13 +02:00
|
|
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/linux-4*)): SITE = $(LINUX_SITE)/v4.x
|
|
|
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/linux-3*)): SITE = $(LINUX_SITE)/v3.x
|
|
|
|
$(patsubst hashes/%.sha1,$(SOURCES)/%,$(wildcard hashes/linux-2.6*)): SITE = $(LINUX_SITE)/v2.6
|
2015-11-10 00:45:56 +01:00
|
|
|
|
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)
|
2016-05-01 07:36:28 +02:00
|
|
|
mkdir -p $@.tmp
|
|
|
|
cd $@.tmp && wget -c -O $(notdir $@) "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=$(CONFIG_SUB_REV)"
|
|
|
|
cd $@.tmp && touch $(notdir $@)
|
|
|
|
cd $@.tmp && sha1sum -c $(PWD)/hashes/$(notdir $@).$(CONFIG_SUB_REV).sha1
|
|
|
|
mv $@.tmp/$(notdir $@) $@
|
|
|
|
rm -rf $@.tmp
|
|
|
|
|
|
|
|
$(SOURCES)/%: hashes/%.sha1 | $(SOURCES)
|
|
|
|
mkdir -p $@.tmp
|
|
|
|
cd $@.tmp && wget -c -O $(notdir $@) $(SITE)/$(notdir $@)
|
|
|
|
cd $@.tmp && touch $(notdir $@)
|
|
|
|
cd $@.tmp && sha1sum -c $(PWD)/hashes/$(notdir $@).sha1
|
|
|
|
mv $@.tmp/$(notdir $@) $@
|
|
|
|
rm -rf $@.tmp
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
endif
|
2015-08-25 21:32:46 +02:00
|
|
|
|
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
# Rules for extracting and patching sources, or checking them out from git.
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
musl-git-%:
|
|
|
|
rm -rf $@.tmp
|
|
|
|
git clone -b $(patsubst musl-git-%,%,$@) $(MUSL_REPO) $@.tmp
|
|
|
|
cd $@.tmp && git fsck
|
|
|
|
mv $@.tmp $@
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
%: $(SOURCES)/%.tar.gz | $(SOURCES)/config.sub
|
|
|
|
rm -rf $@.tmp
|
|
|
|
mkdir $@.tmp
|
|
|
|
( cd $@.tmp && tar zxvf - ) < $<
|
|
|
|
test ! -d patches/$@ || cat patches/$@/* | ( cd $@.tmp/$@ && patch -p1 )
|
|
|
|
test ! -f $@.tmp/$@/config.sub || cp -f $(SOURCES)/config.sub $@.tmp/$@
|
|
|
|
rm -rf $@
|
|
|
|
touch $@.tmp/$@
|
|
|
|
mv $@.tmp/$@ $@
|
|
|
|
rm -rf $@.tmp
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
%: $(SOURCES)/%.tar.bz2 | $(SOURCES)/config.sub
|
|
|
|
rm -rf $@.tmp
|
|
|
|
mkdir $@.tmp
|
|
|
|
( cd $@.tmp && tar jxvf - ) < $<
|
|
|
|
test ! -d patches/$@ || cat patches/$@/* | ( cd $@.tmp/$@ && patch -p1 )
|
|
|
|
test ! -f $@.tmp/$@/config.sub || cp -f $(SOURCES)/config.sub $@.tmp/$@
|
|
|
|
rm -rf $@
|
|
|
|
touch $@.tmp/$@
|
|
|
|
mv $@.tmp/$@ $@
|
|
|
|
rm -rf $@.tmp
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-14 06:14:52 +02:00
|
|
|
%: $(SOURCES)/%.tar.xz | $(SOURCES)/config.sub
|
|
|
|
rm -rf $@.tmp
|
|
|
|
mkdir $@.tmp
|
|
|
|
( cd $@.tmp && tar Jxvf - ) < $<
|
|
|
|
test ! -d patches/$@ || cat patches/$@/* | ( cd $@.tmp/$@ && patch -p1 )
|
|
|
|
test ! -f $@.tmp/$@/config.sub || cp -f $(SOURCES)/config.sub $@.tmp/$@
|
|
|
|
rm -rf $@
|
|
|
|
touch $@.tmp/$@
|
|
|
|
mv $@.tmp/$@ $@
|
|
|
|
rm -rf $@.tmp
|
|
|
|
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
# Rules for building.
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
ifeq ($(TARGET),)
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
all:
|
|
|
|
@echo TARGET must be set via config.mak or command line.
|
|
|
|
@exit 1
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
else
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
$(BUILD_DIR):
|
|
|
|
mkdir -p $@
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
$(BUILD_DIR)/Makefile: | $(BUILD_DIR)
|
|
|
|
ln -sf ../litecross/Makefile $@
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
$(BUILD_DIR)/config.mak: | $(BUILD_DIR)
|
|
|
|
printf >$@ -- '%s\n' \
|
|
|
|
"MUSL_SRCDIR = ../musl-$(MUSL_VER)" \
|
|
|
|
"GCC_SRCDIR = ../gcc-$(GCC_VER)" \
|
|
|
|
"BINUTILS_SRCDIR = ../binutils-$(BINUTILS_VER)" \
|
|
|
|
$(if $(GMP_VER),"GMP_SRCDIR = ../gmp-$(GMP_VER)") \
|
|
|
|
$(if $(MPC_VER),"MPC_SRCDIR = ../mpc-$(MPC_VER)") \
|
|
|
|
$(if $(MPFR_VER),"MPFR_SRCDIR = ../mpfr-$(MPFR_VER)") \
|
2016-05-14 06:14:52 +02:00
|
|
|
$(if $(LINUX_VER),"LINUX_SRCDIR = ../linux-$(LINUX_VER)") \
|
2016-05-01 07:36:28 +02:00
|
|
|
"-include ../config.mak"
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
all: | $(SRC_DIRS) $(BUILD_DIR) $(BUILD_DIR)/Makefile $(BUILD_DIR)/config.mak
|
|
|
|
cd $(BUILD_DIR) && $(MAKE) $@
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
install: | $(SRC_DIRS) $(BUILD_DIR) $(BUILD_DIR)/Makefile $(BUILD_DIR)/config.mak
|
|
|
|
cd $(BUILD_DIR) && $(MAKE) OUTPUT=$(OUTPUT) $@
|
2015-08-25 21:32:46 +02:00
|
|
|
|
2016-05-01 07:36:28 +02:00
|
|
|
endif
|