7797031fd6143376a702ac9794d670f60d965065
[openwrt-10.03/.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         LIBTOOL=$(STAGING_DIR_HOST)/bin/libtool \
25         M4=$(STAGING_DIR_HOST)/bin/m4 \
26         AUTOPOINT=true
27
28 # 1: build dir
29 # 2: remove files
30 # 3: automake paths
31 # 4: libtool paths
32 # 5: extra m4 dirs
33 define autoreconf
34         (cd $(1); \
35                 $(patsubst %,rm -f %;,$(2)) \
36                 $(foreach p,$(3), \
37                         if [ -f $(p)/configure.ac ] || [ -f $(p)/configure.in ]; then \
38                                 [ -d $(p)/autom4te.cache ] && rm -rf autom4te.cache; \
39                                 touch NEWS AUTHORS COPYING ChangeLog; \
40                                 $(AM_TOOL_PATHS) $(STAGING_DIR_HOST)/bin/autoreconf -v -f -i -s \
41                                         -B $(STAGING_DIR_HOST)/share/aclocal \
42                                         $(patsubst %,-I %,$(5)) \
43                                         $(patsubst %,-I %,$(4)) $(4) || true; \
44                                 [ -e $(p)/config.rpath ] || \
45                                                 ln -s $(SCRIPT_DIR)/config.rpath $(p)/config.rpath;
46                         fi; \
47                 ) \
48         );
49 endef
50
51
52 PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH)
53 PKG_AUTOMAKE_PATHS?=$(CONFIGURE_PATH)
54 PKG_MACRO_PATHS?=m4
55 PKG_REMOVE_FILES?=aclocal.m4
56
57 Hooks/InstallDev/Post += libtool_remove_files
58
59 define autoreconf_target
60   $(strip $(call autoreconf, \
61     $(PKG_BUILD_DIR), $(PKG_REMOVE_FILES), \
62     $(PKG_AUTOMAKE_PATHS), $(PKG_LIBTOOL_PATHS), \
63     $(STAGING_DIR)/host/share/aclocal $(STAGING_DIR)/usr/share/aclocal $(PKG_MACRO_PATHS)))
64 endef
65
66 ifneq ($(filter libtool,$(PKG_FIXUP)),)
67   PKG_BUILD_DEPENDS += libtool libintl libiconv
68  ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
69   Hooks/Configure/Pre += autoreconf_target
70  endif
71 endif
72
73 ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
74   PKG_BUILD_DEPENDS += libtool libintl libiconv
75  ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
76   Hooks/Configure/Pre += autoreconf_target
77  endif
78 endif
79
80 ifneq ($(filter autoreconf,$(PKG_FIXUP)),)
81   ifeq ($(filter autoreconf,$(Hooks/Configure/Pre)),)
82     Hooks/Configure/Pre += autoreconf_target
83   endif
84 endif
85
86
87 HOST_FIXUP?=$(PKG_FIXUP)
88 HOST_LIBTOOL_PATHS?=$(if $(PKG_LIBTOOL_PATHS),$(PKG_LIBTOOL_PATHS),.)
89 HOST_AUTOMAKE_PATHS?=$(if $(PKG_AUTOMAKE_PATHS),$(PKG_AUTOMAKE_PATHS),.)
90 HOST_MACRO_PATHS?=$(if $(PKG_MACRO_PATHS),$(PKG_MACRO_PATHS),m4)
91 HOST_REMOVE_FILES?=$(PKG_REMOVE_FILES)
92
93 define autoreconf_host
94   $(strip $(call autoreconf, \
95     $(HOST_BUILD_DIR), $(HOST_REMOVE_FILES), \
96     $(HOST_AUTOMAKE_PATHS), $(HOST_LIBTOOL_PATHS), \
97     $(HOST_MACRO_PATHS)))
98 endef
99
100 ifneq ($(filter libtool,$(HOST_FIXUP)),)
101  ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
102   Hooks/HostConfigure/Pre += autoreconf_host
103  endif
104 endif
105
106 ifneq ($(filter libtool-ucxx,$(HOST_FIXUP)),)
107  ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
108   Hooks/HostConfigure/Pre += autoreconf_host
109  endif
110 endif
111
112 ifneq ($(filter autoreconf,$(HOST_FIXUP)),)
113   ifeq ($(filter autoreconf,$(Hooks/HostConfigure/Pre)),)
114     Hooks/HostConfigure/Pre += autoreconf_host
115   endif
116 endif