Import security/amavis-stats version 0.1.12_3
[dports.git] / Mk / bsd.autotools.mk
1 #-*- tab-width: 4; -*-
2 # ex:ts=4
3 #
4 # $FreeBSD$
5 #
6 # Please view me with 4 column tabs!
7 #
8 # IMPORTANT NOTE:
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.
14
15 Autotools_Include_MAINTAINER=   autotools@FreeBSD.org
16
17 #---------------------------------------------------------------------------
18 # USE_AUTOTOOLS= tool[:env] ...
19 #
20 # 'tool' can currently be one of the following:
21 #               autoconf, autoheader
22 #               autoconf213, autoheader213 (legacy version)
23 #               automake, aclocal
24 #               automake14, aclocal14 (legacy version)
25 #               libtool, libtoolize, libltdl
26 #
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
30 #
31 # In addition, these variables can be set in the port Makefile to be
32 # passed to the relevant tools:
33 #
34 # AUTOMAKE_ARGS=...
35 #       - Extra arguments passed to automake during configure step
36 #
37 # ACLOCAL_ARGS=...
38 #       - Arguments passed to aclocal during configure step
39 #
40 # AUTOCONF_ARGS=...
41 #       - Extra arguments passed to autoconf during configure step
42 #
43 # AUTOHEADER_ARGS=...
44 #       - Extra arguments passed to autoheader during configure step
45 #
46 # LIBTOOLIZE_ARGS=...
47 #       - Extra arguments passed to libtoolize during configure step
48 #
49 # LIBTOOLFLAGS=<value>
50 #       - Arguments passed to libtool during configure step
51 #
52 # LIBTOOLFILES=<list-of-files>
53 #       - A list of files to patch during libtool pre-configuration
54 #
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
58 #
59 #---------------------------------------------------------------------------
60
61 #---------------------------------------------------------------------------
62 # NO USER-SERVICABLE PARTS BEYOND THIS POINT.  REALLY.  WE MEAN IT.
63 #---------------------------------------------------------------------------
64
65 # Known autotools components
66 _AUTOTOOLS_ALL= autoconf autoheader autoconf213 autoheader213 \
67                                 automake aclocal automake14 aclocal14 \
68                                 libtool libtoolize libltdl
69
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
79
80 #---------------------------------------------------------------------------
81 # Primary magic to break out the USE_AUTOTOOLS stanza into something
82 # more useful, along with substantial error checking to prevent
83 # foot-shooting
84 #---------------------------------------------------------------------------
85
86 # Break out the stanza
87 #
88 _AUTOTOOLS_IMPL=
89 .for stanza in ${USE_AUTOTOOLS}
90 _AUTOTOOLS_IMPL+= ${stanza:C/^([^:]+).*/\1/}
91 _AUTOTOOL_${stanza:C/^([^:]+).*/\1/}= ${stanza:C/^[^:]+:([^:]+)/\1/}
92 .endfor
93
94 # Verify each component, normalize
95 #
96 _AUTOTOOLS_NOCOMP=
97 .for component in ${_AUTOTOOLS_IMPL}
98 . if ${_AUTOTOOLS_ALL:M${component}}==""
99 _AUTOTOOLS_NOCOMP+=     ${component}
100 . endif
101 . if ${_AUTOTOOL_${component}}==${component}
102 _AUTOTOOL_${component}=  yes
103 . elsif ${_AUTOTOOL_${component}}!="env" && ${_AUTOTOOL_${component}}!="yes"
104 _AUTOTOOLS_BADCOMP+= ${component}:${_AUTOTOOL_${component}}
105 . endif
106 .endfor
107 .if !empty(_AUTOTOOLS_NOCOMP)
108 IGNORE+=        Unknown autotool: ${_AUTOTOOLS_NOCOMP:O:u}
109 .endif
110
111 # Check for anything other than 'yes' or 'env'
112 #
113 _AUTOTOOLS_BADCOMP=
114 .for component in ${_AUTOTOOLS_IMPL}
115 . if ${_AUTOTOOL_${component}}!="env" && ${_AUTOTOOL_${component}}!="yes"
116 _AUTOTOOLS_BADCOMP+= ${component}:${_AUTOTOOL_${component}}
117 . endif
118 .endfor
119 .if !empty(_AUTOTOOLS_BADCOMP)
120 IGNORE+=        Bad autotool stanza: ${_AUTOTOOLS_BADCOMP:O:u}
121 .endif
122
123 # Check for incompatible mixes of components
124 #
125 _AUTOTOOLS_IGN=
126 .for component in ${_AUTOTOOLS_IMPL}
127 . for ignore in ${_AUTOTOOLS_IGN_${component}}
128 .  if defined(_AUTOTOOL_${ignore})
129 _AUTOTOOLS_IGN+=        ${component}
130 .  endif
131 . endfor
132 .endfor
133 .if !empty(_AUTOTOOLS_IGN)
134 IGNORE+=        Incompatible autotools: ${_AUTOTOOLS_IGN:O:u}
135 .endif
136
137 #---------------------------------------------------------------------------
138 # automake and aclocal
139 #---------------------------------------------------------------------------
140
141 .if defined(_AUTOTOOL_aclocal) && ${_AUTOTOOL_aclocal} == "yes"
142 _AUTOTOOL_automake?=            env
143 _AUTOTOOL_rule_aclocal=         yes
144 GNU_CONFIGURE=                          yes
145 .endif
146
147 .if defined(_AUTOTOOL_automake)
148 AUTOMAKE_VERSION=       1.14
149 AUTOMAKE_APIVER=        1.14
150 AUTOMAKE_PORT=          devel/automake
151
152 . if ${_AUTOTOOL_automake} == "yes"
153 _AUTOTOOL_rule_automake=        yes
154 GNU_CONFIGURE?=                         yes
155 . endif
156 .endif
157
158 .if defined(_AUTOTOOL_aclocal14) && ${_AUTOTOOL_aclocal14} == "yes"
159 _AUTOTOOL_automake14?=          env
160 _AUTOTOOL_rule_aclocal14=       yes
161 GNU_CONFIGURE?=                         yes
162 .endif
163
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
169
170 . if ${_AUTOTOOL_automake14} == "yes"
171 _AUTOTOOL_rule_automake=        yes
172 GNU_CONFIGURE?=                         yes
173 . endif
174 .endif
175
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}
181
182 . if defined(_AUTOTOOL_aclocal)
183 ACLOCAL_ARGS?=          --automake-acdir=${ACLOCAL_DIR}
184 . endif
185 . if defined(_AUTOTOOL_aclocal14)
186 ACLOCAL_ARGS?=          --acdir=${ACLOCAL_DIR}
187 . endif
188
189 AUTOMAKE_VARS=          AUTOMAKE=${AUTOMAKE} \
190                                         AUTOMAKE_DIR=${AUTOMAKE_DIR} \
191                                         AUTOMAKE_VERSION=${AUTOMAKE_VERSION} \
192                                         AUTOMAKE_APIVER=${AUTOMAKE_APIVER} \
193                                         ACLOCAL=${ACLOCAL} \
194                                         ACLOCAL_DIR=${ACLOCAL_DIR}
195
196 AUTOMAKE_DEPENDS=       ${AUTOMAKE}:${PORTSDIR}/${AUTOMAKE_PORT}
197 BUILD_DEPENDS+=         ${AUTOMAKE_DEPENDS}
198 .endif
199
200 #---------------------------------------------------------------------------
201 # autoconf and autoheader
202 #---------------------------------------------------------------------------
203
204 .if defined(_AUTOTOOL_autoheader) && ${_AUTOTOOL_autoheader} == "yes"
205 _AUTOTOOL_autoconf=                     yes
206 _AUTOTOOL_rule_autoheader=      yes
207 GNU_CONFIGURE?=                         yes
208 .endif
209
210 .if defined(_AUTOTOOL_autoconf)
211 AUTOCONF_VERSION=       2.69
212 AUTOCONF_PORT=          devel/autoconf
213
214 . if ${_AUTOTOOL_autoconf} == "yes"
215 _AUTOTOOL_rule_autoconf=        yes
216 GNU_CONFIGURE?=                         yes
217 . endif
218 .endif
219
220 .if defined(_AUTOTOOL_autoheader213) && ${_AUTOTOOL_autoheader213} == "yes"
221 _AUTOTOOL_autoconf213=          yes
222 _AUTOTOOL_rule_autoheader=      yes
223 GNU_CONFIGURE?=                         yes
224 .endif
225
226 .if defined(_AUTOTOOL_autoconf213)
227 AUTOCONF_VERSION=       2.13
228 AUTOCONF_PORT=          devel/autoconf213
229 AUTOM4TE=                       ${FALSE}        # doesn't exist here
230
231 . if ${_AUTOTOOL_autoconf213} == "yes"
232 _AUTOTOOL_rule_autoconf=        yes
233 GNU_CONFIGURE?=                         yes
234 . endif
235 .endif
236
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
247 AUTOCONF_VARS=          AUTOCONF=${AUTOCONF} \
248                                         AUTOCONF_DIR=${AUTOCONF_DIR} \
249                                         AUTOHEADER=${AUTOHEADER} \
250                                         AUTOIFNAMES=${AUTOIFNAMES} \
251                                         AUTOM4TE=${AUTOM4TE} \
252                                         AUTORECONF=${AUTORECONF} \
253                                         AUTOSCAN=${AUTOSCAN} \
254                                         AUTOUPDATE=${AUTOUPDATE} \
255                                         AUTOCONF_VERSION=${AUTOCONF_VERSION}
256
257 AUTOCONF_DEPENDS=       ${AUTOCONF}:${PORTSDIR}/${AUTOCONF_PORT}
258 BUILD_DEPENDS+=         ${AUTOCONF_DEPENDS}
259 .endif
260
261 #---------------------------------------------------------------------------
262 # libltdl
263 #---------------------------------------------------------------------------
264
265 .if defined(_AUTOTOOL_libltdl)
266 LIB_DEPENDS+=           libltdl.so:${PORTSDIR}/devel/libltdl
267 .endif
268
269 #---------------------------------------------------------------------------
270 # libtool/libtoolize
271 #---------------------------------------------------------------------------
272
273 .if defined(_AUTOTOOL_libtool) || defined(_AUTOTOOL_libtoolize)
274 LIBTOOL_VERSION=        2.4
275 LIBTOOL_PORT=           devel/libtool
276
277 . if defined(_AUTOTOOL_libtool) && ${_AUTOTOOL_libtool} == "yes"
278 _AUTOTOOL_rule_libtool=         yes
279 GNU_CONFIGURE?=                         yes
280 . endif
281 . if defined(_AUTOTOOL_libtoolize) && ${_AUTOTOOL_libtoolize} == "yes"
282 _AUTOTOOL_rule_libtoolize=      yes
283 GNU_CONFIGURE?=                         yes
284 . endif
285
286 .endif
287
288 .if defined(LIBTOOL_VERSION)
289 LIBTOOL=                        ${LOCALBASE}/bin/libtool
290 LIBTOOLIZE=                     ${LOCALBASE}/bin/libtoolize
291 LIBTOOL_LIBEXECDIR=     ${LOCALBASE}/libexec/libtool
292 LIBTOOL_SHAREDIR=       ${LOCALBASE}/share/libtool
293 LIBTOOL_M4=                     ${LOCALBASE}/share/aclocal/libtool.m4
294 LTMAIN=                         ${LOCALBASE}/share/libtool/config/ltmain.sh
295
296 LIBTOOL_VARS=           LIBTOOL=${LIBTOOL} \
297                                         LIBTOOLIZE=${LIBTOOLIZE} \
298                                         LIBTOOL_LIBEXECDIR=${LIBTOOL_LIBEXECDIR} \
299                                         LIBTOOL_SHAREDIR=${LIBTOOL_SHAREDIR} \
300                                         LIBTOOL_M4=${LIBTOOL_M4} \
301                                         LTMAIN=${LTMAIN}
302
303 LIBTOOLFLAGS?=          # default to empty
304
305 . if defined(_AUTOTOOL_rule_autoconf) || defined(_AUTOTOOL_rule_autoconf213)
306 LIBTOOLFILES?=          aclocal.m4
307 . elif defined(_AUTOTOOL_rule_libtool)
308 LIBTOOLFILES?=          ${CONFIGURE_SCRIPT}
309 . endif
310
311 LIBTOOL_DEPENDS=        libtool>=2.4:${PORTSDIR}/${LIBTOOL_PORT}
312 BUILD_DEPENDS+=         ${LIBTOOL_DEPENDS}
313 .endif
314
315 #---------------------------------------------------------------------------
316 # Add to the environment
317 #---------------------------------------------------------------------------
318
319 AUTOTOOLS_VARS=         ${AUTOMAKE_VARS} ${AUTOCONF_VARS} ${LIBTOOL_VARS}
320
321 .if defined(AUTOTOOLS_VARS) && !empty(AUTOTOOLS_VARS)
322 . for var in AUTOTOOLS CONFIGURE MAKE SCRIPTS
323 ${var:tu}_ENV+=         ${AUTOTOOLS_VARS}
324 . endfor
325 .endif
326
327 #---------------------------------------------------------------------------
328 # Make targets
329 #---------------------------------------------------------------------------
330
331 .if !target(run-autotools)
332 .ORDER:                 run-autotools run-autotools-aclocal \
333                                 patch-autotools-libtool run-autotools-autoheader \
334                                 run-autotools-libtoolize run-autotools-autoconf \
335                                 run-autotools-automake
336
337 run-autotools:: run-autotools-aclocal \
338                                 patch-autotools-libtool run-autotools-autoheader \
339                                 run-autotools-libtoolize run-autotools-autoconf \
340                                 run-autotools-automake
341 .endif
342
343 .if !target(run-autotools-aclocal)
344 run-autotools-aclocal:
345 . if defined(_AUTOTOOL_rule_aclocal)
346         @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${ACLOCAL} \
347                 ${ACLOCAL_ARGS})
348 . else
349         @${DO_NADA}
350 . endif
351 .endif
352
353 .if !target(run-autotools-automake)
354 run-autotools-automake:
355 . if defined(_AUTOTOOL_rule_automake)
356         @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${AUTOMAKE} \
357                 ${AUTOMAKE_ARGS})
358 . else
359         @${DO_NADA}
360 . endif
361 .endif
362
363 .if !target(run-autotools-autoconf)
364 run-autotools-autoconf:
365 . if defined(_AUTOTOOL_rule_autoconf)
366         @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${AUTOCONF} \
367                 ${AUTOCONF_ARGS})
368 . else
369         @${DO_NADA}
370 . endif
371 .endif
372
373 .if !target(run-autotools-autoheader)
374 run-autotools-autoheader:
375 . if defined(_AUTOTOOL_rule_autoheader)
376         @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${AUTOHEADER} \
377                 ${AUTOHEADER_ARGS})
378 . else
379         @${DO_NADA}
380 . endif
381 .endif
382
383 .if !target(run-autotools-libtoolize)
384 run-autotools-libtoolize:
385 . if defined(_AUTOTOOL_rule_libtoolize)
386         @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${LIBTOOLIZE} \
387                 ${LIBTOOLIZE_ARGS})
388 . else
389         @${DO_NADA}
390 . endif
391 .endif
392
393 .if !target(patch-autotools-libtool)
394 patch-autotools-libtool::
395 . if defined(_AUTOTOOL_rule_libtool)
396         @for file in ${LIBTOOLFILES}; do \
397                 ${REINPLACE_CMD} -e \
398                         "/^ltmain=/!s|\$$ac_aux_dir/ltmain.sh|${LIBTOOLFLAGS} ${LTMAIN}|g; \
399                         /^LIBTOOL=/s|\$$(top_builddir)/libtool|${LIBTOOL}|g" \
400                         ${PATCH_WRKSRC}/$$file; \
401         done;
402 . else
403         @${DO_NADA}
404 . endif
405 .endif
406
407 #---------------------------------------------------------------------------
408 # Reduce patch churn by auto-substituting data from AUTOTOOLS_VARS
409 # into the correct places.  Code shamelessly stolen from PLIST_SUB.
410
411 AUTOTOOLSFILES?=        # default to empty
412 AUTOTOOLS_VARS?=        # empty if not already set
413
414 .if !target(configure-autotools)
415 configure-autotools::
416 . if ${AUTOTOOLS_VARS}!="" && ${AUTOTOOLSFILES} != ""
417         @for file in ${AUTOTOOLSFILES}; do \
418                 ${REINPLACE_CMD} ${AUTOTOOLS_VARS:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
419                         ${WRKSRC}/$${file} ; \
420         done
421 . else
422         @${DO_NADA}
423 . endif
424 .endif