1 #---------------------------------------------------------------------------
5 # Copyright (c) 2013 Daniel Stenberg <daniel@haxx.se>
7 # Permission to use, copy, modify, and distribute this software for any
8 # purpose with or without fee is hereby granted, provided that the above
9 # copyright notice and this permission notice appear in all copies.
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #---------------------------------------------------------------------------
24 dnl The funny name of this file is intentional in order to make it
25 dnl sort alphabetically after any libtool, autoconf or automake
26 dnl provided .m4 macro file that might get copied into this same
27 dnl subdirectory. This allows that macro (re)definitions from this
28 dnl file may override those provided in other files.
32 dnl -------------------------------------------------
35 m4_define([XC_CONFIGURE_PREAMBLE_VER_MAJOR],[1])dnl
36 m4_define([XC_CONFIGURE_PREAMBLE_VER_MINOR],[0])dnl
39 dnl _XC_CFG_PRE_PREAMBLE
40 dnl -------------------------------------------------
43 AC_DEFUN([_XC_CFG_PRE_PREAMBLE],
45 ## -------------------------------- ##
46 @%:@@%:@ [XC_CONFIGURE_PREAMBLE] ver: []dnl
47 XC_CONFIGURE_PREAMBLE_VER_MAJOR.[]dnl
48 XC_CONFIGURE_PREAMBLE_VER_MINOR ##
49 ## -------------------------------- ##
51 xc_configure_preamble_ver_major='XC_CONFIGURE_PREAMBLE_VER_MAJOR'
52 xc_configure_preamble_ver_minor='XC_CONFIGURE_PREAMBLE_VER_MINOR'
54 xc_configure_preamble_prev_IFS=$IFS
56 xc_msg_warn='configure: WARNING:'
57 xc_msg_abrt='Can not continue.'
58 xc_msg_err='configure: error:'
62 dnl _XC_CFG_PRE_BASIC_CHK_CMD_ECHO
63 dnl -------------------------------------------------
66 dnl Emits shell code that verifies that 'echo' command
67 dnl is available, otherwise aborts execution.
69 AC_DEFUN([_XC_CFG_PRE_BASIC_CHK_CMD_ECHO],
71 AC_REQUIRE([_XC_CFG_PRE_PREAMBLE])dnl
73 # Verify that 'echo' command is available, otherwise abort.
77 (`echo "$xc_tst_str" >/dev/null 2>&1`) && xc_tst_str='success'
78 case "x$xc_tst_str" in @%:@ ((
83 # Try built-in echo, and fail.
84 echo "$xc_msg_err 'echo' command not found. $xc_msg_abrt" >&2
91 dnl _XC_CFG_PRE_BASIC_CHK_CMD_TEST
92 dnl -------------------------------------------------
95 dnl Emits shell code that verifies that 'test' command
96 dnl is available, otherwise aborts execution.
98 AC_DEFUN([_XC_CFG_PRE_BASIC_CHK_CMD_TEST],
100 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_CMD_ECHO])dnl
102 # Verify that 'test' command is available, otherwise abort.
106 (`test -n "$xc_tst_str" >/dev/null 2>&1`) && xc_tst_str='success'
107 case "x$xc_tst_str" in @%:@ ((
112 echo "$xc_msg_err 'test' command not found. $xc_msg_abrt" >&2
119 dnl _XC_CFG_PRE_BASIC_CHK_VAR_PATH
120 dnl -------------------------------------------------
123 dnl Emits shell code that verifies that 'PATH' variable
124 dnl is set, otherwise aborts execution.
126 AC_DEFUN([_XC_CFG_PRE_BASIC_CHK_VAR_PATH],
128 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_CMD_TEST])dnl
130 # Verify that 'PATH' variable is set, otherwise abort.
134 (`test -n "$PATH" >/dev/null 2>&1`) && xc_tst_str='success'
135 case "x$xc_tst_str" in @%:@ ((
140 echo "$xc_msg_err 'PATH' variable not set. $xc_msg_abrt" >&2
147 dnl _XC_CFG_PRE_BASIC_CHK_CMD_EXPR
148 dnl -------------------------------------------------
151 dnl Emits shell code that verifies that 'expr' command
152 dnl is available, otherwise aborts execution.
154 AC_DEFUN([_XC_CFG_PRE_BASIC_CHK_CMD_EXPR],
156 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_VAR_PATH])dnl
158 # Verify that 'expr' command is available, otherwise abort.
162 xc_tst_str=`expr "$xc_tst_str" : '.*' 2>/dev/null`
163 case "x$xc_tst_str" in @%:@ ((
168 echo "$xc_msg_err 'expr' command not found. $xc_msg_abrt" >&2
175 dnl _XC_CFG_PRE_BASIC_CHK_UTIL_SED
176 dnl -------------------------------------------------
179 dnl Emits shell code that verifies that 'sed' utility
180 dnl is found within 'PATH', otherwise aborts execution.
182 dnl This 'sed' is required in order to allow configure
183 dnl script bootstrapping itself. No fancy testing for a
184 dnl proper 'sed' this early, that should be done later.
186 AC_DEFUN([_XC_CFG_PRE_BASIC_CHK_UTIL_SED],
188 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_VAR_PATH])dnl
190 # Verify that 'sed' utility is found within 'PATH', otherwise abort.
194 xc_tst_str=`echo "$xc_tst_str" 2>/dev/null \
195 | sed -e 's:unknown:success:' 2>/dev/null`
196 case "x$xc_tst_str" in @%:@ ((
201 echo "$xc_msg_err 'sed' utility not found in 'PATH'. $xc_msg_abrt" >&2
208 dnl _XC_CFG_PRE_BASIC_CHK_UTIL_GREP
209 dnl -------------------------------------------------
212 dnl Emits shell code that verifies that 'grep' utility
213 dnl is found within 'PATH', otherwise aborts execution.
215 dnl This 'grep' is required in order to allow configure
216 dnl script bootstrapping itself. No fancy testing for a
217 dnl proper 'grep' this early, that should be done later.
219 AC_DEFUN([_XC_CFG_PRE_BASIC_CHK_UTIL_GREP],
221 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_VAR_PATH])dnl
223 # Verify that 'grep' utility is found within 'PATH', otherwise abort.
227 (`echo "$xc_tst_str" 2>/dev/null \
228 | grep 'unknown' >/dev/null 2>&1`) && xc_tst_str='success'
229 case "x$xc_tst_str" in @%:@ ((
234 echo "$xc_msg_err 'grep' utility not found in 'PATH'. $xc_msg_abrt" >&2
241 dnl _XC_CFG_PRE_BASIC_CHK_UTIL_TR
242 dnl -------------------------------------------------
245 dnl Emits shell code that verifies that 'tr' utility
246 dnl is found within 'PATH', otherwise aborts execution.
248 AC_DEFUN([_XC_CFG_PRE_BASIC_CHK_UTIL_TR],
250 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_VAR_PATH])dnl
252 # Verify that 'tr' utility is found within 'PATH', otherwise abort.
255 xc_tst_str='98s7u6c5c4e3s2s10'
256 xc_tst_str=`echo "$xc_tst_str" 2>/dev/null \
257 | tr -d '0123456789' 2>/dev/null`
258 case "x$xc_tst_str" in @%:@ ((
263 echo "$xc_msg_err 'tr' utility not found in 'PATH'. $xc_msg_abrt" >&2
270 dnl _XC_CFG_PRE_BASIC_CHK_UTIL_WC
271 dnl -------------------------------------------------
274 dnl Emits shell code that verifies that 'wc' utility
275 dnl is found within 'PATH', otherwise aborts execution.
277 AC_DEFUN([_XC_CFG_PRE_BASIC_CHK_UTIL_WC],
279 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_VAR_PATH])dnl
281 # Verify that 'wc' utility is found within 'PATH', otherwise abort.
284 xc_tst_str='unknown unknown unknown unknown'
285 xc_tst_str=`echo "$xc_tst_str" 2>/dev/null \
287 case "x$xc_tst_str" in @%:@ ((
292 echo "$xc_msg_err 'wc' utility not found in 'PATH'. $xc_msg_abrt" >&2
299 dnl _XC_CFG_PRE_BASIC_CHK_UTIL_CAT
300 dnl -------------------------------------------------
303 dnl Emits shell code that verifies that 'cat' utility
304 dnl is found within 'PATH', otherwise aborts execution.
306 AC_DEFUN([_XC_CFG_PRE_BASIC_CHK_UTIL_CAT],
308 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_UTIL_WC])dnl
310 # Verify that 'cat' utility is found within 'PATH', otherwise abort.
314 xc_tst_str=`cat <<_EOT 2>/dev/null | wc -l 2>/dev/null
319 case "x$xc_tst_str" in @%:@ ((
324 echo "$xc_msg_err 'cat' utility not found in 'PATH'. $xc_msg_abrt" >&2
331 dnl _XC_CFG_PRE_CHECK_PATH_SEPARATOR
332 dnl -------------------------------------------------
335 dnl Emits shell code that computes the path separator
336 dnl and stores the result in 'PATH_SEPARATOR', unless
337 dnl the user has already set it with a non-empty value.
339 dnl This path separator is the symbol used to separate
340 dnl or diferentiate paths inside the 'PATH' environment
343 dnl Non-empty user provided 'PATH_SEPARATOR' always
344 dnl overrides the auto-detected one.
346 AC_DEFUN([_XC_CFG_PRE_CHECK_PATH_SEPARATOR],
348 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_CMD_EXPR])dnl
350 # Auto-detect and set 'PATH_SEPARATOR', unless it is already non-empty set.
353 # Directory count in 'PATH' when using a colon separator.
355 xc_tst_prev_IFS=$IFS; IFS=':'
356 for xc_tst_dir in $PATH; do
358 xc_tst_dirs_col="x$xc_tst_dirs_col"
361 xc_tst_dirs_col=`expr "$xc_tst_dirs_col" : '.*'`
363 # Directory count in 'PATH' when using a semicolon separator.
365 xc_tst_prev_IFS=$IFS; IFS=';'
366 for xc_tst_dir in $PATH; do
368 xc_tst_dirs_sem="x$xc_tst_dirs_sem"
371 xc_tst_dirs_sem=`expr "$xc_tst_dirs_sem" : '.*'`
373 if test $xc_tst_dirs_sem -eq $xc_tst_dirs_col; then
374 # When both counting methods give the same result we do not want to
375 # chose one over the other, and consider auto-detection not possible.
376 if test -z "$PATH_SEPARATOR"; then
377 # Stop dead until user provides 'PATH_SEPARATOR' definition.
378 echo "$xc_msg_err 'PATH_SEPARATOR' variable not set. $xc_msg_abrt" >&2
382 # Separator with the greater directory count is the auto-detected one.
383 if test $xc_tst_dirs_sem -gt $xc_tst_dirs_col; then
384 xc_tst_auto_separator=';'
386 xc_tst_auto_separator=':'
388 if test -z "$PATH_SEPARATOR"; then
389 # Simply use the auto-detected one when not already set.
390 PATH_SEPARATOR=$xc_tst_auto_separator
391 elif test "x$PATH_SEPARATOR" != "x$xc_tst_auto_separator"; then
392 echo "$xc_msg_warn 'PATH_SEPARATOR' does not match auto-detected one." >&2
395 xc_PATH_SEPARATOR=$PATH_SEPARATOR
396 AC_SUBST([PATH_SEPARATOR])dnl
400 dnl _XC_CFG_PRE_POSTLUDE
401 dnl -------------------------------------------------
404 AC_DEFUN([_XC_CFG_PRE_POSTLUDE],
406 AC_REQUIRE([_XC_CFG_PRE_PREAMBLE])dnl
407 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_CMD_ECHO])dnl
408 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_CMD_TEST])dnl
409 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_VAR_PATH])dnl
410 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_CMD_EXPR])dnl
411 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_UTIL_SED])dnl
412 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_UTIL_GREP])dnl
413 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_UTIL_TR])dnl
414 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_UTIL_WC])dnl
415 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_UTIL_CAT])dnl
416 AC_REQUIRE([_XC_CFG_PRE_CHECK_PATH_SEPARATOR])dnl
417 IFS=$xc_configure_preamble_prev_IFS
419 xc_configure_preamble_result='yes'
423 dnl XC_CONFIGURE_PREAMBLE
424 dnl -------------------------------------------------
427 dnl This macro emits shell code which does some
428 dnl very basic checks related with the availability
429 dnl of some commands and utilities needed to allow
430 dnl configure script bootstrapping itself when using
431 dnl these to figure out other settings. Also emits
432 dnl code that performs PATH_SEPARATOR auto-detection
433 dnl and sets its value unless it is already set with
434 dnl a non-empty value.
436 dnl These basic checks are intended to be placed and
437 dnl executed as early as possible in the resulting
438 dnl configure script, and as such these must be pure
439 dnl and portable shell code.
441 dnl This macro may be used directly, or indirectly
442 dnl when using other macros that AC_REQUIRE it such
443 dnl as XC_CHECK_PATH_SEPARATOR.
445 dnl Currently the mechanism used to ensure that this
446 dnl macro expands early enough in generated configure
447 dnl script is making it override autoconf and libtool
448 dnl PATH_SEPARATOR check.
450 AC_DEFUN([XC_CONFIGURE_PREAMBLE],
454 AC_BEFORE([$0],[_XC_CFG_PRE_PREAMBLE])dnl
455 AC_BEFORE([$0],[_XC_CFG_PRE_BASIC_CHK_CMD_ECHO])dnl
456 AC_BEFORE([$0],[_XC_CFG_PRE_BASIC_CHK_CMD_TEST])dnl
457 AC_BEFORE([$0],[_XC_CFG_PRE_BASIC_CHK_VAR_PATH])dnl
458 AC_BEFORE([$0],[_XC_CFG_PRE_BASIC_CHK_CMD_EXPR])dnl
459 AC_BEFORE([$0],[_XC_CFG_PRE_BASIC_CHK_UTIL_SED])dnl
460 AC_BEFORE([$0],[_XC_CFG_PRE_BASIC_CHK_UTIL_GREP])dnl
461 AC_BEFORE([$0],[_XC_CFG_PRE_BASIC_CHK_UTIL_TR])dnl
462 AC_BEFORE([$0],[_XC_CFG_PRE_BASIC_CHK_UTIL_WC])dnl
463 AC_BEFORE([$0],[_XC_CFG_PRE_BASIC_CHK_UTIL_CAT])dnl
464 AC_BEFORE([$0],[_XC_CFG_PRE_CHECK_PATH_SEPARATOR])dnl
465 AC_BEFORE([$0],[_XC_CFG_PRE_POSTLUDE])dnl
467 AC_BEFORE([$0],[AC_CHECK_TOOL])dnl
468 AC_BEFORE([$0],[AC_CHECK_PROG])dnl
469 AC_BEFORE([$0],[AC_CHECK_TOOLS])dnl
470 AC_BEFORE([$0],[AC_CHECK_PROGS])dnl
472 AC_BEFORE([$0],[AC_PATH_TOOL])dnl
473 AC_BEFORE([$0],[AC_PATH_PROG])dnl
474 AC_BEFORE([$0],[AC_PATH_PROGS])dnl
476 AC_BEFORE([$0],[AC_PROG_SED])dnl
477 AC_BEFORE([$0],[AC_PROG_GREP])dnl
478 AC_BEFORE([$0],[AC_PROG_LN_S])dnl
479 AC_BEFORE([$0],[AC_PROG_MKDIR_P])dnl
480 AC_BEFORE([$0],[AC_PROG_INSTALL])dnl
481 AC_BEFORE([$0],[AC_PROG_MAKE_SET])dnl
482 AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
484 AC_BEFORE([$0],[LT_INIT])dnl
485 AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl
486 AC_BEFORE([$0],[AC_LIBTOOL_WIN32_DLL])dnl
488 AC_REQUIRE([_XC_CFG_PRE_PREAMBLE])dnl
489 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_CMD_ECHO])dnl
490 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_CMD_TEST])dnl
491 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_VAR_PATH])dnl
492 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_CMD_EXPR])dnl
493 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_UTIL_SED])dnl
494 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_UTIL_GREP])dnl
495 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_UTIL_TR])dnl
496 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_UTIL_WC])dnl
497 AC_REQUIRE([_XC_CFG_PRE_BASIC_CHK_UTIL_CAT])dnl
498 AC_REQUIRE([_XC_CFG_PRE_CHECK_PATH_SEPARATOR])dnl
499 AC_REQUIRE([_XC_CFG_PRE_POSTLUDE])dnl
501 m4_pattern_forbid([^_*XC])dnl
502 m4_define([$0],[])dnl
506 dnl Override autoconf and libtool PATH_SEPARATOR check
507 dnl -------------------------------------------------
508 dnl Macros overriding.
510 dnl This is done to ensure that the same check is
511 dnl used across different autoconf versions and to
512 dnl allow expansion of XC_CONFIGURE_PREAMBLE macro
513 dnl early enough in the generated configure script.
516 dnl Override when using autoconf 2.53 and newer.
519 m4_ifdef([_AS_PATH_SEPARATOR_PREPARE],
521 m4_undefine([_AS_PATH_SEPARATOR_PREPARE])dnl
522 m4_defun([_AS_PATH_SEPARATOR_PREPARE],
524 AC_REQUIRE([XC_CONFIGURE_PREAMBLE])dnl
525 m4_define([$0],[])dnl
530 dnl Override when using autoconf 2.50 to 2.52
533 m4_ifdef([_AC_INIT_PREPARE_FS_SEPARATORS],
535 m4_undefine([_AC_INIT_PREPARE_FS_SEPARATORS])dnl
536 m4_defun([_AC_INIT_PREPARE_FS_SEPARATORS],
538 AC_REQUIRE([XC_CONFIGURE_PREAMBLE])dnl
539 ac_path_separator=$PATH_SEPARATOR
540 m4_define([$0],[])dnl
545 dnl Override when using libtool 1.4.2
548 m4_ifdef([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR],
550 m4_undefine([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl
551 m4_defun([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR],
553 AC_REQUIRE([XC_CONFIGURE_PREAMBLE])dnl
554 lt_cv_sys_path_separator=$PATH_SEPARATOR
555 m4_define([$0],[])dnl
560 dnl XC_CHECK_PATH_SEPARATOR
561 dnl -------------------------------------------------
564 dnl Usage of this macro ensures that generated configure
565 dnl script uses the same PATH_SEPARATOR check irrespective
566 dnl of autoconf or libtool version being used to generate
567 dnl configure script.
569 dnl Emits shell code that computes the path separator
570 dnl and stores the result in 'PATH_SEPARATOR', unless
571 dnl the user has already set it with a non-empty value.
573 dnl This path separator is the symbol used to separate
574 dnl or diferentiate paths inside the 'PATH' environment
577 dnl Non-empty user provided 'PATH_SEPARATOR' always
578 dnl overrides the auto-detected one.
580 dnl Strictly speaking the check is done in two steps. The
581 dnl first, which does the actual check, takes place in
582 dnl XC_CONFIGURE_PREAMBLE macro and happens very early in
583 dnl generated configure script. The second one shows and
584 dnl logs the result of the check into config.log at a later
585 dnl configure stage. Placement of this second stage in
586 dnl generated configure script will be done where first
587 dnl direct or indirect usage of this macro happens.
589 AC_DEFUN([XC_CHECK_PATH_SEPARATOR],
593 AC_BEFORE([$0],[AC_CHECK_TOOL])dnl
594 AC_BEFORE([$0],[AC_CHECK_PROG])dnl
595 AC_BEFORE([$0],[AC_CHECK_TOOLS])dnl
596 AC_BEFORE([$0],[AC_CHECK_PROGS])dnl
598 AC_BEFORE([$0],[AC_PATH_TOOL])dnl
599 AC_BEFORE([$0],[AC_PATH_PROG])dnl
600 AC_BEFORE([$0],[AC_PATH_PROGS])dnl
602 AC_BEFORE([$0],[AC_PROG_SED])dnl
603 AC_BEFORE([$0],[AC_PROG_GREP])dnl
604 AC_BEFORE([$0],[AC_PROG_LN_S])dnl
605 AC_BEFORE([$0],[AC_PROG_MKDIR_P])dnl
606 AC_BEFORE([$0],[AC_PROG_INSTALL])dnl
607 AC_BEFORE([$0],[AC_PROG_MAKE_SET])dnl
608 AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
610 AC_BEFORE([$0],[LT_INIT])dnl
611 AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl
612 AC_BEFORE([$0],[AC_LIBTOOL_WIN32_DLL])dnl
614 AC_REQUIRE([XC_CONFIGURE_PREAMBLE])dnl
617 # Check that 'XC_CONFIGURE_PREAMBLE' has already run.
620 if test -z "$xc_configure_preamble_result"; then
621 AC_MSG_ERROR([xc_configure_preamble_result not set (internal problem)])
625 # Check that 'PATH_SEPARATOR' has already been set.
628 if test -z "$xc_PATH_SEPARATOR"; then
629 AC_MSG_ERROR([xc_PATH_SEPARATOR not set (internal problem)])
631 if test -z "$PATH_SEPARATOR"; then
632 AC_MSG_ERROR([PATH_SEPARATOR not set (internal or config.site problem)])
634 AC_MSG_CHECKING([for path separator])
635 AC_MSG_RESULT([$PATH_SEPARATOR])
636 if test "x$PATH_SEPARATOR" != "x$xc_PATH_SEPARATOR"; then
637 AC_MSG_CHECKING([for initial path separator])
638 AC_MSG_RESULT([$xc_PATH_SEPARATOR])
639 AC_MSG_ERROR([path separator mismatch (internal or config.site problem)])
642 m4_pattern_forbid([^_*XC])dnl
643 m4_define([$0],[])dnl