4 # $FreeBSD: Mk/bsd.autotools.mk 325841 2013-09-01 01:18:05Z koobs $
6 # Please view me with 4 column tabs!
9 # Before making any changes to this file, contact portmgr to arrange
10 # for an experimental ports run.
11 # Untested commits will almost certainly break the tree, incur the
12 # wrath of countless folks, and be unceremoniously backed out by
13 # the maintainer and/or portmgr.
15 Autotools_Include_MAINTAINER= autotools@FreeBSD.org
17 #---------------------------------------------------------------------------
18 # USE_AUTOTOOLS= tool[:env] ...
20 # 'tool' can currently be one of the following:
21 # autoconf, autoheader
22 # autoconf213, autoheader213 (legacy version)
24 # automake14, aclocal14 (legacy version)
25 # libtool, libtoolize, libltdl
27 # ':env' is used to specify that the environmental variables are needed
28 # but the relevant tool should NOT be run as part of the
29 # 'run-autotools' target
31 # In addition, these variables can be set in the port Makefile to be
32 # passed to the relevant tools:
35 # - Extra arguments passed to automake during configure step
38 # - Arguments passed to aclocal during configure step
41 # - Extra arguments passed to autoconf during configure step
44 # - Extra arguments passed to autoheader during configure step
47 # - Extra arguments passed to libtoolize during configure step
49 # LIBTOOLFLAGS=<value>
50 # - Arguments passed to libtool during configure step
52 # LIBTOOLFILES=<list-of-files>
53 # - A list of files to patch during libtool pre-configuration
55 # AUTOTOOLSFILES=<list-of-files>
56 # - A list of files to further patch with derived information
57 # post-patching to reduce churn during component updates
59 #---------------------------------------------------------------------------
61 #---------------------------------------------------------------------------
62 # NO USER-SERVICABLE PARTS BEYOND THIS POINT. REALLY. WE MEAN IT.
63 #---------------------------------------------------------------------------
65 # Known autotools components
66 _AUTOTOOLS_ALL= autoconf autoheader autoconf213 autoheader213 \
67 automake aclocal automake14 aclocal14 \
68 libtool libtoolize libltdl
70 # Incompatible autotools mixing
71 _AUTOTOOLS_IGN_autoconf= autoconf213 autoheader213
72 _AUTOTOOLS_IGN_autoheader= autoconf213 autoheader213
73 _AUTOTOOLS_IGN_autoconf213= autoconf autoheader
74 _AUTOTOOLS_IGN_autoheader213= autoconf autoheader
75 _AUTOTOOLS_IGN_automake= automake14 aclocal14
76 _AUTOTOOLS_IGN_aclocal= automake14 aclocal14
77 _AUTOTOOLS_IGN_automake14= automake aclocal
78 _AUTOTOOLS_IGN_aclocal14= automake aclocal
80 #---------------------------------------------------------------------------
81 # Primary magic to break out the USE_AUTOTOOLS stanza into something
82 # more useful, along with substantial error checking to prevent
84 #---------------------------------------------------------------------------
86 # Break out the stanza
89 .for stanza in ${USE_AUTOTOOLS}
90 _AUTOTOOLS_IMPL+= ${stanza:C/^([^:]+).*/\1/}
91 _AUTOTOOL_${stanza:C/^([^:]+).*/\1/}= ${stanza:C/^[^:]+:([^:]+)/\1/}
94 # Verify each component, normalize
97 .for component in ${_AUTOTOOLS_IMPL}
98 . if ${_AUTOTOOLS_ALL:M${component}}==""
99 _AUTOTOOLS_NOCOMP+= ${component}
101 . if ${_AUTOTOOL_${component}}==${component}
102 _AUTOTOOL_${component}= yes
103 . elsif ${_AUTOTOOL_${component}}!="env" && ${_AUTOTOOL_${component}}!="yes"
104 _AUTOTOOLS_BADCOMP+= ${component}:${_AUTOTOOL_${component}}
107 .if !empty(_AUTOTOOLS_NOCOMP)
108 IGNORE+= Unknown autotool: ${_AUTOTOOLS_NOCOMP:O:u}
111 # Check for anything other than 'yes' or 'env'
114 .for component in ${_AUTOTOOLS_IMPL}
115 . if ${_AUTOTOOL_${component}}!="env" && ${_AUTOTOOL_${component}}!="yes"
116 _AUTOTOOLS_BADCOMP+= ${component}:${_AUTOTOOL_${component}}
119 .if !empty(_AUTOTOOLS_BADCOMP)
120 IGNORE+= Bad autotool stanza: ${_AUTOTOOLS_BADCOMP:O:u}
123 # Check for incompatible mixes of components
126 .for component in ${_AUTOTOOLS_IMPL}
127 . for ignore in ${_AUTOTOOLS_IGN_${component}}
128 . if defined(_AUTOTOOL_${ignore})
129 _AUTOTOOLS_IGN+= ${component}
133 .if !empty(_AUTOTOOLS_IGN)
134 IGNORE+= Incompatible autotools: ${_AUTOTOOLS_IGN:O:u}
137 #---------------------------------------------------------------------------
138 # automake and aclocal
139 #---------------------------------------------------------------------------
141 .if defined(_AUTOTOOL_aclocal) && ${_AUTOTOOL_aclocal} == "yes"
142 _AUTOTOOL_automake?= env
143 _AUTOTOOL_rule_aclocal= yes
147 .if defined(_AUTOTOOL_automake)
148 AUTOMAKE_VERSION= 1.14
149 AUTOMAKE_APIVER= 1.14
150 AUTOMAKE_PORT= devel/automake
152 . if ${_AUTOTOOL_automake} == "yes"
153 _AUTOTOOL_rule_automake= yes
158 .if defined(_AUTOTOOL_aclocal14) && ${_AUTOTOOL_aclocal14} == "yes"
159 _AUTOTOOL_automake14?= env
160 _AUTOTOOL_rule_aclocal14= yes
164 .if defined(_AUTOTOOL_automake14)
165 AUTOMAKE_VERSION= 1.4
166 AUTOMAKE_APIVER= 1.4.6
167 AUTOMAKE_PORT= devel/automake14
168 AUTOMAKE_ARGS+= -i # backwards compatibility shim
170 . if ${_AUTOTOOL_automake14} == "yes"
171 _AUTOTOOL_rule_automake= yes
176 .if defined(AUTOMAKE_VERSION)
177 AUTOMAKE= ${LOCALBASE}/bin/automake-${AUTOMAKE_VERSION}
178 AUTOMAKE_DIR= ${LOCALBASE}/share/automake-${AUTOMAKE_VERSION}
179 ACLOCAL= ${LOCALBASE}/bin/aclocal-${AUTOMAKE_VERSION}
180 ACLOCAL_DIR= ${LOCALBASE}/share/aclocal-${AUTOMAKE_VERSION}
182 . if defined(_AUTOTOOL_aclocal)
183 ACLOCAL_ARGS?= --automake-acdir=${ACLOCAL_DIR}
185 . if defined(_AUTOTOOL_aclocal14)
186 ACLOCAL_ARGS?= --acdir=${ACLOCAL_DIR}
189 AUTOMAKE_VARS= AUTOMAKE=${AUTOMAKE} \
190 AUTOMAKE_DIR=${AUTOMAKE_DIR} \
191 AUTOMAKE_VERSION=${AUTOMAKE_VERSION} \
192 AUTOMAKE_APIVER=${AUTOMAKE_APIVER} \
194 ACLOCAL_DIR=${ACLOCAL_DIR}
196 AUTOMAKE_DEPENDS= ${AUTOMAKE}:${PORTSDIR}/${AUTOMAKE_PORT}
197 BUILD_DEPENDS+= ${AUTOMAKE_DEPENDS}
200 #---------------------------------------------------------------------------
201 # autoconf and autoheader
202 #---------------------------------------------------------------------------
204 .if defined(_AUTOTOOL_autoheader) && ${_AUTOTOOL_autoheader} == "yes"
205 _AUTOTOOL_autoconf= yes
206 _AUTOTOOL_rule_autoheader= yes
210 .if defined(_AUTOTOOL_autoconf)
211 AUTOCONF_VERSION= 2.69
212 AUTOCONF_PORT= devel/autoconf
214 . if ${_AUTOTOOL_autoconf} == "yes"
215 _AUTOTOOL_rule_autoconf= yes
220 .if defined(_AUTOTOOL_autoheader213) && ${_AUTOTOOL_autoheader213} == "yes"
221 _AUTOTOOL_autoconf213= yes
222 _AUTOTOOL_rule_autoheader= yes
226 .if defined(_AUTOTOOL_autoconf213)
227 AUTOCONF_VERSION= 2.13
228 AUTOCONF_PORT= devel/autoconf213
229 AUTOM4TE= ${FALSE} # doesn't exist here
231 . if ${_AUTOTOOL_autoconf213} == "yes"
232 _AUTOTOOL_rule_autoconf= yes
237 .if defined(AUTOCONF_VERSION)
238 AUTOCONF= ${LOCALBASE}/bin/autoconf-${AUTOCONF_VERSION}
239 AUTOCONF_DIR= ${LOCALBASE}/share/autoconf-${AUTOCONF_VERSION}
240 AUTOHEADER= ${LOCALBASE}/bin/autoheader-${AUTOCONF_VERSION}
241 AUTOIFNAMES= ${LOCALBASE}/bin/ifnames-${AUTOCONF_VERSION}
242 AUTOM4TE?= ${LOCALBASE}/bin/autom4te-${AUTOCONF_VERSION}
243 AUTORECONF= ${LOCALBASE}/bin/autoreconf-${AUTOCONF_VERSION}
244 AUTOSCAN= ${LOCALBASE}/bin/autoscan-${AUTOCONF_VERSION}
245 AUTOUPDATE= ${LOCALBASE}/bin/autoupdate-${AUTOCONF_VERSION}
246 AUTOCONFWRAP= ${LOCALBASE}/bin/autoconf
247 AUTOCWPORT= devel/autoconf-wrapper
249 AUTOCONF_VARS= AUTOCONF=${AUTOCONF} \
250 AUTOCONF_DIR=${AUTOCONF_DIR} \
251 AUTOHEADER=${AUTOHEADER} \
252 AUTOIFNAMES=${AUTOIFNAMES} \
253 AUTOM4TE=${AUTOM4TE} \
254 AUTORECONF=${AUTORECONF} \
255 AUTOSCAN=${AUTOSCAN} \
256 AUTOUPDATE=${AUTOUPDATE} \
257 AUTOCONF_VERSION=${AUTOCONF_VERSION}
259 AUTOCONF_DEPENDS= ${AUTOCONF}:${PORTSDIR}/${AUTOCONF_PORT}
260 AUTOCONF_DEPENDS+= ${AUTOCONFWRAP}:${PORTSDIR}/${AUTOCWPORT}
261 AUTOCONF_DEPENDS+= gm4:${PORTSDIR}/devel/m4
262 BUILD_DEPENDS+= ${AUTOCONF_DEPENDS}
265 #---------------------------------------------------------------------------
267 #---------------------------------------------------------------------------
269 .if defined(_AUTOTOOL_libltdl)
270 LIB_DEPENDS+= ltdl.7:${PORTSDIR}/devel/libltdl
273 #---------------------------------------------------------------------------
275 #---------------------------------------------------------------------------
277 .if defined(_AUTOTOOL_libtool) || defined(_AUTOTOOL_libtoolize)
279 LIBTOOL_PORT= devel/libtool
281 . if defined(_AUTOTOOL_libtool) && ${_AUTOTOOL_libtool} == "yes"
282 _AUTOTOOL_rule_libtool= yes
285 . if defined(_AUTOTOOL_libtoolize) && ${_AUTOTOOL_libtoolize} == "yes"
286 _AUTOTOOL_rule_libtoolize= yes
292 .if defined(LIBTOOL_VERSION)
293 LIBTOOL= ${LOCALBASE}/bin/libtool
294 LIBTOOLIZE= ${LOCALBASE}/bin/libtoolize
295 LIBTOOL_LIBEXECDIR= ${LOCALBASE}/libexec/libtool
296 LIBTOOL_SHAREDIR= ${LOCALBASE}/share/libtool
297 LIBTOOL_M4= ${LOCALBASE}/share/aclocal/libtool.m4
298 LTMAIN= ${LOCALBASE}/share/libtool/config/ltmain.sh
300 LIBTOOL_VARS= LIBTOOL=${LIBTOOL} \
301 LIBTOOLIZE=${LIBTOOLIZE} \
302 LIBTOOL_LIBEXECDIR=${LIBTOOL_LIBEXECDIR} \
303 LIBTOOL_SHAREDIR=${LIBTOOL_SHAREDIR} \
304 LIBTOOL_M4=${LIBTOOL_M4} \
307 LIBTOOLFLAGS?= # default to empty
309 . if defined(_AUTOTOOL_rule_autoconf) || defined(_AUTOTOOL_rule_autoconf213)
310 LIBTOOLFILES?= aclocal.m4
311 . elif defined(_AUTOTOOL_rule_libtool)
312 LIBTOOLFILES?= ${CONFIGURE_SCRIPT}
315 LIBTOOL_DEPENDS= libtool>=2.4:${PORTSDIR}/${LIBTOOL_PORT}
316 BUILD_DEPENDS+= ${LIBTOOL_DEPENDS}
319 #---------------------------------------------------------------------------
320 # Add to the environment
321 #---------------------------------------------------------------------------
323 AUTOTOOLS_VARS= ${AUTOMAKE_VARS} ${AUTOCONF_VARS} ${LIBTOOL_VARS}
325 .if defined(AUTOTOOLS_VARS) && !empty(AUTOTOOLS_VARS)
326 . for var in AUTOTOOLS CONFIGURE MAKE SCRIPTS
327 ${var:tu}_ENV+= ${AUTOTOOLS_VARS}
331 #---------------------------------------------------------------------------
333 #---------------------------------------------------------------------------
335 .if !target(run-autotools)
336 .ORDER: run-autotools run-autotools-aclocal \
337 patch-autotools-libtool run-autotools-autoheader \
338 run-autotools-libtoolize run-autotools-autoconf \
339 run-autotools-automake
341 run-autotools:: run-autotools-aclocal \
342 patch-autotools-libtool run-autotools-autoheader \
343 run-autotools-libtoolize run-autotools-autoconf \
344 run-autotools-automake
347 .if !target(run-autotools-aclocal)
348 run-autotools-aclocal:
349 . if defined(_AUTOTOOL_rule_aclocal)
350 @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${ACLOCAL} \
357 .if !target(run-autotools-automake)
358 run-autotools-automake:
359 . if defined(_AUTOTOOL_rule_automake)
360 @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${AUTOMAKE} \
367 .if !target(run-autotools-autoconf)
368 run-autotools-autoconf:
369 . if defined(_AUTOTOOL_rule_autoconf)
370 @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${AUTOCONF} \
377 .if !target(run-autotools-autoheader)
378 run-autotools-autoheader:
379 . if defined(_AUTOTOOL_rule_autoheader)
380 @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${AUTOHEADER} \
387 .if !target(run-autotools-libtoolize)
388 run-autotools-libtoolize:
389 . if defined(_AUTOTOOL_rule_libtoolize)
390 @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${LIBTOOLIZE} \
397 .if !target(patch-autotools-libtool)
398 patch-autotools-libtool::
399 . if defined(_AUTOTOOL_rule_libtool)
400 @for file in ${LIBTOOLFILES}; do \
401 ${REINPLACE_CMD} -e \
402 "/^ltmain=/!s|\$$ac_aux_dir/ltmain.sh|${LIBTOOLFLAGS} ${LTMAIN}|g; \
403 /^LIBTOOL=/s|\$$(top_builddir)/libtool|${LIBTOOL}|g" \
404 ${PATCH_WRKSRC}/$$file; \
411 #---------------------------------------------------------------------------
412 # Reduce patch churn by auto-substituting data from AUTOTOOLS_VARS
413 # into the correct places. Code shamelessly stolen from PLIST_SUB.
415 AUTOTOOLSFILES?= # default to empty
416 AUTOTOOLS_VARS?= # empty if not already set
418 .if !target(configure-autotools)
419 configure-autotools::
420 . if ${AUTOTOOLS_VARS}!="" && ${AUTOTOOLSFILES} != ""
421 @for file in ${AUTOTOOLSFILES}; do \
422 ${REINPLACE_CMD} ${AUTOTOOLS_VARS:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
423 ${WRKSRC}/$${file} ; \