Commit | Line | Data |
---|---|---|
abad11c5 C |
1 | dnl run 'autoreconf' to obtain aclocal.m4, and update configure and setup/pkg.m4 |
2 | dnl run 'automake -acf' to update setup/{install-sh,missing} | |
3 | ||
feec80c3 | 4 | dnl standard initialization (we only use autoconf not automake) |
d6ce1786 C |
5 | AC_PREREQ([2.68]) |
6 | AC_INIT([coccinelle], m4_esyscmd([cat ./version | tr -d '\n']), [cocci@diku.dk], [], [http://coccinelle.lip6.fr/]) | |
7 | AC_CONFIG_MACRO_DIR([setup]) | |
8 | AC_CONFIG_AUX_DIR([setup]) | |
d6ce1786 C |
9 | AC_SUBST([CONFIGURE_FLAGS], ["$*"]) |
10 | AC_SUBST([COCCI_VERSION], ["$PACKAGE_VERSION"]) | |
11 | AC_SUBST([COCCI_SRCDIR], ["$(pwd)"]) | |
feec80c3 | 12 | AC_MSG_NOTICE([configuring coccinelle $COCCI_VERSION in $COCCI_SRCDIR]) |
abad11c5 | 13 | AM_INIT_AUTOMAKE |
feec80c3 C |
14 | |
15 | AC_CONFIG_SRCDIR([cocci.ml]) dnl this file must be present in our src directory | |
16 | AC_COCCI_CONFVERSION | |
17 | ||
18 | dnl reminder that this configure depends on macros generated by aclocal | |
19 | AC_MSG_NOTICE([this configure program uses pkg-config m4 macros]) | |
20 | AC_MSG_NOTICE([this configure program uses ocaml m4 macros (see setup/ocaml.m4)]) | |
21 | AC_MSG_NOTICE([this configure program uses custom m4 macros (see setup/cocci.m4)]) | |
22 | AC_MSG_NOTICE([some fake substitutions for required but unavailable programs may be used (see setup/fake*)]) | |
23 | ||
24 | ||
25 | dnl | |
26 | dnl Note: the conditionals in this configure script are tricky. | |
27 | dnl The approach taken here is that many tools can be enabled/disabled | |
28 | dnl and paths can be given explicitly via commandline parameters or | |
29 | dnl environment variables. | |
30 | dnl | |
31 | ||
32 | ||
33 | dnl | |
34 | dnl Basic tools | |
35 | dnl | |
36 | ||
37 | AC_MSG_NOTICE([verifying basic tools]) | |
38 | ||
39 | AC_PROG_INSTALL | |
40 | AC_PROG_MKDIR_P | |
41 | AC_PROG_CPP | |
42 | AC_PATH_PROG([TAR],[tar]) | |
43 | AC_PATH_PROG([PATCH],[patch]) | |
abad11c5 C |
44 | |
45 | dnl ensures that INSTALL points to an absolute install-sh when that one is configured. | |
46 | AS_IF([test "$INSTALL" = "setup/install-sh -c" -o "$INSTALL" = "./setup-install-sh -c"], | |
47 | [dnl | |
48 | AC_SUBST([INSTALL], ["$COCCI_SRCDIR/$INSTALL"]) | |
49 | ]) | |
50 | ||
51 | dnl the same for MKDIR_P | |
52 | AS_IF([test "$MKDIR_P" = "setup/install-sh -c -d" -o "$INSTALL" = "./setup-install-sh -c -d"], | |
53 | [dnl | |
54 | AC_SUBST([MKDIR_P], ["$COCCI_SRCDIR/$MKDIR_P"]) | |
55 | ]) | |
56 | ||
57 | dnl patchelf is an optional dependency and in principle not used for building coccinelle | |
d6ce1786 | 58 | AC_PATH_PROG([PATCHELF],[patchelf]) |
feec80c3 | 59 | |
abad11c5 C |
60 | dnl pkg config is required, but we have an alternative script for it |
61 | AC_COCCI_TOOL([PKG_CONFIG],[pkg-config]) | |
feec80c3 | 62 | AS_IF([test "x$PKG_CONFIG" = xno], |
abad11c5 C |
63 | [dnl no specific pkg-config configured |
64 | AC_SUBST([PKG_CONFIG_ORIG],[pkg-config]) | |
65 | ], | |
66 | [dnl a specific pkg-config configured | |
67 | AC_SUBST([PKG_CONFIG_ORIG],[$PKG_CONFIG]) | |
feec80c3 C |
68 | ]) |
69 | ||
abad11c5 C |
70 | dnl always use the wrapper around pkg-config |
71 | AC_SUBST([PKG_CONFIG],["$COCCI_SRCDIR/setup/fake-subst.sh $PKG_CONFIG_ORIG"]) | |
72 | ||
73 | ||
74 | dnl ocaml compiler configuration | |
feec80c3 C |
75 | AC_PROG_OCAML |
76 | AC_CHECK_OCAMLVERSION([OCAMLATLEAST310],[3.10]) | |
77 | AC_CHECK_OCAMLVERSION([OCAMLATLEAST311],[3.11]) | |
755320b0 | 78 | AC_SUBST([OCAMLCORIG],["$OCAMLC"]) |
feec80c3 C |
79 | |
80 | AS_IF([test "x$OCAMLC" = xno -o "x$OCAMLDEP" = xno -o "x$OCAMLDOC" = xno -o "x$OCAMLMKLIB" = xno], | |
81 | [dnl | |
82 | AC_MSG_ERROR([You must install the OCaml compiler]) | |
83 | ]) | |
84 | AS_IF([test "x$OCAMLATLEAST310" = xno],[AC_MSG_NOTICE([a more recent OCaml installation may be required])]) | |
85 | ||
86 | dnl ocaml tools | |
87 | AC_PROG_CAMLP4 | |
88 | AC_COCCI_TOOL([OCAMLLEX],[ocamllex],[]) | |
89 | AC_COCCI_TOOL([OCAMLYACC],[ocamlyacc],[]) | |
90 | AC_COCCI_TOOL([OCAMLFIND],[ocamlfind],[$COCCI_SRCDIR/setup/fake-subst.sh ocamlfind]) | |
755320b0 | 91 | AC_COCCI_TOOL([OCAMLPROF],[ocamlprof],[]) |
feec80c3 C |
92 | |
93 | dnl enforce ocaml tool requirements | |
94 | AS_IF([test "x$OCAMLLEX" = xno], | |
95 | [dnl | |
96 | AC_MSG_ERROR([the OCaml Lexer needs to be installed (the ocamllex command). It should be part of your OCaml distribution.]) | |
97 | ]) | |
98 | ||
99 | AS_IF([test "x$OCAMLYACC" = xno], | |
100 | [dnl | |
101 | AC_MSG_ERROR([The OCaml parser generated needs to be installed (the ocamlyacc command). It should be part of your OCaml distribution.]) | |
102 | ]) | |
103 | ||
104 | AS_IF([test "x$OCAMLFIND" = xno], | |
105 | [dnl | |
106 | AC_MSG_ERROR([A suitable OCaml findlib (the ocamlfind command) could not be found.]) | |
107 | ]) | |
108 | ||
d6ce1786 | 109 | dnl these runtime commands can also be passed as runtime flags to spatch. |
feec80c3 C |
110 | AC_COCCI_RUNTIME_CMD([OCAMLFIND],[ocamlfind]) |
111 | AC_COCCI_RUNTIME_CMD([OCAMLC],[ocamlc]) | |
112 | AC_COCCI_RUNTIME_CMD([OCAMLOPT],[ocamlopt]) | |
113 | AC_COCCI_RUNTIME_CMD([OCAMLDEP],[ocamldep]) | |
114 | AC_COCCI_RUNTIME_CMD([CAMLP4],[camlp4]) | |
115 | AC_COCCI_RUNTIME_CMD([CAMLP4O],[camlp4o]) | |
116 | ||
755320b0 | 117 | dnl AC_CACHE_SAVE |
feec80c3 C |
118 | |
119 | ||
120 | dnl | |
121 | dnl Basic ocaml modules | |
122 | dnl | |
123 | ||
124 | AC_MSG_NOTICE([verifying basic ocaml modules]) | |
125 | ||
126 | dnl default dir with the bundled ocaml packages | |
127 | AC_COCCI_SET_EXTERNAL_DIR([$COCCI_SRCDIR/bundles]) | |
128 | ||
129 | dnl set some defaults | |
130 | dnl add a line for each package that is | |
131 | dnl configured via AC_CHECK_COCCI_EXTPKG | |
132 | dnl or AC_REQ_COCCI_EXTPKG | |
feec80c3 | 133 | AC_COCCI_INIT_PKG_EMPTY([menhirLib]) |
feec80c3 C |
134 | AC_COCCI_INIT_PKG_EMPTY([dynlink]) |
135 | AC_COCCI_INIT_PKG_EMPTY([pcre]) | |
136 | AC_COCCI_INIT_PKG_EMPTY([pycaml]) | |
137 | AC_COCCI_INIT_PKG_EMPTY([camlp4]) | |
138 | ||
139 | dnl required ocaml packages | |
140 | AC_MSG_NOTICE([the following OCaml packages should be provided by your ocaml installation]) | |
141 | AC_REQ_COCCI_STDPKG([unix]) | |
142 | AC_REQ_COCCI_STDPKG([bigarray]) | |
143 | AC_REQ_COCCI_STDPKG([num]) | |
144 | AC_REQ_COCCI_STDPKG([str]) | |
feec80c3 C |
145 | |
146 | dnl required modules (Some are available locally too) | |
147 | AC_REQ_COCCI_EXTPKG([dynlink]) | |
148 | AC_REQ_COCCI_EXTPKG([camlp4]) | |
feec80c3 | 149 | AC_REQ_COCCI_EXTPKG([menhirLib]) |
feec80c3 C |
150 | |
151 | ||
755320b0 | 152 | dnl AC_CACHE_SAVE |
feec80c3 C |
153 | |
154 | ||
155 | dnl | |
156 | dnl Handling of optional features | |
157 | dnl | |
158 | ||
159 | AC_MSG_NOTICE([verifying optional features]) | |
160 | ||
d6ce1786 C |
161 | dnl test if the optimized version of dynlink is available |
162 | AS_IF([test "x$OCAML_PKG_dynlink" != xno -a -f "$PATH_dynlink/dynlink.cmxa"], | |
163 | [dnl yes | |
164 | AC_SUBST([OPTIMIZED_dynlink], [yes]) | |
165 | ], | |
166 | [dnl no | |
167 | AC_SUBST([OPTIMIZED_dynlink], [no]) | |
168 | ]) | |
169 | ||
feec80c3 C |
170 | |
171 | dnl menhir handling | |
172 | dnl variables: | |
173 | dnl with_menhir: whether or not menhir must be used | |
174 | AC_COCCI_TOOL([MENHIR],[menhir],[$COCCI_SRCDIR/setup/fake-menhir.sh menhir]) | |
175 | AS_IF([test "x$SUBSTITUTED_MENHIR" = xyes], | |
176 | [dnl | |
177 | AC_MSG_NOTICE([pregenerated parsers will be required as substitute for Menhir]) | |
178 | ]) | |
179 | ||
180 | ||
181 | dnl ocaml script handling | |
182 | dnl variables: | |
183 | dnl enable_ocaml: whether to enable ocaml scripts | |
184 | AC_ARG_ENABLE([ocaml], AS_HELP_STRING([--enable-ocaml], [enable ocaml scripting (default: auto)])) | |
185 | AS_IF([test "x$OCAML_PKG_dynlink" = xno], | |
186 | [dnl | |
187 | AS_IF([test -z "$enable_ocaml"], | |
188 | [dnl | |
d6ce1786 | 189 | AC_SUBST([enable_ocaml], [no]) |
feec80c3 C |
190 | AC_MSG_NOTICE([ocaml scripting is disabled because the 'dynlink' package is not installed]) |
191 | ], [test "x$enable_ocaml" != xno], | |
192 | [dnl | |
193 | AC_MSG_ERROR([the OCaml package dynlink is required for ocaml scripting]) | |
194 | ]) | |
195 | ]) | |
196 | ||
197 | dnl too old ocaml version, disable dynlink by default | |
198 | AS_IF([test "x$OCAMLATLEAST311" = xno], | |
199 | [dnl | |
d6ce1786 C |
200 | AS_IF([test -z "$enable_ocaml"], |
201 | [dnl | |
202 | AC_SUBST([enable_ocaml], [no]) | |
203 | AC_MSG_NOTICE([ocaml scripting has been disabled by default because your OCaml version may not support dynamic linking properly]) | |
204 | ], [test "x$enable_ocaml" = xyes], | |
205 | [dnl | |
206 | AC_MSG_NOTICE([warning: your ocaml version may be too old for dynamic linking, thus ocaml scripting may not work]) | |
207 | ]) | |
208 | ]) | |
209 | ||
210 | dnl no optimized version, disable dynlink by default | |
211 | AS_IF([test "x$OPTIMIZED_dynlink" = xno], | |
212 | [dnl | |
213 | AS_IF([test -z "$enable_ocaml"], | |
214 | [dnl | |
215 | AC_SUBST([enable_ocaml], [no]) | |
216 | AC_MSG_NOTICE([ocaml scripting has been disabled by default because the optimized version of dynlink is not available]) | |
217 | ], [test "x$enable_ocaml" = xyes], | |
218 | [dnl | |
219 | AC_MSG_NOTICE([warning: the optimized version of dynlink is not available, thus ocaml scripting may not work]) | |
220 | ]) | |
feec80c3 C |
221 | ]) |
222 | ||
223 | dnl scripting requirement on ocamlfind | |
224 | AS_IF([test -n "$SUBSTITUTED_OCAMLFIND"], | |
225 | [dnl | |
226 | AS_IF([test -z "$enable_ocaml"], | |
227 | [dnl this is perhaps a bit too strict | |
228 | AC_SUBST([enable_ocaml],[no]) | |
229 | AC_MSG_NOTICE([ocaml scripting is disabled because it depends on ocamlfind]) | |
230 | ], [test "x$enable_ocaml" != xno], | |
231 | [dnl | |
d6ce1786 | 232 | AC_MSG_NOTICE([warning: ocamlfind is not found but may be required when ocaml scripts are used]) |
feec80c3 C |
233 | ]) |
234 | ]) | |
235 | ||
236 | dnl scripting requirement on camlp4 | |
237 | AS_IF([test "x$CAMLP4" = xno], | |
238 | [dnl | |
239 | AS_IF([test -z "$enable_ocaml"], | |
240 | [dnl this is perhaps a bit too strict | |
241 | AC_SUBST([enable_ocaml],no) | |
d6ce1786 | 242 | AC_MSG_NOTICE([ocaml scripting is disabled because it requires camlp4 which is not available]) |
feec80c3 C |
243 | ], [test "x$enable_ocaml" != xno], |
244 | [dnl | |
d6ce1786 | 245 | AC_MSG_NOTICE([warning: camlp4 is not found but may be required when ocaml scripts are used]) |
feec80c3 C |
246 | ]) |
247 | ]) | |
248 | ||
249 | AS_IF([test "x$enable_ocaml" = xno], | |
250 | [dnl | |
251 | AC_COCCI_INIT_PKG_EMPTY([dynlink]) dnl prevent linking with it | |
d6ce1786 C |
252 | AC_SUBST(OCAMLCOCCI_MODULE, [No_prepare_ocamlcocci]) |
253 | AC_SUBST(OCAMLCOCCI_FILE, [no_prepare_ocamlcocci.ml]) | |
feec80c3 C |
254 | ], |
255 | [dnl | |
d6ce1786 C |
256 | AC_SUBST([enable_ocaml], [yes]) |
257 | AC_SUBST(OCAMLCOCCI_MODULE, [Yes_prepare_ocamlcocci]) | |
258 | AC_SUBST(OCAMLCOCCI_FILE, [yes_prepare_ocamlcocci.ml]) | |
feec80c3 C |
259 | ]) |
260 | ||
261 | ||
262 | dnl python handling | |
263 | dnl variables: | |
264 | dnl with_python: whether to enable the python feature (and what version) | |
265 | dnl OCAML_PKG_pycaml: if "local" use local pycaml package | |
266 | AC_ARG_VAR([PYTHON], [path to python when the version is determined automatically]) | |
267 | AC_ARG_ENABLE([python], [AS_HELP_STRING([--enable-python], [enable python scripting (yes/no) (default: auto)])]) | |
268 | AS_IF([test "x$enable_python" != xno], | |
269 | [dnl | |
d6ce1786 C |
270 | dnl an explicitly set --with-python disables the global pycaml by default |
271 | dnl set --enable-pycaml if it is clear that the installed pycaml library | |
272 | dnl is consistent with the chosen python version | |
feec80c3 C |
273 | AS_IF([test -n "$enable_python" -a -z "$enable_pycaml"], |
274 | [dnl if explicit python given: | |
275 | AC_MSG_NOTICE([skipped the selection of a global pycaml module because --enable-python is given explicitly but --enable-pycaml is not.]) | |
d6ce1786 | 276 | AC_SUBST([enable_pycaml], [no]) |
feec80c3 C |
277 | ]) |
278 | ||
279 | dnl sets "$PYVER" if python is available | |
280 | AC_COCCI_PYVER | |
281 | ||
282 | AS_IF([test -z "$PYVER"], | |
283 | [dnl PYVER undetermined | |
284 | AS_IF([test "x$enable_python" = xyes], | |
285 | [dnl | |
286 | AC_MSG_ERROR([python scripting is enabled explicitly but the version of python could not be determined]) | |
287 | ]) | |
288 | ], | |
289 | [dnl | |
d6ce1786 | 290 | AC_MSG_NOTICE([looking for the corresponding python library]) |
feec80c3 C |
291 | PKG_CHECK_MODULES([PYTHON], [python-$PYVER],[AC_SUBST(HAVE_PYTHON,[yes])],[AC_SUBST(HAVE_PYTHON,[no])]) |
292 | ||
293 | AS_IF([test "x$HAVE_PYTHON" != xyes -a "x$enable_python" != xyes], | |
294 | [dnl fallback if the above failed | |
d6ce1786 | 295 | AC_MSG_NOTICE([trying the default python library as fallback]) |
feec80c3 C |
296 | PKG_CHECK_MODULES([PYTHON], [python],[AC_SUBST(HAVE_PYTHON,[yes])],[AC_SUBST(HAVE_PYTHON,[no])]) |
297 | ]) | |
298 | ]) | |
299 | ]) | |
300 | ||
301 | AS_IF([test -z "$enable_python"], | |
302 | [dnl | |
303 | AS_IF([test "x$HAVE_PYTHON" = xyes], | |
304 | [dnl | |
d6ce1786 | 305 | AC_SUBST([enable_python], [yes]) |
feec80c3 C |
306 | ], |
307 | [dnl | |
d6ce1786 | 308 | AC_SUBST([enable_python], [no]) |
feec80c3 C |
309 | ]) |
310 | ]) | |
311 | ||
312 | AS_IF([test "x$enable_python" != xno], | |
313 | [dnl | |
314 | AS_IF([test "x$HAVE_PYTHON" = xyes], | |
315 | [dnl | |
316 | AC_MSG_NOTICE([support for python scripts is enabled]) | |
317 | ], | |
318 | [dnl | |
319 | AC_MSG_ERROR([the python scripts feature is enabled but the pkg-config python library is not found]) | |
320 | ]) | |
321 | ||
322 | AC_REQ_COCCI_EXTPKG([pycaml]) | |
323 | AC_SUBST([PYCOCCI_MODULE], [Yes_pycocci]) | |
324 | AC_SUBST([PYCOCCI_FILE],[yes_pycocci.ml]) | |
325 | ], | |
326 | [dnl | |
327 | AC_COCCI_INIT_PKG_EMPTY([pycaml]) | |
328 | AC_SUBST([PYCOCCI_MODULE], [No_pycocci]) | |
329 | AC_SUBST([PYCOCCI_FILE],[no_pycocci.ml]) | |
330 | ]) | |
331 | ||
332 | ||
333 | dnl pcre handling | |
334 | dnl variables: | |
335 | dnl enable_pcre: whether to enable the pcre feature | |
336 | dnl OCAML_PKG_pcre: if "local" use str package | |
337 | AC_ARG_ENABLE([pcre-syntax], AS_HELP_STRING([--enable-pcre-syntax], [enable pcre regular expression syntax (default: auto)])) | |
338 | AS_IF([test "x$enable_pcre_syntax" != "xno"], | |
339 | [dnl | |
340 | PKG_CHECK_MODULES([PCRE], [libpcre],[AC_SUBST([HAVE_PCRE],[yes])],[AC_SUBST([HAVE_PCRE],[no])]) | |
341 | AS_IF([test -z "$enable_pcre_syntax" -a "x$HAVE_PCRE" != xyes], | |
342 | [dnl | |
d6ce1786 | 343 | AC_SUBST([enable_pcre_syntax], [no]) |
feec80c3 C |
344 | ], |
345 | [dnl | |
346 | AC_CHECK_COCCI_EXTPKG([pcre]) dnl will set $enable_pcre to 'yes', 'no', or 'local' | |
347 | enable_pcre_syntax=$enable_pcre | |
348 | ]) | |
349 | ]) | |
350 | ||
351 | AS_IF([test "x$enable_pcre_syntax" != xno], | |
352 | [dnl | |
353 | AS_IF([test "x$HAVE_PCRE" = xyes], | |
354 | [dnl | |
355 | AC_MSG_NOTICE([support for pcre syntax is enabled]) | |
356 | ], | |
357 | [dnl | |
358 | AC_MSG_ERROR([the pcre feature is enabled but the pkg-config libpcre library is not found]) | |
359 | ]) | |
360 | ||
361 | AC_SUBST([REGEXP_MODULE], [Regexp_pcre]) | |
362 | AC_SUBST([REGEXP_FILE], [regexp_pcre.ml]) | |
363 | ], | |
364 | [dnl | |
365 | AC_COCCI_INIT_PKG_EMPTY([pcre]) | |
366 | AC_SUBST([REGEXP_MODULE], [Regexp_str]) | |
367 | AC_SUBST([REGEXP_FILE], [regexp_str.ml]) | |
368 | ]) | |
369 | ||
370 | ||
755320b0 | 371 | dnl AC_CACHE_SAVE |
feec80c3 C |
372 | |
373 | ||
374 | dnl obtain the value of $prefix | |
375 | AS_IF([test "$prefix" = "NONE"],[prefix=$ac_default_prefix]) | |
376 | ||
377 | ||
378 | dnl | |
379 | dnl backwards compatibility | |
380 | dnl | |
381 | ||
382 | dnl defines some variables needed by the Make infrastructure | |
383 | AC_SUBST(SHAREDIR,["${prefix}/share/coccinelle"]) | |
384 | ||
385 | AS_IF([test "x$enable_python" != xno], | |
386 | [dnl | |
d6ce1786 | 387 | AC_SUBST(FEATURE_PYTHON, [1]) |
feec80c3 C |
388 | ], |
389 | [dnl | |
d6ce1786 | 390 | AC_SUBST(FEATURE_PYTHON, [0]) |
feec80c3 C |
391 | ]) |
392 | ||
393 | AS_IF([test "x$enable_ocaml" != xno], | |
394 | [dnl | |
d6ce1786 | 395 | AC_SUBST(FEATURE_OCAML, [1]) |
feec80c3 C |
396 | ], |
397 | [dnl | |
d6ce1786 | 398 | AC_SUBST(FEATURE_OCAML, [0]) |
feec80c3 C |
399 | ]) |
400 | ||
401 | dnl dynlink stuff depending on the OCaml version and whether it is enabled | |
d6ce1786 | 402 | AS_IF([test "x$OCAMLATLEAST311" = xyes -a "x$enable_ocaml" = xyes -a "x$OCAMLOPT" != xno], |
feec80c3 | 403 | [dnl |
d6ce1786 | 404 | AC_SUBST([DYNLINK_IS_NATIVE], [Dynlink.is_native]) |
feec80c3 C |
405 | ], |
406 | [dnl | |
d6ce1786 | 407 | AC_SUBST([DYNLINK_IS_NATIVE], [false]) |
feec80c3 C |
408 | ]) |
409 | ||
410 | dnl in case of the compilation of the manual | |
411 | AC_COCCI_TOOL([PDFLATEX],[pdflatex],[$COCCI_SRCDIR/setup/fake-pdflatex.sh pdflatex]) | |
412 | ||
413 | ||
d6ce1786 | 414 | dnl determine release configuration |
755320b0 | 415 | AC_ARG_ENABLE([release], [AS_HELP_STRING([--enable-release], [build with a release configuration (yes,no,profile default: no)])]) |
feec80c3 C |
416 | AS_IF([test -z "$enable_release"], |
417 | [dnl | |
418 | AC_MSG_NOTICE([choosing the development Makefile configuration because the release configuration is not explicitly requested.]) | |
419 | AC_SUBST([enable_release], [no]) | |
420 | ]) | |
421 | ||
755320b0 | 422 | AC_SUBST([MODULES_profiling],[]) |
feec80c3 | 423 | AS_IF([test "x$enable_release" = xyes], |
d6ce1786 | 424 | [dnl set the default target to 'release' when enable_release is given |
feec80c3 C |
425 | AC_SUBST([MAKETARGET_ALL], [all-release]) |
426 | ], [test "x$enable_release" = xno], | |
d6ce1786 | 427 | [dnl otherwise, set the default target to 'dev' |
feec80c3 | 428 | AC_SUBST([MAKETARGET_ALL], [all-dev]) |
755320b0 C |
429 | ], [test "x$enable_release" = xprofile], |
430 | [dnl selected profiling | |
431 | AS_IF([test -z "$OCAMLPROF" -o "x$OCAMLPROF" = xno], | |
432 | [dnl | |
433 | AC_MSG_ERROR([ocamlprof is required for profiling, but is absent.]) | |
434 | ]) | |
435 | ||
436 | dnl configuration-time overrides for profiling | |
437 | AC_SUBST([MAKETARGET_ALL], [all-dev]) | |
abad11c5 | 438 | AC_SUBST([OCAMLC], ["$COCCI_SRCDIR/setup/wrapper-ocamlcp.sh $OCAMLCORIG $OCAMLPROF"]) |
755320b0 C |
439 | AC_SUBST([MODULES_profiling], [profiling.cmo]) |
440 | AC_MSG_NOTICE([configured coccinelle for profiling]) | |
feec80c3 C |
441 | ], |
442 | [dnl custom target given | |
443 | AC_SUBST([MAKETARGET_ALL], ["$enable_release"]) | |
444 | ]) | |
445 | ||
d6ce1786 C |
446 | dnl determine whether to build the optimizing version |
447 | AC_ARG_ENABLE([opt], [AS_HELP_STRING([--enable-opt], [build an optimized spatch (yes,no, default: auto)])]) | |
448 | AS_IF([test "x$OCAMLOPT" = xno -a "x$enable_opt" != xno], | |
449 | [dnl | |
450 | AS_IF([test -n "$enable_release" -a "x$enable_release" != xyes -a "x$enable_release" != xno], | |
451 | [dnl | |
452 | AC_MSG_NOTICE([warning: ensure that make target $enable_release does not depend on the unavailable ocamlopt]) | |
453 | ], [test "x$enable_opt" = xyes], | |
454 | [dnl | |
455 | AC_MSG_ERROR([the optimized version of coccinelle is requested explicitly, but ocamlopt is absent]) | |
456 | ], | |
457 | [dnl | |
458 | AC_MSG_NOTICE([the optimized version of coccinelle will not be build because ocamlopt is not present]) | |
459 | AC_SUBST([enable_opt], [no]) | |
460 | ]) | |
461 | ]) | |
462 | ||
463 | AS_IF([test "x$OCAMLVERSION" = x3.11.2 -a -z "$enable_opt"], | |
464 | [dnl the optimized version may not be buildable with ocaml 3.11.2 (know bug), hence disable it by default | |
465 | AC_MSG_NOTICE([the optimized version of coccinelle will not be build by default due to OCaml version $OCAMLVERSION]) | |
466 | AC_SUBST([enable_opt], [no]) | |
467 | ]) | |
468 | ||
469 | dnl disable the optimized target when dynlinking is enabled but the optimized version of dynlink is not available | |
470 | AS_IF([test "x$OPTIMIZED_dynlink" = xno -a "x$enable_ocaml" = xyes], | |
471 | [dnl | |
472 | AS_IF([test -z "$enable_opt"], | |
473 | [dnl | |
474 | AC_MSG_NOTICE([the optimized version of coccinelle will not be build by default because ocaml scripting is enabled but the required optimized dynlink package is not present]) | |
475 | AC_SUBST([enable_opt], [no]) | |
476 | ], [test "x$enable_opt" = xyes], | |
477 | [dnl | |
478 | AC_MSG_ERROR([the optimized version of coccinelle in combination with ocaml scripting requires the optimized version of the dynlik package, which is not present]) | |
479 | ]) | |
480 | ]) | |
481 | ||
abad11c5 | 482 | dnl set the default enable-opt setting |
d6ce1786 C |
483 | AS_IF([test -z "$enable_opt"], |
484 | [dnl | |
485 | AS_IF([test "x$enable_release" = xyes -o "x$enable_release" = xno], | |
486 | [dnl | |
487 | AC_SUBST([enable_opt], ["$enable_release"]) | |
488 | ]) | |
489 | ]) | |
490 | ||
491 | dnl variables depending on whether we build the optimized spatch | |
492 | AS_IF([test "x$enable_opt" = xyes], | |
493 | [dnl default target for the optimized version | |
494 | AC_SUBST([SPATCHNAME], [spatch.opt]) | |
495 | AC_SUBST([MAKETARGET_SPATCH], [opt-only]) | |
496 | ], | |
497 | [dnl default target for the bytecode version | |
498 | AC_SUBST([SPATCHNAME], [spatch]) | |
499 | AC_SUBST([MAKETARGET_SPATCH], [byte-only]) | |
500 | ]) | |
feec80c3 C |
501 | |
502 | ||
abad11c5 C |
503 | dnl ocamlbuild handling |
504 | AC_ARG_ENABLE([ocamlbuild], AS_HELP_STRING([--enable-ocamlbuild], [enable ocamlbuild support (default: no)])) | |
505 | AS_IF([test "x$enable_ocamlbuild" = xyes], | |
506 | [dnl ocamlbuild support requested | |
507 | AS_IF([test -z "$OCAMLBUILD" -o "x$OCAMLBUILD" = xno], | |
508 | [dnl | |
509 | AC_MSG_ERROR([Ocamlbuild is required but is not installed.]) | |
510 | ]) | |
511 | ||
512 | AC_SUBST([FEATURE_OCAMLBUILD], [yes]) | |
513 | ], | |
514 | [dnl default: disable ocamlbuild support | |
515 | AC_SUBST([FEATURE_OCAMLBUILD], [ ]) | |
516 | ]) | |
517 | ||
518 | ||
feec80c3 C |
519 | dnl |
520 | dnl generating configuration | |
521 | dnl | |
522 | ||
d6ce1786 C |
523 | AC_CONFIG_FILES([ |
524 | Makefile.config | |
525 | version.ml | |
526 | commons/commands.ml | |
527 | globals/config.ml globals/regexp.ml python/pycocci.ml | |
528 | ocaml/prepare_ocamlcocci.ml | |
529 | scripts/spatch.sh | |
530 | docs/spatch.1 | |
abad11c5 C |
531 | myocamlbuild.ml |
532 | ||
533 | setup/Makefile | |
d6ce1786 | 534 | ]) |
feec80c3 C |
535 | |
536 | AC_OUTPUT | |
537 | ||
538 | AC_MSG_NOTICE([configuration completed]) | |
539 | ||
540 | cat << EOF | |
541 | ------------------------------------------------------------------------------ | |
542 | Summary | |
543 | ||
d6ce1786 C |
544 | configure flags: $CONFIGURE_FLAGS |
545 | findlib: $OCAMLFIND (an actual version is strongly recommended) | |
546 | menhir: $MENHIR (should be an optional tool) | |
755320b0 | 547 | menhirLib module: $enable_menhirLib (for local package use --disable-menhirLib) |
feec80c3 | 548 | |
d6ce1786 C |
549 | ocaml scripting: $enable_ocaml (overridable with --enable-ocaml) |
550 | python scripting: $enable_python (overridable with --enable-python) | |
551 | pycaml module: $enable_pycaml (for local package use --disable-pycaml) | |
feec80c3 | 552 | |
d6ce1786 C |
553 | pcre regexes: $enable_pcre_syntax (overridable with --enable-pcre-syntax) |
554 | pcre module: $enable_pcre (for local package use --disable-pcre) | |
555 | pcre library: $HAVE_PCRE (requires the dev version of libpcre) | |
feec80c3 | 556 | |
d6ce1786 C |
557 | release config: $enable_release (strongly recommended to be 'yes', overridable with --enable-release) |
558 | optimized spatch: $enable_opt (overridable with --disable-opt) | |
feec80c3 | 559 | |
feec80c3 C |
560 | ------------------------------------------------------------------------------ |
561 | Coccinelle can now be compiled and installed. | |
562 | ||
563 | ||
564 | If you compile coccinelle again after source code changes or | |
565 | configuration changes, you may need to run first: | |
566 | \$ make clean | |
567 | ||
568 | To compile coccinelle, run: | |
569 | \$ make all | |
570 | ||
571 | To install coccinelle, run: | |
572 | \$ make install | |
573 | ||
d6ce1786 C |
574 | Then, to test coccinelle, run for example: |
575 | \$ spatch -sp_file demos/simple.cocci demos/simple.c -o /tmp/new_simple.c | |
576 | ||
577 | Or when coccinelle is not installed yet: | |
578 | \$ COCCINELLE_HOME=$(pwd) ./scripts/spatch -sp_file demos/simple.cocci demos/simple.c -o /tmp/new_simple.c | |
feec80c3 C |
579 | EOF |
580 | ||
581 | if test "x$enable_python" != "xno"; then | |
582 | cat << EOF | |
583 | ------------------------------------------------------------------------------ | |
584 | You may need to set some environment variables so that the python | |
585 | libraries are found. The frontend 'spatch' sets the following variables: | |
586 | ||
587 | \$ export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$prefix/lib | |
588 | \$ export PYTHONPATH=\$PYTHONPATH:$prefix/share/coccinelle/python | |
589 | ||
590 | EOF | |
591 | fi | |
592 | ||
593 | cat << EOF | |
594 | ------------------------------------------------------------------------------ | |
595 | EOF |