2007-08-10 21:07:51 +02:00
|
|
|
################################################################################
|
2009-11-08 18:37:49 +01:00
|
|
|
# Autotools package infrastructure
|
2007-08-10 21:07:51 +02:00
|
|
|
#
|
2009-11-08 18:37:49 +01:00
|
|
|
# This file implements an infrastructure that eases development of
|
|
|
|
# package .mk files for autotools packages. It should be used for all
|
2012-04-17 16:45:20 +02:00
|
|
|
# packages that use the autotools as their build system.
|
2007-08-10 21:07:51 +02:00
|
|
|
#
|
2009-11-08 18:37:49 +01:00
|
|
|
# See the Buildroot documentation for details on the usage of this
|
|
|
|
# infrastructure
|
2007-08-10 21:07:51 +02:00
|
|
|
#
|
2009-11-08 18:37:49 +01:00
|
|
|
# In terms of implementation, this autotools infrastructure requires
|
|
|
|
# the .mk file to only specify metadata informations about the
|
|
|
|
# package: name, version, download URL, etc.
|
2007-09-30 14:46:02 +02:00
|
|
|
#
|
2009-11-08 18:37:49 +01:00
|
|
|
# We still allow the package .mk file to override what the different
|
|
|
|
# steps are doing, if needed. For example, if <PKG>_BUILD_CMDS is
|
|
|
|
# already defined, it is used as the list of commands to perform to
|
|
|
|
# build the package, instead of the default autotools behaviour. The
|
|
|
|
# package can also define some post operation hooks.
|
2007-09-30 14:46:02 +02:00
|
|
|
#
|
2007-08-10 21:07:51 +02:00
|
|
|
################################################################################
|
|
|
|
|
2011-08-31 23:35:06 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Utility function to upgrade config.sub and config.guess files
|
|
|
|
#
|
|
|
|
# argument 1 : directory into which config.guess and config.sub need
|
|
|
|
# to be updated. Note that config.sub and config.guess are searched
|
|
|
|
# recursively in this directory.
|
|
|
|
#
|
|
|
|
define CONFIG_UPDATE
|
|
|
|
for file in config.guess config.sub; do \
|
|
|
|
for i in $$(find $(1) -name $$file); do \
|
|
|
|
cp support/gnuconfig/$$file $$i; \
|
|
|
|
done; \
|
|
|
|
done
|
|
|
|
endef
|
|
|
|
|
2009-01-16 11:27:48 +01:00
|
|
|
################################################################################
|
2012-07-03 00:07:08 +02:00
|
|
|
# inner-autotools-package -- defines how the configuration, compilation and
|
2009-11-08 18:37:49 +01:00
|
|
|
# installation of an autotools package should be done, implements a
|
|
|
|
# few hooks to tune the build process for autotools specifities and
|
|
|
|
# calls the generic package infrastructure to generate the necessary
|
|
|
|
# make targets
|
2009-01-16 11:27:48 +01:00
|
|
|
#
|
2009-11-08 18:37:49 +01:00
|
|
|
# argument 1 is the lowercase package name
|
|
|
|
# argument 2 is the uppercase package name, including an HOST_ prefix
|
|
|
|
# for host packages
|
|
|
|
# argument 3 is the uppercase package name, without the HOST_ prefix
|
|
|
|
# for host packages
|
|
|
|
# argument 4 is the package directory prefix
|
|
|
|
# argument 5 is the type (target or host)
|
2007-08-10 21:07:51 +02:00
|
|
|
################################################################################
|
|
|
|
|
2012-07-03 00:07:08 +02:00
|
|
|
define inner-autotools-package
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2010-04-28 23:40:45 +02:00
|
|
|
ifndef $(2)_LIBTOOL_PATCH
|
|
|
|
ifdef $(3)_LIBTOOL_PATCH
|
|
|
|
$(2)_LIBTOOL_PATCH = $($(3)_LIBTOOL_PATCH)
|
|
|
|
else
|
|
|
|
$(2)_LIBTOOL_PATCH ?= YES
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2011-05-17 10:00:01 +02:00
|
|
|
ifndef $(2)_MAKE
|
|
|
|
ifdef $(3)_MAKE
|
|
|
|
$(2)_MAKE = $($(3)_MAKE)
|
|
|
|
else
|
|
|
|
$(2)_MAKE ?= $(MAKE)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2013-10-02 23:37:58 +02:00
|
|
|
ifndef $(2)_AUTORECONF
|
|
|
|
ifdef $(3)_AUTORECONF
|
|
|
|
$(2)_AUTORECONF = $($(3)_AUTORECONF)
|
|
|
|
else
|
|
|
|
$(2)_AUTORECONF ?= NO
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2007-08-10 21:07:51 +02:00
|
|
|
$(2)_CONF_ENV ?=
|
|
|
|
$(2)_CONF_OPT ?=
|
2007-09-30 14:46:02 +02:00
|
|
|
$(2)_MAKE_ENV ?=
|
2007-08-10 21:07:51 +02:00
|
|
|
$(2)_MAKE_OPT ?=
|
2013-10-02 23:37:58 +02:00
|
|
|
$(2)_AUTORECONF_OPT ?= $($(3)_AUTORECONF_OPT)
|
2013-06-30 21:28:53 +02:00
|
|
|
$(2)_INSTALL_OPT ?= install
|
2007-08-10 21:07:51 +02:00
|
|
|
$(2)_INSTALL_STAGING_OPT ?= DESTDIR=$$(STAGING_DIR) install
|
2010-03-30 17:20:55 +02:00
|
|
|
$(2)_INSTALL_TARGET_OPT ?= DESTDIR=$$(TARGET_DIR) install
|
2007-08-10 21:07:51 +02:00
|
|
|
|
|
|
|
|
2009-11-08 18:37:49 +01:00
|
|
|
#
|
|
|
|
# Configure step. Only define it if not already defined by the package
|
|
|
|
# .mk file. And take care of the differences between host and target
|
|
|
|
# packages.
|
|
|
|
#
|
|
|
|
ifndef $(2)_CONFIGURE_CMDS
|
|
|
|
ifeq ($(5),target)
|
|
|
|
|
|
|
|
# Configure package for target
|
|
|
|
define $(2)_CONFIGURE_CMDS
|
|
|
|
(cd $$($$(PKG)_SRCDIR) && rm -rf config.cache && \
|
|
|
|
$$(TARGET_CONFIGURE_OPTS) \
|
|
|
|
$$(TARGET_CONFIGURE_ARGS) \
|
|
|
|
$$($$(PKG)_CONF_ENV) \
|
|
|
|
./configure \
|
|
|
|
--target=$$(GNU_TARGET_NAME) \
|
|
|
|
--host=$$(GNU_TARGET_NAME) \
|
|
|
|
--build=$$(GNU_HOST_NAME) \
|
|
|
|
--prefix=/usr \
|
|
|
|
--exec-prefix=/usr \
|
|
|
|
--sysconfdir=/etc \
|
2011-08-10 00:12:34 +02:00
|
|
|
--program-prefix="" \
|
2009-11-08 18:37:49 +01:00
|
|
|
$$(DISABLE_DOCUMENTATION) \
|
|
|
|
$$(DISABLE_NLS) \
|
|
|
|
$$(DISABLE_LARGEFILE) \
|
|
|
|
$$(DISABLE_IPV6) \
|
package/autotools: add --{enable,disable}-{shared,static} automatically
For target packages, depending on BR2_PREFER_STATIC_LIB, add the
correct combination of --{enable,disable}-{shared,static} flags to
./configure calls.
* When BR2_PREFER_STATIC_LIB is enabled, we pass --enable-static
--disable-shared.
* When BR2_PREFER_STATIC_LIB is disabled, we pass --enable-static
--enable-shared. We enable static libraries since they can still be
useful to statically link applications against some libraries
(sometimes it is useful for size reasons). Static libraries are
anyway only installed in the STAGING_DIR, so it doesn't increase in
any way the size of the TARGET_DIR.
For host packages, always pass --enable-shared and --disable-static.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
2011-05-30 23:57:02 +02:00
|
|
|
$$(SHARED_STATIC_LIBS_OPTS) \
|
2009-11-08 18:37:49 +01:00
|
|
|
$$(QUIET) $$($$(PKG)_CONF_OPT) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
else
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2009-11-08 18:37:49 +01:00
|
|
|
# Configure package for host
|
2012-12-12 05:07:22 +01:00
|
|
|
# disable all kind of documentation generation in the process,
|
|
|
|
# because it often relies on host tools which may or may not be
|
|
|
|
# installed.
|
2009-11-08 18:37:49 +01:00
|
|
|
define $(2)_CONFIGURE_CMDS
|
|
|
|
(cd $$($$(PKG)_SRCDIR) && rm -rf config.cache; \
|
|
|
|
$$(HOST_CONFIGURE_OPTS) \
|
|
|
|
CFLAGS="$$(HOST_CFLAGS)" \
|
|
|
|
LDFLAGS="$$(HOST_LDFLAGS)" \
|
2010-04-30 02:24:09 +02:00
|
|
|
$$($$(PKG)_CONF_ENV) \
|
2009-11-08 18:37:49 +01:00
|
|
|
./configure \
|
|
|
|
--prefix="$$(HOST_DIR)/usr" \
|
|
|
|
--sysconfdir="$$(HOST_DIR)/etc" \
|
package/autotools: add --{enable,disable}-{shared,static} automatically
For target packages, depending on BR2_PREFER_STATIC_LIB, add the
correct combination of --{enable,disable}-{shared,static} flags to
./configure calls.
* When BR2_PREFER_STATIC_LIB is enabled, we pass --enable-static
--disable-shared.
* When BR2_PREFER_STATIC_LIB is disabled, we pass --enable-static
--enable-shared. We enable static libraries since they can still be
useful to statically link applications against some libraries
(sometimes it is useful for size reasons). Static libraries are
anyway only installed in the STAGING_DIR, so it doesn't increase in
any way the size of the TARGET_DIR.
For host packages, always pass --enable-shared and --disable-static.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
2011-05-30 23:57:02 +02:00
|
|
|
--enable-shared --disable-static \
|
2012-12-12 05:07:22 +01:00
|
|
|
--disable-gtk-doc \
|
|
|
|
--disable-doc \
|
|
|
|
--disable-docs \
|
|
|
|
--disable-documentation \
|
|
|
|
--with-xmlto=no \
|
|
|
|
--with-fop=no \
|
2013-07-17 09:37:36 +02:00
|
|
|
$$(QUIET) $$($$(PKG)_CONF_OPT) \
|
2009-11-08 18:37:49 +01:00
|
|
|
)
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
endif
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2009-11-08 18:37:49 +01:00
|
|
|
#
|
|
|
|
# Hook to update config.sub and config.guess if needed
|
|
|
|
#
|
|
|
|
define UPDATE_CONFIG_HOOK
|
2013-03-11 16:58:31 +01:00
|
|
|
@$$(call MESSAGE,"Updating config.sub and config.guess")
|
2011-08-31 23:35:06 +02:00
|
|
|
$$(call CONFIG_UPDATE,$$(@D))
|
2009-11-08 18:37:49 +01:00
|
|
|
endef
|
2007-09-30 14:46:02 +02:00
|
|
|
|
2009-11-08 18:37:49 +01:00
|
|
|
$(2)_POST_PATCH_HOOKS += UPDATE_CONFIG_HOOK
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2009-11-08 18:37:49 +01:00
|
|
|
#
|
|
|
|
# Hook to patch libtool to make it work properly for cross-compilation
|
|
|
|
#
|
|
|
|
define LIBTOOL_PATCH_HOOK
|
2010-11-04 03:50:22 +01:00
|
|
|
@$$(call MESSAGE,"Patching libtool")
|
2010-10-09 12:52:49 +02:00
|
|
|
$(Q)if test "$$($$(PKG)_LIBTOOL_PATCH)" = "YES" \
|
|
|
|
-a "$$($$(PKG)_AUTORECONF)" != "YES"; then \
|
|
|
|
for i in `find $$($$(PKG)_SRCDIR) -name ltmain.sh`; do \
|
|
|
|
ltmain_version=`sed -n '/^[ ]*VERSION=/{s/^[ ]*VERSION=//;p;q;}' $$$$i | \
|
|
|
|
sed -e 's/\([0-9].[0-9]*\).*/\1/' -e 's/\"//'`; \
|
|
|
|
if test $$$${ltmain_version} = '1.5'; then \
|
2011-08-31 23:35:04 +02:00
|
|
|
support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v1.5.patch; \
|
2010-10-09 12:52:49 +02:00
|
|
|
elif test $$$${ltmain_version} = "2.2"; then\
|
2011-08-31 23:35:04 +02:00
|
|
|
support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v2.2.patch; \
|
2011-03-28 21:45:06 +02:00
|
|
|
elif test $$$${ltmain_version} = "2.4"; then\
|
2011-08-31 23:35:04 +02:00
|
|
|
support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v2.4.patch; \
|
2010-10-09 12:52:49 +02:00
|
|
|
fi \
|
2009-11-08 18:37:49 +01:00
|
|
|
done \
|
|
|
|
fi
|
|
|
|
endef
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2009-12-30 13:42:01 +01:00
|
|
|
# default values are not evaluated yet, so don't rely on this defaulting to YES
|
2010-04-28 23:40:47 +02:00
|
|
|
ifneq ($$($(2)_LIBTOOL_PATCH),NO)
|
2009-11-08 18:37:49 +01:00
|
|
|
$(2)_POST_PATCH_HOOKS += LIBTOOL_PATCH_HOOK
|
|
|
|
endif
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2009-11-08 18:37:49 +01:00
|
|
|
#
|
|
|
|
# Hook to autoreconf the package if needed
|
|
|
|
#
|
|
|
|
define AUTORECONF_HOOK
|
2010-11-04 03:50:22 +01:00
|
|
|
@$$(call MESSAGE,"Autoreconfiguring")
|
2009-11-08 18:37:49 +01:00
|
|
|
$(Q)cd $$($$(PKG)_SRCDIR) && $(AUTORECONF) $$($$(PKG)_AUTORECONF_OPT)
|
2010-10-09 12:52:49 +02:00
|
|
|
$(Q)if test "$$($$(PKG)_LIBTOOL_PATCH)" = "YES"; then \
|
2009-11-08 18:37:49 +01:00
|
|
|
for i in `find $$($$(PKG)_SRCDIR) -name ltmain.sh`; do \
|
2013-03-20 21:09:42 +01:00
|
|
|
ltmain_version=`sed -n '/^[ ]*VERSION=/{s/^[ ]*VERSION=//;p;q;}' $$$$i | \
|
|
|
|
sed -e 's/\([0-9].[0-9]*\).*/\1/' -e 's/\"//'`; \
|
2010-10-09 12:52:49 +02:00
|
|
|
if test $$$${ltmain_version} = "1.5"; then \
|
2011-09-17 14:16:42 +02:00
|
|
|
support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v1.5.patch; \
|
2010-10-09 12:52:49 +02:00
|
|
|
elif test $$$${ltmain_version} = "2.2"; then\
|
2011-09-17 14:16:42 +02:00
|
|
|
support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v2.2.patch; \
|
2011-05-03 10:01:28 +02:00
|
|
|
elif test $$$${ltmain_version} = "2.4"; then\
|
2011-09-17 14:16:42 +02:00
|
|
|
support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v2.4.patch; \
|
2010-10-09 12:52:49 +02:00
|
|
|
fi \
|
2009-11-08 18:37:49 +01:00
|
|
|
done \
|
|
|
|
fi
|
|
|
|
endef
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2012-07-03 00:07:08 +02:00
|
|
|
# This must be repeated from inner-generic-package, otherwise we get an empty
|
2012-01-16 14:58:35 +01:00
|
|
|
# _DEPENDENCIES if _AUTORECONF is YES. Also filter the result of _AUTORECONF
|
|
|
|
# away from the non-host rule
|
2012-07-14 22:31:19 +02:00
|
|
|
$(2)_DEPENDENCIES ?= $(filter-out host-automake host-autoconf host-libtool $(1),\
|
2012-01-16 14:58:35 +01:00
|
|
|
$(patsubst host-host-%,host-%,$(addprefix host-,$($(3)_DEPENDENCIES))))
|
2012-01-18 15:54:55 +01:00
|
|
|
|
2012-01-16 14:58:35 +01:00
|
|
|
|
autotools: fix autoreconf check
The autoreconf check was incorrect, missing a $ sign to properly
reference a package-specific variable. There was no visible effect
until now since :
* The existing syntax allowed to access the value defined in the
package specific .mk file, so when AUTORECONF was set to YES by a
package, it was working.
* The default value in Makefile.autotools.in was NO. In fact, when a
package .mkf file wasn't defining the AUTORECONF variable, the
Makefile.autotools.in test was testing the empty string against
'YES', which was false, leading to the AUTORECONF not being done,
which was the desired effect.
However, in a later patch, we intend to change this default value.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
2010-04-28 23:40:42 +02:00
|
|
|
ifeq ($$($(2)_AUTORECONF),YES)
|
2010-11-04 03:50:24 +01:00
|
|
|
$(2)_PRE_CONFIGURE_HOOKS += AUTORECONF_HOOK
|
2007-08-22 17:52:01 +02:00
|
|
|
$(2)_DEPENDENCIES += host-automake host-autoconf host-libtool
|
2009-11-08 18:37:49 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
#
|
|
|
|
# Build step. Only define it if not already defined by the package .mk
|
|
|
|
# file.
|
|
|
|
#
|
|
|
|
ifndef $(2)_BUILD_CMDS
|
|
|
|
ifeq ($(5),target)
|
|
|
|
define $(2)_BUILD_CMDS
|
2011-12-24 13:07:03 +01:00
|
|
|
$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPT) -C $$($$(PKG)_SRCDIR)
|
2009-11-08 18:37:49 +01:00
|
|
|
endef
|
2007-08-10 21:07:51 +02:00
|
|
|
else
|
2009-11-08 18:37:49 +01:00
|
|
|
define $(2)_BUILD_CMDS
|
2011-12-24 13:07:03 +01:00
|
|
|
$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPT) -C $$($$(PKG)_SRCDIR)
|
2009-11-08 18:37:49 +01:00
|
|
|
endef
|
|
|
|
endif
|
2007-08-10 21:07:51 +02:00
|
|
|
endif
|
|
|
|
|
2009-11-08 18:37:49 +01:00
|
|
|
#
|
|
|
|
# Host installation step. Only define it if not already defined by the
|
|
|
|
# package .mk file.
|
|
|
|
#
|
|
|
|
ifndef $(2)_INSTALL_CMDS
|
|
|
|
define $(2)_INSTALL_CMDS
|
2013-06-30 21:28:53 +02:00
|
|
|
$$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_OPT) -C $$($$(PKG)_SRCDIR)
|
2009-11-08 18:37:49 +01:00
|
|
|
endef
|
|
|
|
endif
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2009-11-08 18:37:49 +01:00
|
|
|
#
|
|
|
|
# Staging installation step. Only define it if not already defined by
|
|
|
|
# the package .mk file.
|
|
|
|
#
|
|
|
|
ifndef $(2)_INSTALL_STAGING_CMDS
|
|
|
|
define $(2)_INSTALL_STAGING_CMDS
|
2011-12-24 13:07:03 +01:00
|
|
|
$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_STAGING_OPT) -C $$($$(PKG)_SRCDIR)
|
2010-01-18 14:53:06 +01:00
|
|
|
for i in $$$$(find $(STAGING_DIR)/usr/lib* -name "*.la"); do \
|
2010-04-30 02:24:06 +02:00
|
|
|
cp -f $$$$i $$$$i~; \
|
2009-11-08 18:37:49 +01:00
|
|
|
$$(SED) "s:\(['= ]\)/usr:\\1$(STAGING_DIR)/usr:g" $$$$i; \
|
|
|
|
done
|
|
|
|
endef
|
|
|
|
endif
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2009-11-08 18:37:49 +01:00
|
|
|
#
|
|
|
|
# Target installation step. Only define it if not already defined by
|
|
|
|
# the package .mk file.
|
|
|
|
#
|
|
|
|
ifndef $(2)_INSTALL_TARGET_CMDS
|
|
|
|
define $(2)_INSTALL_TARGET_CMDS
|
2011-12-24 13:07:03 +01:00
|
|
|
$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_TARGET_OPT) -C $$($$(PKG)_SRCDIR)
|
2009-11-08 18:37:49 +01:00
|
|
|
endef
|
|
|
|
endif
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2009-11-08 18:37:49 +01:00
|
|
|
# Call the generic package infrastructure to generate the necessary
|
|
|
|
# make targets
|
2012-07-03 00:07:08 +02:00
|
|
|
$(call inner-generic-package,$(1),$(2),$(3),$(4),$(5))
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2009-11-08 18:37:49 +01:00
|
|
|
endef
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2009-11-08 18:37:49 +01:00
|
|
|
################################################################################
|
2012-07-03 00:07:08 +02:00
|
|
|
# autotools-package -- the target generator macro for autotools packages
|
2009-11-08 18:37:49 +01:00
|
|
|
################################################################################
|
2007-08-10 21:07:51 +02:00
|
|
|
|
2014-02-05 10:44:00 +01:00
|
|
|
autotools-package = $(call inner-autotools-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),$(pkgparentdir),target)
|
|
|
|
host-autotools-package = $(call inner-autotools-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),$(pkgparentdir),host)
|