blob: cfbdc271612ca4bb14bdc1092248b66ec4b3a760 [file] [log] [blame]
Eric Andersena7e49eb2007-08-10 19:07:51 +00001################################################################################
Thomas Petazzonid8b55b92009-11-08 18:37:49 +01002# Autotools package infrastructure
Eric Andersena7e49eb2007-08-10 19:07:51 +00003#
Thomas Petazzonid8b55b92009-11-08 18:37:49 +01004# This file implements an infrastructure that eases development of
5# package .mk files for autotools packages. It should be used for all
Thomas Petazzonic0e6b522012-04-17 16:45:20 +02006# packages that use the autotools as their build system.
Eric Andersena7e49eb2007-08-10 19:07:51 +00007#
Thomas Petazzonid8b55b92009-11-08 18:37:49 +01008# See the Buildroot documentation for details on the usage of this
9# infrastructure
Eric Andersena7e49eb2007-08-10 19:07:51 +000010#
Thomas Petazzonid8b55b92009-11-08 18:37:49 +010011# In terms of implementation, this autotools infrastructure requires
12# the .mk file to only specify metadata informations about the
13# package: name, version, download URL, etc.
Bernhard Reutner-Fischer00b84562007-09-30 12:46:02 +000014#
Thomas Petazzonid8b55b92009-11-08 18:37:49 +010015# We still allow the package .mk file to override what the different
16# steps are doing, if needed. For example, if <PKG>_BUILD_CMDS is
17# already defined, it is used as the list of commands to perform to
18# build the package, instead of the default autotools behaviour. The
19# package can also define some post operation hooks.
Bernhard Reutner-Fischer00b84562007-09-30 12:46:02 +000020#
Eric Andersena7e49eb2007-08-10 19:07:51 +000021################################################################################
22
Thomas Petazzoni102a93b2011-08-31 23:35:06 +020023
24#
25# Utility function to upgrade config.sub and config.guess files
26#
27# argument 1 : directory into which config.guess and config.sub need
28# to be updated. Note that config.sub and config.guess are searched
29# recursively in this directory.
30#
31define CONFIG_UPDATE
32 for file in config.guess config.sub; do \
33 for i in $$(find $(1) -name $$file); do \
34 cp support/gnuconfig/$$file $$i; \
35 done; \
36 done
37endef
38
Peter Korsgaardd58636d2009-01-16 10:27:48 +000039################################################################################
Arnout Vandecappelle (Essensium/Mind)46fa5cb2012-07-03 00:07:08 +020040# inner-autotools-package -- defines how the configuration, compilation and
Thomas Petazzonid8b55b92009-11-08 18:37:49 +010041# installation of an autotools package should be done, implements a
42# few hooks to tune the build process for autotools specifities and
43# calls the generic package infrastructure to generate the necessary
44# make targets
Peter Korsgaardd58636d2009-01-16 10:27:48 +000045#
Thomas Petazzonid8b55b92009-11-08 18:37:49 +010046# argument 1 is the lowercase package name
47# argument 2 is the uppercase package name, including an HOST_ prefix
48# for host packages
49# argument 3 is the uppercase package name, without the HOST_ prefix
50# for host packages
Thomas De Schampheleire26aef882014-02-05 10:44:03 +010051# argument 4 is the type (target or host)
Peter Korsgaardd58636d2009-01-16 10:27:48 +000052################################################################################
53
Arnout Vandecappelle (Essensium/Mind)46fa5cb2012-07-03 00:07:08 +020054define inner-autotools-package
Eric Andersena7e49eb2007-08-10 19:07:51 +000055
Thomas Petazzonid2c73f52010-04-28 23:40:45 +020056ifndef $(2)_LIBTOOL_PATCH
57 ifdef $(3)_LIBTOOL_PATCH
58 $(2)_LIBTOOL_PATCH = $($(3)_LIBTOOL_PATCH)
59 else
60 $(2)_LIBTOOL_PATCH ?= YES
61 endif
62endif
63
Peter Korsgaardce1ae872011-05-17 10:00:01 +020064ifndef $(2)_MAKE
65 ifdef $(3)_MAKE
66 $(2)_MAKE = $($(3)_MAKE)
67 else
68 $(2)_MAKE ?= $(MAKE)
69 endif
70endif
71
Peter Korsgaard97c68702013-10-02 23:37:58 +020072ifndef $(2)_AUTORECONF
73 ifdef $(3)_AUTORECONF
74 $(2)_AUTORECONF = $($(3)_AUTORECONF)
75 else
76 $(2)_AUTORECONF ?= NO
77 endif
78endif
79
Eric Andersena7e49eb2007-08-10 19:07:51 +000080$(2)_CONF_ENV ?=
81$(2)_CONF_OPT ?=
Bernhard Reutner-Fischer00b84562007-09-30 12:46:02 +000082$(2)_MAKE_ENV ?=
Eric Andersena7e49eb2007-08-10 19:07:51 +000083$(2)_MAKE_OPT ?=
Peter Korsgaard97c68702013-10-02 23:37:58 +020084$(2)_AUTORECONF_OPT ?= $($(3)_AUTORECONF_OPT)
Thomas Petazzoni598ade92013-06-30 21:28:53 +020085$(2)_INSTALL_OPT ?= install
Eric Andersena7e49eb2007-08-10 19:07:51 +000086$(2)_INSTALL_STAGING_OPT ?= DESTDIR=$$(STAGING_DIR) install
Paulius Zaleckas31365de2010-03-30 17:20:55 +020087$(2)_INSTALL_TARGET_OPT ?= DESTDIR=$$(TARGET_DIR) install
Eric Andersena7e49eb2007-08-10 19:07:51 +000088
89
Thomas Petazzonid8b55b92009-11-08 18:37:49 +010090#
91# Configure step. Only define it if not already defined by the package
92# .mk file. And take care of the differences between host and target
93# packages.
94#
95ifndef $(2)_CONFIGURE_CMDS
Thomas De Schampheleire26aef882014-02-05 10:44:03 +010096ifeq ($(4),target)
Eric Andersena7e49eb2007-08-10 19:07:51 +000097
Thomas Petazzonid8b55b92009-11-08 18:37:49 +010098# Configure package for target
99define $(2)_CONFIGURE_CMDS
100 (cd $$($$(PKG)_SRCDIR) && rm -rf config.cache && \
101 $$(TARGET_CONFIGURE_OPTS) \
102 $$(TARGET_CONFIGURE_ARGS) \
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100103 $$($$(PKG)_CONF_ENV) \
104 ./configure \
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100105 --target=$$(GNU_TARGET_NAME) \
106 --host=$$(GNU_TARGET_NAME) \
107 --build=$$(GNU_HOST_NAME) \
108 --prefix=/usr \
109 --exec-prefix=/usr \
110 --sysconfdir=/etc \
Yann E. MORINa8d6e2c2011-08-10 00:12:34 +0200111 --program-prefix="" \
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100112 $$(DISABLE_DOCUMENTATION) \
113 $$(DISABLE_NLS) \
114 $$(DISABLE_LARGEFILE) \
115 $$(DISABLE_IPV6) \
Thomas Petazzoni009d8fc2011-05-30 23:57:02 +0200116 $$(SHARED_STATIC_LIBS_OPTS) \
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100117 $$(QUIET) $$($$(PKG)_CONF_OPT) \
118 )
119endef
Eric Andersena7e49eb2007-08-10 19:07:51 +0000120else
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100121
122# Configure package for host
Arnout Vandecappelle489970e2012-12-12 04:07:22 +0000123# disable all kind of documentation generation in the process,
124# because it often relies on host tools which may or may not be
125# installed.
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100126define $(2)_CONFIGURE_CMDS
127 (cd $$($$(PKG)_SRCDIR) && rm -rf config.cache; \
128 $$(HOST_CONFIGURE_OPTS) \
129 CFLAGS="$$(HOST_CFLAGS)" \
130 LDFLAGS="$$(HOST_LDFLAGS)" \
Lionel Landwerlin1b41e322010-04-30 02:24:09 +0200131 $$($$(PKG)_CONF_ENV) \
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100132 ./configure \
133 --prefix="$$(HOST_DIR)/usr" \
134 --sysconfdir="$$(HOST_DIR)/etc" \
Thomas Petazzoni009d8fc2011-05-30 23:57:02 +0200135 --enable-shared --disable-static \
Arnout Vandecappelle489970e2012-12-12 04:07:22 +0000136 --disable-gtk-doc \
137 --disable-doc \
138 --disable-docs \
139 --disable-documentation \
140 --with-xmlto=no \
141 --with-fop=no \
Peter Korsgaard9f5a9de2013-07-17 09:37:36 +0200142 $$(QUIET) $$($$(PKG)_CONF_OPT) \
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100143 )
144endef
145endif
Eric Andersena7e49eb2007-08-10 19:07:51 +0000146endif
147
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100148#
149# Hook to update config.sub and config.guess if needed
150#
151define UPDATE_CONFIG_HOOK
Danomi Manchego28bb03a2013-03-11 15:58:31 +0000152 @$$(call MESSAGE,"Updating config.sub and config.guess")
Thomas Petazzoni102a93b2011-08-31 23:35:06 +0200153 $$(call CONFIG_UPDATE,$$(@D))
Eric Andersena7e49eb2007-08-10 19:07:51 +0000154endef
155
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100156$(2)_POST_PATCH_HOOKS += UPDATE_CONFIG_HOOK
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100157
158#
159# Hook to patch libtool to make it work properly for cross-compilation
160#
161define LIBTOOL_PATCH_HOOK
Lionel Landwerline1317732010-11-04 03:50:22 +0100162 @$$(call MESSAGE,"Patching libtool")
Martin Banky83af8222010-10-09 12:52:49 +0200163 $(Q)if test "$$($$(PKG)_LIBTOOL_PATCH)" = "YES" \
164 -a "$$($$(PKG)_AUTORECONF)" != "YES"; then \
165 for i in `find $$($$(PKG)_SRCDIR) -name ltmain.sh`; do \
166 ltmain_version=`sed -n '/^[ ]*VERSION=/{s/^[ ]*VERSION=//;p;q;}' $$$$i | \
167 sed -e 's/\([0-9].[0-9]*\).*/\1/' -e 's/\"//'`; \
168 if test $$$${ltmain_version} = '1.5'; then \
Thomas Petazzoni59a326b2011-08-31 23:35:04 +0200169 support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v1.5.patch; \
Martin Banky83af8222010-10-09 12:52:49 +0200170 elif test $$$${ltmain_version} = "2.2"; then\
Thomas Petazzoni59a326b2011-08-31 23:35:04 +0200171 support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v2.2.patch; \
Peter Korsgaardf055b262011-03-28 21:45:06 +0200172 elif test $$$${ltmain_version} = "2.4"; then\
Thomas Petazzoni59a326b2011-08-31 23:35:04 +0200173 support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v2.4.patch; \
Martin Banky83af8222010-10-09 12:52:49 +0200174 fi \
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100175 done \
176 fi
177endef
178
Peter Korsgaard073af422009-12-30 13:42:01 +0100179# default values are not evaluated yet, so don't rely on this defaulting to YES
Thomas Petazzoni87d0af92010-04-28 23:40:47 +0200180ifneq ($$($(2)_LIBTOOL_PATCH),NO)
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100181$(2)_POST_PATCH_HOOKS += LIBTOOL_PATCH_HOOK
182endif
183
184#
185# Hook to autoreconf the package if needed
186#
187define AUTORECONF_HOOK
Lionel Landwerline1317732010-11-04 03:50:22 +0100188 @$$(call MESSAGE,"Autoreconfiguring")
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100189 $(Q)cd $$($$(PKG)_SRCDIR) && $(AUTORECONF) $$($$(PKG)_AUTORECONF_OPT)
Martin Banky83af8222010-10-09 12:52:49 +0200190 $(Q)if test "$$($$(PKG)_LIBTOOL_PATCH)" = "YES"; then \
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100191 for i in `find $$($$(PKG)_SRCDIR) -name ltmain.sh`; do \
przemyslaw34006632013-03-20 20:09:42 +0000192 ltmain_version=`sed -n '/^[ ]*VERSION=/{s/^[ ]*VERSION=//;p;q;}' $$$$i | \
193 sed -e 's/\([0-9].[0-9]*\).*/\1/' -e 's/\"//'`; \
Martin Banky83af8222010-10-09 12:52:49 +0200194 if test $$$${ltmain_version} = "1.5"; then \
Peter Korsgaard16d6e9b2011-09-17 14:16:42 +0200195 support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v1.5.patch; \
Martin Banky83af8222010-10-09 12:52:49 +0200196 elif test $$$${ltmain_version} = "2.2"; then\
Peter Korsgaard16d6e9b2011-09-17 14:16:42 +0200197 support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v2.2.patch; \
Peter Korsgaard3178a202011-05-03 10:01:28 +0200198 elif test $$$${ltmain_version} = "2.4"; then\
Peter Korsgaard16d6e9b2011-09-17 14:16:42 +0200199 support/scripts/apply-patches.sh $$$${i%/*} support/libtool buildroot-libtool-v2.4.patch; \
Martin Banky83af8222010-10-09 12:52:49 +0200200 fi \
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100201 done \
202 fi
203endef
204
Arnout Vandecappelle (Essensium/Mind)46fa5cb2012-07-03 00:07:08 +0200205# This must be repeated from inner-generic-package, otherwise we get an empty
Arnout Vandecappelle (Essensium/Mind)bbc53fa2012-01-16 14:58:35 +0100206# _DEPENDENCIES if _AUTORECONF is YES. Also filter the result of _AUTORECONF
207# away from the non-host rule
Arnout Vandecappelle (Essensium/Mind)cbf16912012-07-14 22:31:19 +0200208$(2)_DEPENDENCIES ?= $(filter-out host-automake host-autoconf host-libtool $(1),\
Arnout Vandecappelle (Essensium/Mind)bbc53fa2012-01-16 14:58:35 +0100209 $(patsubst host-host-%,host-%,$(addprefix host-,$($(3)_DEPENDENCIES))))
Peter Korsgaard1b079282012-01-18 15:54:55 +0100210
Arnout Vandecappelle (Essensium/Mind)bbc53fa2012-01-16 14:58:35 +0100211
Thomas Petazzoni7dfa3b32010-04-28 23:40:42 +0200212ifeq ($$($(2)_AUTORECONF),YES)
Lionel Landwerlin89d1ad92010-11-04 03:50:24 +0100213$(2)_PRE_CONFIGURE_HOOKS += AUTORECONF_HOOK
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100214$(2)_DEPENDENCIES += host-automake host-autoconf host-libtool
215endif
216
217#
218# Build step. Only define it if not already defined by the package .mk
219# file.
220#
221ifndef $(2)_BUILD_CMDS
Thomas De Schampheleire26aef882014-02-05 10:44:03 +0100222ifeq ($(4),target)
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100223define $(2)_BUILD_CMDS
Thomas Petazzoni43695a92011-12-24 13:07:03 +0100224 $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPT) -C $$($$(PKG)_SRCDIR)
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100225endef
226else
227define $(2)_BUILD_CMDS
Thomas Petazzoni43695a92011-12-24 13:07:03 +0100228 $$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPT) -C $$($$(PKG)_SRCDIR)
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100229endef
230endif
231endif
232
233#
234# Host installation step. Only define it if not already defined by the
235# package .mk file.
236#
237ifndef $(2)_INSTALL_CMDS
238define $(2)_INSTALL_CMDS
Thomas Petazzoni598ade92013-06-30 21:28:53 +0200239 $$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_OPT) -C $$($$(PKG)_SRCDIR)
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100240endef
241endif
242
243#
244# Staging installation step. Only define it if not already defined by
245# the package .mk file.
246#
247ifndef $(2)_INSTALL_STAGING_CMDS
248define $(2)_INSTALL_STAGING_CMDS
Thomas Petazzoni43695a92011-12-24 13:07:03 +0100249 $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_STAGING_OPT) -C $$($$(PKG)_SRCDIR)
Peter Korsgaardecf59392010-01-18 14:53:06 +0100250 for i in $$$$(find $(STAGING_DIR)/usr/lib* -name "*.la"); do \
Lionel Landwerline8b469b2010-04-30 02:24:06 +0200251 cp -f $$$$i $$$$i~; \
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100252 $$(SED) "s:\(['= ]\)/usr:\\1$(STAGING_DIR)/usr:g" $$$$i; \
253 done
254endef
255endif
256
257#
258# Target installation step. Only define it if not already defined by
259# the package .mk file.
260#
261ifndef $(2)_INSTALL_TARGET_CMDS
262define $(2)_INSTALL_TARGET_CMDS
Thomas Petazzoni43695a92011-12-24 13:07:03 +0100263 $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_TARGET_OPT) -C $$($$(PKG)_SRCDIR)
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100264endef
265endif
266
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100267# Call the generic package infrastructure to generate the necessary
268# make targets
Thomas De Schampheleire26aef882014-02-05 10:44:03 +0100269$(call inner-generic-package,$(1),$(2),$(3),$(4))
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100270
271endef
272
273################################################################################
Arnout Vandecappelle (Essensium/Mind)46fa5cb2012-07-03 00:07:08 +0200274# autotools-package -- the target generator macro for autotools packages
Thomas Petazzonid8b55b92009-11-08 18:37:49 +0100275################################################################################
276
Thomas De Schampheleire26aef882014-02-05 10:44:03 +0100277autotools-package = $(call inner-autotools-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
278host-autotools-package = $(call inner-autotools-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)