5e1c1053e487a78e7fcb0b459d041773ac759d26
[openwrt/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 AUTOPOINT=true
26
27 # 1: build dir
28 # 2: remove files
29 # 3: automake paths
30 # 4: libtool paths
31 # 5: extra m4 dirs
32 define autoreconf
33 (cd $(1); \
34 $(patsubst %,rm -f %;,$(2)) \
35 $(foreach p,$(3), \
36 if [ -f $(p)/configure.ac ] || [ -f $(p)/configure.in ]; then \
37 [ -f $(p)/aclocal.m4 ] && [ ! -f $(p)/acinclude.m4 ] && mv aclocal.m4 acinclude.m4; \
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 %,-B %,$(5)) \
43 $(patsubst %,-I %,$(4)) -I m4 $(4) || true; \
44 fi; \
45 ) \
46 );
47 endef
48
49
50 PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH)
51 PKG_AUTOMAKE_PATHS?=$(CONFIGURE_PATH)
52 PKG_REMOVE_FILES?=aclocal.m4
53
54 Hooks/InstallDev/Post += libtool_remove_files
55
56 define autoreconf_target
57 $(strip $(call autoreconf, \
58 $(PKG_BUILD_DIR), $(PKG_REMOVE_FILES), \
59 $(PKG_AUTOMAKE_PATHS), $(PKG_LIBTOOL_PATHS), \
60 $(STAGING_DIR)/host/share/aclocal $(STAGING_DIR)/usr/share/aclocal))
61 endef
62
63 ifneq ($(filter libtool,$(PKG_FIXUP)),)
64 PKG_BUILD_DEPENDS += libtool
65 ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
66 Hooks/Configure/Pre += autoreconf_target
67 endif
68 endif
69
70 ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
71 PKG_BUILD_DEPENDS += libtool
72 ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
73 Hooks/Configure/Pre += autoreconf_target
74 endif
75 endif
76
77 ifneq ($(filter autoreconf,$(PKG_FIXUP)),)
78 ifeq ($(filter autoreconf,$(Hooks/Configure/Pre)),)
79 Hooks/Configure/Pre += autoreconf_target
80 endif
81 endif
82
83
84 HOST_FIXUP?=$(PKG_FIXUP)
85 HOST_LIBTOOL_PATHS?=$(if $(PKG_LIBTOOL_PATHS),$(PKG_LIBTOOL_PATHS),.)
86 HOST_AUTOMAKE_PATHS?=$(if $(PKG_AUTOMAKE_PATHS),$(PKG_AUTOMAKE_PATHS),.)
87 HOST_REMOVE_FILES?=$(PKG_REMOVE_FILES)
88
89 define autoreconf_host
90 $(strip $(call autoreconf, \
91 $(HOST_BUILD_DIR), $(HOST_REMOVE_FILES), \
92 $(HOST_AUTOMAKE_PATHS), $(HOST_LIBTOOL_PATHS)))
93 endef
94
95 ifneq ($(filter libtool,$(HOST_FIXUP)),)
96 ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
97 Hooks/HostConfigure/Pre += autoreconf_host
98 endif
99 endif
100
101 ifneq ($(filter libtool-ucxx,$(HOST_FIXUP)),)
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