pyodide/cpython/Makefile

85 lines
2.6 KiB
Makefile
Raw Normal View History

2018-03-30 17:08:06 +00:00
PYODIDE_ROOT=$(abspath ..)
include ../Makefile.envs
2018-02-27 22:57:22 +00:00
PYVERSION=3.6.4
PYMINOR=$(basename $(PYVERSION))
ROOT=$(abspath .)
HOSTINSTALL=$(ROOT)/build/$(PYVERSION)/host
HOSTBUILD=$(HOSTINSTALL)/Python-$(PYVERSION)
HOSTPYTHON=$(HOSTINSTALL)/bin/python3$(EXE)
HOSTPGEN=$(HOSTINSTALL)/bin/pgen$(EXE)
BUILD=$(ROOT)/build/$(PYVERSION)/Python-$(PYVERSION)
INSTALL=$(ROOT)/installs/python-$(PYVERSION)
TARBALL=$(ROOT)/downloads/Python-$(PYVERSION).tgz
URL=https://www.python.org/ftp/python/$(PYVERSION)/Python-$(PYVERSION).tgz
LIB=libpython$(PYMINOR).a
2018-03-20 22:58:59 +00:00
all: $(INSTALL)/lib/$(LIB)
2018-02-27 22:57:22 +00:00
2018-03-20 22:58:59 +00:00
$(INSTALL)/lib/$(LIB): $(BUILD)/$(LIB)
2018-02-27 22:57:22 +00:00
( \
cd $(BUILD); \
sed -i -e 's/libinstall:.*/libinstall:/' Makefile; \
2018-03-20 22:58:59 +00:00
touch $(BUILD)/$(LIB) ; \
2018-02-27 22:57:22 +00:00
emmake make HOSTPYTHON=$(HOSTPYTHON) PYTHON_FOR_BUILD=$(HOSTPYTHON) CROSS_COMPILE=yes inclinstall libinstall $(LIB) && \
cp $(LIB) $(INSTALL)/lib/ && \
2018-03-07 16:04:15 +00:00
cp $(HOSTINSTALL)/lib/python$(PYMINOR)/`$(HOSTPYTHON) -c "import sysconfig; print(sysconfig._get_sysconfigdata_name())"`.py $(INSTALL)/lib/python$(PYMINOR)/_sysconfigdata__emscripten_.py \
2018-02-27 22:57:22 +00:00
)
clean:
-rm -fr $(HOSTINSTALL)
-rm -fr $(BUILD)
2018-02-28 20:39:16 +00:00
-rm -fr $(INSTALL)
2018-02-27 22:57:22 +00:00
$(TARBALL):
[ -d $(ROOT)/downloads ] || mkdir $(ROOT)/downloads
wget -q -O $@ $(URL)
md5sum --quiet --check checksums || (rm $@; false)
$(HOSTPYTHON) $(HOSTPGEN): $(TARBALL)
mkdir -p $(HOSTINSTALL)
[ -d $(HOSTBUILD) ] || tar -C $(HOSTINSTALL) -xf $(TARBALL)
( \
cd $(HOSTBUILD); \
./configure --prefix=$(HOSTINSTALL) || cat config.log && \
make regen-grammar && \
make install && \
cp Parser/pgen$(EXE) $(HOSTINSTALL)/bin/ && \
make distclean \
)
$(BUILD)/.patched: $(TARBALL)
[ -d $(BUILD) ] || (mkdir -p $(dir $(BUILD)); tar -C $(dir $(BUILD)) -xf $(TARBALL))
cat patches/*.patch | (cd $(BUILD) ; patch -p1)
touch $@
$(BUILD)/Makefile: $(BUILD)/.patched
cp config.site $(BUILD)/
( \
cd $(BUILD); \
CONFIG_SITE=./config.site READELF=true emconfigure ./configure --without-threads --without-pymalloc --disable-shared --disable-ipv6 --without-gcc --host=asmjs-unknown-emscripten --build=$(shell $(BUILD)/config.guess) --prefix=$(INSTALL) ; \
)
$(BUILD)/$(LIB): $(BUILD)/Makefile $(HOSTPYTHON) $(HOSTPGEN) Setup.local
cp Setup.local $(BUILD)/Modules/
( \
cd $(BUILD)/Modules/zlib; \
emconfigure ./configure --static \
)
( \
2018-04-09 14:39:52 +00:00
cp build/$(PYVERSION)/host/lib/python$(PYMINOR)/`$(HOSTPYTHON) -c "import sysconfig; print(sysconfig._get_sysconfigdata_name())"`.py build/$(PYVERSION)/Python-$(PYVERSION)/Lib/_sysconfigdata__emscripten_.py; \
2018-02-27 22:57:22 +00:00
cd $(BUILD); \
emmake make HOSTPYTHON=$(HOSTPYTHON) HOSTPGEN=$(HOSTPGEN) CROSS_COMPILE=yes $(LIB) \
)
2018-03-20 22:58:59 +00:00
touch $(BUILD)/$(LIB)