# This file is part of MXE. See LICENSE.md for licensing information. MAKEFILE := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))TOP_DIR := $(patsubst %/,%,$(dir $(MAKEFILE)))EXT_DIR := $(TOP_DIR)/ext # GNU Make Standard Library (https://gmsl.sourceforge.io/)# See docs/gmsl.html for further informationinclude $(EXT_DIR)/gmsl MXE_TRIPLETS := i686-w64-mingw32 x86_64-w64-mingw32MXE_LIB_TYPES := static sharedMXE_TARGET_LIST := $(strip $(foreach TRIPLET,$(MXE_TRIPLETS),\ $(addprefix $(TRIPLET).,$(MXE_LIB_TYPES))))MXE_TARGETS := i686-w64-mingw32.static.DEFAULT_GOAL := all-filtered DEFAULT_MAX_JOBS := 6PRINTF_COL_1_WIDTH := 13DUMMY_PROXY := 192.0.2.0SOURCEFORGE_MIRROR := downloads.sourceforge.netMXE_MIRROR := https://mirror.mxe.cc/pkgPKG_MIRROR := https://mxe-pkg.s3.amazonaws.comPKG_CDN := http://d1yihgixbnrglp.cloudfront.net# reorder as required, ensuring final one is a http fallbackMIRROR_SITES := MXE_MIRROR PKG_MIRROR PKG_CDN PWD := $(shell pwd)SHELL := bash MXE_TMP := $(PWD) ORIG_PATH := $(call merge,:,$(filter-out $(PREFIX)/$(BUILD)/bin $(PREFIX)/bin,$(call split,:,$(PATH))))BUILD_CC := $(shell (gcc --help >/dev/null 2>&1 && echo gcc) || (clang --help >/dev/null 2>&1 && echo clang))BUILD_CXX := $(shell (g++ --help >/dev/null 2>&1 && echo g++) || (clang++ --help >/dev/null 2>&1 && echo clang++))DATE := $(shell gdate --help >/dev/null 2>&1 && echo g)dateINSTALL := $(shell ginstall --help >/dev/null 2>&1 && echo g)installLIBTOOL := $(shell glibtool --help >/dev/null 2>&1 && echo g)libtoolLIBTOOLIZE := $(shell glibtoolize --help >/dev/null 2>&1 && echo g)libtoolizeOPENSSL := opensslPATCH := $(shell gpatch --help >/dev/null 2>&1 && echo g)patchPYTHON := $(shell PATH="$(ORIG_PATH)" which python)PYTHON3 := $(shell PATH="$(ORIG_PATH)" which python3)PY_XY_VER := $(if $(PYTHON),$(shell $(PYTHON) -c "import sys; print('{0[0]}.{0[1]}'.format(sys.version_info))"))SED := $(shell gsed --help >/dev/null 2>&1 && echo g)sedSORT := $(shell gsort --help >/dev/null 2>&1 && echo g)sortTOUCH := $(shell gtouch --help >/dev/null 2>&1 && echo g)touchDEFAULT_UA := $(shell wget --version | $(SED) -n 's,GNU \(Wget\) \([0-9.]*\).*,\1/\2,p')WGET_TOOL = wgetWGET = $(WGET_TOOL) --user-agent='$(or $($(1)_UA),$(DEFAULT_UA))' -t 2 --timeout=6 REQUIREMENTS := \ 7za \ autoconf \ automake \ autopoint \ bash \ bison \ $(BUILD_CC) \ $(BUILD_CXX) \ bzip2 \ flex \ gdk-pixbuf-csource \ gperf \ intltoolize \ $(LIBTOOL) \ $(LIBTOOLIZE) \ lzip \ $(MAKE) \ mako-render \ $(OPENSSL) \ $(PATCH) \ perl \ $(PYTHON) \ $(PYTHON3) \ ruby \ $(SED) \ $(SORT) \ unzip \ wget \ xz MXE_PREFIX := $(PWD)/usrPREFIX := $(MXE_PREFIX)LOG_DIR := $(PWD)/logGITS_DIR := $(PWD)/gitsGIT_HEAD := $(shell git rev-parse HEAD)TIMESTAMP := $(shell date +%Y%m%d_%H%M%S)PKG_DIR := $(PWD)/pkgTMP_DIR = $(MXE_TMP)/tmp-$(1)BUILD := $(shell '$(EXT_DIR)/config.guess')PATH := $(PREFIX)/$(BUILD)/bin:$(PREFIX)/bin:$(shell echo $$PATH | $(SED) -e 's,:\.$$,,' -e 's,\.:,,g') # set to empty or $(false) to disable strippingSTRIP_TOOLCHAIN := $(true)STRIP_LIB := $(false)STRIP_EXE := $(true) # disable by setting MXE_USE_CCACHEMXE_USE_CCACHE := mxeMXE_CCACHE_DIR := $(PWD)/.ccacheMXE_CCACHE_BASE_DIR := $(PWD)MXE_CCACHE_CACHE_DIR := $(MXE_CCACHE_DIR)/ccache # set to major.minor for LTS# MXE_QT6_ID := qt6.2MXE_QT6_ID := qt6 # define some whitespace variablesdefine newline endef \n := $(newline)comma := ,null :=space := $(null) $(null)repeat = $(subst x,$(1),$(subst $(space),,$(call int_encode,$(2)))) PLUGIN_HEADER = $(info $(shell printf '%-$(PRINTF_COL_1_WIDTH)s %s\n' [plugin] $(dir $(lastword $(MAKEFILE_LIST))))) MXE_DISABLE_DOC_OPTS = \ ac_cv_prog_HAVE_DOXYGEN="false" \ --enable-doc=no \ --enable-gtk-doc=no \ --enable-gtk-doc-html=no \ --enable-gtk-doc-pdf=no \ --{docdir,infodir,mandir,with-html-dir}='$(BUILD_DIR).sink' \ --disable-doxygen MXE_CONFIGURE_OPTS = \ --host='$(TARGET)' \ --build='$(BUILD)' \ --prefix='$(PREFIX)/$(TARGET)' \ $(if $(BUILD_STATIC), \ --enable-static --disable-shared , \ --disable-static --enable-shared ) \ $(MXE_DISABLE_DOC_OPTS) MXE_MESON_WRAPPER = '$(PREFIX)/bin/$(TARGET)-meson'MXE_MESON_NATIVE_WRAPPER = '$(PREFIX)/bin/mxe-native-meson'MXE_NINJA = '$(PREFIX)/$(BUILD)/bin/ninja' # Please edit meson wrapper and/or target file instead of this,# unless your changes only apply to building MXE's packagesMXE_MESON_OPTS = \ --buildtype=release \ --wrap-mode=nofallback \ $(if $(findstring mxe,$(MXE_USE_CCACHE)), \ --cross-file='$(PREFIX)/$(TARGET)/share/meson/mxe-crossfile-internal.meson') PKG_MESON_OPTS = \ $(_$(PKG)_MESON_OPTS) \ $($(PKG)_MESON_OPTS) PKG_CONFIGURE_OPTS = \ $(_$(PKG)_CONFIGURE_OPTS) \ $($(PKG)_CONFIGURE_OPTS) PKG_CMAKE_OPTS = \ $(_$(PKG)_CMAKE_OPTS) \ $($(PKG)_CMAKE_OPTS) \ $($(PKG)_$(TARGET)_CMAKE_OPTS) # GCC threads and exceptionsMXE_GCC_THREADS = \ $(if $(findstring win32,$(or $(TARGET),$(1))),win32,posix) # allowed exception handling for targets# default (first item) and alternate, revisit if gcc/mingw-w64 change defaultsi686-w64-mingw32_EH := sjlj dw2x86_64-w64-mingw32_EH := seh sjlj # functions to determine exception handling from user-specified target# $(or $(TARGET),$(1)) allows use as both function and inline snippetTARGET_EH_LIST = $($(firstword $(call split,.,$(or $(TARGET),$(1))))_EH)DEFAULT_EH = $(firstword $(TARGET_EH_LIST))GCC_EXCEPTIONS = \ $(lastword $(DEFAULT_EH) \ $(filter $(TARGET_EH_LIST),$(call split,.,$(or $(TARGET),$(1)))))MXE_GCC_EXCEPTION_OPTS = \ $(if $(call seq,sjlj,$(GCC_EXCEPTIONS)),--enable-sjlj-exceptions) \ $(if $(call seq,dw2,$(GCC_EXCEPTIONS)),--disable-sjlj-exceptions) # Append these to the "make" and "make install" steps of autotools packages# in order to neither build nor install unwanted binaries, manpages,# infopages and API documentation (reduces build time and disk space usage).# NOTE: We don't include bin_SCRIPTS (and variations), since many packages# install files such as pcre-config (which we do want to be installed). MXE_DISABLE_PROGRAMS = \ dist_bin_SCRIPTS= \ bin_PROGRAMS= \ sbin_PROGRAMS= \ noinst_PROGRAMS= \ check_PROGRAMS= MXE_DISABLE_DOCS = \ man_MANS= \ man1_MANS= \ man2_MANS= \ man3_MANS= \ man4_MANS= \ man5_MANS= \ man6_MANS= \ man7_MANS= \ man8_MANS= \ man9_MANS= \ dist_man_MANS= \ dist_man1_MANS= \ dist_man2_MANS= \ dist_man3_MANS= \ dist_man4_MANS= \ dist_man5_MANS= \ dist_man6_MANS= \ dist_man7_MANS= \ dist_man8_MANS= \ dist_man9_MANS= \ nodist_man_MANS= \ nodist_man1_MANS= \ nodist_man2_MANS= \ nodist_man3_MANS= \ nodist_man4_MANS= \ nodist_man5_MANS= \ nodist_man6_MANS= \ nodist_man7_MANS= \ nodist_man8_MANS= \ nodist_man9_MANS= \ notrans_dist_man_MANS= \ MANLINKS= \ info_TEXINFOS= \ doc_DATA= \ dist_doc_DATA= \ html_DATA= \ dist_html_DATA= MXE_DISABLE_CRUFT = $(MXE_DISABLE_PROGRAMS) $(MXE_DISABLE_DOCS) MAKE_SHARED_FROM_STATIC = \ '$(TOP_DIR)/tools/make-shared-from-static' \ $(if $(findstring mingw,$(TARGET)),--windowsdll) \ --ar '$(TARGET)-ar' \ --ld '$(TARGET)-gcc' \ --install '$(INSTALL)' \ --libdir '$(PREFIX)/$(TARGET)/lib' \ --bindir '$(PREFIX)/$(TARGET)/bin' define AUTOTOOLS_CONFIGURE cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \ $(MXE_CONFIGURE_OPTS)endef define AUTOTOOLS_MAKE $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' $(MXE_DISABLE_DOCS) $(MAKE) -C '$(BUILD_DIR)' -j 1 install $(MXE_DISABLE_DOCS)endef define AUTOTOOLS_BUILD $(AUTOTOOLS_CONFIGURE) $(AUTOTOOLS_MAKE)endef define CMAKE_TEST # test cmake mkdir '$(BUILD_DIR).test-cmake' cd '$(BUILD_DIR).test-cmake' && '$(TARGET)-cmake' \ -DPKG=$(PKG) \ -DPKG_VERSION=$($(PKG)_VERSION) \ '$(PWD)/src/cmake/test' $(MAKE) -C '$(BUILD_DIR).test-cmake' -j 1 installendef # include github related functionsinclude $(PWD)/mxe.github.mk # shared lib preload to disable networking, enable faketime etcPRELOAD_VARS := LD_PRELOAD DYLD_FORCE_FLAT_NAMESPACE DYLD_INSERT_LIBRARIES # use a minimal whitelist of safe environment variables# basic working shell environment and mxe variables# see http://www.linuxfromscratch.org/lfs/view/stable/chapter04/settingenvironment.htmlENV_WHITELIST := EDITOR HOME LANG LC_% PATH %PROXY %proxy PS1 TERMENV_WHITELIST += MAKE% MXE% $(PRELOAD_VARS) WINEPREFIX # OS/Distro related issues - "unsafe" but practical# 1. https://github.com/mxe/mxe/issues/697ENV_WHITELIST += ACLOCAL_PATH LD_LIBRARY_PATH unexport $(filter-out $(ENV_WHITELIST),$(shell env | cut -d '=' -f1)) SHORT_PKG_VERSION = \ $(word 1,$(subst ., ,$($(1)_VERSION))).$(word 2,$(subst ., ,$($(1)_VERSION))) UNPACK_ARCHIVE = \ $(if $(filter %.tar, $(1)),tar xf '$(1)', \ $(if $(filter %.tgz, $(1)),tar xzf '$(1)', \ $(if $(filter %.tar.gz, $(1)),tar xzf '$(1)', \ $(if $(filter %.tar.Z, $(1)),tar xzf '$(1)', \ $(if $(filter %.tbz2, $(1)),tar xjf '$(1)', \ $(if $(filter %.tar.bz2, $(1)),tar xjf '$(1)', \ $(if $(filter %.tar.lz, $(1)),lzip -dc '$(1)'| tar xf -, \ $(if $(filter %.tar.lzma,$(1)),xz -dc -F lzma '$(1)' | tar xf -, \ $(if $(filter %.txz, $(1)),xz -dc '$(1)' | tar xf -, \ $(if $(filter %.tar.xz, $(1)),xz -dc '$(1)' | tar xf -, \ $(if $(filter %.7z, $(1)),7za x '$(1)', \ $(if $(filter %.zip, $(1)),unzip -q '$(1)', \ $(if $(filter %.deb, $(1)),ar x '$(1)' && tar xf data.tar*, \ $(error Unknown archive format: $(1))))))))))))))) UNPACK_PKG_ARCHIVE = \ $(call UNPACK_ARCHIVE,$(PKG_DIR)/$($(1)_FILE)) # some shortcuts for awareness of MXE_PLUGIN_DIRS# all files for extension plugins will be considered for outdated checksPKG_MAKEFILES = $(realpath $(sort $(wildcard $(addsuffix /$(1).mk, $(MXE_PLUGIN_DIRS)))))PKG_TESTFILES = $(realpath $(sort $(wildcard $(addsuffix /$(1)-test*, $(MXE_PLUGIN_DIRS)))))# allow packages to specify a list of zero or more patchesPKG_PATCHES = $(if $(findstring undefined,$(origin $(1)_PATCHES)), \ $(realpath $(sort $(wildcard $(addsuffix /$(1)-[0-9]*.patch, $(MXE_PLUGIN_DIRS))))) \ $(else), \ $($(1)_PATCHES)) define PREPARE_PKG_SOURCE $(if $($(1)_SOURCE_TREE),\ ln -si '$(realpath $($(1)_SOURCE_TREE))' '$(2)/$($(1)_SUBDIR)' $(else),\ cd '$(2)' && $(call UNPACK_PKG_ARCHIVE,$(1)) cd '$(2)/$($(1)_SUBDIR)' $(foreach PKG_PATCH,$($(1)_PATCHES), (cd '$(2)/$($(1)_SUBDIR)' && $(PATCH) -p1 -u) < $(PKG_PATCH)) )endef PKG_CHECKSUM = \ $(OPENSSL) dgst -sha256 '$(or $(2),$(PKG_DIR)/$($(1)_FILE))' 2>/dev/null | $(SED) -n 's,^.*\([0-9a-f]\{64\}\)$$,\1,p' CHECK_PKG_ARCHIVE = \ $(if $($(1)_SOURCE_TREE),\ $(PRINTF_FMT) '[local]' '$(1)' '$($(1)_SOURCE_TREE)' | $(RTRIM)\ $(else),$(if $(SKIP_CHECKSUM),true, \ [ '$($(1)_CHECKSUM)' == "`$$(call PKG_CHECKSUM,$(1),$(2))`" ]\ )) ESCAPE_PKG = \ echo '$($(1)_FILE)' | perl -lpe 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($$$$1))/seg' BACKUP_DOWNLOAD = \ (echo "MXE Warning! Downloading $(1) from backup." >&2 && \ ($(foreach SITE,$(MIRROR_SITES), \ $(WGET) -O '$(TMP_FILE)' $($(SITE))/`$(call ESCAPE_PKG,$(1))`_$($(1)_CHECKSUM) || \ $(WGET) -O '$(TMP_FILE)' $($(SITE))/`$(call ESCAPE_PKG,$(1))` || ) false)) DOWNLOAD_PKG_ARCHIVE = \ $(eval TMP_FILE := $(PKG_DIR)/.tmp-$($(1)_FILE)) \ $(if $($(1)_SOURCE_TREE),\ true\ $(else),\ mkdir -p '$(PKG_DIR)' && ( \ ($(WGET) -T 30 -t 3 -O '$(TMP_FILE)' '$($(1)_URL)' && \ $(call CHECK_PKG_ARCHIVE,$(1),'$(TMP_FILE)')) \ $(if $($(1)_URL_2), \ || (echo "MXE Warning! Downloading $(1) from second URL." >&2 && \ $(WGET) -T 30 -t 3 -O '$(TMP_FILE)' '$($(1)_URL_2)' && \ $(call CHECK_PKG_ARCHIVE,$(1),'$(TMP_FILE)'))) \ $(if $(MXE_NO_BACKUP_DL),, \ || $(BACKUP_DOWNLOAD)) \ ) && cat '$(TMP_FILE)' \ $(if $($(1)_FIX_GZIP), \ | gzip -d | gzip -9n, \ ) \ > '$(PKG_DIR)/$($(1)_FILE)' && \ $(if $(CREATE_SUFFIXED_ARCHIVE),cp '$(PKG_DIR)/$($(1)_FILE)' '$(PKG_DIR)/$($(1)_FILE)_$($(1)_CHECKSUM)' &&) \ rm '$(TMP_FILE)' || \ ( echo; \ echo 'Download failed!'; \ echo; \ rm -f '$(PKG_DIR)/$($(1)_FILE)' '$(TMP_FILE)'; )\ ) # open issue from 2002:# https://savannah.gnu.org/bugs/?712ifneq ($(words $(PWD)),1) $(error GNU Make chokes on paths with spaces)endif # dollar signs also cause troublesifneq (,$(findstring $$,$(PWD))) $(error GNU Make chokes on paths with dollar signs)endif ifeq ($(IGNORE_SETTINGS),yes) $(info [ignore settings.mk])else ifeq ($(wildcard $(PWD)/settings.mk),$(PWD)/settings.mk) include $(PWD)/settings.mkelse $(info [create settings.mk]) $(shell { \ echo '# This is a template of configuration file for MXE. See'; \ echo '# docs/index.html for more extensive documentations.'; \ echo; \ echo '# This variable controls the number of compilation processes'; \ echo '# within one package ("intra-package parallelism").'; \ echo '#JOBS := $(JOBS)'; \ echo; \ echo '# This variable controls where intermediate files are created'; \ echo '# this is necessary when compiling inside a virtualbox shared'; \ echo '# directory. Some commands like strip fail in there with Protocol error'; \ echo '# default is the current directory'; \ echo '#MXE_TMP := /tmp'; \ echo; \ echo '# This variable controls the targets that will build.'; \ echo '#MXE_TARGETS := $(MXE_TARGET_LIST)'; \ echo; \ echo '# This variable controls which plugins are in use.'; \ echo '# See plugins/README.md for further information.'; \ echo '#override MXE_PLUGIN_DIRS += plugins/apps plugins/native'; \ echo; \ echo '# This variable controls the download mirror for SourceForge,'; \ echo '# when it is used. Enabling the value below means auto.'; \ echo '#SOURCEFORGE_MIRROR := downloads.sourceforge.net'; \ echo; \ echo '# The three lines below makes `make` build these "local'; \ echo '# packages" instead of all packages.'; \ echo '#LOCAL_PKG_LIST := boost curl file flac lzo pthreads vorbis wxwidgets'; \ echo '#.DEFAULT_GOAL := local-pkg-list'; \ echo '#local-pkg-list: $$(LOCAL_PKG_LIST)'; \ } >'$(PWD)/settings.mk')endif ifneq ($(LOCAL_PKG_LIST),) .DEFAULT_GOAL := local-pkg-list $(info [pkg-list] $(LOCAL_PKG_LIST))endif # Numeric min and max list functionsLIST_NMAX = $(shell echo '$(strip $(1))' | tr ' ' '\n' | sort -n | tail -1)LIST_NMIN = $(shell echo '$(strip $(1))' | tr ' ' '\n' | sort -n | head -1) NPROCS := $(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1)JOBS ?= $(call LIST_NMIN, $(DEFAULT_MAX_JOBS) $(NPROCS)) # Core packages.override MXE_PLUGIN_DIRS := \ $(realpath $(TOP_DIR)/src) \ $(realpath $(TOP_DIR)/src/qt/$(MXE_QT6_ID)) \ $(MXE_PLUGIN_DIRS) # Build native requirements for certain systemsOS_SHORT_NAME := $(call lc,$(shell lsb_release -sc 2>/dev/null || uname -s))override MXE_PLUGIN_DIRS += $(realpath $(TOP_DIR)/plugins/native/$(OS_SHORT_NAME)) .PHONY: check-requirementsdefine CHECK_REQUIREMENT @if ! ( $(1) --help || $(1) help ) &>/dev/null; then \ echo 'Missing requirement: $(1)'; \ touch check-requirements-failed; \ fi endefdefine CHECK_REQUIREMENT_VERSION @if ! $(1) --version | head -1 | grep ' \($(2)\)$$' >/dev/null; then \ echo 'Wrong version of requirement: $(1)'; \ touch check-requirements-failed; \ fi endef %/.gitkeep: +@mkdir -p '$(dir $@)' @touch '$@' check-requirements: $(PREFIX)/installed/check-requirements$(PREFIX)/installed/check-requirements: $(MAKEFILE) | $(PREFIX)/installed/.gitkeep @echo '[check reqs]' $(foreach REQUIREMENT,$(REQUIREMENTS),$(call CHECK_REQUIREMENT,$(REQUIREMENT))) $(call CHECK_REQUIREMENT_VERSION,autoconf,2\.6[8-9]\|2\.[7-9][0-9]) $(call CHECK_REQUIREMENT_VERSION,automake,1\.11\.[3-9]\|1\.[1-9][2-9]\(\.[0-9]\+\)\?) @if [ -e check-requirements-failed ]; then \ echo; \ echo 'Please have a look at "docs/index.html" to ensure'; \ echo 'that your system meets all requirements.'; \ echo; \ rm check-requirements-failed; \ exit 1; \ fi @touch '$@' .PHONY: print-git-onelineprint-git-oneline: $(PREFIX)/installed/print-git-oneline-$(GIT_HEAD)$(PREFIX)/installed/print-git-oneline-$(GIT_HEAD): | $(PREFIX)/installed/.gitkeep @git log --pretty=tformat:'[git-log] %h %s' -1 | cat @rm -f '$(PREFIX)/installed/print-git-oneline-'* @touch '$@' # Common dependency lists for `make` prerequisites and `build-pkg`# - `make` considers only explicit normal deps to trigger rebuilds# - packages can add themselves to implicit BOOTSTRAP_PKGS in the case# of a tool like `patch` which may be outdated on some systemsLines 1–500 of 1170. Load more
# This file is part of MXE. See LICENSE.md for licensing information. MAKEFILE := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) TOP_DIR := $(patsubst %/,%,$(dir $(MAKEFILE))) EXT_DIR := $(TOP_DIR)/ext # GNU Make Standard Library (https://gmsl.sourceforge.io/) # See docs/gmsl.html for further information include $(EXT_DIR)/gmsl MXE_TRIPLETS := i686-w64-mingw32 x86_64-w64-mingw32 MXE_LIB_TYPES := static shared MXE_TARGET_LIST := $(strip $(foreach TRIPLET,$(MXE_TRIPLETS),\ $(addprefix $(TRIPLET).,$(MXE_LIB_TYPES)))) MXE_TARGETS := i686-w64-mingw32.static .DEFAULT_GOAL := all-filtered DEFAULT_MAX_JOBS := 6 PRINTF_COL_1_WIDTH := 13 DUMMY_PROXY := 192.0.2.0 SOURCEFORGE_MIRROR := downloads.sourceforge.net MXE_MIRROR := https://mirror.mxe.cc/pkg PKG_MIRROR := https://mxe-pkg.s3.amazonaws.com PKG_CDN := http://d1yihgixbnrglp.cloudfront.net # reorder as required, ensuring final one is a http fallback MIRROR_SITES := MXE_MIRROR PKG_MIRROR PKG_CDN PWD := $(shell pwd) SHELL := bash MXE_TMP := $(PWD) ORIG_PATH := $(call merge,:,$(filter-out $(PREFIX)/$(BUILD)/bin $(PREFIX)/bin,$(call split,:,$(PATH)))) BUILD_CC := $(shell (gcc --help >/dev/null 2>&1 && echo gcc) || (clang --help >/dev/null 2>&1 && echo clang)) BUILD_CXX := $(shell (g++ --help >/dev/null 2>&1 && echo g++) || (clang++ --help >/dev/null 2>&1 && echo clang++)) DATE := $(shell gdate --help >/dev/null 2>&1 && echo g)date INSTALL := $(shell ginstall --help >/dev/null 2>&1 && echo g)install LIBTOOL := $(shell glibtool --help >/dev/null 2>&1 && echo g)libtool LIBTOOLIZE := $(shell glibtoolize --help >/dev/null 2>&1 && echo g)libtoolize OPENSSL := openssl PATCH := $(shell gpatch --help >/dev/null 2>&1 && echo g)patch PYTHON := $(shell PATH="$(ORIG_PATH)" which python) PYTHON3 := $(shell PATH="$(ORIG_PATH)" which python3) PY_XY_VER := $(if $(PYTHON),$(shell $(PYTHON) -c "import sys; print('{0[0]}.{0[1]}'.format(sys.version_info))")) SED := $(shell gsed --help >/dev/null 2>&1 && echo g)sed SORT := $(shell gsort --help >/dev/null 2>&1 && echo g)sort TOUCH := $(shell gtouch --help >/dev/null 2>&1 && echo g)touch DEFAULT_UA := $(shell wget --version | $(SED) -n 's,GNU \(Wget\) \([0-9.]*\).*,\1/\2,p') WGET_TOOL = wget WGET = $(WGET_TOOL) --user-agent='$(or $($(1)_UA),$(DEFAULT_UA))' -t 2 --timeout=6 REQUIREMENTS := \ 7za \ autoconf \ automake \ autopoint \ bash \ bison \ $(BUILD_CC) \ $(BUILD_CXX) \ bzip2 \ flex \ gdk-pixbuf-csource \ gperf \ intltoolize \ $(LIBTOOL) \ $(LIBTOOLIZE) \ lzip \ $(MAKE) \ mako-render \ $(OPENSSL) \ $(PATCH) \ perl \ $(PYTHON) \ $(PYTHON3) \ ruby \ $(SED) \ $(SORT) \ unzip \ wget \ xz MXE_PREFIX := $(PWD)/usr PREFIX := $(MXE_PREFIX) LOG_DIR := $(PWD)/log GITS_DIR := $(PWD)/gits GIT_HEAD := $(shell git rev-parse HEAD) TIMESTAMP := $(shell date +%Y%m%d_%H%M%S) PKG_DIR := $(PWD)/pkg TMP_DIR = $(MXE_TMP)/tmp-$(1) BUILD := $(shell '$(EXT_DIR)/config.guess') PATH := $(PREFIX)/$(BUILD)/bin:$(PREFIX)/bin:$(shell echo $$PATH | $(SED) -e 's,:\.$$,,' -e 's,\.:,,g') # set to empty or $(false) to disable stripping STRIP_TOOLCHAIN := $(true) STRIP_LIB := $(false) STRIP_EXE := $(true) # disable by setting MXE_USE_CCACHE MXE_USE_CCACHE := mxe MXE_CCACHE_DIR := $(PWD)/.ccache MXE_CCACHE_BASE_DIR := $(PWD) MXE_CCACHE_CACHE_DIR := $(MXE_CCACHE_DIR)/ccache # set to major.minor for LTS # MXE_QT6_ID := qt6.2 MXE_QT6_ID := qt6 # define some whitespace variables define newline endef \n := $(newline) comma := , null := space := $(null) $(null) repeat = $(subst x,$(1),$(subst $(space),,$(call int_encode,$(2)))) PLUGIN_HEADER = $(info $(shell printf '%-$(PRINTF_COL_1_WIDTH)s %s\n' [plugin] $(dir $(lastword $(MAKEFILE_LIST))))) MXE_DISABLE_DOC_OPTS = \ ac_cv_prog_HAVE_DOXYGEN="false" \ --enable-doc=no \ --enable-gtk-doc=no \ --enable-gtk-doc-html=no \ --enable-gtk-doc-pdf=no \ --{docdir,infodir,mandir,with-html-dir}='$(BUILD_DIR).sink' \ --disable-doxygen MXE_CONFIGURE_OPTS = \ --host='$(TARGET)' \ --build='$(BUILD)' \ --prefix='$(PREFIX)/$(TARGET)' \ $(if $(BUILD_STATIC), \ --enable-static --disable-shared , \ --disable-static --enable-shared ) \ $(MXE_DISABLE_DOC_OPTS) MXE_MESON_WRAPPER = '$(PREFIX)/bin/$(TARGET)-meson' MXE_MESON_NATIVE_WRAPPER = '$(PREFIX)/bin/mxe-native-meson' MXE_NINJA = '$(PREFIX)/$(BUILD)/bin/ninja' # Please edit meson wrapper and/or target file instead of this, # unless your changes only apply to building MXE's packages MXE_MESON_OPTS = \ --buildtype=release \ --wrap-mode=nofallback \ $(if $(findstring mxe,$(MXE_USE_CCACHE)), \ --cross-file='$(PREFIX)/$(TARGET)/share/meson/mxe-crossfile-internal.meson') PKG_MESON_OPTS = \ $(_$(PKG)_MESON_OPTS) \ $($(PKG)_MESON_OPTS) PKG_CONFIGURE_OPTS = \ $(_$(PKG)_CONFIGURE_OPTS) \ $($(PKG)_CONFIGURE_OPTS) PKG_CMAKE_OPTS = \ $(_$(PKG)_CMAKE_OPTS) \ $($(PKG)_CMAKE_OPTS) \ $($(PKG)_$(TARGET)_CMAKE_OPTS) # GCC threads and exceptions MXE_GCC_THREADS = \ $(if $(findstring win32,$(or $(TARGET),$(1))),win32,posix) # allowed exception handling for targets # default (first item) and alternate, revisit if gcc/mingw-w64 change defaults i686-w64-mingw32_EH := sjlj dw2 x86_64-w64-mingw32_EH := seh sjlj # functions to determine exception handling from user-specified target # $(or $(TARGET),$(1)) allows use as both function and inline snippet TARGET_EH_LIST = $($(firstword $(call split,.,$(or $(TARGET),$(1))))_EH) DEFAULT_EH = $(firstword $(TARGET_EH_LIST)) GCC_EXCEPTIONS = \ $(lastword $(DEFAULT_EH) \ $(filter $(TARGET_EH_LIST),$(call split,.,$(or $(TARGET),$(1))))) MXE_GCC_EXCEPTION_OPTS = \ $(if $(call seq,sjlj,$(GCC_EXCEPTIONS)),--enable-sjlj-exceptions) \ $(if $(call seq,dw2,$(GCC_EXCEPTIONS)),--disable-sjlj-exceptions) # Append these to the "make" and "make install" steps of autotools packages # in order to neither build nor install unwanted binaries, manpages, # infopages and API documentation (reduces build time and disk space usage). # NOTE: We don't include bin_SCRIPTS (and variations), since many packages # install files such as pcre-config (which we do want to be installed). MXE_DISABLE_PROGRAMS = \ dist_bin_SCRIPTS= \ bin_PROGRAMS= \ sbin_PROGRAMS= \ noinst_PROGRAMS= \ check_PROGRAMS= MXE_DISABLE_DOCS = \ man_MANS= \ man1_MANS= \ man2_MANS= \ man3_MANS= \ man4_MANS= \ man5_MANS= \ man6_MANS= \ man7_MANS= \ man8_MANS= \ man9_MANS= \ dist_man_MANS= \ dist_man1_MANS= \ dist_man2_MANS= \ dist_man3_MANS= \ dist_man4_MANS= \ dist_man5_MANS= \ dist_man6_MANS= \ dist_man7_MANS= \ dist_man8_MANS= \ dist_man9_MANS= \ nodist_man_MANS= \ nodist_man1_MANS= \ nodist_man2_MANS= \ nodist_man3_MANS= \ nodist_man4_MANS= \ nodist_man5_MANS= \ nodist_man6_MANS= \ nodist_man7_MANS= \ nodist_man8_MANS= \ nodist_man9_MANS= \ notrans_dist_man_MANS= \ MANLINKS= \ info_TEXINFOS= \ doc_DATA= \ dist_doc_DATA= \ html_DATA= \ dist_html_DATA= MXE_DISABLE_CRUFT = $(MXE_DISABLE_PROGRAMS) $(MXE_DISABLE_DOCS) MAKE_SHARED_FROM_STATIC = \ '$(TOP_DIR)/tools/make-shared-from-static' \ $(if $(findstring mingw,$(TARGET)),--windowsdll) \ --ar '$(TARGET)-ar' \ --ld '$(TARGET)-gcc' \ --install '$(INSTALL)' \ --libdir '$(PREFIX)/$(TARGET)/lib' \ --bindir '$(PREFIX)/$(TARGET)/bin' define AUTOTOOLS_CONFIGURE cd '$(BUILD_DIR)' && $(SOURCE_DIR)/configure \ $(MXE_CONFIGURE_OPTS) endef define AUTOTOOLS_MAKE $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' $(MXE_DISABLE_DOCS) $(MAKE) -C '$(BUILD_DIR)' -j 1 install $(MXE_DISABLE_DOCS) endef define AUTOTOOLS_BUILD $(AUTOTOOLS_CONFIGURE) $(AUTOTOOLS_MAKE) endef define CMAKE_TEST # test cmake mkdir '$(BUILD_DIR).test-cmake' cd '$(BUILD_DIR).test-cmake' && '$(TARGET)-cmake' \ -DPKG=$(PKG) \ -DPKG_VERSION=$($(PKG)_VERSION) \ '$(PWD)/src/cmake/test' $(MAKE) -C '$(BUILD_DIR).test-cmake' -j 1 install endef # include github related functions include $(PWD)/mxe.github.mk # shared lib preload to disable networking, enable faketime etc PRELOAD_VARS := LD_PRELOAD DYLD_FORCE_FLAT_NAMESPACE DYLD_INSERT_LIBRARIES # use a minimal whitelist of safe environment variables # basic working shell environment and mxe variables # see http://www.linuxfromscratch.org/lfs/view/stable/chapter04/settingenvironment.html ENV_WHITELIST := EDITOR HOME LANG LC_% PATH %PROXY %proxy PS1 TERM ENV_WHITELIST += MAKE% MXE% $(PRELOAD_VARS) WINEPREFIX # OS/Distro related issues - "unsafe" but practical # 1. https://github.com/mxe/mxe/issues/697 ENV_WHITELIST += ACLOCAL_PATH LD_LIBRARY_PATH unexport $(filter-out $(ENV_WHITELIST),$(shell env | cut -d '=' -f1)) SHORT_PKG_VERSION = \ $(word 1,$(subst ., ,$($(1)_VERSION))).$(word 2,$(subst ., ,$($(1)_VERSION))) UNPACK_ARCHIVE = \ $(if $(filter %.tar, $(1)),tar xf '$(1)', \ $(if $(filter %.tgz, $(1)),tar xzf '$(1)', \ $(if $(filter %.tar.gz, $(1)),tar xzf '$(1)', \ $(if $(filter %.tar.Z, $(1)),tar xzf '$(1)', \ $(if $(filter %.tbz2, $(1)),tar xjf '$(1)', \ $(if $(filter %.tar.bz2, $(1)),tar xjf '$(1)', \ $(if $(filter %.tar.lz, $(1)),lzip -dc '$(1)'| tar xf -, \ $(if $(filter %.tar.lzma,$(1)),xz -dc -F lzma '$(1)' | tar xf -, \ $(if $(filter %.txz, $(1)),xz -dc '$(1)' | tar xf -, \ $(if $(filter %.tar.xz, $(1)),xz -dc '$(1)' | tar xf -, \ $(if $(filter %.7z, $(1)),7za x '$(1)', \ $(if $(filter %.zip, $(1)),unzip -q '$(1)', \ $(if $(filter %.deb, $(1)),ar x '$(1)' && tar xf data.tar*, \ $(error Unknown archive format: $(1))))))))))))))) UNPACK_PKG_ARCHIVE = \ $(call UNPACK_ARCHIVE,$(PKG_DIR)/$($(1)_FILE)) # some shortcuts for awareness of MXE_PLUGIN_DIRS # all files for extension plugins will be considered for outdated checks PKG_MAKEFILES = $(realpath $(sort $(wildcard $(addsuffix /$(1).mk, $(MXE_PLUGIN_DIRS))))) PKG_TESTFILES = $(realpath $(sort $(wildcard $(addsuffix /$(1)-test*, $(MXE_PLUGIN_DIRS))))) # allow packages to specify a list of zero or more patches PKG_PATCHES = $(if $(findstring undefined,$(origin $(1)_PATCHES)), \ $(realpath $(sort $(wildcard $(addsuffix /$(1)-[0-9]*.patch, $(MXE_PLUGIN_DIRS))))) \ $(else), \ $($(1)_PATCHES)) define PREPARE_PKG_SOURCE $(if $($(1)_SOURCE_TREE),\ ln -si '$(realpath $($(1)_SOURCE_TREE))' '$(2)/$($(1)_SUBDIR)' $(else),\ cd '$(2)' && $(call UNPACK_PKG_ARCHIVE,$(1)) cd '$(2)/$($(1)_SUBDIR)' $(foreach PKG_PATCH,$($(1)_PATCHES), (cd '$(2)/$($(1)_SUBDIR)' && $(PATCH) -p1 -u) < $(PKG_PATCH)) ) endef PKG_CHECKSUM = \ $(OPENSSL) dgst -sha256 '$(or $(2),$(PKG_DIR)/$($(1)_FILE))' 2>/dev/null | $(SED) -n 's,^.*\([0-9a-f]\{64\}\)$$,\1,p' CHECK_PKG_ARCHIVE = \ $(if $($(1)_SOURCE_TREE),\ $(PRINTF_FMT) '[local]' '$(1)' '$($(1)_SOURCE_TREE)' | $(RTRIM)\ $(else),$(if $(SKIP_CHECKSUM),true, \ [ '$($(1)_CHECKSUM)' == "`$$(call PKG_CHECKSUM,$(1),$(2))`" ]\ )) ESCAPE_PKG = \ echo '$($(1)_FILE)' | perl -lpe 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($$$$1))/seg' BACKUP_DOWNLOAD = \ (echo "MXE Warning! Downloading $(1) from backup." >&2 && \ ($(foreach SITE,$(MIRROR_SITES), \ $(WGET) -O '$(TMP_FILE)' $($(SITE))/`$(call ESCAPE_PKG,$(1))`_$($(1)_CHECKSUM) || \ $(WGET) -O '$(TMP_FILE)' $($(SITE))/`$(call ESCAPE_PKG,$(1))` || ) false)) DOWNLOAD_PKG_ARCHIVE = \ $(eval TMP_FILE := $(PKG_DIR)/.tmp-$($(1)_FILE)) \ $(if $($(1)_SOURCE_TREE),\ true\ $(else),\ mkdir -p '$(PKG_DIR)' && ( \ ($(WGET) -T 30 -t 3 -O '$(TMP_FILE)' '$($(1)_URL)' && \ $(call CHECK_PKG_ARCHIVE,$(1),'$(TMP_FILE)')) \ $(if $($(1)_URL_2), \ || (echo "MXE Warning! Downloading $(1) from second URL." >&2 && \ $(WGET) -T 30 -t 3 -O '$(TMP_FILE)' '$($(1)_URL_2)' && \ $(call CHECK_PKG_ARCHIVE,$(1),'$(TMP_FILE)'))) \ $(if $(MXE_NO_BACKUP_DL),, \ || $(BACKUP_DOWNLOAD)) \ ) && cat '$(TMP_FILE)' \ $(if $($(1)_FIX_GZIP), \ | gzip -d | gzip -9n, \ ) \ > '$(PKG_DIR)/$($(1)_FILE)' && \ $(if $(CREATE_SUFFIXED_ARCHIVE),cp '$(PKG_DIR)/$($(1)_FILE)' '$(PKG_DIR)/$($(1)_FILE)_$($(1)_CHECKSUM)' &&) \ rm '$(TMP_FILE)' || \ ( echo; \ echo 'Download failed!'; \ echo; \ rm -f '$(PKG_DIR)/$($(1)_FILE)' '$(TMP_FILE)'; )\ ) # open issue from 2002: # https://savannah.gnu.org/bugs/?712 ifneq ($(words $(PWD)),1) $(error GNU Make chokes on paths with spaces) endif # dollar signs also cause troubles ifneq (,$(findstring $$,$(PWD))) $(error GNU Make chokes on paths with dollar signs) endif ifeq ($(IGNORE_SETTINGS),yes) $(info [ignore settings.mk]) else ifeq ($(wildcard $(PWD)/settings.mk),$(PWD)/settings.mk) include $(PWD)/settings.mk else $(info [create settings.mk]) $(shell { \ echo '# This is a template of configuration file for MXE. See'; \ echo '# docs/index.html for more extensive documentations.'; \ echo; \ echo '# This variable controls the number of compilation processes'; \ echo '# within one package ("intra-package parallelism").'; \ echo '#JOBS := $(JOBS)'; \ echo; \ echo '# This variable controls where intermediate files are created'; \ echo '# this is necessary when compiling inside a virtualbox shared'; \ echo '# directory. Some commands like strip fail in there with Protocol error'; \ echo '# default is the current directory'; \ echo '#MXE_TMP := /tmp'; \ echo; \ echo '# This variable controls the targets that will build.'; \ echo '#MXE_TARGETS := $(MXE_TARGET_LIST)'; \ echo; \ echo '# This variable controls which plugins are in use.'; \ echo '# See plugins/README.md for further information.'; \ echo '#override MXE_PLUGIN_DIRS += plugins/apps plugins/native'; \ echo; \ echo '# This variable controls the download mirror for SourceForge,'; \ echo '# when it is used. Enabling the value below means auto.'; \ echo '#SOURCEFORGE_MIRROR := downloads.sourceforge.net'; \ echo; \ echo '# The three lines below makes `make` build these "local'; \ echo '# packages" instead of all packages.'; \ echo '#LOCAL_PKG_LIST := boost curl file flac lzo pthreads vorbis wxwidgets'; \ echo '#.DEFAULT_GOAL := local-pkg-list'; \ echo '#local-pkg-list: $$(LOCAL_PKG_LIST)'; \ } >'$(PWD)/settings.mk') endif ifneq ($(LOCAL_PKG_LIST),) .DEFAULT_GOAL := local-pkg-list $(info [pkg-list] $(LOCAL_PKG_LIST)) endif # Numeric min and max list functions LIST_NMAX = $(shell echo '$(strip $(1))' | tr ' ' '\n' | sort -n | tail -1) LIST_NMIN = $(shell echo '$(strip $(1))' | tr ' ' '\n' | sort -n | head -1) NPROCS := $(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) JOBS ?= $(call LIST_NMIN, $(DEFAULT_MAX_JOBS) $(NPROCS)) # Core packages. override MXE_PLUGIN_DIRS := \ $(realpath $(TOP_DIR)/src) \ $(realpath $(TOP_DIR)/src/qt/$(MXE_QT6_ID)) \ $(MXE_PLUGIN_DIRS) # Build native requirements for certain systems OS_SHORT_NAME := $(call lc,$(shell lsb_release -sc 2>/dev/null || uname -s)) override MXE_PLUGIN_DIRS += $(realpath $(TOP_DIR)/plugins/native/$(OS_SHORT_NAME)) .PHONY: check-requirements define CHECK_REQUIREMENT @if ! ( $(1) --help || $(1) help ) &>/dev/null; then \ echo 'Missing requirement: $(1)'; \ touch check-requirements-failed; \ fi endef define CHECK_REQUIREMENT_VERSION @if ! $(1) --version | head -1 | grep ' \($(2)\)$$' >/dev/null; then \ echo 'Wrong version of requirement: $(1)'; \ touch check-requirements-failed; \ fi endef %/.gitkeep: +@mkdir -p '$(dir $@)' @touch '$@' check-requirements: $(PREFIX)/installed/check-requirements $(PREFIX)/installed/check-requirements: $(MAKEFILE) | $(PREFIX)/installed/.gitkeep @echo '[check reqs]' $(foreach REQUIREMENT,$(REQUIREMENTS),$(call CHECK_REQUIREMENT,$(REQUIREMENT))) $(call CHECK_REQUIREMENT_VERSION,autoconf,2\.6[8-9]\|2\.[7-9][0-9]) $(call CHECK_REQUIREMENT_VERSION,automake,1\.11\.[3-9]\|1\.[1-9][2-9]\(\.[0-9]\+\)\?) @if [ -e check-requirements-failed ]; then \ echo; \ echo 'Please have a look at "docs/index.html" to ensure'; \ echo 'that your system meets all requirements.'; \ echo; \ rm check-requirements-failed; \ exit 1; \ fi @touch '$@' .PHONY: print-git-oneline print-git-oneline: $(PREFIX)/installed/print-git-oneline-$(GIT_HEAD) $(PREFIX)/installed/print-git-oneline-$(GIT_HEAD): | $(PREFIX)/installed/.gitkeep @git log --pretty=tformat:'[git-log] %h %s' -1 | cat @rm -f '$(PREFIX)/installed/print-git-oneline-'* @touch '$@' # Common dependency lists for `make` prerequisites and `build-pkg` # - `make` considers only explicit normal deps to trigger rebuilds # - packages can add themselves to implicit BOOTSTRAP_PKGS in the case # of a tool like `patch` which may be outdated on some systems