summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Theodore <tonyt@logyst.com>2016-07-17 02:58:54 (GMT)
committerGitHub <noreply@github.com>2016-07-17 02:58:54 (GMT)
commit3246cbdf81895737ea059d9a12381557aafa8657 (patch)
treed6a187d7726c6c2b9af9caa56536eb60fa95f367
parentc97ae303d619310b69b2b709bb5f7572ebd0a82c (diff)
parentbc5c058fe790d1d2a2e0ebb7494245a7196d0417 (diff)
downloadmxe-3246cbdf81895737ea059d9a12381557aafa8657.zip
mxe-3246cbdf81895737ea059d9a12381557aafa8657.tar.gz
mxe-3246cbdf81895737ea059d9a12381557aafa8657.tar.bz2
Merge pull request #1436 from tonytheodore/host-tools
host-toolchain plugin: build qt5 test, cmake, and pkgconf, add `make` binary download
-rw-r--r--plugins/examples/host-toolchain/README.md63
-rw-r--r--plugins/examples/host-toolchain/binutils-host.mk3
-rw-r--r--plugins/examples/host-toolchain/cmake-host.mk22
l---------plugins/examples/host-toolchain/gcc-host-1.patch1
-rw-r--r--plugins/examples/host-toolchain/gcc-host.mk18
-rw-r--r--plugins/examples/host-toolchain/make-w32-bin.mk22
-rw-r--r--plugins/examples/host-toolchain/pkgconf-host.mk47
-rw-r--r--plugins/examples/host-toolchain/qt5-host-tools.mk92
8 files changed, 221 insertions, 47 deletions
diff --git a/plugins/examples/host-toolchain/README.md b/plugins/examples/host-toolchain/README.md
index a22215e..cecefd4 100644
--- a/plugins/examples/host-toolchain/README.md
+++ b/plugins/examples/host-toolchain/README.md
@@ -15,7 +15,49 @@ second pass to cross-compile the basic toolchain (`binutils` and `gcc`).
Once complete, copy `usr/{target}` to an appropriate Windows machine
and execute the `usr\{target}\bin\test-gcc-host.bat` batch file. This
-builds and runs the `libgomp` test as a sanity check.
+builds and runs the `libgomp` test as a sanity check. The cross and host
+built programs should be identical (after stripping), confirmed with the
+final step:
+
+```
+>fc /b test-gcc-host.exe test-pthreads-libgomp.exe
+Comparing files test-gcc-host.exe and TEST-PTHREADS-LIBGOMP.EXE
+FC: no differences encountered
+```
+
+#### CMake
+
+```
+make cmake-host MXE_PLUGIN_DIRS=plugins/examples/host-toolchain/
+```
+
+CMake defaults to Visual Studio generators and additional configuration is
+required for [MinGW or MSYS Makefiles][cmake-generators]. MinGW uses `cmd.exe`
+and requires `mingw32-make`, MSYS uses `make` and requires `/bin/sh`. The
+latter is recommended for further investigation since it's closest to the
+normal environment MXE expects. See the following projects for shells and
+terminal emulators:
+
+ - [MSYS2][msys2]
+ - [Git for Windows][git-win] - uses MSYS2
+ - [ConEmu][conemu] - usable terminal
+ - [cmder][cmder] - bundles ConEmu and Git
+
+#### Make
+
+Make is difficult to cross-compile so it is downloaded from the [source
+recommended by the GNU Make team](http://git.savannah.gnu.org/cgit/make.git/tree/README.W32.template).
+
+#### pkgconf/pkg-config
+
+```
+make pkgconf-host MXE_PLUGIN_DIRS=plugins/examples/host-toolchain/
+```
+
+This will cross-compile `pkgconf` and create the `pkg-config` wrapper. The
+wrapper requires `/bin/sh` so one of the [MSYS2][msys2] options should be used.
+Run the `usr/{target}/bin/test-pkgconf-host` script to build `libffi` test
+with non-standard include paths.
#### Qt5 tools (`qmake.exe`, `rcc.exe`, etc.)
@@ -23,8 +65,15 @@ builds and runs the `libgomp` test as a sanity check.
make qt5-host-tools MXE_PLUGIN_DIRS=plugins/examples/host-toolchain/
```
-This will build `qtbase` then run a second pass to cross-compile the qt tools
-and install them to `usr/{target}/qt5-host-tools/bin`.
+This will build `qtbase`, cross-compile the toolchain and qt tools, and
+download `make` binaries.
+
+On a windows machine, execute
+`usr\{target}\qt5\test-qt5-host-tools\test-qt5-host-tools.bat` to build and
+confirm the normal `qt` test with the cross-compiled `qtbase` libraries.
+
+**N.B.** shared `gcc` doesn't work with the test program. To build a shared
+test, use the additional option `gcc-host_CONFIGURE_OPTS=--disable-shared`.
Why?
----
@@ -33,3 +82,11 @@ Simply for curiosity, it's hard to see a practical use for this. Certainly,
attempting to use it as a way to bootstrap MXE on Windows would strain
one's sanity and cross-compiling is the recommended way (even if that means
running a Linux VM on Windows).
+
+
+
+[cmake-generators]:https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html
+[cmder]:http://cmder.net/
+[conemu]:https://conemu.github.io/
+[git-win]:https://git-for-windows.github.io/
+[msys2]:https://msys2.github.io/
diff --git a/plugins/examples/host-toolchain/binutils-host.mk b/plugins/examples/host-toolchain/binutils-host.mk
index 678fed8..bed45ea 100644
--- a/plugins/examples/host-toolchain/binutils-host.mk
+++ b/plugins/examples/host-toolchain/binutils-host.mk
@@ -22,5 +22,6 @@ define $(PKG)_BUILD
--host='$(TARGET)',\
$(binutils_BUILD))
- #rm -rf '$(PREFIX)/$(TARGET)/$(TARGET)'
+ # tools seem to be duplicates of '$(PREFIX)/$(TARGET)'
+ rm -rf '$(PREFIX)/$(TARGET)/$(TARGET)'
endef
diff --git a/plugins/examples/host-toolchain/cmake-host.mk b/plugins/examples/host-toolchain/cmake-host.mk
new file mode 100644
index 0000000..253dbc4
--- /dev/null
+++ b/plugins/examples/host-toolchain/cmake-host.mk
@@ -0,0 +1,22 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG := cmake-host
+$(PKG)_IGNORE = $(cmake_IGNORE)
+$(PKG)_VERSION = $(cmake_VERSION)
+$(PKG)_CHECKSUM = $(cmake_CHECKSUM)
+$(PKG)_SUBDIR = $(cmake_SUBDIR)
+$(PKG)_FILE = $(cmake_FILE)
+$(PKG)_URL = $(cmake_URL)
+$(PKG)_URL_2 = $(cmake_URL_2)
+$(PKG)_DEPS := gcc
+
+define $(PKG)_UPDATE
+ echo $(cmake_VERSION)
+endef
+
+define $(PKG)_BUILD
+ cd '$(BUILD_DIR)' && $(TARGET)-cmake '$(SOURCE_DIR)'
+ $(MAKE) -C '$(BUILD_DIR)' -j $(JOBS) VERBOSE=1
+ $(MAKE) -C '$(BUILD_DIR)' -j 1 install
+endef
diff --git a/plugins/examples/host-toolchain/gcc-host-1.patch b/plugins/examples/host-toolchain/gcc-host-1.patch
deleted file mode 120000
index d63be56..0000000
--- a/plugins/examples/host-toolchain/gcc-host-1.patch
+++ /dev/null
@@ -1 +0,0 @@
-src/gcc-1.patch \ No newline at end of file
diff --git a/plugins/examples/host-toolchain/gcc-host.mk b/plugins/examples/host-toolchain/gcc-host.mk
index d0e9076..d83adda 100644
--- a/plugins/examples/host-toolchain/gcc-host.mk
+++ b/plugins/examples/host-toolchain/gcc-host.mk
@@ -7,17 +7,17 @@ $(PKG)_VERSION = $(gcc_VERSION)
$(PKG)_CHECKSUM = $(gcc_CHECKSUM)
$(PKG)_SUBDIR = $(gcc_SUBDIR)
$(PKG)_FILE = $(gcc_FILE)
+$(PKG)_PATCHES = $(realpath $(sort $(wildcard $(addsuffix /gcc-[0-9]*.patch, $(TOP_DIR)/src))))
$(PKG)_URL = $(gcc_URL)
$(PKG)_URL_2 = $(gcc_URL_2)
-$(PKG)_DEPS := gcc binutils-host cloog gmp isl mpfr mpc
+$(PKG)_DEPS := gcc binutils-host cloog gmp isl mpfr mpc pthreads
define $(PKG)_UPDATE
echo $(gcc_VERSION)
endef
define $(PKG)_BUILD
- mkdir '$(1).build'
- cd '$(1).build' && '$(1)/configure' \
+ cd '$(BUILD_DIR)' && '$(SOURCE_DIR)/configure' \
--host='$(TARGET)' \
--target='$(TARGET)' \
--build='$(BUILD)' \
@@ -36,16 +36,20 @@ define $(PKG)_BUILD
--disable-win32-registry \
--enable-threads=$(MXE_GCC_THREADS) \
--enable-libgomp \
- --with-{cloog,gmp,isl,mpc,mpfr}='$(PREFIX)/$(TARGET)'
+ --with-{cloog,gmp,isl,mpc,mpfr}='$(PREFIX)/$(TARGET)' \
+ $($(PKG)_CONFIGURE_OPTS)
- $(MAKE) -C '$(1).build' -j '$(JOBS)'
- $(MAKE) -C '$(1).build' -j 1 install
+ $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)'
+ $(MAKE) -C '$(BUILD_DIR)' -j 1 install
# test compilation on host
+ # strip and compare cross and host-built tests
cp '$(TOP_DIR)/src/pthreads-libgomp-test.c' '$(PREFIX)/$(TARGET)/bin/test-$(PKG).c'
(printf 'set PATH=..\\bin;%%PATH%%\r\n'; \
printf 'gcc test-$(PKG).c -o test-$(PKG).exe -fopenmp -v\r\n'; \
printf 'test-$(PKG).exe\r\n'; \
- printf 'pause\r\n';) \
+ printf 'strip test-$(PKG).exe test-pthreads-libgomp.exe\r\n'; \
+ printf 'fc /b test-$(PKG).exe test-pthreads-libgomp.exe\r\n'; \
+ printf 'cmd\r\n';) \
> '$(PREFIX)/$(TARGET)/bin/test-$(PKG).bat'
endef
diff --git a/plugins/examples/host-toolchain/make-w32-bin.mk b/plugins/examples/host-toolchain/make-w32-bin.mk
new file mode 100644
index 0000000..040916b
--- /dev/null
+++ b/plugins/examples/host-toolchain/make-w32-bin.mk
@@ -0,0 +1,22 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG := make-w32-bin
+$(PKG)_IGNORE :=
+$(PKG)_VERSION := 4.2
+$(PKG)_CHECKSUM := 6cab11301e601996ab0cb7b3b903e5a55d5bd795614946cf6bd025cd61c710c6
+$(PKG)_SUBDIR := .
+$(PKG)_FILE := make-$($(PKG)_VERSION)-without-guile-w32-bin.zip
+$(PKG)_URL := http://$(SOURCEFORGE_MIRROR)/project/ezwinports/$($(PKG)_FILE)
+$(PKG)_DEPS :=
+
+define $(PKG)_UPDATE
+ $(WGET) -q -O- 'http://sourceforge.net/projects/ezwinports/files/' | \
+ $(SED) -n 's,.*/make-\([0-9.]*\)-without-guile.*,\1,p' | \
+ head -1
+endef
+
+define $(PKG)_BUILD
+ cp '$(1)/bin/'* '$(PREFIX)/$(TARGET)/bin/'
+ cp '$(1)/lib/'* '$(PREFIX)/$(TARGET)/lib/'
+endef
diff --git a/plugins/examples/host-toolchain/pkgconf-host.mk b/plugins/examples/host-toolchain/pkgconf-host.mk
new file mode 100644
index 0000000..c971044
--- /dev/null
+++ b/plugins/examples/host-toolchain/pkgconf-host.mk
@@ -0,0 +1,47 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG := pkgconf-host
+$(PKG)_IGNORE = $(pkgconf_IGNORE)
+$(PKG)_VERSION = $(pkgconf_VERSION)
+$(PKG)_CHECKSUM = $(pkgconf_CHECKSUM)
+$(PKG)_SUBDIR = $(pkgconf_SUBDIR)
+$(PKG)_FILE = $(pkgconf_FILE)
+$(PKG)_URL = $(pkgconf_URL)
+$(PKG)_URL_2 = $(pkgconf_URL_2)
+$(PKG)_DEPS := gcc libffi
+
+define $(PKG)_UPDATE
+ echo $(pkgconf_VERSION)
+endef
+
+define $(PKG)_BUILD
+ cd '$(SOURCE_DIR)' && ./autogen.sh
+ cd '$(BUILD_DIR)' && '$(SOURCE_DIR)/configure' \
+ $(MXE_CONFIGURE_OPTS)
+ $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)'
+ $(MAKE) -C '$(BUILD_DIR)' -j 1 install
+
+ # create pkg-config script with relative paths
+ (echo '#!/bin/sh'; \
+ echo 'PKG_CONFIG_PATH="../qt5/lib/pkgconfig":"$$PKG_CONFIG_PATH_$(subst .,_,$(subst -,_,$(TARGET)))" \
+ PKG_CONFIG_LIBDIR='\''../lib/pkgconfig'\'' \
+ exec '../bin/pkgconf' \
+ $(if $(BUILD_STATIC),--static) \
+ --define-variable=prefix=.. \
+ "$$@"' \
+ ) > '$(PREFIX)/$(TARGET)/bin/pkg-config'
+ chmod 0755 '$(PREFIX)/$(TARGET)/bin/pkg-config'
+
+ # test compilation on host with libffi in non-std prefix
+ cp '$(PWD)/src/libffi-test.c' '$(PREFIX)/$(TARGET)/bin/test-$(PKG).c'
+ (echo '#!/bin/sh'; \
+ echo 'export PATH=../bin:$PATH'; \
+ echo 'gcc -v \
+ -W -Wall -Werror -ansi -pedantic \
+ test-$(PKG).c -o test-$(PKG).exe \
+ `pkg-config --cflags --libs libffi`'; \
+ echo 'test-$(PKG).exe'; \
+ ) > '$(PREFIX)/$(TARGET)/bin/test-$(PKG)'
+ chmod 0755 '$(PREFIX)/$(TARGET)/bin/test-$(PKG)'
+endef
diff --git a/plugins/examples/host-toolchain/qt5-host-tools.mk b/plugins/examples/host-toolchain/qt5-host-tools.mk
index 07fcacb..4904fef 100644
--- a/plugins/examples/host-toolchain/qt5-host-tools.mk
+++ b/plugins/examples/host-toolchain/qt5-host-tools.mk
@@ -5,7 +5,7 @@ PKG := $(basename $(notdir $(lastword $(MAKEFILE_LIST))))
$(PKG)_FILE = $(qtbase_FILE)
$(PKG)_PATCHES = $(realpath $(sort $(wildcard $(addsuffix /qtbase-[0-9]*.patch, $(TOP_DIR)/src))))
$(PKG)_SUBDIR = $(qtbase_SUBDIR)
-$(PKG)_DEPS := gcc qtbase
+$(PKG)_DEPS := gcc gcc-host make-w32-bin qtbase
# main configure options: -platform -host-option -external-hostbindir
# further testing needed: -prefix -extprefix -hostprefix -sysroot -no-gcc-sysroot
@@ -13,40 +13,62 @@ $(PKG)_DEPS := gcc qtbase
define $(PKG)_BUILD
$(SED) -i 's,BUILD_ON_MAC=yes,BUILD_ON_MAC=no,g' '$(1)/configure'
- mkdir '$(1).build'
- cd '$(1).build' && '$(1)/configure' \
- -prefix '$(PREFIX)/$(TARGET)/$(PKG)' \
- -static \
- -release \
- -c++std c++11 \
- -platform win32-g++ \
- -host-option CROSS_COMPILE=${TARGET}- \
- -external-hostbindir '$(PREFIX)/$(TARGET)/qt5/bin' \
- -device-option PKG_CONFIG='${TARGET}-pkg-config' \
- -device-option CROSS_COMPILE=${TARGET}- \
- -force-pkg-config \
- -no-sql-{db2,ibase,mysql,oci,odbc,psql,sqlite,sqlite2,tds} \
- -no-use-gold-linker \
- -nomake examples \
- -nomake tests \
- -opensource \
- -confirm-license \
- -continue \
- -verbose
-
- rm -rf '$(PREFIX)/$(TARGET)/$(PKG)'
- # install qmake.exe (created by configure)
- # and generate remaining build configuration
- $(MAKE) -C '$(1).build' -j $(JOBS) \
- sub-qmake-qmake-aux-pro-install_subtargets \
+ cd '$(BUILD_DIR)' && '$(SOURCE_DIR)/configure' \
+ -prefix '$(PREFIX)/$(TARGET)/qt5' \
+ -static \
+ -release \
+ -c++std c++11 \
+ -platform win32-g++ \
+ -host-option CROSS_COMPILE=${TARGET}- \
+ -external-hostbindir '$(PREFIX)/$(TARGET)/qt5/bin' \
+ -device-option PKG_CONFIG='$(TARGET)-pkg-config' \
+ -device-option CROSS_COMPILE=$(TARGET)- \
+ -force-pkg-config \
+ -no-icu \
+ -no-sql-{db2,ibase,mysql,oci,odbc,psql,sqlite,sqlite2,tds} \
+ -no-use-gold-linker \
+ -nomake examples \
+ -nomake tests \
+ -opensource \
+ -confirm-license \
+ -continue \
+ -verbose
+
+ # generate remaining build configuration (qmake is created by configure)
+ $(MAKE) -C '$(BUILD_DIR)' -j $(JOBS) \
sub-src-qmake_all
- # build and install other tools
- $(MAKE) -C '$(1).build/src' -j $(JOBS) \
- sub-moc-install_subtargets \
- sub-qdbuscpp2xml-install_subtargets \
- sub-qdbusxml2cpp-install_subtargets \
- sub-qlalr-install_subtargets \
- sub-rcc-install_subtargets \
- sub-uic-install_subtargets
+ # build other tools
+ $(MAKE) -C '$(BUILD_DIR)/src' -j $(JOBS) \
+ sub-{moc,qdbuscpp2xml,qdbusxml2cpp,qlalr,rcc,uic}-all
+
+ # install tools and create `qt.conf` for runtime config
+ cp '$(BUILD_DIR)/bin'/*.exe '$(PREFIX)/$(TARGET)/qt5/bin/'
+ (printf '[Paths]\r\n'; \
+ printf 'Prefix = ..\r\n'; \
+ ) > '$(PREFIX)/$(TARGET)/qt5/bin/qt.conf'
+
+ # test compilation on host
+ # windows can't work with symlinks
+ $(and $(BUILD_STATIC),
+ rm -f '$(PREFIX)/$(TARGET)/lib/libpng.a' && \
+ cp '$(PREFIX)/$(TARGET)/lib/libpng16.a' '$(PREFIX)/$(TARGET)/lib/libpng.a';
+ rm -f '$(PREFIX)/$(TARGET)/lib/libharfbuzz_too.a' && \
+ cp '$(PREFIX)/$(TARGET)/lib/libharfbuzz.a' '$(PREFIX)/$(TARGET)/lib/libharfbuzz_too.a';
+ )
+
+ # copy required test files and create batch file
+ mkdir -p '$(PREFIX)/$(TARGET)/qt5/test-$(PKG)'
+ cp '$(PWD)/src/qt-test.'* '$(PREFIX)/$(TARGET)/qt5/test-$(PKG)/'
+ cp '$(PWD)/src/qt.mk' '$(PREFIX)/$(TARGET)/qt5/test-$(PKG)/'
+ (printf 'set PWD=%%~dp0\r\n'; \
+ printf 'set PATH=%%PWD%%..\\bin;%%PWD%%..\\..\\bin;%%PWD%%..\\lib;%%PWD%%..\\..\\lib;%%PATH%%\r\n'; \
+ printf 'set QT_QPA_PLATFORM_PLUGIN_PATH=%%PWD%%..\\plugins\r\n'; \
+ printf 'mkdir build\r\n'; \
+ printf 'cd build\r\n'; \
+ printf 'qmake ..\r\n'; \
+ printf 'make -j $(JOBS)\r\n'; \
+ printf '%%PWD%%\\build\\release\\test-qt5.exe\r\n'; \
+ printf 'cmd\r\n'; \
+ ) > '$(PREFIX)/$(TARGET)/qt5/test-$(PKG)/test-$(PKG).bat'
endef