1 ################################################################################
2 # Autotools package infrastructure
4 # This file implements an infrastructure that eases development of
5 # package .mk files for autotools packages. It should be used for all
6 # packages that use the autotools as their build system.
8 # See the Buildroot documentation for details on the usage of this
11 # In terms of implementation, this autotools infrastructure requires
12 # the .mk file to only specify metadata information about the
13 # package: name, version, download URL, etc.
15 # 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.
21 ################################################################################
25 # Utility function to upgrade config.sub and config.guess files
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.
32 for file in config.guess config.sub
; do \
33 for i in
$$(find
$(1) -name
$$file); do \
34 cp support
/gnuconfig
/$$file $$i; \
39 # This function generates the ac_cv_file_<foo> value for a given
40 # filename. This is needed to convince configure script doing
41 # AC_CHECK_FILE() tests that the file actually exists, since such
42 # tests cannot be done in a cross-compilation context. This function
43 # takes as argument the path of the file. An example usage is:
46 # $(call AUTOCONF_AC_CHECK_FILE_VAL,/dev/random)=yes
47 AUTOCONF_AC_CHECK_FILE_VAL
= ac_cv_file_
$(subst -,_
,$(subst /,_
,$(subst .
,_
,$(1))))
50 # Hook to update config.sub and config.guess if needed
52 define UPDATE_CONFIG_HOOK
53 @
$(call MESSAGE
,"Updating config.sub and config.guess")
54 $(call CONFIG_UPDATE
,$(@D
))
58 # Hook to patch libtool to make it work properly for cross-compilation
60 define LIBTOOL_PATCH_HOOK
61 @
$(call MESSAGE
,"Patching libtool")
62 $(Q
)for i in
`find $($(PKG)_SRCDIR) -name ltmain.sh`; do \
63 ltmain_version
=`sed -n '/^[ \t]*VERSION=/{s/^[ \t]*VERSION=//;p;q;}' $$i | \
64 sed -e 's/\([0-9]*\.[0-9]*\).*/\1/' -e 's/\"//'`; \
65 ltmain_patchlevel
=`sed -n '/^[ \t]*VERSION=/{s/^[ \t]*VERSION=//;p;q;}' $$i | \
66 sed -e 's/\([0-9]*\.[0-9]*\.*\)\([0-9]*\).*/\2/' -e 's/\"//'`; \
67 if
test $${ltmain_version} = '1.5'; then \
68 patch
-i support
/libtool
/buildroot-libtool-v1.5.patch
$${i}; \
69 elif
test $${ltmain_version} = "2.2"; then\
70 patch
-i support
/libtool
/buildroot-libtool-v2.2.patch
$${i}; \
71 elif
test $${ltmain_version} = "2.4"; then\
72 if
test $${ltmain_patchlevel
:-0} -gt
2; then\
73 patch
-i support
/libtool
/buildroot-libtool-v2.4
.4.patch
$${i}; \
75 patch
-i support
/libtool
/buildroot-libtool-v2.4.patch
$${i}; \
82 # Hook to gettextize the package if needed
84 define GETTEXTIZE_HOOK
85 @
$(call MESSAGE
,"Gettextizing")
86 $(Q
)cd
$($(PKG
)_SRCDIR
) && $(GETTEXTIZE
) $($(PKG
)_GETTEXTIZE_OPTS
)
90 # Hook to autoreconf the package if needed
92 define AUTORECONF_HOOK
93 @
$(call MESSAGE
,"Autoreconfiguring")
94 $(Q
)cd
$($(PKG
)_SRCDIR
) && $($(PKG
)_AUTORECONF_ENV
) $(AUTORECONF
) $($(PKG
)_AUTORECONF_OPTS
)
97 ################################################################################
98 # inner-autotools-package -- defines how the configuration, compilation and
99 # installation of an autotools package should be done, implements a
100 # few hooks to tune the build process for autotools specifities and
101 # calls the generic package infrastructure to generate the necessary
104 # argument 1 is the lowercase package name
105 # argument 2 is the uppercase package name, including a HOST_ prefix
107 # argument 3 is the uppercase package name, without the HOST_ prefix
109 # argument 4 is the type (target or host)
110 ################################################################################
112 define inner-autotools-package
114 ifndef $(2)_LIBTOOL_PATCH
115 ifdef $(3)_LIBTOOL_PATCH
116 $(2)_LIBTOOL_PATCH
= $$($(3)_LIBTOOL_PATCH
)
118 $(2)_LIBTOOL_PATCH ?
= YES
124 $(2)_MAKE
= $$($(3)_MAKE
)
126 $(2)_MAKE ?
= $$(MAKE
)
130 ifndef $(2)_AUTORECONF
131 ifdef $(3)_AUTORECONF
132 $(2)_AUTORECONF
= $$($(3)_AUTORECONF
)
134 $(2)_AUTORECONF ?
= NO
138 ifndef $(2)_GETTEXTIZE
139 ifdef $(3)_GETTEXTIZE
140 $(2)_GETTEXTIZE
= $$($(3)_GETTEXTIZE
)
142 $(2)_GETTEXTIZE ?
= NO
147 $(2)_GETTEXTIZE_OPTS ?
= $$($(3)_GETTEXTIZE_OPTS
)
151 $(2)_AUTORECONF_OPTS ?
= $$($(3)_AUTORECONF_OPTS
)
158 $(2)_INSTALL_OPTS ?
= install
159 $(2)_INSTALL_STAGING_OPTS ?
= DESTDIR
=$$(STAGING_DIR
) install
160 $(2)_INSTALL_TARGET_OPTS ?
= DESTDIR
=$$(TARGET_DIR
) install
163 # Configure step. Only define it if not already defined by the package
164 # .mk file. And take care of the differences between host and target
167 ifndef $(2)_CONFIGURE_CMDS
170 # Configure package for target
171 define $(2)_CONFIGURE_CMDS
172 (cd
$$($$(PKG
)_SRCDIR
) && rm -rf config.cache
&& \
173 $$(TARGET_CONFIGURE_OPTS
) \
174 $$(TARGET_CONFIGURE_ARGS
) \
175 $$($$(PKG
)_CONF_ENV
) \
176 CONFIG_SITE
=/dev
/null \
178 --target
=$$(GNU_TARGET_NAME
) \
179 --host
=$$(GNU_TARGET_NAME
) \
180 --build
=$$(GNU_HOST_NAME
) \
184 --localstatedir
=/var \
185 --program-prefix
="" \
187 --disable-gtk-doc-html \
190 --disable-documentation \
193 --disable-dependency-tracking \
196 $$(SHARED_STATIC_LIBS_OPTS
) \
197 $$(QUIET
) $$($$(PKG
)_CONF_OPTS
) \
202 # Configure package for host
203 # disable all kind of documentation generation in the process,
204 # because it often relies on host tools which may or may not be
206 define $(2)_CONFIGURE_CMDS
207 (cd
$$($$(PKG
)_SRCDIR
) && rm -rf config.cache
; \
208 $$(HOST_CONFIGURE_OPTS
) \
209 CFLAGS
="$$(HOST_CFLAGS)" \
210 LDFLAGS
="$$(HOST_LDFLAGS)" \
211 $$($$(PKG
)_CONF_ENV
) \
212 CONFIG_SITE
=/dev
/null \
214 --prefix="$$(HOST_DIR)/usr" \
215 --sysconfdir
="$$(HOST_DIR)/etc" \
216 --localstatedir
="$$(HOST_DIR)/var" \
217 --enable-shared
--disable-static \
219 --disable-gtk-doc-html \
222 --disable-documentation \
226 --disable-dependency-tracking \
227 $$(QUIET
) $$($$(PKG
)_CONF_OPTS
) \
233 $(2)_POST_PATCH_HOOKS
+= UPDATE_CONFIG_HOOK
235 ifeq ($$($(2)_AUTORECONF
),YES
)
237 # This has to come before autoreconf
238 ifeq ($$($(2)_GETTEXTIZE
),YES
)
239 $(2)_PRE_CONFIGURE_HOOKS
+= GETTEXTIZE_HOOK
240 $(2)_DEPENDENCIES
+= host-gettext
242 $(2)_PRE_CONFIGURE_HOOKS
+= AUTORECONF_HOOK
243 # default values are not evaluated yet, so don't rely on this defaulting to YES
244 ifneq ($$($(2)_LIBTOOL_PATCH
),NO
)
245 $(2)_PRE_CONFIGURE_HOOKS
+= LIBTOOL_PATCH_HOOK
247 $(2)_DEPENDENCIES
+= host-automake host-autoconf host-libtool
249 else # ! AUTORECONF = YES
251 # default values are not evaluated yet, so don't rely on this defaulting to YES
252 ifneq ($$($(2)_LIBTOOL_PATCH
),NO
)
253 $(2)_POST_PATCH_HOOKS
+= LIBTOOL_PATCH_HOOK
259 # Build step. Only define it if not already defined by the package .mk
262 ifndef $(2)_BUILD_CMDS
264 define $(2)_BUILD_CMDS
265 $$(TARGET_MAKE_ENV
) $$($$(PKG
)_MAKE_ENV
) $$($$(PKG
)_MAKE
) $$($$(PKG
)_MAKE_OPTS
) -C
$$($$(PKG
)_SRCDIR
)
268 define $(2)_BUILD_CMDS
269 $$(HOST_MAKE_ENV
) $$($$(PKG
)_MAKE_ENV
) $$($$(PKG
)_MAKE
) $$($$(PKG
)_MAKE_OPTS
) -C
$$($$(PKG
)_SRCDIR
)
275 # Host installation step. Only define it if not already defined by the
278 ifndef $(2)_INSTALL_CMDS
279 define $(2)_INSTALL_CMDS
280 $$(HOST_MAKE_ENV
) $$($$(PKG
)_MAKE_ENV
) $$($$(PKG
)_MAKE
) $$($$(PKG
)_INSTALL_OPTS
) -C
$$($$(PKG
)_SRCDIR
)
285 # Staging installation step. Only define it if not already defined by
286 # the package .mk file.
288 ifndef $(2)_INSTALL_STAGING_CMDS
289 define $(2)_INSTALL_STAGING_CMDS
290 $$(TARGET_MAKE_ENV
) $$($$(PKG
)_MAKE_ENV
) $$($$(PKG
)_MAKE
) $$($$(PKG
)_INSTALL_STAGING_OPTS
) -C
$$($$(PKG
)_SRCDIR
)
295 # Target installation step. Only define it if not already defined by
296 # the package .mk file.
298 ifndef $(2)_INSTALL_TARGET_CMDS
299 define $(2)_INSTALL_TARGET_CMDS
300 $$(TARGET_MAKE_ENV
) $$($$(PKG
)_MAKE_ENV
) $$($$(PKG
)_MAKE
) $$($$(PKG
)_INSTALL_TARGET_OPTS
) -C
$$($$(PKG
)_SRCDIR
)
304 # Call the generic package infrastructure to generate the necessary
306 $(call inner-generic-package
,$(1),$(2),$(3),$(4))
310 ################################################################################
311 # autotools-package -- the target generator macro for autotools packages
312 ################################################################################
314 autotools-package
= $(call inner-autotools-package
,$(pkgname
),$(call UPPERCASE
,$(pkgname
)),$(call UPPERCASE
,$(pkgname
)),target
)
315 host-autotools-package
= $(call inner-autotools-package
,host-
$(pkgname
),$(call UPPERCASE
,host-
$(pkgname
)),$(call UPPERCASE
,$(pkgname
)),host
)