Merge pull request #925 from tonytheodore/toolchain

Toolchain re-org - target dependencies
This commit is contained in:
Tony Theodore 2015-10-25 13:02:30 +11:00
commit ffca3f5b83
17 changed files with 241 additions and 388 deletions

2
.gitignore vendored
View File

@ -10,6 +10,6 @@
# generated by build-pkg # generated by build-pkg
/*-*.list /*-*.list
/mxe-*.tar.xz /mxe-*.tar.xz
/mxe-*.deb /mxe-*.deb*
/wheezy /wheezy
/jessie /jessie

View File

@ -253,7 +253,8 @@ 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) NPROCS := $(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1)
JOBS_AUTO := $(call LIST_NMIN, $(DEFAULT_MAX_JOBS) $(NPROCS)) JOBS_AUTO := $(call LIST_NMIN, $(DEFAULT_MAX_JOBS) $(NPROCS))
JOBS := $(strip $(if $(findstring undefined,$(origin JOBS)),\ JOBS := $(strip $(if $(findstring undefined,$(origin JOBS)),\
$(info [using autodetected $(JOBS_AUTO) job(s)]) \ $(if $(and $(MAKECMDGOALS),$(filter $(MAKECMDGOALS),$(PKGS))), \
$(info [using autodetected $(JOBS_AUTO) job(s)])) \
$(JOBS_AUTO)\ $(JOBS_AUTO)\
,\ ,\
$(JOBS))) $(JOBS)))
@ -327,6 +328,21 @@ BUILD_PKGS := $(call set_create, \
$(SED) -n 's,.*src/\(.*\)\.mk,\1,p'), \ $(SED) -n 's,.*src/\(.*\)\.mk,\1,p'), \
$(if $(value $(call LOOKUP_PKG_RULE,$(PKG),BUILD,$(BUILD))), $(PKG)))) $(if $(value $(call LOOKUP_PKG_RULE,$(PKG),BUILD,$(BUILD))), $(PKG))))
# create target sets for PKG_TARGET_RULE loop to avoid creating empty rules
# and having to explicitly disable $(BUILD) for most packages
CROSS_TARGETS := $(filter-out $(BUILD),$(MXE_TARGETS))
$(foreach PKG,$(PKGS), \
$(foreach TARGET,$(or $(sort $($(PKG)_TARGETS)),$(CROSS_TARGETS)), \
$(eval $(TARGET)_PKGS += $(PKG)) \
$(eval FILTERED_PKGS += $(PKG))))
# cross targets depend on native target
$(foreach TARGET,$(CROSS_TARGETS),\
$(eval $(TARGET)_DEPS = $(BUILD)))
# always add $(BUILD) to our targets
override MXE_TARGETS := $(CROSS_TARGETS) $(BUILD)
# set column widths for build status messages # set column widths for build status messages
PKG_COL_WIDTH := $(call plus,2,$(call LIST_NMAX, $(sort $(call map, strlen, $(PKGS))))) PKG_COL_WIDTH := $(call plus,2,$(call LIST_NMAX, $(sort $(call map, strlen, $(PKGS)))))
MAX_TARGET_WIDTH := $(call LIST_NMAX, $(sort $(call map, strlen, $(MXE_TARGETS)))) MAX_TARGET_WIDTH := $(call LIST_NMAX, $(sort $(call map, strlen, $(MXE_TARGETS))))
@ -394,6 +410,7 @@ $(PREFIX)/$(3)/installed/$(1): $(TOP_DIR)/src/$(1).mk \
$(PATCHES) \ $(PATCHES) \
$(wildcard $(TOP_DIR)/src/$(1)-test*) \ $(wildcard $(TOP_DIR)/src/$(1)-test*) \
$(addprefix $(PREFIX)/$(3)/installed/,$(value $(call LOOKUP_PKG_RULE,$(1),DEPS,$(3)))) \ $(addprefix $(PREFIX)/$(3)/installed/,$(value $(call LOOKUP_PKG_RULE,$(1),DEPS,$(3)))) \
$(and $($(3)_DEPS),$(addprefix $(PREFIX)/$($(3)_DEPS)/installed/,$($($(3)_DEPS)_PKGS))) \
| $(if $(DONT_CHECK_REQUIREMENTS),,check-requirements) \ | $(if $(DONT_CHECK_REQUIREMENTS),,check-requirements) \
$(if $(value $(call LOOKUP_PKG_RULE,$(1),URL,$(3))),download-only-$(1)) \ $(if $(value $(call LOOKUP_PKG_RULE,$(1),URL,$(3))),download-only-$(1)) \
$(addprefix $(PREFIX)/$(3)/installed/,$(if $(call set_is_not_member,$(1),$(MXE_CONF_PKGS)),$(MXE_CONF_PKGS))) $(addprefix $(PREFIX)/$(3)/installed/,$(if $(call set_is_not_member,$(1),$(MXE_CONF_PKGS)),$(MXE_CONF_PKGS)))
@ -456,7 +473,7 @@ build-only-$(1)_$(3):
endef endef
$(foreach TARGET,$(MXE_TARGETS), \ $(foreach TARGET,$(MXE_TARGETS), \
$(shell [ -d '$(PREFIX)/$(TARGET)/installed' ] || mkdir -p '$(PREFIX)/$(TARGET)/installed') \ $(shell [ -d '$(PREFIX)/$(TARGET)/installed' ] || mkdir -p '$(PREFIX)/$(TARGET)/installed') \
$(foreach PKG,$(PKGS), \ $(foreach PKG,$($(TARGET)_PKGS), \
$(eval $(call PKG_TARGET_RULE,$(PKG),$(call TMP_DIR,$(PKG)-$(TARGET)),$(TARGET))))) $(eval $(call PKG_TARGET_RULE,$(PKG),$(call TMP_DIR,$(PKG)-$(TARGET)),$(TARGET)))))
# convenience set-like functions for unique lists # convenience set-like functions for unique lists
@ -495,7 +512,7 @@ RECURSIVELY_EXCLUDED_PKGS = \
$(call WALK_DOWNSTREAM,$(EXCLUDE_PKGS))) $(call WALK_DOWNSTREAM,$(EXCLUDE_PKGS)))
.PHONY: all-filtered .PHONY: all-filtered
all-filtered: $(filter-out $(call RECURSIVELY_EXCLUDED_PKGS),$(PKGS)) all-filtered: $(filter-out $(call RECURSIVELY_EXCLUDED_PKGS),$(FILTERED_PKGS))
# print a list of upstream dependencies and downstream dependents # print a list of upstream dependencies and downstream dependents
show-deps-%: show-deps-%:
@ -525,9 +542,24 @@ show-upstream-deps-%:
@echo -n,\ @echo -n,\
$(error Package $* not found in index.html)) $(error Package $* not found in index.html))
# print first level pkg deps for use in build-pkg.lua
.PHONY: print-deps-for-build-pkg
print-deps-for-build-pkg:
$(foreach TARGET,$(MXE_TARGETS), \
$(foreach PKG,$(sort $($(TARGET)_PKGS)), \
$(info for-build-pkg $(TARGET)~$(PKG) \
$(subst $(space),-,$($(PKG)_VERSION)) \
$(addprefix $(TARGET)~,$(value $(call LOOKUP_PKG_RULE,$(PKG),DEPS,$(TARGET)))) \
$(addprefix $(TARGET)~,$(if $(call set_is_not_member,$(PKG),$(MXE_CONF_PKGS)),$(MXE_CONF_PKGS))) \
$(and $($(TARGET)_DEPS),$(addprefix $($(TARGET)_DEPS)~,$($($(TARGET)_DEPS)_PKGS))))))
@echo -n
BUILD_PKG_TMP_FILES := *-*.list mxe-*.tar.xz mxe-*.deb* wheezy jessie
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf $(call TMP_DIR,*) $(PREFIX) build-matrix.html rm -rf $(call TMP_DIR,*) $(PREFIX) build-matrix.html \
$(addprefix $(TOP_DIR)/, $(BUILD_PKG_TMP_FILES))
.PHONY: clean-pkg .PHONY: clean-pkg
clean-pkg: clean-pkg:

View File

@ -1290,22 +1290,6 @@ local-pkg-list: $(LOCAL_PKG_LIST)</pre>
<td class="package">gcc</td> <td class="package">gcc</td>
<td class="website"><a href="http://gcc.gnu.org/">GCC</a></td> <td class="website"><a href="http://gcc.gnu.org/">GCC</a></td>
</tr> </tr>
<tr>
<td class="package">gcc-gmp</td>
<td class="website"><a href="http://www.gmplib.org/">GMP for GCC</a></td>
</tr>
<tr>
<td class="package">gcc-isl</td>
<td class="website"><a href="http://isl.gforge.inria.fr/">ISL for GCC</a></td>
</tr>
<tr>
<td class="package">gcc-mpc</td>
<td class="website"><a href="http://www.multiprecision.org/">MPC for GCC</a></td>
</tr>
<tr>
<td class="package">gcc-mpfr</td>
<td class="website"><a href="http://www.mpfr.org/">MPFR for GCC</a></td>
</tr>
<tr> <tr>
<td class="package">gd</td> <td class="package">gd</td>
<td class="website"><a href="http://www.libgd.org/">GD (without support for xpm)</a></td> <td class="website"><a href="http://www.libgd.org/">GD (without support for xpm)</a></td>

View File

@ -1,27 +0,0 @@
# This file is part of MXE.
# See index.html for further information.
PKG := gcc-gmp
$(PKG)_IGNORE = $(gmp_IGNORE)
$(PKG)_VERSION = $(gmp_VERSION)
$(PKG)_CHECKSUM = $(gmp_CHECKSUM)
$(PKG)_SUBDIR = $(gmp_SUBDIR)
$(PKG)_FILE = $(gmp_FILE)
$(PKG)_URL = $(gmp_URL)
$(PKG)_URL_2 = $(gmp_URL_2)
$(PKG)_DEPS :=
define $(PKG)_UPDATE
echo $(gmp_VERSION)
endef
define $(PKG)_BUILD
mkdir '$(1).build'
cd '$(1).build' && '$(1)/configure' \
--prefix='$(PREFIX)' \
--disable-shared
$(MAKE) -C '$(1).build' -j '$(JOBS)'
$(MAKE) -C '$(1).build' -j 1 install
endef
$(PKG)_BUILD_$(BUILD) =

View File

@ -1,28 +0,0 @@
# This file is part of MXE.
# See index.html for further information.
PKG := gcc-isl
$(PKG)_IGNORE = $(isl_IGNORE)
$(PKG)_VERSION = $(isl_VERSION)
$(PKG)_CHECKSUM = $(isl_CHECKSUM)
$(PKG)_SUBDIR = $(isl_SUBDIR)
$(PKG)_FILE = $(isl_FILE)
$(PKG)_URL = $(isl_URL)
$(PKG)_URL_2 = $(isl_URL_2)
$(PKG)_DEPS := gcc-gmp
define $(PKG)_UPDATE
echo $(isl_VERSION)
endef
define $(PKG)_BUILD
mkdir '$(1).build'
cd '$(1).build' && '$(1)/configure' \
--prefix='$(PREFIX)' \
--disable-shared \
--with-gmp-prefix='$(PREFIX)'
$(MAKE) -C '$(1).build' -j '$(JOBS)'
$(MAKE) -C '$(1).build' -j 1 install
endef
$(PKG)_BUILD_$(BUILD) =

View File

@ -1,28 +0,0 @@
# This file is part of MXE.
# See index.html for further information.
PKG := gcc-mpc
$(PKG)_IGNORE = $(mpc_IGNORE)
$(PKG)_VERSION = $(mpc_VERSION)
$(PKG)_CHECKSUM = $(mpc_CHECKSUM)
$(PKG)_SUBDIR = $(mpc_SUBDIR)
$(PKG)_FILE = $(mpc_FILE)
$(PKG)_URL = $(mpc_URL)
$(PKG)_URL_2 = $(mpc_URL_2)
$(PKG)_DEPS := gcc-gmp gcc-mpfr
define $(PKG)_UPDATE
echo $(mpc_VERSION)
endef
define $(PKG)_BUILD
mkdir '$(1).build'
cd '$(1).build' && '$(1)/configure' \
--prefix='$(PREFIX)' \
--disable-shared \
--with-gmp='$(PREFIX)'
$(MAKE) -C '$(1).build' -j '$(JOBS)'
$(MAKE) -C '$(1).build' -j 1 install
endef
$(PKG)_BUILD_$(BUILD) =

View File

@ -1,28 +0,0 @@
# This file is part of MXE.
# See index.html for further information.
PKG := gcc-mpfr
$(PKG)_IGNORE = $(mpfr_IGNORE)
$(PKG)_VERSION = $(mpfr_VERSION)
$(PKG)_CHECKSUM = $(mpfr_CHECKSUM)
$(PKG)_SUBDIR = $(mpfr_SUBDIR)
$(PKG)_FILE = $(mpfr_FILE)
$(PKG)_URL = $(mpfr_URL)
$(PKG)_URL_2 = $(mpfr_URL_2)
$(PKG)_DEPS := gcc-gmp
define $(PKG)_UPDATE
echo $(mpfr_VERSION)
endef
define $(PKG)_BUILD
mkdir '$(1).build'
cd '$(1).build' && '$(1)/configure' \
--prefix='$(PREFIX)' \
--disable-shared \
--with-gmp='$(PREFIX)'
$(MAKE) -C '$(1).build' -j '$(JOBS)'
$(MAKE) -C '$(1).build' -j 1 install
endef
$(PKG)_BUILD_$(BUILD) =

View File

@ -9,7 +9,7 @@ $(PKG)_SUBDIR := gcc-$($(PKG)_VERSION)
$(PKG)_FILE := gcc-$($(PKG)_VERSION).tar.bz2 $(PKG)_FILE := gcc-$($(PKG)_VERSION).tar.bz2
$(PKG)_URL := http://ftp.gnu.org/pub/gnu/gcc/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE) $(PKG)_URL := http://ftp.gnu.org/pub/gnu/gcc/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE)
$(PKG)_URL_2 := ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE) $(PKG)_URL_2 := ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE)
$(PKG)_DEPS := binutils gcc-gmp gcc-isl gcc-mpc gcc-mpfr mingw-w64 $(PKG)_DEPS := binutils mingw-w64
$(PKG)_FILE_$(BUILD) := $(PKG)_FILE_$(BUILD) :=
@ -40,10 +40,10 @@ define $(PKG)_CONFIGURE
--disable-win32-registry \ --disable-win32-registry \
--enable-threads=win32 \ --enable-threads=win32 \
--disable-libgomp \ --disable-libgomp \
--with-gmp='$(PREFIX)' \ --with-gmp='$(PREFIX)/$(BUILD)' \
--with-isl='$(PREFIX)' \ --with-isl='$(PREFIX)/$(BUILD)' \
--with-mpc='$(PREFIX)' \ --with-mpc='$(PREFIX)/$(BUILD)' \
--with-mpfr='$(PREFIX)' \ --with-mpfr='$(PREFIX)/$(BUILD)' \
--with-as='$(PREFIX)/bin/$(TARGET)-as' \ --with-as='$(PREFIX)/bin/$(TARGET)-as' \
--with-ld='$(PREFIX)/bin/$(TARGET)-ld' \ --with-ld='$(PREFIX)/bin/$(TARGET)-ld' \
--with-nm='$(PREFIX)/bin/$(TARGET)-nm' \ --with-nm='$(PREFIX)/bin/$(TARGET)-nm' \
@ -55,8 +55,11 @@ define $(PKG)_POST_BUILD
rm -f $(addprefix $(PREFIX)/$(TARGET)/bin/, c++ g++ gcc gfortran) rm -f $(addprefix $(PREFIX)/$(TARGET)/bin/, c++ g++ gcc gfortran)
-mv '$(PREFIX)/lib/gcc/$(TARGET)/lib/'* '$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)/' -mv '$(PREFIX)/lib/gcc/$(TARGET)/lib/'* '$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)/'
-mv '$(PREFIX)/lib/gcc/$(TARGET)/'*.dll '$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)/' -mv '$(PREFIX)/lib/gcc/$(TARGET)/'*.dll '$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)/'
-cp '$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)/'*.dll '$(PREFIX)/$(TARGET)/bin/' -mv '$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)/'*.dll '$(PREFIX)/$(TARGET)/bin/'
-cp '$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)/'*.dll.a '$(PREFIX)/$(TARGET)/lib/' -cp '$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)/'*.dll.a '$(PREFIX)/$(TARGET)/lib/'
# remove incorrectly installed libcc1
rm -f '$(PREFIX)/lib/'libcc1*
endef endef
define $(PKG)_BUILD_mingw-w64 define $(PKG)_BUILD_mingw-w64
@ -78,6 +81,9 @@ define $(PKG)_BUILD_mingw-w64
# build rest of gcc # build rest of gcc
cd '$(1).build' cd '$(1).build'
$(MAKE) -C '$(1).build' -j '$(JOBS)' $(MAKE) -C '$(1).build' -j '$(JOBS)'
# cc1libdir isn't passed to subdirs so install correctly and rm later
$(MAKE) -C '$(1).build/libcc1' -j 1 install cc1libdir='$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)'
$(MAKE) -C '$(1).build' -j 1 install $(MAKE) -C '$(1).build' -j 1 install
$($(PKG)_POST_BUILD) $($(PKG)_POST_BUILD)

View File

@ -18,7 +18,7 @@ define $(PKG)_BUILD
cd '$(1)/mingw-w64-tools/gendef' && ./configure \ cd '$(1)/mingw-w64-tools/gendef' && ./configure \
--host='$(BUILD)' \ --host='$(BUILD)' \
--build='$(BUILD)' \ --build='$(BUILD)' \
--prefix='$(PREFIX)' \ --prefix='$(PREFIX)/$(TARGET)' \
--target='$(TARGET)' --target='$(TARGET)'
$(MAKE) -C '$(1)/mingw-w64-tools/gendef' -j '$(JOBS)' install $(MAKE) -C '$(1)/mingw-w64-tools/gendef' -j '$(JOBS)' install
endef endef

View File

@ -9,8 +9,11 @@ $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION)
$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION)a.tar.bz2 $(PKG)_FILE := $(PKG)-$($(PKG)_VERSION)a.tar.bz2
$(PKG)_URL := http://ftp.gnu.org/gnu/$(PKG)/$($(PKG)_FILE) $(PKG)_URL := http://ftp.gnu.org/gnu/$(PKG)/$($(PKG)_FILE)
$(PKG)_URL_2 := ftp://ftp.cs.tu-berlin.de/pub/gnu/$(PKG)/$($(PKG)_FILE) $(PKG)_URL_2 := ftp://ftp.cs.tu-berlin.de/pub/gnu/$(PKG)/$($(PKG)_FILE)
$(PKG)_TARGETS := $(BUILD) $(MXE_TARGETS)
$(PKG)_DEPS := gcc $(PKG)_DEPS := gcc
$(PKG)_DEPS_$(BUILD) :=
define $(PKG)_UPDATE define $(PKG)_UPDATE
$(WGET) -q -O- 'http://www.gmplib.org/' | \ $(WGET) -q -O- 'http://www.gmplib.org/' | \
grep '<a href="' | \ grep '<a href="' | \
@ -41,8 +44,7 @@ endef
define $(PKG)_BUILD_$(BUILD) define $(PKG)_BUILD_$(BUILD)
mkdir '$(1).build' mkdir '$(1).build'
cd '$(1).build' && '$(1)/configure' \ cd '$(1).build' && '$(1)/configure' \
--prefix='$(PREFIX)/$(TARGET)' \ $(MXE_CONFIGURE_OPTS)
--disable-shared
$(MAKE) -C '$(1).build' -j '$(JOBS)' man1_MANS= $(MAKE) -C '$(1).build' -j '$(JOBS)' man1_MANS=
$(MAKE) -C '$(1).build' -j 1 install man1_MANS= $(MAKE) -C '$(1).build' -j 1 install man1_MANS=
endef endef

View File

@ -9,8 +9,11 @@ $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION)
$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.bz2 $(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.bz2
$(PKG)_URL := http://isl.gforge.inria.fr/$($(PKG)_FILE) $(PKG)_URL := http://isl.gforge.inria.fr/$($(PKG)_FILE)
$(PKG)_URL_2 := ftp://gcc.gnu.org/pub/gcc/infrastructure/$($(PKG)_FILE) $(PKG)_URL_2 := ftp://gcc.gnu.org/pub/gcc/infrastructure/$($(PKG)_FILE)
$(PKG)_TARGETS := $(BUILD) $(MXE_TARGETS)
$(PKG)_DEPS := gcc gmp $(PKG)_DEPS := gcc gmp
$(PKG)_DEPS_$(BUILD) := gmp
# stick to tested versions from gcc # stick to tested versions from gcc
define $(PKG)_UPDATE define $(PKG)_UPDATE
$(WGET) -q -O- 'ftp://gcc.gnu.org/pub/gcc/infrastructure/' | \ $(WGET) -q -O- 'ftp://gcc.gnu.org/pub/gcc/infrastructure/' | \
@ -21,10 +24,7 @@ endef
define $(PKG)_BUILD define $(PKG)_BUILD
cd '$(1)' && ./configure \ cd '$(1)' && ./configure \
--host='$(TARGET)' \ $(MXE_CONFIGURE_OPTS) \
--enable-static \
--disable-shared \
--prefix='$(PREFIX)/$(TARGET)' \
--with-gmp-prefix='$(PREFIX)/$(TARGET)' --with-gmp-prefix='$(PREFIX)/$(TARGET)'
$(MAKE) -C '$(1)' -j '$(JOBS)' $(MAKE) -C '$(1)' -j '$(JOBS)'
$(MAKE) -C '$(1)' -j '$(JOBS)' install $(MAKE) -C '$(1)' -j '$(JOBS)' install

View File

@ -9,22 +9,28 @@ $(PKG)_SUBDIR := mpc-$($(PKG)_VERSION)
$(PKG)_FILE := mpc-$($(PKG)_VERSION).tar.gz $(PKG)_FILE := mpc-$($(PKG)_VERSION).tar.gz
$(PKG)_URL := http://www.multiprecision.org/mpc/download/$($(PKG)_FILE) $(PKG)_URL := http://www.multiprecision.org/mpc/download/$($(PKG)_FILE)
$(PKG)_URL_2 := http://ftp.debian.org/debian/pool/main/m/mpclib/mpclib_$($(PKG)_VERSION).orig.tar.gz $(PKG)_URL_2 := http://ftp.debian.org/debian/pool/main/m/mpclib/mpclib_$($(PKG)_VERSION).orig.tar.gz
$(PKG)_TARGETS := $(BUILD) $(MXE_TARGETS)
$(PKG)_DEPS := gcc gmp mpfr $(PKG)_DEPS := gcc gmp mpfr
$(PKG)_DEPS_$(BUILD) := gmp mpfr
define $(PKG)_UPDATE define $(PKG)_UPDATE
$(WGET) -q -O- 'https://gforge.inria.fr/scm/viewvc.php/tags/?root=mpc&sortby=date' | \ $(WGET) -q -O- 'https://gforge.inria.fr/scm/viewvc.php/tags/?root=mpc&sortby=date' | \
$(SED) -n 's,.*<a name="\([0-9][^"]*\)".*,\1,p' | \ $(SED) -n 's,.*<a name="\([0-9][^"]*\)".*,\1,p' | \
head -1 head -1
endef endef
define $(PKG)_BUILD define $(PKG)_BUILD_$(BUILD)
cd '$(1)' && ./configure \ cd '$(1)' && ./configure \
$(MXE_CONFIGURE_OPTS) \ $(MXE_CONFIGURE_OPTS) \
--with-gmp='$(PREFIX)/$(TARGET)/' \ --with-gmp='$(PREFIX)/$(TARGET)/' \
--with-mpfr='$(PREFIX)/$(TARGET)/' --with-mpfr='$(PREFIX)/$(TARGET)/'
$(MAKE) -C '$(1)' -j '$(JOBS)' $(MAKE) -C '$(1)' -j '$(JOBS)'
$(MAKE) -C '$(1)' -j '$(JOBS)' install $(MAKE) -C '$(1)' -j '$(JOBS)' install
endef
define $(PKG)_BUILD
$($(PKG)_BUILD_$(BUILD))
# build runtime tests to verify toolchain components # build runtime tests to verify toolchain components
-$(MAKE) -C '$(1)' -j '$(JOBS)' check -k -$(MAKE) -C '$(1)' -j '$(JOBS)' check -k
rm -rf '$(PREFIX)/$(TARGET)/bin/$(PKG)-tests' rm -rf '$(PREFIX)/$(TARGET)/bin/$(PKG)-tests'

View File

@ -9,8 +9,11 @@ $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION)
$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.xz $(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.xz
$(PKG)_URL := ftp://ftp.gnu.org/pub/gnu/$(PKG)/$($(PKG)_FILE) $(PKG)_URL := ftp://ftp.gnu.org/pub/gnu/$(PKG)/$($(PKG)_FILE)
$(PKG)_URL_2 := http://www.mpfr.org/mpfr-$($(PKG)_VERSION)/$($(PKG)_FILE) $(PKG)_URL_2 := http://www.mpfr.org/mpfr-$($(PKG)_VERSION)/$($(PKG)_FILE)
$(PKG)_TARGETS := $(BUILD) $(MXE_TARGETS)
$(PKG)_DEPS := gcc gmp $(PKG)_DEPS := gcc gmp
$(PKG)_DEPS_$(BUILD) := gmp
define $(PKG)_UPDATE define $(PKG)_UPDATE
$(WGET) -q -O- 'http://www.mpfr.org/mpfr-current/#download' | \ $(WGET) -q -O- 'http://www.mpfr.org/mpfr-current/#download' | \
grep 'mpfr-' | \ grep 'mpfr-' | \
@ -37,3 +40,12 @@ define $(PKG)_BUILD
printf 'for /R %%%%f in (*.exe) do %%%%f || echo %%%%f fail >> all-tests-$(PKG)-$($(PKG)_VERSION).txt\r\n';) \ printf 'for /R %%%%f in (*.exe) do %%%%f || echo %%%%f fail >> all-tests-$(PKG)-$($(PKG)_VERSION).txt\r\n';) \
> '$(PREFIX)/$(TARGET)/bin/$(PKG)-tests/all-tests-$(PKG)-$($(PKG)_VERSION).bat' > '$(PREFIX)/$(TARGET)/bin/$(PKG)-tests/all-tests-$(PKG)-$($(PKG)_VERSION).bat'
endef endef
define $(PKG)_BUILD_$(BUILD)
mkdir '$(1).build'
cd '$(1).build' && '$(1)/configure' \
$(MXE_CONFIGURE_OPTS) \
--with-gmp='$(PREFIX)/$(TARGET)'
$(MAKE) -C '$(1).build' -j '$(JOBS)'
$(MAKE) -C '$(1).build' -j 1 install
endef

View File

@ -4,17 +4,14 @@
PKG := mxe-conf PKG := mxe-conf
$(PKG)_VERSION := 1 $(PKG)_VERSION := 1
$(PKG)_UPDATE := echo 1 $(PKG)_UPDATE := echo 1
$(PKG)_TARGETS := $(BUILD) $(MXE_TARGETS)
define $(PKG)_BUILD_COMMON define $(PKG)_BUILD
# install target-specific autotools config file # install target-specific autotools config file
$(INSTALL) -d '$(PREFIX)/$(TARGET)/share' $(INSTALL) -d '$(PREFIX)/$(TARGET)/share'
# setting ac_cv_build bypasses the config.guess check in every package # setting ac_cv_build bypasses the config.guess check in every package
echo "ac_cv_build=$(BUILD)" > '$(PREFIX)/$(TARGET)/share/config.site' echo "ac_cv_build=$(BUILD)" > '$(PREFIX)/$(TARGET)/share/config.site'
# install config.guess for general use
$(INSTALL) -d '$(PREFIX)/bin'
$(INSTALL) -m755 '$(EXT_DIR)/config.guess' '$(PREFIX)/bin/'
# create the CMake toolchain file # create the CMake toolchain file
# individual packages (e.g. hdf5) should add their # individual packages (e.g. hdf5) should add their
# own files under CMAKE_TOOLCHAIN_DIR # own files under CMAKE_TOOLCHAIN_DIR
@ -31,7 +28,7 @@ define $(PKG)_BUILD_COMMON
echo 'set(CMAKE_CXX_COMPILER $(PREFIX)/bin/$(TARGET)-g++)'; \ echo 'set(CMAKE_CXX_COMPILER $(PREFIX)/bin/$(TARGET)-g++)'; \
echo 'set(CMAKE_Fortran_COMPILER $(PREFIX)/bin/$(TARGET)-gfortran)'; \ echo 'set(CMAKE_Fortran_COMPILER $(PREFIX)/bin/$(TARGET)-gfortran)'; \
echo 'set(CMAKE_RC_COMPILER $(PREFIX)/bin/$(TARGET)-windres)'; \ echo 'set(CMAKE_RC_COMPILER $(PREFIX)/bin/$(TARGET)-windres)'; \
echo 'set(CMAKE_MODULE_PATH "$(PWD)/src/cmake/modules" $${CMAKE_MODULE_PATH}) # For mxe FindPackage scripts'; \ echo 'set(CMAKE_MODULE_PATH "$(PREFIX)/share/cmake/modules" $${CMAKE_MODULE_PATH}) # For mxe FindPackage scripts'; \
echo 'set(CMAKE_INSTALL_PREFIX $(PREFIX)/$(TARGET) CACHE PATH "Installation Prefix")'; \ echo 'set(CMAKE_INSTALL_PREFIX $(PREFIX)/$(TARGET) CACHE PATH "Installation Prefix")'; \
echo 'set(CMAKE_BUILD_TYPE Release CACHE STRING "Debug|Release|RelWithDebInfo|MinSizeRel")'; \ echo 'set(CMAKE_BUILD_TYPE Release CACHE STRING "Debug|Release|RelWithDebInfo|MinSizeRel")'; \
echo 'set(CMAKE_CROSS_COMPILING ON) # Workaround for http://www.cmake.org/Bug/view.php?id=14075'; \ echo 'set(CMAKE_CROSS_COMPILING ON) # Workaround for http://www.cmake.org/Bug/view.php?id=14075'; \
@ -66,10 +63,6 @@ define $(PKG)_BUILD_COMMON
#create readonly directory to force wine to fail #create readonly directory to force wine to fail
$(INSTALL) -m444 -d "$$WINEPREFIX" $(INSTALL) -m444 -d "$$WINEPREFIX"
endef
define $(PKG)_BUILD
$($(PKG)_BUILD_COMMON)
# create pkg-config files for OpenGL/GLU # create pkg-config files for OpenGL/GLU
$(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/pkgconfig' $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/pkgconfig'
@ -85,6 +78,17 @@ define $(PKG)_BUILD
echo 'Libs: -lglu32';) \ echo 'Libs: -lglu32';) \
> '$(PREFIX)/$(TARGET)/lib/pkgconfig/glu.pc' > '$(PREFIX)/$(TARGET)/lib/pkgconfig/glu.pc'
endef
define $(PKG)_BUILD_$(BUILD)
# install config.guess for general use
$(INSTALL) -d '$(PREFIX)/bin'
$(INSTALL) -m755 '$(EXT_DIR)/config.guess' '$(PREFIX)/bin/'
# install cmake modules
$(INSTALL) -d '$(PREFIX)/share/cmake/modules'
$(INSTALL) -m644 '$(PWD)/src/cmake/modules/'* '$(PREFIX)/share/cmake/modules'
# fail early if autotools can't autoreconf # fail early if autotools can't autoreconf
# 1. detect mismatches in installation locations # 1. detect mismatches in installation locations
# 2. ??? # 2. ???
@ -97,5 +101,3 @@ define $(PKG)_BUILD
cd '$(1)' && autoreconf -fiv cd '$(1)' && autoreconf -fiv
cd '$(1)' && ./configure cd '$(1)' && ./configure
endef endef
$(PKG)_BUILD_$(BUILD) = $($(PKG)_BUILD_COMMON)

View File

@ -8,10 +8,9 @@ $(PKG)_CHECKSUM := 91b2e5d7ce06583d5920c373b61d7d6554cd085cbd61ed176c7ff7ff30325
$(PKG)_SUBDIR := $(PKG)-$(PKG)-$($(PKG)_VERSION) $(PKG)_SUBDIR := $(PKG)-$(PKG)-$($(PKG)_VERSION)
$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.gz $(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.gz
$(PKG)_URL := http://github.com/$(PKG)/$(PKG)/tarball/$($(PKG)_VERSION)/$($(PKG)_FILE) $(PKG)_URL := http://github.com/$(PKG)/$(PKG)/tarball/$($(PKG)_VERSION)/$($(PKG)_FILE)
$(PKG)_TARGETS := $(BUILD) $(MXE_TARGETS)
$(PKG)_DEPS := $(PKG)_DEPS :=
$(PKG)_DEPS_$(BUILD) := automake
$(PKG)_UPDATE = $(call MXE_GET_GITHUB_SHA, pkgconf/pkgconf, master) $(PKG)_UPDATE = $(call MXE_GET_GITHUB_SHA, pkgconf/pkgconf, master)
define $(PKG)_UPDATE define $(PKG)_UPDATE
@ -20,15 +19,9 @@ define $(PKG)_UPDATE
endef endef
define $(PKG)_BUILD define $(PKG)_BUILD
cd '$(1)' && ./autogen.sh
cd '$(1)' && ./configure \
--prefix='$(PREFIX)/$(TARGET)'
$(MAKE) -C '$(1)' -j '$(JOBS)'
$(MAKE) -C '$(1)' -j 1 install
# create pkg-config script # create pkg-config script
(echo '#!/bin/sh'; \ (echo '#!/bin/sh'; \
echo 'PKG_CONFIG_PATH="$(PREFIX)/$(TARGET)/qt5/lib/pkgconfig":"$$PKG_CONFIG_PATH_$(subst .,_,$(subst -,_,$(TARGET)))" PKG_CONFIG_LIBDIR='\''$(PREFIX)/$(TARGET)/lib/pkgconfig'\'' exec '$(PREFIX)/$(TARGET)/bin/pkgconf' $(if $(BUILD_STATIC),--static) "$$@"') \ echo 'PKG_CONFIG_PATH="$(PREFIX)/$(TARGET)/qt5/lib/pkgconfig":"$$PKG_CONFIG_PATH_$(subst .,_,$(subst -,_,$(TARGET)))" PKG_CONFIG_LIBDIR='\''$(PREFIX)/$(TARGET)/lib/pkgconfig'\'' exec '$(PREFIX)/$(BUILD)/bin/pkgconf' $(if $(BUILD_STATIC),--static) "$$@"') \
> '$(PREFIX)/bin/$(TARGET)-pkg-config' > '$(PREFIX)/bin/$(TARGET)-pkg-config'
chmod 0755 '$(PREFIX)/bin/$(TARGET)-pkg-config' chmod 0755 '$(PREFIX)/bin/$(TARGET)-pkg-config'
@ -37,3 +30,11 @@ define $(PKG)_BUILD
> '$(CMAKE_TOOLCHAIN_DIR)/pkgconf.cmake' > '$(CMAKE_TOOLCHAIN_DIR)/pkgconf.cmake'
endef endef
define $(PKG)_BUILD_$(BUILD)
cd '$(1)' && ./autogen.sh
cd '$(1)' && ./configure \
--prefix='$(PREFIX)/$(TARGET)'
$(MAKE) -C '$(1)' -j '$(JOBS)'
$(MAKE) -C '$(1)' -j 1 install
endef

View File

@ -7,8 +7,11 @@ $(PKG)_CHECKSUM := 3dce6601b495f5b3d45b59f7d2492a340ee7e84b5beca17e48f862502bd56
$(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION) $(PKG)_SUBDIR := $(PKG)-$($(PKG)_VERSION)
$(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.gz $(PKG)_FILE := $(PKG)-$($(PKG)_VERSION).tar.gz
$(PKG)_URL := http://www.tortall.net/projects/$(PKG)/releases/$($(PKG)_FILE) $(PKG)_URL := http://www.tortall.net/projects/$(PKG)/releases/$($(PKG)_FILE)
$(PKG)_TARGETS := $(BUILD) $(MXE_TARGETS)
$(PKG)_DEPS := gcc $(PKG)_DEPS := gcc
$(PKG)_DEPS_$(BUILD) :=
define $(PKG)_UPDATE define $(PKG)_UPDATE
$(WGET) -q -O- 'https://github.com/yasm/yasm/tags' | \ $(WGET) -q -O- 'https://github.com/yasm/yasm/tags' | \
$(SED) -n 's,.*href="/yasm/yasm/archive/v\([0-9][^"]*\)\.tar.*,\1,p' | \ $(SED) -n 's,.*href="/yasm/yasm/archive/v\([0-9][^"]*\)\.tar.*,\1,p' | \
@ -16,21 +19,14 @@ define $(PKG)_UPDATE
endef endef
define $(PKG)_BUILD define $(PKG)_BUILD
# native build of yasm - will the same for all targets # link to native yasm compiler on cross builds
# but we don't want to conflict with an un-prefixed version $(if $(call sne,$(TARGET),$(BUILD)),
mkdir '$(1).native' ln -sf '$(PREFIX)/$(BUILD)/bin/yasm' '$(PREFIX)/bin/$(TARGET)-yasm')
cd '$(1).native' && '$(1)/configure' \
--prefix='$(PREFIX)' \
--program-prefix='$(TARGET)-' \
--disable-nls \
--disable-python
$(MAKE) -C '$(1).native' -j '$(JOBS)' install
# yasm is always static # yasm is always static
cd '$(1)' && '$(1)/configure' \ cd '$(1)' && '$(1)/configure' \
--host='$(TARGET)' \ $(MXE_CONFIGURE_OPTS) \
--build="`config.guess`" \ --disable-nls \
--prefix='$(PREFIX)/$(TARGET)' \ --disable-python
--disable-nls
$(MAKE) -C '$(1)' -j '$(JOBS)' install $(MAKE) -C '$(1)' -j '$(JOBS)' install
endef endef

View File

@ -22,7 +22,7 @@ set environment variable MXE_NO_DEBS to 1
In this case fakeroot and dpkg-deb are not needed. In this case fakeroot and dpkg-deb are not needed.
To limit number of packages being built to x, To limit number of packages being built to x,
set environment variable MXE_MAX_PACKAGES to x, set environment variable MXE_MAX_ITEMS to x,
The following error: The following error:
> fakeroot, while creating message channels: Invalid argument > fakeroot, while creating message channels: Invalid argument
@ -32,7 +32,7 @@ can be caused by leaked ipc resources originating in fakeroot.
How to remove them: http://stackoverflow.com/a/4262545 How to remove them: http://stackoverflow.com/a/4262545
]] ]]
local max_packages = tonumber(os.getenv('MXE_MAX_PACKAGES')) local max_items = tonumber(os.getenv('MXE_MAX_ITEMS'))
local no_debs = os.getenv('MXE_NO_DEBS') local no_debs = os.getenv('MXE_NO_DEBS')
local ARCH = 'amd64' local ARCH = 'amd64'
@ -43,47 +43,15 @@ local GIT = 'git --work-tree=./usr/ --git-dir=./usr/.git '
local BLACKLIST = { local BLACKLIST = {
'^usr/installed/check%-requirements$', '^usr/installed/check%-requirements$',
'^usr/share/', -- usr/share/cmake if useful
'^usr/share/doc/',
'^usr/share/info/',
'^usr/share/man/',
'^usr/share/gcc',
'^usr/[^/]+/share/doc/', '^usr/[^/]+/share/doc/',
'^usr/[^/]+/share/info/', '^usr/[^/]+/share/info/',
} }
local COMMON_FILES = {
['gcc-isl'] = {
'^usr/include/isl/',
'^usr/lib/libisl%.',
'^usr/lib/pkgconfig/isl.pc$',
},
['gcc-mpc'] = {
'^usr/include/mpc.h$',
'^usr/lib/libmpc%.',
},
['gcc-gmp'] = {
'^usr/include/gmp.h$',
'^usr/lib/libgmp%.',
},
['gcc-mpfr'] = {
'^usr/include/mpf2mpfr.h$',
'^usr/include/mpfr.h$',
'^usr/lib/libmpfr%.',
},
['gcc'] = {
'^usr/lib/libcc1%.',
},
['yasm'] = {
'^usr/include/libyasm',
'^usr/lib/libyasm.a$',
},
['ncurses'] = {
'^usr/lib/pkgconfig/',
},
['pkgconf'] = {
'^usr/bin/config.guess$',
},
}
local ARCH_FOR_COMMON = 'i686-w64-mingw32.static'
local TARGETS = { local TARGETS = {
'i686-w64-mingw32.static', 'i686-w64-mingw32.static',
'x86_64-w64-mingw32.static', 'x86_64-w64-mingw32.static',
@ -91,10 +59,8 @@ local TARGETS = {
'x86_64-w64-mingw32.shared', 'x86_64-w64-mingw32.shared',
} }
local target -- used by many functions
local function log(fmt, ...) local function log(fmt, ...)
print('[build-pkg]', target, fmt:format(...)) print('[build-pkg]', fmt:format(...))
end end
-- based on http://lua-users.org/wiki/SplitJoin -- based on http://lua-users.org/wiki/SplitJoin
@ -129,14 +95,27 @@ local function trim(str)
end end
local function isInArray(element, array) local function isInArray(element, array)
for _, item in ipairs(array) do for _, member in ipairs(array) do
if item == element then if member == element then
return true return true
end end
end end
return false return false
end end
local function sliceArray(list, nelements)
nelements = nelements or #list
local new_list = {}
for i = 1, nelements do
new_list[i] = list[i]
end
return new_list
end
local function isInString(substring, string)
return string:find(substring, 1, true)
end
local function shell(cmd) local function shell(cmd)
local f = io.popen(cmd, 'r') local f = io.popen(cmd, 'r')
local text = f:read('*all') local text = f:read('*all')
@ -179,34 +158,27 @@ local function fileExists(name)
end end
end end
-- return several tables describing packages local NATIVE_TARGET = trim(shell("ext/config.guess"))
-- * list of packages local function isCross(target)
-- * map from package to list of deps return target ~= NATIVE_TARGET
-- * map from package to version of package end
local function getPkgs()
-- create file deps.mk showing deps -- return target and package from item name
-- (make show-upstream-deps-% does not present in local function parseItem(item)
-- stable MXE) return item:match("([^~]+)~([^~]+)")
local deps_mk_content = [[ end
include Makefile
NOTHING:= -- return several tables describing packages for all targets
SPACE:=$(NOTHING) $(NOTHING) -- * list of items
NAME_WITH_UNDERSCORES:=$(subst $(SPACE),_,$(NAME)) -- * map from item to list of deps (which are also items)
print-deps: -- * map from item to version
@$(foreach pkg,$(PKGS),echo \ -- Item is a string like "target~pkg"
for-build-pkg $(pkg) \ local function getItems()
$(subst $(SPACE),-,$($(pkg)_VERSION)) \ local items = {}
$($(pkg)_DEPS) \ local item2deps = {}
$(if $(call set_is_not_member,$(pkg),$(MXE_CONF_PKGS)), \ local item2ver = {}
$(MXE_CONF_PKGS));)]] local cmd = '%s print-deps-for-build-pkg MXE_TARGETS=%q'
local deps_mk_file = io.open('deps.mk', 'w') cmd = cmd:format(tool 'make', table.concat(TARGETS, ' '))
deps_mk_file:write(deps_mk_content)
deps_mk_file:close()
local pkgs = {}
local pkg2deps = {}
local pkg2ver = {}
local cmd = '%s -f deps.mk print-deps MXE_TARGETS=%s'
cmd = cmd:format(tool 'make', target)
local make = io.popen(cmd) local make = io.popen(cmd)
for line in make:lines() do for line in make:lines() do
local deps = split(trim(line)) local deps = split(trim(line))
@ -214,29 +186,36 @@ print-deps:
-- first value is marker 'for-build-pkg' -- first value is marker 'for-build-pkg'
table.remove(deps, 1) table.remove(deps, 1)
-- first value is name of package which depends on -- first value is name of package which depends on
local pkg = table.remove(deps, 1) local item = table.remove(deps, 1)
-- second value is version of package -- second value is version of package
local ver = table.remove(deps, 1) local ver = table.remove(deps, 1)
table.insert(pkgs, pkg) table.insert(items, item)
pkg2deps[pkg] = deps item2deps[item] = deps
pkg2ver[pkg] = ver item2ver[item] = ver
local target, _ = parseItem(item)
for _, dep_item in ipairs(deps) do
local target2, _ = parseItem(dep_item)
if isCross(target2) and target2 ~= target then
log("Cross-target dependency %s -> %s",
target2, target)
end
end
end end
end end
make:close() make:close()
os.remove('deps.mk') return items, item2deps, item2ver
return pkgs, pkg2deps, pkg2ver
end end
-- return packages ordered in build order -- return items ordered in build order
-- this means, if pkg1 depends on pkg2, then -- this means, if item depends on item2, then
-- pkg2 preceeds pkg1 in the list -- item2 preceeds item1 in the list
local function sortForBuild(pkgs, pkg2deps) local function sortForBuild(items, item2deps)
-- use sommand tsort -- use sommand tsort
local tsort_input_fname = os.tmpname() local tsort_input_fname = os.tmpname()
local tsort_input = io.open(tsort_input_fname, 'w') local tsort_input = io.open(tsort_input_fname, 'w')
for _, pkg1 in ipairs(pkgs) do for _, item1 in ipairs(items) do
for _, pkg2 in ipairs(pkg2deps[pkg1]) do for _, item2 in ipairs(item2deps[item1]) do
tsort_input:write(pkg2 .. ' ' .. pkg1 .. '\n') tsort_input:write(item2 .. ' ' .. item1 .. '\n')
end end
end end
tsort_input:close() tsort_input:close()
@ -244,8 +223,8 @@ local function sortForBuild(pkgs, pkg2deps)
local build_list = {} local build_list = {}
local tsort = io.popen('tsort ' .. tsort_input_fname, 'r') local tsort = io.popen('tsort ' .. tsort_input_fname, 'r')
for line in tsort:lines() do for line in tsort:lines() do
local pkg = trim(line) local item = trim(line)
table.insert(build_list, pkg) table.insert(build_list, item)
end end
tsort:close() tsort:close()
os.remove(tsort_input_fname) os.remove(tsort_input_fname)
@ -315,12 +294,13 @@ local function gitCommit(message)
os.execute(cmd:format(message)) os.execute(cmd:format(message))
end end
local function isValidBinary(file) local function isValidBinary(target, file)
local cmd = './usr/bin/%s-objdump -t %s > /dev/null 2>&1' local cmd = './usr/bin/%s-objdump -t %s > /dev/null 2>&1'
return execute(cmd:format(target, file)) return execute(cmd:format(target, file))
end end
local function checkFile(file, pkg) local function checkFile(file, item)
local target, _ = parseItem(item)
-- if it is PE32 file, it must have '.exe' in name -- if it is PE32 file, it must have '.exe' in name
local ext = file:sub(-4):lower() local ext = file:sub(-4):lower()
local cmd = 'file --dereference --brief %q' local cmd = 'file --dereference --brief %q'
@ -330,73 +310,68 @@ local function checkFile(file, pkg)
elseif ext == '.exe' then elseif ext == '.exe' then
if not file_type:match('PE32') then if not file_type:match('PE32') then
log('File %s (%s) is %q. Remove .exe', log('File %s (%s) is %q. Remove .exe',
file, pkg, file_type) file, item, file_type)
end end
elseif ext == '.dll' then elseif ext == '.dll' then
if not file_type:match('PE32.*DLL') then if not file_type:match('PE32.*DLL') then
log('File %s (%s) is %q. Remove .dll', log('File %s (%s) is %q. Remove .dll',
file, pkg, file_type) file, item, file_type)
end end
else else
if file_type:match('PE32') then if file_type:match('PE32') then
log('File %s (%s) is %q. Add exe or dll', log('File %s (%s) is %q. Add exe or dll',
file, pkg, file_type) file, item, file_type)
end end
end end
for _, t in ipairs(TARGETS) do for _, t in ipairs(TARGETS) do
if t ~= target and file:match(t) then if t ~= target and isInString(t, file) then
log('File %s (%s): other target %s in name', log('File %s (%s): other target %s in name',
file, pkg, t) file, item, t)
end end
end end
if file:match('/lib/.*%.dll$') then if file:match('/lib/.*%.dll$') then
log('File %s (%s): DLL in /lib/', file, pkg) log('File %s (%s): DLL in /lib/', file, item)
end end
if file:match('%.dll$') or file:match('%.a$') then if file:match('%.dll$') or file:match('%.a$') then
if file:find(target, 1, true) then -- not common if isInString(target, file) and isCross(target) then
if not isValidBinary(file) then -- cross-compiled
if not isValidBinary(target, file) then
log('File %s (%s): not recognized library', log('File %s (%s): not recognized library',
file, pkg) file, item)
end end
end end
end end
end end
-- builds package, returns list of new files -- builds package, returns list of new files
local function buildPackage(pkg, pkg2deps, file2pkg) local function buildItem(item, item2deps, file2item)
local target, pkg = parseItem(item)
local cmd = '%s %s MXE_TARGETS=%s --jobs=1' local cmd = '%s %s MXE_TARGETS=%s --jobs=1'
os.execute(cmd:format(tool 'make', pkg, target)) os.execute(cmd:format(tool 'make', pkg, target))
gitAdd() gitAdd()
local new_files, changed_files = gitStatus() local new_files, changed_files = gitStatus()
gitCommit(("Build %s for target %s"):format(pkg, target)) gitCommit(("Build %s"):format(item))
for _, file in ipairs(new_files) do for _, file in ipairs(new_files) do
checkFile(file, pkg) checkFile(file, item)
file2pkg[file] = {pkg=pkg, target=target} file2item[file] = item
end end
for _, file in ipairs(changed_files) do for _, file in ipairs(changed_files) do
checkFile(file, pkg) checkFile(file, item)
-- add a dependency on a package created this file -- add a dependency on a package created this file
local creator_pkg = assert(file2pkg[file]).pkg local creator_item = assert(file2item[file])
local creator_target = assert(file2pkg[file]).target if not isInArray(creator_item, item2deps[item]) then
local level = '' table.insert(item2deps[item], creator_item)
if target == creator_target then
if not isInArray(creator_pkg, pkg2deps[pkg]) then
table.insert(pkg2deps[pkg], creator_pkg)
end
else
level = 'error'
end end
log('Package %s changes %s, created by %s (%s) %s', log('Item %s changes %s, created by %s',
pkg, file, creator_pkg, creator_target, level) item, file, creator_item)
end end
return new_files return new_files
end end
local function nameToDebian(pkg, t) local function nameToDebian(item)
local name = 'mxe-%s-%s' item = item:gsub('[~_]', '-')
name = name:format(t or target, pkg) local name = 'mxe-%s'
name = name:gsub('_', '-') return name:format(item)
return name
end end
local function protectVersion(ver) local function protectVersion(ver)
@ -409,7 +384,8 @@ local function protectVersion(ver)
end end
end end
local function listFile(pkg) local function listFile(item)
local target, pkg = parseItem(item)
return ('%s-%s.list'):format(target, pkg) return ('%s-%s.list'):format(target, pkg)
end end
@ -429,8 +405,9 @@ Description: MXE package %s for %s
This package contains the files for MXE package %s. This package contains the files for MXE package %s.
]] ]]
local function makeDeb(pkg, list_path, deps, ver, add_common) local function makeDeb(item, list_path, deps, ver)
local deb_pkg = nameToDebian(pkg) local target, pkg = parseItem(item)
local deb_pkg = nameToDebian(item)
local dirname = ('%s_%s'):format(deb_pkg, local dirname = ('%s_%s'):format(deb_pkg,
protectVersion(ver)) protectVersion(ver))
-- make .tar.xz file -- make .tar.xz file
@ -451,9 +428,6 @@ local function makeDeb(pkg, list_path, deps, ver, add_common)
for _, dep in ipairs(deps) do for _, dep in ipairs(deps) do
table.insert(deb_deps, nameToDebian(dep)) table.insert(deb_deps, nameToDebian(dep))
end end
if add_common then
table.insert(deb_deps, nameToDebian(pkg, 'common'))
end
local deb_deps_str = table.concat(deb_deps, ', ') local deb_deps_str = table.concat(deb_deps, ', ')
-- make DEBIAN/control file -- make DEBIAN/control file
os.execute(('mkdir -p %s/DEBIAN'):format(dirname)) os.execute(('mkdir -p %s/DEBIAN'):format(dirname))
@ -462,6 +436,9 @@ local function makeDeb(pkg, list_path, deps, ver, add_common)
control:write(CONTROL:format(deb_pkg, protectVersion(ver), control:write(CONTROL:format(deb_pkg, protectVersion(ver),
ARCH, deb_deps_str, pkg, target, pkg)) ARCH, deb_deps_str, pkg, target, pkg))
control:close() control:close()
-- keep a copy of control file
local cmd = 'cp %s %s.deb-control'
os.execute(cmd:format(control_fname, dirname))
if not no_debs then if not no_debs then
-- make .deb file -- make .deb file
local cmd = 'fakeroot -i deb.fakeroot dpkg-deb -b %s' local cmd = 'fakeroot -i deb.fakeroot dpkg-deb -b %s'
@ -471,14 +448,6 @@ local function makeDeb(pkg, list_path, deps, ver, add_common)
os.execute(('rm -fr %s deb.fakeroot'):format(dirname)) os.execute(('rm -fr %s deb.fakeroot'):format(dirname))
end end
local function readFileList(list_file)
local list = {}
for installed_file in io.lines(list_file) do
table.insert(list, installed_file)
end
return list
end
local function saveFileList(list_file, list) local function saveFileList(list_file, list)
local file = io.open(list_file, 'w') local file = io.open(list_file, 'w')
for _, installed_file in ipairs(list) do for _, installed_file in ipairs(list) do
@ -487,7 +456,8 @@ local function saveFileList(list_file, list)
file:close() file:close()
end end
local function isBuilt(pkg, files) local function isBuilt(item, files)
local target, pkg = parseItem(item)
local INSTALLED = 'usr/%s/installed/%s' local INSTALLED = 'usr/%s/installed/%s'
local installed = INSTALLED:format(target, pkg) local installed = INSTALLED:format(target, pkg)
for _, file in ipairs(files) do for _, file in ipairs(files) do
@ -498,94 +468,46 @@ local function isBuilt(pkg, files)
return false return false
end end
-- build all packages, save filelist to file #pkg.list -- build all packages, save filelist to list file
local function buildPackages(pkgs, pkg2deps, file2pkg) local function buildPackages(items, item2deps)
local broken = {} local broken = {}
local unbroken = {} local unbroken = {}
local function brokenDep(pkg) local file2item = {}
for _, dep in ipairs(pkg2deps[pkg]) do local function brokenDep(item)
for _, dep in ipairs(item2deps[item]) do
if broken[dep] then if broken[dep] then
return dep return dep
end end
end end
return false return false
end end
for _, pkg in ipairs(pkgs) do for _, item in ipairs(items) do
if not brokenDep(pkg) then if not brokenDep(item) then
local files = buildPackage(pkg, pkg2deps, file2pkg) local files = buildItem(item, item2deps, file2item)
if isBuilt(pkg, files) then if isBuilt(item, files) then
saveFileList(listFile(pkg), files) saveFileList(listFile(item), files)
table.insert(unbroken, pkg) table.insert(unbroken, item)
else else
-- broken package -- broken package
broken[pkg] = true broken[item] = true
log('The package is broken: %s', pkg) log('Item is broken: %s', item)
end end
else else
broken[pkg] = true broken[item] = true
log('Package %s depends on broken %s', log('Item %s depends on broken item %s',
pkg, brokenDep(pkg)) item, brokenDep(item))
end end
end end
return unbroken return unbroken
end end
local function filterFiles(pkg, filter_common) local function makeDebs(items, item2deps, item2ver)
local list = readFileList(listFile(pkg)) for _, item in ipairs(items) do
local list2 = {} local deps = assert(item2deps[item], item)
local common_list = COMMON_FILES[pkg] local ver = assert(item2ver[item], item)
for _, installed_file in ipairs(list) do local list_path = listFile(item)
local listed = isListed(installed_file, common_list) makeDeb(item, list_path, deps, ver)
if listed == filter_common then
table.insert(list2, installed_file)
end
end end
return list2
end
local function excludeCommon(pkg)
local noncommon_files = filterFiles(pkg, false)
saveFileList(listFile(pkg), noncommon_files)
end
local function makeCommonDeb(pkg, ver)
local common_files = filterFiles(pkg, true)
local list_path = ('common-%s.list'):format(pkg)
saveFileList(list_path, common_files)
local orig_target = target
target = 'common'
makeDeb(pkg, list_path, {}, ver)
target = orig_target
end
local function makeDebs(pkgs, pkg2deps, pkg2ver)
for _, pkg in ipairs(pkgs) do
local deps = assert(pkg2deps[pkg], pkg)
local ver = assert(pkg2ver[pkg], pkg)
local list_path = listFile(pkg)
local add_common = false
if COMMON_FILES[pkg] then
if target == ARCH_FOR_COMMON then
makeCommonDeb(pkg, ver)
end
add_common = true
excludeCommon(pkg)
end
makeDeb(pkg, list_path, deps, ver, add_common)
end
end
local function buildForTarget(mxe_target, file2pkg)
target = mxe_target
local pkgs, pkg2deps, pkg2ver = getPkgs()
local build_list = sortForBuild(pkgs, pkg2deps)
if max_packages then
while #build_list > max_packages do
table.remove(build_list)
end
end
local unbroken = buildPackages(build_list, pkg2deps, file2pkg)
makeDebs(unbroken, pkg2deps, pkg2ver)
end end
local function getMxeVersion() local function getMxeVersion()
@ -654,10 +576,11 @@ assert(execute(("%s check-requirements"):format(tool 'make')))
while not execute(('%s download -j 6 -k'):format(tool 'make')) do while not execute(('%s download -j 6 -k'):format(tool 'make')) do
end end
gitInit() gitInit()
local file2pkg = {} local items, item2deps, item2ver = getItems()
for _, t in ipairs(TARGETS) do local build_list = sortForBuild(items, item2deps)
buildForTarget(t, file2pkg) build_list = sliceArray(build_list, max_items)
end local unbroken = buildPackages(build_list, item2deps)
makeDebs(unbroken, item2deps, item2ver)
if not no_debs then if not no_debs then
makeMxeRequirementsDeb('wheezy') makeMxeRequirementsDeb('wheezy')
makeMxeRequirementsDeb('jessie') makeMxeRequirementsDeb('jessie')