mxe/mxe — pull request #263 by tonytheodore (2013-10-20 11:58:00+00:00)
Title: Shared builds using target-triplet suffixes

This is one option for how shared builds can be enabled in mxe with minimal boilerplate and overhead. We can extend the current definition of a "target" (since it's already overloaded) to be a 'dot' separated combination of triplet, link style, and any other exception handling/threading variants we need.

The main problem with manipulating the "target triplet" is that some build systems hard code things like `*-pc-mingw32`. I've tested various `i686-pc-mingw32.static.sjlj.win32` and `x86_64-w64-mingw32.shared.seh.posix` etc. and I've only seen two packages fail. Note that when testing those, I didn't put any logic around the variants - I was just testing that the suffixes were ignored.

icu4c fails at configure time and poppler fails as it uses the `PKG_CONFIG_PATH...` env variable and env variables can't have 'dots' in them. Both are easy fixes (though icu4c has a config system that doesn't really even work for itself).

The other early problem with triplets was that binutils/gcc have specific handling for `*-w64-*`, but this doesn't use the vendor segment.

This changeset isn't complete (no pkg-config, cmake, shared libgcc etc.), but it should illustrate the build rules for static/shared builds. We have:
- common build rules that are handled by $(MXE_CONFIGURE_OPTS) [libiconv](https://github.com/tonytheodore/mxe/blob/shared-using-target/src/libiconv.mk)
- builds that are slightly different or require some post-processing [icu4c](https://github.com/tonytheodore/mxe/blob/shared-using-target/src/icu4c.mk)
- and builds that are totally different [zlib](https://github.com/tonytheodore/mxe/blob/shared-using-target/src/zlib.mk)

The changes to the Makefile involve setting the new `MXE_CONFIGURE_OPTS` snippet and setting the order of precedence for build rules.

This also doesn't address anything we've patched heavily to support static builds - not sure there is much to be done for that.

The main reason I like this approach is that directory layout and $PATH are transparent. I haven't yet come up with something that uses 'canonical' triplets that doesn't involve a lot of directory and env manipulation. We'd have to make something like `tools/mxe-activate` the way to access the toolchain you're after.