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.
31 dnl _XC_CONFIGURE_PREAMBLE_COMMENT
32 dnl -------------------------------------------------
35 AC_DEFUN([_XC_CONFIGURE_PREAMBLE_COMMENT],
37 ## ---------------------------- ##
38 ## XC_CONFIGURE_PREAMBLE rev: 1 ##
39 ## ---------------------------- ##
43 dnl _XC_CHECK_COMMAND_TEST
44 dnl -------------------------------------------------
47 dnl Check that 'test' command is available, else abort.
49 AC_DEFUN([_XC_CHECK_COMMAND_TEST],
52 # Require that 'test' command is available.
56 test -n "$xc_tst_str" && xc_tst_str='success'
57 case "x$xc_tst_str" in
62 echo "configure: error: 'test' command not found. Can not continue."
70 dnl -------------------------------------------------
73 dnl Check that PATH is set, otherwise abort.
75 AC_DEFUN([_XC_CHECK_PATH],
77 AC_REQUIRE([_XC_CHECK_COMMAND_TEST])dnl
79 # Require that PATH variable is set.
83 test -n "$PATH" && xc_tst_str='success'
84 case "x$xc_tst_str" in
89 echo "configure: error: PATH variable not set. Can not continue."
96 dnl _XC_CHECK_COMMAND_EXPR
97 dnl -------------------------------------------------
100 dnl Check that 'expr' command is available, else abort.
102 AC_DEFUN([_XC_CHECK_COMMAND_EXPR],
105 # Require that 'expr' command is available.
109 xc_tst_str=`expr "$xc_tst_str" : '.*'`
110 case "x$xc_tst_str" in
115 echo "configure: error: 'expr' command not found. Can not continue."
122 dnl _XC_CHECK_UTILITY_SED
123 dnl -------------------------------------------------
126 dnl Check that 'sed' utility is found within PATH. This
127 dnl 'sed' is required in order to allow configure script
128 dnl bootstrapping itself. No fancy testing for a proper
129 dnl 'sed' this early please, that should be done later.
131 AC_DEFUN([_XC_CHECK_UTILITY_SED],
134 # Require that 'sed' utility is found within PATH.
138 xc_tst_str=`echo "$xc_tst_str" | sed -e 's:unknown:success:'`
139 case "x$xc_tst_str" in
144 echo "configure: error: 'sed' utility not in PATH. Can not continue."
151 dnl _XC_CHECK_UTILITY_GREP
152 dnl -------------------------------------------------
155 dnl Check that 'grep' utility is found within PATH. This
156 dnl 'grep' is required in order to allow configure script
157 dnl bootstrapping itself. No fancy testing for a proper
158 dnl 'grep' this early please, that should be done later.
160 AC_DEFUN([_XC_CHECK_UTILITY_GREP],
163 # Require that 'grep' utility is found within PATH.
167 echo "$xc_tst_str" | grep 'unknown' >/dev/null 2>&1 && xc_tst_str='success'
168 case "x$xc_tst_str" in
173 echo "configure: error: 'grep' utility not in PATH. Can not continue."
180 dnl _XC_CHECK_PATH_SEPARATOR
181 dnl -------------------------------------------------
184 dnl Check and compute the path separator for us. This
185 dnl path separator is the symbol used to diferentiate
186 dnl or separate paths inside the PATH environment var.
188 dnl User provided PATH_SEPARATOR always overrides the
189 dnl auto-detected one.
191 AC_DEFUN([_XC_CHECK_PATH_SEPARATOR],
193 AC_REQUIRE([_XC_CHECK_COMMAND_TEST])dnl
194 AC_REQUIRE([_XC_CHECK_PATH])dnl
195 AC_REQUIRE([_XC_CHECK_COMMAND_EXPR])dnl
197 # Auto-detect and set PATH_SEPARATOR, unless it is already set.
200 # Directory count in PATH when using a colon separator.
202 xc_tst_prev_IFS=$IFS; IFS=':'
203 for xc_tst_dir in $PATH; do
205 test -d "$xc_tst_dir" && xc_tst_dirs_col=`expr $xc_tst_dirs_col + 1`
209 # Directory count in PATH when using a semicolon separator.
211 xc_tst_prev_IFS=$IFS; IFS=';'
212 for xc_tst_dir in $PATH; do
214 test -d "$xc_tst_dir" && xc_tst_dirs_sem=`expr $xc_tst_dirs_sem + 1`
218 if test $xc_tst_dirs_sem -eq $xc_tst_dirs_col; then
219 # When both counting methods give the same result we do not want to
220 # chose one over the other, and consider auto-detection not possible.
221 if test -z "$PATH_SEPARATOR"; then
222 # Stop dead until user provides PATH_SEPARATOR definition.
223 echo "configure: error: PATH_SEPARATOR variable not set. Can not continue."
227 # Separator with the greater directory count is the auto-detected one.
228 if test $xc_tst_dirs_sem -gt $xc_tst_dirs_col; then
229 xc_tst_auto_separator=';'
231 xc_tst_auto_separator=':'
233 if test -z "$PATH_SEPARATOR"; then
234 # Simply use the auto-detected one when not already set.
235 PATH_SEPARATOR="$xc_tst_auto_separator"
236 elif "x$PATH_SEPARATOR" != "x$xc_tst_auto_separator"; then
237 echo "configure: warning: PATH_SEPARATOR does not match auto-detected one."
240 AC_SUBST([PATH_SEPARATOR])dnl
244 dnl _XC_CONFIGURE_PREAMBLE
245 dnl -------------------------------------------------
248 AC_DEFUN([_XC_CONFIGURE_PREAMBLE],
250 AC_REQUIRE([_XC_CONFIGURE_PREAMBLE_COMMENT])dnl
251 AC_REQUIRE([_XC_CHECK_COMMAND_TEST])dnl
252 AC_REQUIRE([_XC_CHECK_PATH])dnl
253 AC_REQUIRE([_XC_CHECK_COMMAND_EXPR])dnl
254 AC_REQUIRE([_XC_CHECK_UTILITY_SED])dnl
255 AC_REQUIRE([_XC_CHECK_UTILITY_GREP])dnl
256 AC_REQUIRE([_XC_CHECK_PATH_SEPARATOR])dnl
257 echo "checking whether some basic commands and utilities are available... yes"
261 dnl XC_CONFIGURE_PREAMBLE
262 dnl -------------------------------------------------
265 dnl This macro macro emits shell code which does some
266 dnl very basic checks related with the availability
267 dnl of some commands and utilities needed to allow
268 dnl configure script bootstrapping itself when using
269 dnl these to figure out other settings. Also performs
270 dnl PATH_SEPARATOR auto-detection and sets its value
271 dnl unless it is already set.
273 dnl These basic checks are intended to be placed and
274 dnl executed as early as possible in the resulting
275 dnl configure script, and as such these must be pure
278 dnl Although this is a public macro it should not be
279 dnl used directly from configure.ac given that in this
280 dnl way its expansion is not placed early enough in
281 dnl generated configure script, it simply makes little
282 dnl sense to perform these basic checks once the script
283 dnl is into more serious business.
285 dnl The proper way of making this macro expand early
286 dnl enough in configure script is using XC_OVR_ZZ40
287 dnl in configure.ac which takes care of everything.
289 AC_DEFUN([XC_CONFIGURE_PREAMBLE],
292 AC_BEFORE([$0],[_XC_CONFIGURE_PREAMBLE])dnl
293 AC_BEFORE([$0],[_XC_CHECK_COMMAND_TEST])dnl
294 AC_BEFORE([$0],[_XC_CHECK_PATH])dnl
295 AC_BEFORE([$0],[_XC_CHECK_COMMAND_EXPR])dnl
296 AC_BEFORE([$0],[_XC_CHECK_UTILITY_SED])dnl
297 AC_BEFORE([$0],[_XC_CHECK_UTILITY_GREP])dnl
298 AC_BEFORE([$0],[_XC_CHECK_PATH_SEPARATOR])dnl
299 AC_REQUIRE([_XC_CONFIGURE_PREAMBLE])dnl
300 m4_define([$0],[])dnl
304 dnl Override autoconf's PATH_SEPARATOR check
305 dnl -------------------------------------------------
306 dnl This is done to ensure that the same check is
307 dnl used across different autoconf versions and to
308 dnl allow us to expand XC_CONFIGURE_PREAMBLE macro
309 dnl early enough in the generated configure script.
312 dnl Override when using autoconf 2.53 and newer.
315 m4_defun([_AS_PATH_SEPARATOR_PREPARE],
317 AC_REQUIRE([XC_CONFIGURE_PREAMBLE])dnl
318 m4_define([$0],[])dnl
322 dnl Override when using autoconf 2.50 to 2.52
325 m4_defun([_AC_INIT_PREPARE_FS_SEPARATORS],
327 AC_REQUIRE([XC_CONFIGURE_PREAMBLE])dnl
328 ac_path_separator=$PATH_SEPARATOR
329 m4_define([$0],[])dnl
333 dnl Override when using libtool 1.4.2
336 m4_defun([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR],
338 AC_REQUIRE([XC_CONFIGURE_PREAMBLE])dnl
339 lt_cv_sys_path_separator=$PATH_SEPARATOR
340 m4_define([$0],[])dnl
345 dnl -------------------------------------------------
346 dnl Placing a call to this macro in configure.ac will
347 dnl make macros in this file visible to other macros
348 dnl used for same configure script, overriding those
349 dnl provided elsewhere.
351 dnl This is the proper and intended way in which macro
352 dnl XC_CONFIGURE_PREAMBLE will expand early enough in
353 dnl generated configure script.
355 AC_DEFUN([XC_OVR_ZZ40],
357 AC_BEFORE([$0],[AC_CHECK_TOOL])dnl
358 AC_BEFORE([$0],[AC_CHECK_PROG])dnl
359 AC_BEFORE([$0],[AC_CHECK_TOOLS])dnl
360 AC_BEFORE([$0],[AC_CHECK_PROGS])dnl
362 AC_BEFORE([$0],[AC_PATH_TOOL])dnl
363 AC_BEFORE([$0],[AC_PATH_PROG])dnl
364 AC_BEFORE([$0],[AC_PATH_PROGS])dnl
366 AC_BEFORE([$0],[AC_PROG_SED])dnl
367 AC_BEFORE([$0],[AC_PROG_GREP])dnl
368 AC_BEFORE([$0],[AC_PROG_LN_S])dnl
369 AC_BEFORE([$0],[AC_PROG_INSTALL])dnl
370 AC_BEFORE([$0],[AC_PROG_MAKE_SET])dnl
371 AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
373 AC_BEFORE([$0],[LT_INIT])dnl
374 AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl
375 AC_BEFORE([$0],[AC_LIBTOOL_WIN32_DLL])dnl
377 AC_BEFORE([$0],[AC_CONFIG_SRCDIR])dnl
378 AC_BEFORE([$0],[AC_CONFIG_HEADERS])dnl
379 AC_BEFORE([$0],[AC_CONFIG_MACRO_DIR])dnl
380 AC_BEFORE([$0],[AC_CONFIG_MACRO_DIRS])dnl
382 m4_define([$0],[])dnl