2018-03-30 17:08:06 +00:00
|
|
|
PYODIDE_ROOT=$(abspath ..)
|
|
|
|
include ../Makefile.envs
|
|
|
|
|
2018-02-27 22:57:22 +00:00
|
|
|
ROOT=$(abspath .)
|
|
|
|
|
2021-03-26 14:37:59 +00:00
|
|
|
PYTHON_CFLAGS=$(CFLAGS_BASE)
|
|
|
|
|
2020-12-07 23:19:16 +00:00
|
|
|
BUILD=$(ROOT)/build/Python-$(PYVERSION)
|
2018-02-27 22:57:22 +00:00
|
|
|
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
|
2021-01-05 13:14:55 +00:00
|
|
|
SYSCONFIG_NAME=_sysconfigdata__emscripten_
|
2018-02-27 22:57:22 +00:00
|
|
|
|
2018-07-18 13:26:18 +00:00
|
|
|
ZLIBVERSION = 1.2.11
|
|
|
|
ZLIBTARBALL=$(ROOT)/downloads/zlib-$(ZLIBVERSION).tar.gz
|
|
|
|
ZLIBBUILD=$(ROOT)/build/zlib-$(ZLIBVERSION)
|
|
|
|
ZLIBURL=https://zlib.net/zlib-1.2.11.tar.gz
|
|
|
|
|
2019-03-26 12:44:21 +00:00
|
|
|
SQLITETARBALL=$(ROOT)/downloads/sqlite-autoconf-3270200.tar.gz
|
|
|
|
SQLITEBUILD=$(ROOT)/build/sqlite-autoconf-3270200
|
|
|
|
SQLITEURL=https://www.sqlite.org/2019/sqlite-autoconf-3270200.tar.gz
|
|
|
|
|
2019-08-22 11:43:18 +00:00
|
|
|
BZIP2TARBALL=$(ROOT)/downloads/bzip2-1.0.2.tar.gz
|
|
|
|
BZIP2BUILD=$(ROOT)/build/bzip2-1.0.2
|
2021-04-01 04:04:58 +00:00
|
|
|
BZIP2URL=https://sourceware.org/pub/bzip2/bzip2-1.0.2.tar.gz
|
2019-08-22 11:43:18 +00:00
|
|
|
|
2018-07-18 13:26:18 +00:00
|
|
|
|
2018-03-20 22:58:59 +00:00
|
|
|
all: $(INSTALL)/lib/$(LIB)
|
2018-02-27 22:57:22 +00:00
|
|
|
|
|
|
|
|
2021-01-10 17:19:34 +00:00
|
|
|
$(INSTALL)/lib/$(LIB): $(BUILD)/$(LIB) remove_modules.txt
|
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) ; \
|
2020-12-07 23:19:16 +00:00
|
|
|
emmake make PYTHON_FOR_BUILD=$(HOSTPYTHON) CROSS_COMPILE=yes inclinstall libinstall $(LIB) -j $${PYODIDE_JOBS:-3} && \
|
2021-01-05 13:14:55 +00:00
|
|
|
cp $(LIB) $(INSTALL)/lib/ \
|
2018-02-27 22:57:22 +00:00
|
|
|
)
|
2021-01-05 13:14:55 +00:00
|
|
|
# Generate sysconfigdata. It outputs into a subfolder of build/, and
|
|
|
|
# the subfolder is written to pybuilddir.txt.
|
|
|
|
_PYTHON_SYSCONFIGDATA_NAME=$(SYSCONFIG_NAME) _PYTHON_PROJECT_BASE=$(BUILD) python -m sysconfig --generate-posix-vars
|
|
|
|
mv `cat pybuilddir.txt`/$(SYSCONFIG_NAME).py $(INSTALL)/lib/python$(PYMINOR)/
|
|
|
|
rmdir `cat pybuilddir.txt`
|
|
|
|
rm pybuilddir.txt
|
2021-01-10 17:19:34 +00:00
|
|
|
cd $(INSTALL)/lib/python$(PYMINOR)/ && rm -rf `cat $(ROOT)/remove_modules.txt`
|
2018-02-27 22:57:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
-rm -fr $(BUILD)
|
2018-02-28 20:39:16 +00:00
|
|
|
-rm -fr $(INSTALL)
|
2018-02-27 22:57:22 +00:00
|
|
|
|
2018-05-16 17:06:44 +00:00
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
2018-07-18 13:26:18 +00:00
|
|
|
$(ZLIBTARBALL):
|
|
|
|
[ -d $(ROOT)/downloads ] || mkdir $(ROOT)/downloads
|
|
|
|
wget -q -O $@ $(ZLIBURL)
|
|
|
|
|
|
|
|
|
2019-03-26 12:44:21 +00:00
|
|
|
$(SQLITETARBALL):
|
|
|
|
[ -d $(ROOT)/downloads ] || mkdir $(ROOT)/downloads
|
|
|
|
wget -q -O $@ $(SQLITEURL)
|
|
|
|
|
|
|
|
|
2019-08-22 11:43:18 +00:00
|
|
|
$(BZIP2TARBALL):
|
|
|
|
[ -d $(ROOT)/downloads ] || mkdir $(ROOT)/downloads
|
|
|
|
wget -q -O $@ $(BZIP2URL)
|
|
|
|
|
|
|
|
|
2018-02-27 22:57:22 +00:00
|
|
|
|
|
|
|
$(BUILD)/.patched: $(TARBALL)
|
|
|
|
[ -d $(BUILD) ] || (mkdir -p $(dir $(BUILD)); tar -C $(dir $(BUILD)) -xf $(TARBALL))
|
|
|
|
cat patches/*.patch | (cd $(BUILD) ; patch -p1)
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
|
2020-12-12 11:33:33 +00:00
|
|
|
$(ZLIBBUILD)/.configured: $(ZLIBTARBALL)
|
2018-07-18 13:26:18 +00:00
|
|
|
[ -d $(ROOT)/build ] || (mkdir $(ROOT)/build)
|
|
|
|
tar -C $(ROOT)/build/ -xf $(ROOT)/downloads/zlib-1.2.11.tar.gz
|
2020-12-12 11:33:33 +00:00
|
|
|
cd $(ZLIBBUILD); emconfigure ./configure
|
2018-07-18 13:26:18 +00:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
|
2019-03-26 12:44:21 +00:00
|
|
|
$(SQLITEBUILD)/libsqlite3.la: $(SQLITETARBALL)
|
|
|
|
[ -d $(ROOT)/build ] || (mkdir $(ROOT)/build)
|
|
|
|
tar -C $(ROOT)/build/ -xf $(SQLITETARBALL)
|
2021-01-01 09:45:44 +00:00
|
|
|
# sqlite fails to detect that popen is not available. We have to set it
|
|
|
|
# as a CPPFLAG
|
2019-03-26 12:44:21 +00:00
|
|
|
( \
|
|
|
|
cd $(SQLITEBUILD); \
|
2021-03-26 14:37:59 +00:00
|
|
|
emconfigure ./configure CFLAGS="$(PYTHON_CFLAGS)" CPPFLAGS="-DSQLITE_OMIT_POPEN"; \
|
2020-06-28 13:51:46 +00:00
|
|
|
emmake make -j $${PYODIDE_JOBS:-3}; \
|
2019-03-26 12:44:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-08-22 11:43:18 +00:00
|
|
|
$(BZIP2BUILD)/libbz2.a: $(BZIP2TARBALL)
|
|
|
|
[ -d $(ROOT)/build ] || (mkdir $(ROOT)/build)
|
|
|
|
tar -C $(ROOT)/build/ -xf $(BZIP2TARBALL)
|
|
|
|
( \
|
|
|
|
cd $(BZIP2BUILD); \
|
2021-03-26 14:37:59 +00:00
|
|
|
emmake make -j $${PYODIDE_JOBS:-3} CC=emcc CFLAGS="$(PYTHON_CFLAGS) -D_FILE_OFFSET_BITS=64" AR=emar RANLIB=emranlib libbz2.a; \
|
2019-08-22 11:43:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-12-12 11:33:33 +00:00
|
|
|
$(BUILD)/Makefile: $(BUILD)/.patched $(ZLIBBUILD)/.configured $(SQLITEBUILD)/libsqlite3.la $(BZIP2BUILD)/libbz2.a
|
2018-02-27 22:57:22 +00:00
|
|
|
cp config.site $(BUILD)/
|
|
|
|
( \
|
|
|
|
cd $(BUILD); \
|
2021-02-06 07:58:12 +00:00
|
|
|
CONFIG_SITE=./config.site READELF=true emconfigure \
|
2019-03-26 12:44:21 +00:00
|
|
|
./configure \
|
2021-03-26 14:37:59 +00:00
|
|
|
CFLAGS="${PYTHON_CFLAGS}" \
|
2020-12-10 19:38:47 +00:00
|
|
|
CPPFLAGS="-I$(SQLITEBUILD) -I$(BZIP2BUILD) -I$(ZLIBBUILD)" \
|
2019-08-22 11:43:18 +00:00
|
|
|
--without-pymalloc \
|
|
|
|
--disable-shared \
|
|
|
|
--disable-ipv6 \
|
|
|
|
--without-gcc \
|
2021-02-06 07:58:12 +00:00
|
|
|
--host=wasm32-unknown-emscripten\
|
2019-08-22 11:43:18 +00:00
|
|
|
--build=$(shell $(BUILD)/config.guess) \
|
|
|
|
--prefix=$(INSTALL) ; \
|
2018-02-27 22:57:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-12-07 23:19:16 +00:00
|
|
|
$(BUILD)/$(LIB): $(BUILD)/Makefile Setup.local
|
2018-02-27 22:57:22 +00:00
|
|
|
cp Setup.local $(BUILD)/Modules/
|
2018-09-25 20:53:40 +00:00
|
|
|
cat pyconfig.undefs.h >> $(BUILD)/pyconfig.h
|
2018-02-27 22:57:22 +00:00
|
|
|
( \
|
|
|
|
cd $(BUILD); \
|
2020-12-07 23:19:16 +00:00
|
|
|
emmake make CROSS_COMPILE=yes $(LIB) -j $${PYODIDE_JOBS:-3} \
|
2018-02-27 22:57:22 +00:00
|
|
|
)
|
2018-03-20 22:58:59 +00:00
|
|
|
touch $(BUILD)/$(LIB)
|