Makefile docs and pkgconf: add support for shared|static variants

This commit is contained in:
Tony Theodore 2014-02-03 18:22:54 +11:00
parent 5a18b2786b
commit 47361fa750
3 changed files with 43 additions and 19 deletions

View File

@ -8,8 +8,12 @@ TOP_DIR := $(patsubst %/,%,$(dir $(MAKEFILE)))
# See doc/gmsl.html for further information
include $(TOP_DIR)/tools/gmsl
MXE_TARGET_LIST := i686-pc-mingw32 x86_64-w64-mingw32 i686-w64-mingw32
MXE_TARGETS := i686-pc-mingw32
MXE_TRIPLETS := i686-pc-mingw32 x86_64-w64-mingw32 i686-w64-mingw32
MXE_LIB_TYPES := static shared
MXE_TARGET_LIST := $(foreach LIB_TYPE,$(MXE_LIB_TYPES),\
$(addsuffix .$(LIB_TYPE),$(MXE_TRIPLETS)))
MXE_TARGETS := i686-pc-mingw32.static
DEFAULT_MAX_JOBS := 6
SOURCEFORGE_MIRROR := freefr.dl.sourceforge.net
PKG_MIRROR := s3.amazonaws.com/mxe-pkg
@ -46,6 +50,14 @@ BUILD := $(shell '$(TOP_DIR)/tools/config.guess')
BUILD_PKGS := $(shell grep -l 'BUILD_$$(BUILD)' '$(TOP_DIR)/src/'*.mk | $(SED) -n 's,.*src/\(.*\)\.mk,\1,p')
PATH := $(PREFIX)/$(BUILD)/bin:$(PREFIX)/bin:$(PATH)
MXE_CONFIGURE_OPTS = \
--host='$(TARGET)' \
--build='$(BUILD)' \
--prefix='$(PREFIX)/$(TARGET)' \
$(if $(BUILD_STATIC), \
--enable-static --disable-shared , \
--disable-static --enable-shared )
# use a minimal whitelist of safe environment variables
ENV_WHITELIST := PATH LANG MAKE% MXE% %PROXY %proxy
unexport $(filter-out $(ENV_WHITELIST),$(shell env | cut -d '=' -f1))
@ -190,6 +202,15 @@ $(1): | $(if $(value $(1)_DEPS), \
$(addprefix $(PREFIX)/$($(1)_DEPS)/installed/,$(PKGS))))) \
$($(1)_DEPS)
@echo '[target] $(1) $(call TARGET_HEADER)'
$(if $(findstring 1,$(words $(subst ., ,$(1)))),
@echo
@echo '------------------------------------------------------------'
@echo 'Warning: Deprecated target name $(1) specified'
@echo
@echo 'Please use $(1).[$(subst $(space),|,$(MXE_LIB_TYPES))] instead'
@echo 'See index.html for further information'
@echo '------------------------------------------------------------'
@echo)
endef
$(foreach TARGET,$(MXE_TARGETS),$(eval $(call TARGET_RULE,$(TARGET))))
@ -199,8 +220,10 @@ $(foreach TARGET,$(MXE_TARGETS),$(eval $(call TARGET_RULE,$(TARGET))))
LOOKUP_PKG_RULE = $(strip \
$(if $(findstring undefined, $(flavor $(1)_$(2)_$(3))),\
$(if $(3),\
$(call LOOKUP_PKG_RULE,$(1),$(2),$(call merge,.,$(call chop,$(call split,.,$(3))))),\
$(1)_$(2)),\
$(call LOOKUP_PKG_RULE,$(1),$(2),$(call merge,.,$(call chop,$(call split,.,$(3)))),$(or $(4),$(call uc,$(word 2,$(subst ., ,$(3)))))),\
$(if $(4),\
$(call LOOKUP_PKG_RULE,$(1),$(2),$(4)),\
$(1)_$(2))),\
$(1)_$(2)_$(3)))
define PKG_RULE
@ -262,6 +285,7 @@ $(PREFIX)/$(3)/installed/$(1): $(TOP_DIR)/src/$(1).mk \
.PHONY: build-only-$(1)_$(3)
build-only-$(1)_$(3): PKG = $(1)
build-only-$(1)_$(3): TARGET = $(3)
build-only-$(1)_$(3): BUILD_$(if $(findstring shared,$(3)),SHARED,STATIC) = TRUE
build-only-$(1)_$(3): CMAKE_TOOLCHAIN_FILE = $(PREFIX)/$(3)/share/cmake/mxe-conf.cmake
build-only-$(1)_$(3):
$(if $(value $(call LOOKUP_PKG_RULE,$(1),BUILD,$(3))),

View File

@ -321,10 +321,10 @@ exit</pre>
<pre>make gtk lua libidn</pre>
<p>
Targets can also be specified on the command line.
By default, only i686-pc-mingw32 is built, but you can
By default, only i686-pc-mingw32.static is built, but you can
build your toolchain(s) of choice with:
</p>
<pre>make MXE_TARGETS='x86_64-w64-mingw32 i686-w64-mingw32'</pre>
<pre>make MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static'</pre>
<p>
or by adjusting the <code>MXE_TARGETS</code> variable
in <code>settings.mk</code>.
@ -363,9 +363,9 @@ exit</pre>
you can add separate entries for cross builds:
</p>
<pre>export PKG_CONFIG_PATH="<em>entries for native builds</em>"</pre>
<pre>export PKG_CONFIG_PATH_i686_pc_mingw32="<em>entries for MXE builds</em>"</pre>
<pre>export PKG_CONFIG_PATH_i686_pc_mingw32_static="<em>entries for MXE builds</em>"</pre>
<p>
Remember to use i686-pc-mingw32-pkg-config
Remember to use i686-pc-mingw32.static-pkg-config
instead of pkg-config for cross builds.
The Autotools do that automatically for you.
</p>
@ -397,13 +397,13 @@ exit</pre>
<a href="https://www.lrde.epita.fr/~adl/autotools.html">Autotools</a>,
all you have to do is:
</p>
<pre>./configure --host=i686-pc-mingw32
<pre>./configure --host=i686-pc-mingw32.static
make</pre>
<p>
If you build a library, you might also want to enforce a static build:
</p>
<pre>./configure --host=i686-pc-mingw32 --enable-static --disable-shared
<pre>./configure --host=i686-pc-mingw32.static --enable-static --disable-shared
make</pre>
<p>
@ -422,7 +422,7 @@ If a cross compiler is detected then cross compile mode will be used.</pre>
<a href="http://www.cmake.org/">CMake</a> project,
you can use the provided toolchain file:
</p>
<pre>cmake ... -DCMAKE_TOOLCHAIN_FILE=/<em>where MXE is installed</em>/usr/i686-pc-mingw32/share/cmake/mxe-conf.cmake</pre>
<pre>cmake ... -DCMAKE_TOOLCHAIN_FILE=/<em>where MXE is installed</em>/usr/i686-pc-mingw32.static/share/cmake/mxe-conf.cmake</pre>
<h3 id="tutorial-5c">Step 5c: Cross compile your Project (Qt)</h3>
@ -431,7 +431,7 @@ If a cross compiler is detected then cross compile mode will be used.</pre>
<a href="https://qt-project.org/">Qt</a> application,
all you have to do is:
</p>
<pre>/where MXE is installed/usr/i686-pc-mingw32/qt/bin/qmake
<pre>/where MXE is installed/usr/i686-pc-mingw32.static/qt/bin/qmake
make</pre>
<p>
Note that Qt 4 is in the "qt" subdirectory. Qt 5 is in the "qt5" subdirectory
@ -466,7 +466,7 @@ PKG_CONFIG=$(CROSS)pkg-config</pre>
<p>
Then, all you have to do is:
</p>
<pre>make CROSS=i686-pc-mingw32-</pre>
<pre>make CROSS=i686-pc-mingw32.static-</pre>
<p>
That's it!
</p>
@ -489,12 +489,12 @@ USE_OSGPLUGIN(&lt;plugin2&gt;)
OpenSceneGraph source distribution for an example. This example can be
compiled with the following command:
</p>
<pre>i686-pc-mingw32-g++ \
<pre>i686-pc-mingw32.static-g++ \
-o osgstaticviewer.exe examples/osgstaticviewer/osgstaticviewer.cpp \
`i686-pc-mingw32-pkg-config --cflags openscenegraph-osgViewer openscenegraph-osgPlugins` \
`i686-pc-mingw32-pkg-config --libs openscenegraph-osgViewer openscenegraph-osgPlugins`</pre>
`i686-pc-mingw32.static-pkg-config --cflags openscenegraph-osgViewer openscenegraph-osgPlugins` \
`i686-pc-mingw32.static-pkg-config --libs openscenegraph-osgViewer openscenegraph-osgPlugins`</pre>
<p>
The <code>i686-pc-mingw32-pkg-config</code> command from MXE will
The <code>i686-pc-mingw32.static-pkg-config</code> command from MXE will
automatically add <code>-DOSG_LIBRARY_STATIC</code> to your compiler flags.
</p>

View File

@ -41,7 +41,7 @@ define $(PKG)_BUILD_COMMON
# create pkg-config script
(echo '#!/bin/sh'; \
echo 'PKG_CONFIG_PATH="$(PREFIX)/$(TARGET)/qt5/lib/pkgconfig":"$$PKG_CONFIG_PATH_$(subst -,_,$(TARGET))" PKG_CONFIG_LIBDIR='\''$(PREFIX)/$(TARGET)/lib/pkgconfig'\'' exec '$(PREFIX)/$(TARGET)/bin/pkg-config' --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)/$(TARGET)/bin/pkg-config' $(if $(BUILD_STATIC),--static) "$$@"') \
> '$(PREFIX)/bin/$(TARGET)-pkg-config'
chmod 0755 '$(PREFIX)/bin/$(TARGET)-pkg-config'
@ -49,7 +49,7 @@ define $(PKG)_BUILD_COMMON
[ -d '$(dir $(CMAKE_TOOLCHAIN_FILE))' ] || mkdir -p '$(dir $(CMAKE_TOOLCHAIN_FILE))'
(echo 'set(CMAKE_SYSTEM_NAME Windows)'; \
echo 'set(MSYS 1)'; \
echo 'set(BUILD_SHARED_LIBS OFF)'; \
echo 'set(BUILD_SHARED_LIBS $(if $(BUILD_SHARED),ON,OFF))'; \
echo 'set(CMAKE_BUILD_TYPE Release)'; \
echo 'set(CMAKE_FIND_ROOT_PATH $(PREFIX)/$(TARGET))'; \
echo 'set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)'; \