[include] autotools.mk: always pass -I m4, some package don't seem to set correct...
[15.05/openwrt.git] / include / autotools.mk
1 #
2 # Copyright (C) 2007-2010 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 autoconf_bool = $(patsubst %,$(if $($(1)),--enable,--disable)-%,$(2))
9
10 # delete *.la-files from staging_dir - we can not yet remove respective lines within all package
11 # Makefiles, since backfire still uses libtool v1.5.x which (may) require those files
12 define libtool_remove_files
13         find $(1) -name '*.la' | $(XARGS) rm -f;
14 endef
15
16
17 AM_TOOL_PATHS:= \
18         AUTOM4TE=$(STAGING_DIR_HOST)/bin/autom4te \
19         AUTOCONF=$(STAGING_DIR_HOST)/bin/autoconf \
20         AUTOMAKE=$(STAGING_DIR_HOST)/bin/automake \
21         ACLOCAL=$(STAGING_DIR_HOST)/bin/aclocal \
22         AUTOHEADER=$(STAGING_DIR_HOST)/bin/autoheader \
23         LIBTOOLIZE=$(STAGING_DIR_HOST)/bin/libtoolize \
24         M4=$(STAGING_DIR_HOST)/bin/m4
25
26 # 1: build dir
27 # 2: remove files
28 # 3: automake paths
29 # 4: libtool paths
30 # 5: extra m4 dirs
31 define autoreconf
32         (cd $(1); \
33                 $(patsubst %,rm -f %;,$(2)) \
34                 $(foreach p,$(3), \
35                         if [ -f $(p)/configure.ac ] || [ -f $(p)/configure.in ]; then \
36                                 [ -f $(p)/aclocal.m4 ] && [ ! -f $(p)/acinclude.m4 ] && mv aclocal.m4 acinclude.m4; \
37                                 [ -d $(p)/autom4te.cache ] && rm -rf autom4te.cache; \
38                                 $(AM_TOOL_PATHS) $(STAGING_DIR_HOST)/bin/autoreconf -v -f -i -s \
39                                         -B $(STAGING_DIR_HOST)/share/aclocal \
40                                         $(patsubst %,-B %,$(5)) \
41                                         $(patsubst %,-I %,$(4)) -I m4 $(4) || true; \
42                         fi; \
43                 ) \
44         );
45 endef
46
47
48 PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH)
49 PKG_AUTOMAKE_PATHS?=$(CONFIGURE_PATH)
50 PKG_REMOVE_FILES?=aclocal.m4
51
52 Hooks/InstallDev/Post += libtool_remove_files
53
54 define autoreconf_target
55   $(strip $(call autoreconf, \
56     $(PKG_BUILD_DIR), $(PKG_REMOVE_FILES), \
57     $(PKG_AUTOMAKE_PATHS), $(PKG_LIBTOOL_PATHS), \
58     $(STAGING_DIR)/host/share/aclocal $(STAGING_DIR)/usr/share/aclocal))
59 endef
60
61 ifneq ($(filter libtool,$(PKG_FIXUP)),)
62   PKG_BUILD_DEPENDS += libtool
63  ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
64   Hooks/Configure/Pre += autoreconf_target
65  endif
66 endif
67
68 ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
69   PKG_BUILD_DEPENDS += libtool
70  ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
71   Hooks/Configure/Pre += autoreconf_target
72  endif
73 endif
74
75 ifneq ($(filter autoreconf,$(PKG_FIXUP)),)
76   ifeq ($(filter autoreconf,$(Hooks/Configure/Pre)),)
77     Hooks/Configure/Pre += autoreconf_target
78   endif
79 endif
80
81
82 HOST_FIXUP?=$(PKG_FIXUP)
83 HOST_LIBTOOL_PATHS?=$(if $(PKG_LIBTOOL_PATHS),$(PKG_LIBTOOL_PATHS),.)
84 HOST_AUTOMAKE_PATHS?=$(if $(PKG_AUTOMAKE_PATHS),$(PKG_AUTOMAKE_PATHS),.)
85 HOST_REMOVE_FILES?=$(PKG_REMOVE_FILES)
86
87 define autoreconf_host
88   $(strip $(call autoreconf, \
89     $(HOST_BUILD_DIR), $(HOST_REMOVE_FILES), \
90     $(HOST_AUTOMAKE_PATHS), $(HOST_LIBTOOL_PATHS)))
91 endef
92
93 ifneq ($(filter libtool,$(HOST_FIXUP)),)
94   HOST_BUILD_DEPENDS += libtool
95  ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
96   Hooks/HostConfigure/Pre += autoreconf_host
97  endif
98 endif
99
100 ifneq ($(filter libtool-ucxx,$(HOST_FIXUP)),)
101   HOST_BUILD_DEPENDS += libtool
102  ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
103   Hooks/HostConfigure/Pre += autoreconf_host
104  endif
105 endif
106
107 ifneq ($(filter autoreconf,$(HOST_FIXUP)),)
108   ifeq ($(filter autoreconf,$(Hooks/HostConfigure/Pre)),)
109     Hooks/HostConfigure/Pre += autoreconf_host
110   endif
111 endif