fix: _brightness.sh - find brighness files with '*video*' path (multiple files)
[cmdllinux.git] / buildroot / _buildroot / engine0010 / pkg-autotools.mk
blob986f524e517c5f807d6639d5d8f7628780bec543
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
9 # infrastructure
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.
31 define 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
37 endef
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:
45 # FOOBAR_CONF_ENV = \
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))
55 endef
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)_DIR) -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}; \
74 else \
75 patch -i support/libtool/buildroot-libtool-v2.4.patch $${i}; \
76 fi \
77 fi \
78 done
79 endef
82 # Hook to patch common issue with configure on powerpc64{,le} failing
83 # to detect shared library support:
85 define CONFIGURE_FIX_POWERPC64_HOOK
86 @$(call MESSAGE,"Checking configure (powerpc64/powerpc64le)")
87 support/scripts/fix-configure-powerpc64.sh $($(PKG)_DIR)
88 endef
91 # Hook to gettextize the package if needed
93 define GETTEXTIZE_HOOK
94 @$(call MESSAGE,"Gettextizing")
95 $(Q)cd $($(PKG)_SRCDIR) && $(GETTEXTIZE) $($(PKG)_GETTEXTIZE_OPTS)
96 endef
99 # Hook to autoreconf the package if needed
101 define AUTORECONF_HOOK
102 @$(call MESSAGE,"Autoreconfiguring")
103 $(Q)cd $($(PKG)_SRCDIR) && $($(PKG)_AUTORECONF_ENV) $(AUTORECONF) $($(PKG)_AUTORECONF_OPTS)
104 endef
106 ################################################################################
107 # inner-autotools-package -- defines how the configuration, compilation and
108 # installation of an autotools package should be done, implements a
109 # few hooks to tune the build process for autotools specifities and
110 # calls the generic package infrastructure to generate the necessary
111 # make targets
113 # argument 1 is the lowercase package name
114 # argument 2 is the uppercase package name, including a HOST_ prefix
115 # for host packages
116 # argument 3 is the uppercase package name, without the HOST_ prefix
117 # for host packages
118 # argument 4 is the type (target or host)
119 ################################################################################
121 define inner-autotools-package
123 ifndef $(2)_LIBTOOL_PATCH
124 ifdef $(3)_LIBTOOL_PATCH
125 $(2)_LIBTOOL_PATCH = $$($(3)_LIBTOOL_PATCH)
126 else
127 $(2)_LIBTOOL_PATCH ?= YES
128 endif
129 endif
131 ifndef $(2)_MAKE
132 ifdef $(3)_MAKE
133 $(2)_MAKE = $$($(3)_MAKE)
134 else
135 $(2)_MAKE ?= $$(MAKE)
136 endif
137 endif
139 ifndef $(2)_AUTORECONF
140 ifdef $(3)_AUTORECONF
141 $(2)_AUTORECONF = $$($(3)_AUTORECONF)
142 else
143 $(2)_AUTORECONF ?= NO
144 endif
145 endif
147 ifndef $(2)_GETTEXTIZE
148 ifdef $(3)_GETTEXTIZE
149 $(2)_GETTEXTIZE = $$($(3)_GETTEXTIZE)
150 else
151 $(2)_GETTEXTIZE ?= NO
152 endif
153 endif
155 ifeq ($(4),host)
156 $(2)_GETTEXTIZE_OPTS ?= $$($(3)_GETTEXTIZE_OPTS)
157 endif
159 ifeq ($(4),host)
160 $(2)_AUTORECONF_OPTS ?= $$($(3)_AUTORECONF_OPTS)
161 endif
163 $(2)_CONF_ENV ?=
164 $(2)_CONF_OPTS ?=
165 $(2)_MAKE_ENV ?=
166 $(2)_MAKE_OPTS ?=
167 $(2)_INSTALL_OPTS ?= install
168 $(2)_INSTALL_STAGING_OPTS ?= DESTDIR=$$(STAGING_DIR) install
169 $(2)_INSTALL_TARGET_OPTS ?= DESTDIR=$$(TARGET_DIR) install
172 # Configure step. Only define it if not already defined by the package
173 # .mk file. And take care of the differences between host and target
174 # packages.
176 ifndef $(2)_CONFIGURE_CMDS
177 ifeq ($(4),target)
179 # Configure package for target
180 define $(2)_CONFIGURE_CMDS
181 (cd $$($$(PKG)_SRCDIR) && rm -rf config.cache && \
182 $$(TARGET_CONFIGURE_OPTS) \
183 $$(TARGET_CONFIGURE_ARGS) \
184 $$($$(PKG)_CONF_ENV) \
185 CONFIG_SITE=/dev/null \
186 ./configure \
187 --prefix=/usr \
188 --exec-prefix=/usr \
189 --sysconfdir=/etc \
190 --localstatedir=/var \
191 --program-prefix="" \
192 --disable-gtk-doc \
193 --disable-gtk-doc-html \
194 --disable-doc \
195 --disable-docs \
196 --disable-documentation \
197 --with-xmlto=no \
198 --with-fop=no \
199 $$(if $$($$(PKG)_OVERRIDE_SRCDIR),,--disable-dependency-tracking) \
200 --enable-ipv6 \
201 $$(DISABLE_NLS) \
202 $$(SHARED_STATIC_LIBS_OPTS) \
203 $$(QUIET) $$($$(PKG)_CONF_OPTS) \
205 endef
206 else
208 # Configure package for host
209 # disable all kind of documentation generation in the process,
210 # because it often relies on host tools which may or may not be
211 # installed.
212 define $(2)_CONFIGURE_CMDS
213 (cd $$($$(PKG)_SRCDIR) && rm -rf config.cache; \
214 $$(HOST_CONFIGURE_OPTS) \
215 CFLAGS="$$(HOST_CFLAGS)" \
216 LDFLAGS="$$(HOST_LDFLAGS)" \
217 $$($$(PKG)_CONF_ENV) \
218 CONFIG_SITE=/dev/null \
219 ./configure \
220 --prefix="$$(HOST_DIR)/usr" \
221 --sysconfdir="$$(HOST_DIR)/etc" \
222 --localstatedir="$$(HOST_DIR)/var" \
223 --enable-shared --enable-static \
224 --disable-gtk-doc \
225 --disable-gtk-doc-html \
226 --disable-doc \
227 --disable-docs \
228 --disable-documentation \
229 --disable-debug \
230 --with-xmlto=no \
231 --with-fop=no \
232 $$(if $$($$(PKG)_OVERRIDE_SRCDIR),,--disable-dependency-tracking) \
233 $$(QUIET) $$($$(PKG)_CONF_OPTS) \
235 endef
236 endif
237 endif
239 $(2)_POST_PATCH_HOOKS += UPDATE_CONFIG_HOOK
241 ifeq ($$($(2)_AUTORECONF),YES)
243 # This has to come before autoreconf
244 ifeq ($$($(2)_GETTEXTIZE),YES)
245 $(2)_PRE_CONFIGURE_HOOKS += GETTEXTIZE_HOOK
246 $(2)_DEPENDENCIES += gettext
247 endif
248 $(2)_PRE_CONFIGURE_HOOKS += AUTORECONF_HOOK
249 # default values are not evaluated yet, so don't rely on this defaulting to YES
250 #ifneq ($$($(2)_LIBTOOL_PATCH),NO)
251 #$(2)_PRE_CONFIGURE_HOOKS += LIBTOOL_PATCH_HOOK
252 #endif
253 $(2)_DEPENDENCIES += automake autoconf libtool
255 else # ! AUTORECONF = YES
257 # default values are not evaluated yet, so don't rely on this defaulting to YES
258 #ifneq ($$($(2)_LIBTOOL_PATCH),NO)
259 #$(2)_POST_PATCH_HOOKS += LIBTOOL_PATCH_HOOK
260 #endif
262 endif
264 # Append a configure hook if building for a powerpc64 (or powerpc64le) arch.
265 # Must be added after other pre-configure hooks that might regenerate the
266 # configure script and overwrite the changes made here.
267 ifneq ($$(filter powerpc64%,$$(if $$(filter target,$(4)),$$(ARCH),$$(HOSTARCH))),)
268 $(2)_PRE_CONFIGURE_HOOKS += CONFIGURE_FIX_POWERPC64_HOOK
269 endif
272 # Build step. Only define it if not already defined by the package .mk
273 # file.
275 ifndef $(2)_BUILD_CMDS
276 ifeq ($(4),target)
277 define $(2)_BUILD_CMDS
278 $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR)
279 endef
280 else
281 define $(2)_BUILD_CMDS
282 $$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_MAKE_OPTS) -C $$($$(PKG)_SRCDIR)
283 endef
284 endif
285 endif
288 # Host installation step. Only define it if not already defined by the
289 # package .mk file.
291 ifndef $(2)_INSTALL_CMDS
292 define $(2)_INSTALL_CMDS
293 $$(HOST_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_OPTS) -C $$($$(PKG)_SRCDIR)
294 endef
295 endif
298 # Staging installation step. Only define it if not already defined by
299 # the package .mk file.
301 ifndef $(2)_INSTALL_STAGING_CMDS
302 define $(2)_INSTALL_STAGING_CMDS
303 $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_STAGING_OPTS) -C $$($$(PKG)_SRCDIR)
304 endef
305 endif
308 # Target installation step. Only define it if not already defined by
309 # the package .mk file.
311 ifndef $(2)_INSTALL_TARGET_CMDS
312 define $(2)_INSTALL_TARGET_CMDS
313 $$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_TARGET_OPTS) -C $$($$(PKG)_SRCDIR)
314 endef
315 endif
317 # Call the generic package infrastructure to generate the necessary
318 # make targets
319 $(call inner-generic-package,$(1),$(2),$(3),$(4))
321 endef
323 ################################################################################
324 # autotools-package -- the target generator macro for autotools packages
325 ################################################################################
327 autotools-package = $(call inner-autotools-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
328 host-autotools-package = $(call inner-autotools-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)