Last active
January 4, 2016 22:49
-
-
Save rday/87248e53fa45fd74addd to your computer and use it in GitHub Desktop.
Makefile for the rump kernel python package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# XXX | |
# When building the latest version of Python (3.5.1) some binaries are built in order | |
# to build other binaries. For example, we need the Parser/pgen binary to generate a | |
# parser from the Grammar file. This requires us to build some *host* binaries before | |
# we apply patches and build the target (-rumprun) version of Python. | |
# | |
# The problem is that the 'hostbuild' task looks like it could be done better. I'm | |
# looking for ideas to improve that piece. | |
include ../Makefile.inc | |
UPSTREAM=https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz | |
TARBALL=$(notdir $(UPSTREAM)) | |
ARCH=$(shell $(RUMPRUN_CC) -dumpmachine) | |
all: $(RUMPRUN_PKGS_DIR)/lib/libsqlite.a images | |
.NOTPARALLEL: $(RUMPRUN_PKGS_DIR)/lib/libsqlite.a | |
$(RUMPRUN_PKGS_DIR)/lib/libsqlite.a: | |
$(MAKE) -C ../sqlite | |
build/python: build/Makefile | |
$(MAKE) -C build | |
$(MAKE) -C build install | |
PYTHON_CONF_ENV += \ | |
LDFLAGS="-static -static-libgcc" \ | |
CPPFLAGS="$(CPPFLAGS) -static" \ | |
CFLAGS="$(CFLAGS) -static" \ | |
CC=$(RUMPRUN_CC) \ | |
CONFIG_SITE=config.site | |
PYTHON_CONF_OPTS += \ | |
--prefix=$(shell pwd)/build/pythondist \ | |
--disable-shared \ | |
--host=$(RUMPRUN_TOOLCHAIN_TUPLE) \ | |
--build $(ARCH) \ | |
--enable-ipv6 \ | |
--without-ensurepip | |
# XXX We have to build python for the host system because we will need | |
# to use the python, Parser/pgen, and freeze_importlib binaries to build | |
# to build the the target. | |
# This step happens without any rumpkernel patches | |
hostbuild: | dl/$(TARBALL) | |
# XXX Make the build directory and untar Python | |
mkdir -p build | |
(cd build && tar -x --strip-components 1 -f ../dl/$(TARBALL)) | |
# XXX Build the relevant host pieces and rename them | |
(cd build; ./configure; make python Parser/pgen) | |
mv build/python build/hostpython | |
mv build/Parser/pgen build/Parser/hostpgen | |
mv build/Programs/_freeze_importlib build/Programs/host_freeze_importlib | |
# XXX Clean up. After this task is finished, we apply patches | |
# and then build the cross compiled target python | |
(cd build; make distclean) | |
build/Makefile: build/stamp_patch | |
(cd build; $(PYTHON_CONF_ENV) ./configure $(PYTHON_CONF_OPTS)) | |
build/stamp_patch: build/configure patches/* | |
cp config.site build/ | |
(cd build && ../../scripts/apply-patches.sh ./ ../patches/*) | |
touch $@ | |
dl/$(TARBALL): | |
mkdir -p dl | |
../scripts/fetch.sh ${UPSTREAM} dl/$(TARBALL) | |
build/configure: hostbuild | |
.PHONY: images | |
images: images/stubetc.iso | |
images/stubetc.iso: images/python.iso ../stubetc/etc/* | |
mkdir -p images | |
genisoimage -l -r -o images/stubetc.iso ../stubetc/etc | |
images/python.iso: build/python | |
mkdir -p images | |
genisoimage -l -r -o images/python.iso build/pythondist/lib/python3.5 | |
.PHONY: clean | |
clean: | |
-$(MAKE) -C build clean | |
rm -f bin/* | |
rm -f images/stubetc.iso images/python.iso | |
rm -f examples/hw.c examples/hw.bin examples/hw | |
.PHONY: distclean | |
distclean: clean | |
rm -rf build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment