edouard@37: edouard@37: installer: edouard@37: mkdir -p installer edouard@116: cp $(src)/winpaths.py installer edouard@37: edouard@37: edouard@37: CURDIR:=$(shell pwd) edouard@37: PACMANPFX=$(CURDIR)/pacman edouard@120: MSYS_DIR=msys64 edouard@120: MSYS_ENV_DIR=ucrt64 edouard@120: MSYS_ENV=mingw-w64-ucrt-x86_64 edouard@120: MSYS_ROOT=$(CURDIR)/$(MSYS_DIR) edouard@37: edouard@94: XVFBRUN ?= xvfb-run -a edouard@79: edouard@120: msysfinaldir=installer/$(MSYS_DIR) edouard@38: edouard@120: pacman-6.0.0/src.stamp: edouard@37: rm -rf pacman pacman-6.0.0 edouard@37: $(call get_src_http,https://sources.archlinux.org/other/pacman,pacman-6.0.0.tar.xz)\ edouard@37: tar -xJf $$dld edouard@120: touch $@ edouard@120: edouard@120: pacman-6.0.0/patched.stamp: pacman-6.0.0/src.stamp edouard@37: cd pacman-6.0.0 ;\ edouard@120: patch -p1 < $(src)/pacman-6.0.0-nogpg-relative_conf.patch ; edouard@120: touch $@ edouard@120: edouard@120: pacman/.stamp: pacman-6.0.0/patched.stamp edouard@120: cd pacman-6.0.0 ;\ edouard@37: meson -Droot-dir=$(MSYS_ROOT) -Dsysconfdir=$(MSYS_ROOT)/etc -Dlocalstatedir=$(MSYS_ROOT)/var build ;\ edouard@37: DESTDIR=$(PACMANPFX) ninja -C build install edouard@37: touch $@ edouard@37: edouard@120: define pacman_call edouard@120: LD_LIBRARY_PATH=$(PACMANPFX)/usr/lib/x86_64-linux-gnu/ fakeroot pacman/usr/bin/pacman $(1) edouard@37: endef edouard@37: edouard@120: pacman_update=$(call pacman_call, -Sy --noconfirm --cachedir $(distfiles)); edouard@120: pacman_install_ming=$(call pacman_call, -S $(1) --arch x86_64 --noconfirm --cachedir $(distfiles)); edouard@120: pacman_install_msys=$(call pacman_call, -S $(1) --noconfirm --cachedir $(distfiles)); edouard@120: edouard@120: # First part are python packages requested by our app and available in msys edouard@120: # Second part are dependencies of packages to be later installed with pip edouard@120: # Third part : neede for cross-install operation edouard@120: # -> all those packages are installed with pacman, ignoring version given in requirements.txt edouard@120: define MSYS_PY_PACKAGES edouard@120: brotli edouard@120: click edouard@120: fonttools edouard@120: lxml edouard@120: matplotlib edouard@120: msgpack edouard@120: pycountry edouard@120: u-msgpack edouard@120: zeroconf edouard@120: twisted edouard@120: edouard@120: cryptography edouard@120: aiosqlite edouard@120: pytz edouard@120: sortedcontainers edouard@120: edouard@120: pip edouard@120: endef edouard@120: edouard@120: define MSYS_PACKAGES_NAMES edouard@120: gcc edouard@120: make edouard@120: wxPython edouard@120: $(foreach package, $(MSYS_PY_PACKAGES), python-$(package)) edouard@120: endef edouard@120: edouard@120: MSYS_PACKAGES=$(foreach package, $(MSYS_PACKAGES_NAMES), $(MSYS_ENV)-$(package)) edouard@120: edouard@120: $(MSYS_DIR)/.stamp: pacman/.stamp edouard@120: rm -rf $(MSYS_DIR) edouard@120: edouard@120: $(call get_src_http,https://repo.msys2.org/distrib/x86_64,msys2-base-x86_64-20230718.tar.xz)\ edouard@38: tar -xJf $$dld edouard@120: edouard@120: # Do NOT update package lists to make build reproducible edouard@120: # All packages version are as given in base image. edouard@120: ## $(pacman_update) edouard@120: edouard@120: $(call pacman_install_ming,$(MSYS_PACKAGES)) edouard@37: touch $@ edouard@37: edouard@120: # filter-out all python packages already installed by pacman edouard@120: filtered_requirements.txt: $(MSYS_DIR)/.stamp sources/beremiz_src edouard@120: grep sources/beremiz/requirements.txt -i -v \ edouard@120: `$(call pacman_call, -Qqs 'python-.*') | sed -e 's/$(MSYS_ENV)-python-/ -e /'` \ edouard@120: -e wxPython \ edouard@120: $(foreach package, $(MSYS_PY_PACKAGES), -e $(package)) > filtered_requirements.txt edouard@120: edouard@120: # download remaining pip packages separtately with local python edouard@120: # workaround msys2's git crashing when launched from pip on wine edouard@120: # bug: https://bugs.winehq.org/show_bug.cgi?id=40528 edouard@120: pip_downloads/.stamp: filtered_requirements.txt edouard@120: rm -rf pip_downloads edouard@120: # python3 -m pip download --no-deps -r filtered_requirements.txt -d pip_downloads edouard@120: python3 -m pip wheel --no-deps -r filtered_requirements.txt -w pip_downloads edouard@120: touch $@ edouard@120: edouard@120: # install downloaded .whl files with wine edouard@120: # TODO: find a less convoluited way instead of wine to unpack wheels edouard@120: # but still populating __pycache__ for this particular python version edouard@120: winpythonbin = $(MSYS_ROOT)/$(MSYS_ENV_DIR)/bin/python.exe edouard@120: wine = WINEPREFIX=$(tmp) $(XVFBRUN) wine edouard@120: pip.stamp: pip_downloads/.stamp edouard@120: cd pip_downloads; $(wine) $(winpythonbin) -m pip install --no-deps * edouard@120: touch $@ edouard@120: edouard@120: $(msysfinaldir)/.stamp: pip.stamp | installer edouard@116: rm -rf $(msysfinaldir) edouard@120: cp -a $(MSYS_DIR) $(msysfinaldir) edouard@120: touch $@ edouard@37: edouard@120: CROSS_COMPILE=x86_64-w64-mingw32 edouard@120: CROSS_COMPILE_LIBS_DIR=$(shell dirname $(shell $(CROSS_COMPILE)-gcc -print-libgcc-file-name)) edouard@37: edouard@37: matiecdir = installer/matiec edouard@37: matiec: $(matiecdir)/.stamp edouard@37: $(matiecdir)/.stamp: sources/matiec_src | installer edouard@37: cp -a sources/matiec $(tmp);\ edouard@37: cd $(tmp)/matiec;\ edouard@120: autoreconf ;\ edouard@120: automake --add-missing ;\ edouard@120: LDFLAGS=-lstdc++ ./configure --host=$(CROSS_COMPILE);\ edouard@120: $(MAKE) -j$(CPUS); edouard@37: rm -rf $(matiecdir) edouard@37: mkdir -p $(matiecdir) edouard@37: mv $(tmp)/matiec/*.exe $(matiecdir) edouard@37: edouard@37: # install necessary shared libraries from local cross-compiler edouard@120: cp $(CROSS_COMPILE_LIBS_DIR)/libgcc_s_seh-1.dll $(matiecdir) edouard@37: cp $(CROSS_COMPILE_LIBS_DIR)/libstdc++-6.dll $(matiecdir) edouard@37: edouard@37: mv $(tmp)/matiec/lib $(matiecdir) edouard@37: touch $@ edouard@37: edouard@37: beremizdir = installer/beremiz edouard@37: edouard@37: beremiz: $(beremizdir)/.stamp edouard@37: $(beremizdir)/.stamp: sources/beremiz_src | installer edouard@37: rm -rf $(beremizdir);\ edouard@37: cp -a sources/beremiz $(beremizdir);\ edouard@120: # populate __pycache__'s .pyc files edouard@120: cd $(beremizdir) ;\ edouard@120: find . -name "*.py" | grep -v \ edouard@120: -e \./etherlab \ edouard@120: -e .*/web_settings.py \ edouard@120: -e \./tests \ edouard@120: -e \./exemples \ edouard@120: > tocompile.lst ;\ edouard@120: $(wine) $(winpythonbin) -m compileall -i tocompile.lst edouard@120: rm $(beremizdir)/tocompile.lst edouard@37: touch $@ edouard@37: edouard@37: ide_revisions = installer/revisions.txt edouard@37: $(ide_revisions): revisions.txt edouard@37: cp $< $@ edouard@37: edouard@120: Beremiz-windows-build: $(msysfinaldir)/.stamp pip.stamp $(matiecdir)/.stamp $(beremizdir)/.stamp ide_targets_from_dist $(ide_revisions) edouard@37: touch $@ edouard@37: edouard@120: Beremiz-portable.zip: Beremiz-windows-build edouard@37: rm -f $@ edouard@37: cd installer; zip -r -q ../$@ . edouard@37: edouard@120: VERSIONPY=sources/beremiz/version.py edouard@120: edouard@120: Beremiz-nsis-installer.exe: Beremiz-windows-build $(src)/license.txt $(src)/install.nsi edouard@120: export BVERSION=`python3 $(VERSIONPY)` ;\ edouard@120: sed -e "s/\$$BVERSION/$$BVERSION/g" $(src)/license.txt > installer/license.txt ;\ edouard@120: sed -e "s/\$$BVERSION/$$BVERSION/g" $(src)/install.nsi |\ edouard@120: sed -e "s#\$$MSYS_DIR#$(MSYS_DIR)#g" |\ edouard@120: sed -e "s#\$$MSYS_ENV_DIR#$(MSYS_ENV_DIR)#g" > install.nsi edouard@120: makensis install.nsi edouard@37: edouard@37: