include: autotools: Add dummy GTKDOCIZE
[openwrt/staging/jow.git] / include / autotools.mk
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2007-2020 OpenWrt.org
4
5 ifneq ($(__autotools_inc),1)
6 __autotools_inc=1
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 GTKDOCIZE=true
28
29 # 1: build dir
30 # 2: remove files
31 # 3: automake paths
32 # 4: libtool paths
33 # 5: extra m4 dirs
34 define autoreconf
35 (cd $(1); \
36 $(patsubst %,rm -f %;,$(2)) \
37 $(foreach p,$(3), \
38 if [ -f $(p)/configure.ac ] || [ -f $(p)/configure.in ]; then \
39 [ -d $(p)/autom4te.cache ] && rm -rf $(p)/autom4te.cache; \
40 [ -e $(p)/config.rpath ] || \
41 ln -s $(SCRIPT_DIR)/config.rpath $(p)/config.rpath; \
42 touch NEWS AUTHORS COPYING ABOUT-NLS ChangeLog; \
43 $(AM_TOOL_PATHS) \
44 LIBTOOLIZE='$(STAGING_DIR_HOST)/bin/libtoolize --install' \
45 $(STAGING_DIR_HOST)/bin/autoreconf -v -f -i -s \
46 $(if $(word 2,$(3)),--no-recursive) \
47 -B $(STAGING_DIR_HOST)/share/aclocal \
48 $(patsubst %,-I %,$(5)) \
49 $(patsubst %,-I %,$(4)) $(p) || true; \
50 fi; \
51 ) \
52 );
53 endef
54
55 # 1: build dir
56 define patch_libtool
57 @(cd $(1); \
58 for lt in $$$$($$(STAGING_DIR_HOST)/bin/find . -name ltmain.sh); do \
59 lt_version="$$$$($$(STAGING_DIR_HOST)/bin/sed -ne 's,^[[:space:]]*VERSION="\?\([0-9]\.[0-9]\+\).*,\1,p' $$$$lt)"; \
60 case "$$$$lt_version" in \
61 1.5|2.2|2.4) echo "autotools.mk: Found libtool v$$$$lt_version - applying patch to $$$$lt"; \
62 (cd $$$$(dirname $$$$lt) && $$(PATCH) -N -s -p1 < $$(TOPDIR)/tools/libtool/files/libtool-v$$$$lt_version.patch || true) ;; \
63 *) echo "autotools.mk: error: Unsupported libtool version v$$$$lt_version - cannot patch $$$$lt"; exit 1 ;; \
64 esac; \
65 done; \
66 );
67 endef
68
69 define set_libtool_abiver
70 sed -i \
71 -e 's,^soname_spec=.*,soname_spec="\\$$$${libname}\\$$$${shared_ext}.$(PKG_ABI_VERSION)",' \
72 -e 's,^library_names_spec=.*,library_names_spec="\\$$$${libname}\\$$$${shared_ext}.$(PKG_ABI_VERSION) \\$$$${libname}\\$$$${shared_ext}",' \
73 $(PKG_BUILD_DIR)/libtool
74 endef
75
76 PKG_LIBTOOL_PATHS?=$(CONFIGURE_PATH)
77 PKG_AUTOMAKE_PATHS?=$(CONFIGURE_PATH)
78 PKG_MACRO_PATHS?=m4
79 PKG_REMOVE_FILES?=aclocal.m4
80
81 Hooks/InstallDev/Post += libtool_remove_files
82
83 define autoreconf_target
84 $(strip $(call autoreconf, \
85 $(PKG_BUILD_DIR), $(PKG_REMOVE_FILES), \
86 $(PKG_AUTOMAKE_PATHS), $(PKG_LIBTOOL_PATHS), \
87 $(STAGING_DIR)/host/share/aclocal $(STAGING_DIR_HOSTPKG)/share/aclocal $(STAGING_DIR)/usr/share/aclocal $(PKG_MACRO_PATHS)))
88 endef
89
90 define patch_libtool_target
91 $(strip $(call patch_libtool, \
92 $(PKG_BUILD_DIR)))
93 endef
94
95 define gettext_version_target
96 (cd $(PKG_BUILD_DIR) && \
97 GETTEXT_VERSION=$(shell $(STAGING_DIR_HOSTPKG)/bin/gettext -V | $(STAGING_DIR_HOST)/bin/sed -rne '1s/.*\b([0-9]\.[0-9]+(\.[0-9]+)?)\b.*/\1/p' ) && \
98 $(STAGING_DIR_HOST)/bin/sed \
99 -i $(PKG_BUILD_DIR)/configure.ac \
100 -e "s/AM_GNU_GETTEXT_VERSION(.*)/AM_GNU_GETTEXT_VERSION(\[$$$$GETTEXT_VERSION\])/g" && \
101 $(STAGING_DIR_HOSTPKG)/bin/autopoint --force \
102 );
103 endef
104
105 ifneq ($(filter gettext-version,$(PKG_FIXUP)),)
106 Hooks/Configure/Pre += gettext_version_target
107 ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
108 Hooks/Configure/Pre += autoreconf_target
109 endif
110 endif
111
112 ifneq ($(filter patch-libtool,$(PKG_FIXUP)),)
113 Hooks/Configure/Pre += patch_libtool_target
114 endif
115
116 ifneq ($(filter libtool,$(PKG_FIXUP)),)
117 PKG_BUILD_DEPENDS += libtool
118 ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
119 Hooks/Configure/Pre += autoreconf_target
120 endif
121 endif
122
123 ifneq ($(filter libtool-abiver,$(PKG_FIXUP)),)
124 Hooks/Configure/Post += set_libtool_abiver
125 endif
126
127 ifneq ($(filter libtool-ucxx,$(PKG_FIXUP)),)
128 PKG_BUILD_DEPENDS += libtool
129 ifeq ($(filter no-autoreconf,$(PKG_FIXUP)),)
130 Hooks/Configure/Pre += autoreconf_target
131 endif
132 endif
133
134 ifneq ($(filter autoreconf,$(PKG_FIXUP)),)
135 ifeq ($(filter autoreconf,$(Hooks/Configure/Pre)),)
136 Hooks/Configure/Pre += autoreconf_target
137 endif
138 endif
139
140
141 HOST_FIXUP?=$(PKG_FIXUP)
142 HOST_LIBTOOL_PATHS?=$(if $(PKG_LIBTOOL_PATHS),$(PKG_LIBTOOL_PATHS),.)
143 HOST_AUTOMAKE_PATHS?=$(if $(PKG_AUTOMAKE_PATHS),$(PKG_AUTOMAKE_PATHS),.)
144 HOST_MACRO_PATHS?=$(if $(PKG_MACRO_PATHS),$(PKG_MACRO_PATHS),m4)
145 HOST_REMOVE_FILES?=$(PKG_REMOVE_FILES)
146
147 define autoreconf_host
148 $(strip $(call autoreconf, \
149 $(HOST_BUILD_DIR), $(HOST_REMOVE_FILES), \
150 $(HOST_AUTOMAKE_PATHS), $(HOST_LIBTOOL_PATHS), \
151 $(HOST_MACRO_PATHS)))
152 endef
153
154 define patch_libtool_host
155 $(strip $(call patch_libtool, \
156 $(HOST_BUILD_DIR)))
157 endef
158
159 ifneq ($(filter patch-libtool,$(HOST_FIXUP)),)
160 Hooks/HostConfigure/Pre += patch_libtool_host
161 endif
162
163 ifneq ($(filter libtool,$(HOST_FIXUP)),)
164 ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
165 Hooks/HostConfigure/Pre += autoreconf_host
166 endif
167 endif
168
169 ifneq ($(filter libtool-ucxx,$(HOST_FIXUP)),)
170 ifeq ($(filter no-autoreconf,$(HOST_FIXUP)),)
171 Hooks/HostConfigure/Pre += autoreconf_host
172 endif
173 endif
174
175 ifneq ($(filter autoreconf,$(HOST_FIXUP)),)
176 ifeq ($(filter autoreconf,$(Hooks/HostConfigure/Pre)),)
177 Hooks/HostConfigure/Pre += autoreconf_host
178 endif
179 endif
180
181 endif #__autotools_inc