Import devel/fpc-fpmkunit version 2.6.4
[dports.git] / Mk / bsd.autotools.mk
1 # $FreeBSD$
2 #
3 # IMPORTANT NOTE:
4 #       Before making any changes to this file, contact portmgr to arrange
5 #       for an experimental ports run.
6 #       Untested commits will almost certainly break the tree, incur the
7 #       wrath of countless folks, and be unceremoniously backed out by
8 #       the maintainer and/or portmgr.
9
10 Autotools_Include_MAINTAINER=   autotools@FreeBSD.org
11
12 #---------------------------------------------------------------------------
13 # USE_AUTOTOOLS= tool[:env] ...
14 #
15 # 'tool' can currently be one of the following:
16 #       autoconf, autoheader
17 #       automake, aclocal
18 #       libtoolize
19 #
20 # ':env' is used to specify that the environmental variables are needed
21 #       but the relevant tool should NOT be run as part of the
22 #       'run-autotools' target
23 #
24 # In addition, these variables can be set in the port Makefile to be
25 # passed to the relevant tools:
26 #
27 # AUTOMAKE_ARGS=...
28 #       - Extra arguments passed to automake during configure step
29 #
30 # ACLOCAL_ARGS=...
31 #       - Arguments passed to aclocal during configure step
32 #
33 # AUTOCONF_ARGS=...
34 #       - Extra arguments passed to autoconf during configure step
35 #
36 # AUTOHEADER_ARGS=...
37 #       - Extra arguments passed to autoheader during configure step
38 #
39 # LIBTOOLIZE_ARGS=...
40 #       - Extra arguments passed to libtoolize during configure step
41 #
42 #---------------------------------------------------------------------------
43
44 #---------------------------------------------------------------------------
45 # NO USER-SERVICABLE PARTS BEYOND THIS POINT.  REALLY.  WE MEAN IT.
46 #---------------------------------------------------------------------------
47
48 # Known autotools components
49 _AUTOTOOLS_ALL= autoconf autoheader \
50                 automake aclocal \
51                 libtoolize
52
53 #---------------------------------------------------------------------------
54 # Primary magic to break out the USE_AUTOTOOLS stanza into something
55 # more useful, along with substantial error checking to prevent
56 # foot-shooting
57 #---------------------------------------------------------------------------
58
59 # Break out the stanza
60 #
61 _AUTOTOOLS_IMPL=
62 .for stanza in ${USE_AUTOTOOLS}
63 _AUTOTOOLS_IMPL+= ${stanza:C/^([^:]+).*/\1/}
64 _AUTOTOOL_${stanza:C/^([^:]+).*/\1/}= ${stanza:C/^[^:]+:([^:]+)/\1/}
65 .endfor
66
67 # Verify each component, normalize
68 #
69 _AUTOTOOLS_NOCOMP=
70 .for component in ${_AUTOTOOLS_IMPL}
71 . if ${_AUTOTOOLS_ALL:M${component}}==""
72 _AUTOTOOLS_NOCOMP+=     ${component}
73 . endif
74 . if ${_AUTOTOOL_${component}}==${component}
75 _AUTOTOOL_${component}=  yes
76 . elsif ${_AUTOTOOL_${component}}!="env" && ${_AUTOTOOL_${component}}!="yes"
77 _AUTOTOOLS_BADCOMP+= ${component}:${_AUTOTOOL_${component}}
78 . endif
79 .endfor
80 .if !empty(_AUTOTOOLS_NOCOMP)
81 IGNORE+=        Unknown autotool: ${_AUTOTOOLS_NOCOMP:O:u}
82 .endif
83
84 # Check for anything other than 'yes' or 'env'
85 #
86 _AUTOTOOLS_BADCOMP=
87 .for component in ${_AUTOTOOLS_IMPL}
88 . if ${_AUTOTOOL_${component}}!="env" && ${_AUTOTOOL_${component}}!="yes"
89 _AUTOTOOLS_BADCOMP+= ${component}:${_AUTOTOOL_${component}}
90 . endif
91 .endfor
92 .if !empty(_AUTOTOOLS_BADCOMP)
93 IGNORE+=        Bad autotool stanza: ${_AUTOTOOLS_BADCOMP:O:u}
94 .endif
95
96 #---------------------------------------------------------------------------
97 # automake and aclocal
98 #---------------------------------------------------------------------------
99
100 .if defined(_AUTOTOOL_aclocal) && ${_AUTOTOOL_aclocal} == "yes"
101 _AUTOTOOL_automake?=    env
102 _AUTOTOOL_rule_aclocal= yes
103 GNU_CONFIGURE=          yes
104 .endif
105
106 .if defined(_AUTOTOOL_automake)
107 AUTOMAKE_VERSION=       1.14
108 AUTOMAKE_APIVER=        1.14
109 AUTOMAKE_PORT=          devel/automake
110
111 . if ${_AUTOTOOL_automake} == "yes"
112 _AUTOTOOL_rule_automake=        yes
113 GNU_CONFIGURE?=                 yes
114 . endif
115 .endif
116
117 .if defined(AUTOMAKE_VERSION)
118 AUTOMAKE=               ${LOCALBASE}/bin/automake-${AUTOMAKE_VERSION}
119 AUTOMAKE_DIR=           ${LOCALBASE}/share/automake-${AUTOMAKE_VERSION}
120 ACLOCAL=                ${LOCALBASE}/bin/aclocal-${AUTOMAKE_VERSION}
121 ACLOCAL_DIR=            ${LOCALBASE}/share/aclocal-${AUTOMAKE_VERSION}
122
123 . if defined(_AUTOTOOL_aclocal)
124 ACLOCAL_ARGS?=          --automake-acdir=${ACLOCAL_DIR}
125 . endif
126
127 AUTOMAKE_VARS=          AUTOMAKE=${AUTOMAKE} \
128                         AUTOMAKE_DIR=${AUTOMAKE_DIR} \
129                         AUTOMAKE_VERSION=${AUTOMAKE_VERSION} \
130                         AUTOMAKE_APIVER=${AUTOMAKE_APIVER} \
131                         ACLOCAL=${ACLOCAL} \
132                         ACLOCAL_DIR=${ACLOCAL_DIR}
133
134 AUTOMAKE_DEPENDS=       ${AUTOMAKE}:${PORTSDIR}/${AUTOMAKE_PORT}
135 BUILD_DEPENDS+=         ${AUTOMAKE_DEPENDS}
136 .endif
137
138 #---------------------------------------------------------------------------
139 # autoconf and autoheader
140 #---------------------------------------------------------------------------
141
142 .if defined(_AUTOTOOL_autoheader) && ${_AUTOTOOL_autoheader} == "yes"
143 _AUTOTOOL_autoconf=             yes
144 _AUTOTOOL_rule_autoheader=      yes
145 GNU_CONFIGURE?=                 yes
146 .endif
147
148 .if defined(_AUTOTOOL_autoconf)
149 AUTOCONF_VERSION=       2.69
150 AUTOCONF_PORT=          devel/autoconf
151
152 . if ${_AUTOTOOL_autoconf} == "yes"
153 _AUTOTOOL_rule_autoconf=        yes
154 GNU_CONFIGURE?=                 yes
155 . endif
156 .endif
157
158 .if defined(AUTOCONF_VERSION)
159 AUTOCONF=               ${LOCALBASE}/bin/autoconf-${AUTOCONF_VERSION}
160 AUTOCONF_DIR=           ${LOCALBASE}/share/autoconf-${AUTOCONF_VERSION}
161 AUTOHEADER=             ${LOCALBASE}/bin/autoheader-${AUTOCONF_VERSION}
162 AUTOIFNAMES=            ${LOCALBASE}/bin/ifnames-${AUTOCONF_VERSION}
163 AUTOM4TE?=              ${LOCALBASE}/bin/autom4te-${AUTOCONF_VERSION}
164 AUTORECONF=             ${LOCALBASE}/bin/autoreconf-${AUTOCONF_VERSION}
165 AUTOSCAN=               ${LOCALBASE}/bin/autoscan-${AUTOCONF_VERSION}
166 AUTOUPDATE=             ${LOCALBASE}/bin/autoupdate-${AUTOCONF_VERSION}
167
168 AUTOCONF_VARS=          AUTOCONF=${AUTOCONF} \
169                         AUTOCONF_DIR=${AUTOCONF_DIR} \
170                         AUTOHEADER=${AUTOHEADER} \
171                         AUTOIFNAMES=${AUTOIFNAMES} \
172                         AUTOM4TE=${AUTOM4TE} \
173                         AUTORECONF=${AUTORECONF} \
174                         AUTOSCAN=${AUTOSCAN} \
175                         AUTOUPDATE=${AUTOUPDATE} \
176                         AUTOCONF_VERSION=${AUTOCONF_VERSION}
177
178 AUTOCONF_DEPENDS=       ${AUTOCONF}:${PORTSDIR}/${AUTOCONF_PORT}
179 BUILD_DEPENDS+=         ${AUTOCONF_DEPENDS}
180 .endif
181
182 #---------------------------------------------------------------------------
183 # libtoolize
184 #---------------------------------------------------------------------------
185
186 .if defined(_AUTOTOOL_libtoolize)
187 LIBTOOL_VERSION=        2.4
188 LIBTOOL_PORT=           devel/libtool
189
190 . if defined(_AUTOTOOL_libtoolize) && ${_AUTOTOOL_libtoolize} == "yes"
191 _AUTOTOOL_rule_libtoolize=      yes
192 GNU_CONFIGURE?=                 yes
193 . endif
194
195 .endif
196
197 .if defined(LIBTOOL_VERSION)
198 LIBTOOLIZE=             ${LOCALBASE}/bin/libtoolize
199 LIBTOOL_LIBEXECDIR=     ${LOCALBASE}/libexec/libtool
200 LIBTOOL_SHAREDIR=       ${LOCALBASE}/share/libtool
201 LIBTOOL_M4=             ${LOCALBASE}/share/aclocal/libtool.m4
202 LTMAIN=                 ${LOCALBASE}/share/libtool/config/ltmain.sh
203
204 LIBTOOL_VARS=           LIBTOOLIZE=${LIBTOOLIZE} \
205                         LIBTOOL_LIBEXECDIR=${LIBTOOL_LIBEXECDIR} \
206                         LIBTOOL_SHAREDIR=${LIBTOOL_SHAREDIR} \
207                         LIBTOOL_M4=${LIBTOOL_M4} \
208                         LTMAIN=${LTMAIN}
209
210 LIBTOOLIZE_ARGS?=       -i -c -f
211
212 LIBTOOL_DEPENDS=        libtool>=2.4:${PORTSDIR}/${LIBTOOL_PORT}
213 BUILD_DEPENDS+=         ${LIBTOOL_DEPENDS}
214 .endif
215
216 #---------------------------------------------------------------------------
217 # Add to the environment
218 #---------------------------------------------------------------------------
219
220 AUTOTOOLS_VARS=         ${AUTOMAKE_VARS} ${AUTOCONF_VARS} ${LIBTOOL_VARS}
221
222 .if defined(AUTOTOOLS_VARS) && !empty(AUTOTOOLS_VARS)
223 . for var in AUTOTOOLS CONFIGURE MAKE SCRIPTS
224 ${var:tu}_ENV+=         ${AUTOTOOLS_VARS}
225 . endfor
226 .endif
227
228 #---------------------------------------------------------------------------
229 # Make targets
230 #---------------------------------------------------------------------------
231
232 .if !target(run-autotools)
233 .ORDER:         run-autotools run-autotools-libtoolize run-autotools-aclocal \
234                 run-autotools-autoconf run-autotools-autoheader \
235                 run-autotools-automake
236
237 run-autotools:: run-autotools-libtoolize run-autotools-aclocal \
238                 run-autotools-autoconf run-autotools-autoheader \
239                 run-autotools-automake
240 .endif
241
242 .if !target(run-autotools-aclocal)
243 run-autotools-aclocal:
244 . if defined(_AUTOTOOL_rule_aclocal)
245         @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${ACLOCAL} \
246                 ${ACLOCAL_ARGS})
247 . else
248         @${DO_NADA}
249 . endif
250 .endif
251
252 .if !target(run-autotools-automake)
253 run-autotools-automake:
254 . if defined(_AUTOTOOL_rule_automake)
255         @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${AUTOMAKE} \
256                 ${AUTOMAKE_ARGS})
257 . else
258         @${DO_NADA}
259 . endif
260 .endif
261
262 .if !target(run-autotools-autoconf)
263 run-autotools-autoconf:
264 . if defined(_AUTOTOOL_rule_autoconf)
265         @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${AUTOCONF} \
266                 ${AUTOCONF_ARGS})
267 . else
268         @${DO_NADA}
269 . endif
270 .endif
271
272 .if !target(run-autotools-autoheader)
273 run-autotools-autoheader:
274 . if defined(_AUTOTOOL_rule_autoheader)
275         @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${AUTOHEADER} \
276                 ${AUTOHEADER_ARGS})
277 . else
278         @${DO_NADA}
279 . endif
280 .endif
281
282 .if !target(run-autotools-libtoolize)
283 run-autotools-libtoolize:
284 . if defined(_AUTOTOOL_rule_libtoolize)
285         @(cd ${CONFIGURE_WRKSRC} && ${SETENV} ${AUTOTOOLS_ENV} ${LIBTOOLIZE} \
286                 ${LIBTOOLIZE_ARGS})
287 . else
288         @${DO_NADA}
289 . endif
290 .endif