1 ##### http://autoconf-archive.cryp.to/ac_path_lib.html
5 # Deprecated with the advent of pkg-config.
9 # AC_PATH_LIB(LIBRARY [, MINIMUM-VERSION [, HEADERS [, CONFIG-SCRIPT [, MODULES [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]]]])
13 # Runs a LIBRARY-config script and defines LIBRARY_CFLAGS and
14 # LIBRARY_LIBS, saving you from writing your own macro specific to
19 # $1 = LIBRARY e.g. gtk, ncurses, z, gimpprint
20 # $2 = MINIMUM-VERSION x.y.z format e.g. 4.2.1
21 # Add ' -nocheck' e.g. '4.2.1 -nocheck' to avoid
22 # checking version with library-defined version
23 # numbers (see below) i.e. --version only
24 # $3 = CONFIG-SCRIPT Name of libconfig script if not
26 # $4 = MODULES List of module names to pass to LIBRARY-config.
27 # It is probably best to use only one, to avoid
28 # two version numbers being reported.
29 # $5 = ACTION-IF-FOUND Shell script to run if library is found
30 # $6 = ACTION-IF-NOT-FOUND Shell script to run if library is not found
32 # pkg-config will be used to obtain cflags, libs and version data by
33 # default. You must have a library.pc file installed. Two macros
34 # enable and disable pkgconfig support:
36 # AC_PATH_LIB_PKGCONFIG Enable pkg-config support
37 # AC_PATH_LIB_LIBCONFIG Disable pkg-config support
39 # When pkg-config is enabled, CONFIG_SCRIPT will be ignored.
41 # LIBRARY-config must support `--cflags' and `--libs' args. If
42 # MINIMUM-VERSION is specified, LIBRARY-config should also support
43 # the `--version' arg, and have version information embedded in its
44 # header as detailed below:
48 # #define LIBRARY_MAJOR_VERSION (@LIBRARY_MAJOR_VERSION@)
49 # #define LIBRARY_MINOR_VERSION (@LIBRARY_MINOR_VERSION@)
50 # #define LIBRARY_MICRO_VERSION (@LIBRARY_MICRO_VERSION@)
52 # Version numbers (defined in the library):
54 # extern const unsigned int library_major_version;
55 # extern const unsigned int library_minor_version;
56 # extern const unsigned int library_micro_version;
58 # If a different naming scheme is used, this may be specified with
59 # AC_PATH_LIB_REGISTER (see below). For example:
61 # AC_PATH_LIB_REGISTER([_AC_PATH_LIB_VERSION_PREFIX], [mylib])
63 # If the header to include is not called LIBRARY/LIBRARY.h, an
64 # alternate header may be specified with AC_PATH_LIB_REGISTER. All
65 # changes are reset to the defaults when the macro completes.
67 # If the above are not defined, then use ' -nocheck'.
69 # If the `--with-library-[exec-]prefix' arguments to ./configure are
70 # given, it must also support `--prefix' and `--exec-prefix'. (In
71 # other words, it must be like gtk-config.)
73 # If modules are to be used, LIBRARY-config must support modules.
77 # AC_PATH_LIB(foo, 1.0.0)
79 # would run `foo-config --version' and check that it is at least
82 # If so, the following would then be defined:
84 # FOO_CFLAGS to `foo-config --cflags`
85 # FOO_LIBS to `foo-config --libs`
86 # FOO_VERSION to `foo-config --version`
88 # Based on `AM_PATH_GTK' (gtk.m4) by Owen Taylor, and
89 # `AC_PATH_GENERIC' (ac_path_generic.m4) by Angus Lees. pkg-config
90 # support based on AM_PATH_GTK_2_0 (gtk-2.0.m4) by Owen Taylor.
98 # Copyright (c) 2007 Roger Leigh <roger@whinlatter.uklinux.net>
100 # Copying and distribution of this file, with or without
101 # modification, are permitted in any medium without royalty provided
102 # the copyright notice and this notice are preserved.
104 ## Table of Contents:
107 ## 3. Integrity checks
108 ## 4. Error reporting
112 ## ------------------ ##
113 ## 1. The main macro. ##
114 ## ------------------ ##
117 # AC_PATH_LIB(LIBRARY, MINIMUM-VERSION, HEADER, CONFIG-SCRIPT,
118 # MODULES, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
119 # -----------------------------------------------------------
120 # Check for the presence of libLIBRARY, with a minumum version
123 # If needed, use the libconfig script CONFIG-SCRIPT. If the script
124 # needs extra modules specifying, pass them as MODULES.
126 # Run ACTION-IF-FOUND if the library is present and all tests pass, or
127 # ACTION-IF-NOT-FOUND if it is not present or any tests fail.
128 AC_DEFUN([AC_PATH_LIB],[# check for presence of lib$1
129 dnl We're going to need uppercase, lowercase and user-friendly
130 dnl versions of the string `LIBRARY', and long and cache variants.
131 m4_pushdef([UP], m4_translit([$1], [a-z], [A-Z]))dnl
132 m4_pushdef([DOWN], m4_translit([$1], [A-Z], [a-z]))dnl
133 m4_pushdef([LDOWN], ac_path_lib_[]DOWN)dnl
134 m4_pushdef([CACHE], ac_cv_path_lib_[]DOWN)dnl
135 m4_pushdef([ERRORLOG], error.[]DOWN[]test)dnl
136 _AC_PATH_LIB_INIT([$1], [$3], [$4])
137 _AC_PATH_LIB_CHECK([$1], [$2], [$5])
138 _AC_PATH_LIB_CHECK_TESTS([$2])
139 _AC_PATH_LIB_ERROR_DUMP
140 _AC_PATH_LIB_FINI([$6], [$7])
141 dnl Pop the macros we defined earlier.
144 m4_popdef([LDOWN])dnl
145 m4_popdef([CACHE])dnl
146 m4_popdef([ERRORLOG])dnl
152 ## --------------- ##
153 ## 2. Core macros. ##
154 ## --------------- ##
157 # _AC_PATH_LIB_INIT(LIBRARY, HEADER, CONFIG-SCRIPT)
158 # -----------------------------------------
159 # Initialisation of defaults and options.
160 # Remove error log from previous runs.
161 AC_DEFUN([_AC_PATH_LIB_INIT],
162 [_AC_PATH_LIB_DEFAULTS([$1], [$2], [$3])
165 # Save variables in case check fails.
166 ac_save_[]UP[]_CFLAGS="$UP[]_CFLAGS"
167 ac_save_[]UP[]_LIBS="$UP[]_LIBS"
168 ac_save_[]UP[]_VERSION="$UP[]_VERSION"
172 # _AC_PATH_LIB_DEFAULTS(LIBRARY, HEADER, CONFIG-SCRIPT)
173 # -----------------------------------------------------
174 # Set up default behaviour.
175 AC_DEFUN([_AC_PATH_LIB_DEFAULTS],
176 [dnl Set up pkgconfig as default config script.
177 m4_ifdef([AC_PATH_LIB_USEPKGCONFIG],, [AC_PATH_LIB_PKGCONFIG])
178 dnl Set default header and config script names.
179 LDOWN[]_header="m4_default([$2], [$1/$1.h])"
180 LDOWN[]_config="m4_default([$3], [$1-config])"
181 ifdef([_AC_PATH_LIB_VERSION_PREFIX],,
182 [m4_define([_AC_PATH_LIB_VERSION_PREFIX],
185 ifdef([_AC_PATH_LIB_VERSION_MAJOR],,
186 [m4_define([_AC_PATH_LIB_VERSION_MAJOR],
189 ifdef([_AC_PATH_LIB_VERSION_MINOR],,
190 [m4_define([_AC_PATH_LIB_VERSION_MINOR],
193 ifdef([_AC_PATH_LIB_VERSION_MICRO],,
194 [m4_define([_AC_PATH_LIB_VERSION_MICRO],
197 ifdef([_AC_PATH_LIB_VERSION_SUFFIX],,
198 [m4_define([_AC_PATH_LIB_VERSION_SUFFIX],
201 ifdef([_AC_PATH_LIB_DEFVERSION_PREFIX],,
202 [m4_define([_AC_PATH_LIB_DEFVERSION_PREFIX],
205 ifdef([_AC_PATH_LIB_DEFVERSION_MAJOR],,
206 [m4_define([_AC_PATH_LIB_DEFVERSION_MAJOR],
209 ifdef([_AC_PATH_LIB_DEFVERSION_MINOR],,
210 [m4_define([_AC_PATH_LIB_DEFVERSION_MINOR],
213 ifdef([_AC_PATH_LIB_DEFVERSION_MICRO],,
214 [m4_define([_AC_PATH_LIB_DEFVERSION_MICRO],
217 ifdef([_AC_PATH_LIB_DEFVERSION_SUFFIX],,
218 [m4_define([_AC_PATH_LIB_DEFVERSION_SUFFIX],
221 ])# _AC_PATH_LIB_DEFAULTS
224 # _AC_PATH_LIB_OPTIONS
225 # --------------------
227 AC_DEFUN([_AC_PATH_LIB_OPTIONS],
228 [m4_if(AC_PATH_LIB_USEPKGCONFIG, [true], ,
229 [AC_ARG_WITH(DOWN-prefix,
230 AC_HELP_STRING([--with-DOWN-prefix=PFX],
231 [prefix where UP is installed (optional)]),
232 [LDOWN[]_config_prefix="$withval"],
233 [LDOWN[]_config_prefix=""])dnl
234 AC_ARG_WITH(DOWN-exec-prefix,
235 AC_HELP_STRING([--with-DOWN-exec-prefix=PFX],
236 [exec-prefix where UP is installed (optional)]),
237 [LDOWN[]_config_exec_prefix="$withval"],
238 [LDOWN[]_config_exec_prefix=""])dnl
240 AC_ARG_ENABLE(DOWN[]test,
241 AC_HELP_STRING([--disable-DOWN[]test],
242 [do not try to compile and run a test UP program]),
243 [LDOWN[]_test_enabled="no"],
244 [LDOWN[]_test_enabled="yes"])dnl
245 ])# _AC_PATH_LIB_OPTIONS
248 # _AC_PATH_LIB_CHECK(LIBRARY, MINIMUM-VERSION, MODULES)
249 # -----------------------------------------------------
250 # Obtain library CFLAGS, LIBS and VERSION information. Cache results,
251 # but set avoidcache to no if config program is not available. Break
252 # up available and minumum version into major, minor and micro version
254 AC_DEFUN([_AC_PATH_LIB_CHECK],
256 # Set up LIBRARY-config script parameters
258 [LDOWN[]_config_args="$LDOWN[]_config_args $3"])
259 LDOWN[]_min_version=`echo "$2" | sed -e 's/ -nocheck//'`
260 m4_if([$2], , ,[if test "$LDOWN[]_min_version" = "$2" ; then
261 LDOWN[]_version_test_enabled="yes"
263 m4_if(AC_PATH_LIB_USEPKGCONFIG, [true],
264 [LDOWN[]_config_args="$1 $LDOWN[]_config_args"
266 [ if test x$LDOWN[]_config_exec_prefix != x ; then
267 LDOWN[]_config_args="$LDOWN[]_config_args --exec-prefix=$LDOWN[]_config_exec_prefix"
269 if test x$LDOWN[]_config_prefix != x ; then
270 LDOWN[]_config_args="$LDOWN[]_config_args --prefix=$LDOWN[]_config_prefix"
273 dnl set --version for libconfig or --modversion for pkgconfig
274 m4_if(AC_PATH_LIB_USEPKGCONFIG, [true],
275 [AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
276 if test x$PKG_CONFIG != xno ; then
277 if pkg-config --atleast-pkgconfig-version 0.7 ; then
280 AC_PATH_LIB_ERROR([A new enough version of pkg-config was not found:])
281 AC_PATH_LIB_ERROR([version 0.7 or better required.])
282 AC_PATH_LIB_ERROR([See http://pkgconfig.sourceforge.net])
286 UP[]_CONFIG="$PKG_CONFIG"
287 LDOWN[]_config="pkg-config"
288 m4_pushdef([LIBCONFIG_CFLAGS], [--cflags])
289 m4_pushdef([LIBCONFIG_LIBS], [--libs])
290 m4_pushdef([LIBCONFIG_VERSION], [--modversion])
292 [AC_PATH_PROG(UP[]_CONFIG, $LDOWN[]_config, no)
293 m4_pushdef([LIBCONFIG_CFLAGS], [--cflags])
294 m4_pushdef([LIBCONFIG_LIBS], [--libs])
295 m4_pushdef([LIBCONFIG_VERSION], [--version])
296 if test x$UP[]_CONFIG = xno ; then
297 AC_PATH_LIB_ERROR([The $LDOWN[]_config script installed by UP could not be found.])
298 AC_PATH_LIB_ERROR([If UP was installed in PREFIX, make sure PREFIX/bin is in])
299 AC_PATH_LIB_ERROR([your path, or set the UP[]_CONFIG environment variable to the])
300 AC_PATH_LIB_ERROR([full path to $LDOWN[]_config.])
304 if test x$UP[]_CONFIG = xno ; then
305 LDOWN[]_present_avoidcache="no"
307 LDOWN[]_present_avoidcache="yes"
309 AC_CACHE_CHECK([for UP CFLAGS],
311 [CACHE[]_cflags=`$UP[]_CONFIG $LDOWN[]_config_args LIBCONFIG_CFLAGS`])
312 AC_CACHE_CHECK([for UP LIBS],
314 [CACHE[]_libs=`$UP[]_CONFIG $LDOWN[]_config_args LIBCONFIG_LIBS`])
315 AC_CACHE_CHECK([for UP VERSION],
317 [CACHE[]_version=`$UP[]_CONFIG $LDOWN[]_config_args LIBCONFIG_VERSION`])
318 UP[]_CFLAGS="$CACHE[]_cflags"
319 UP[]_LIBS="$CACHE[]_libs"
320 UP[]_VERSION="$CACHE[]_version"
321 LDOWN[]_config_major_version=`echo "$CACHE[]_version" | \
322 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
323 LDOWN[]_config_minor_version=`echo "$CACHE[]_version" | \
324 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
325 LDOWN[]_config_micro_version=`echo "$CACHE[]_version" | \
326 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
327 LDOWN[]_min_major_version=`echo "$LDOWN[]_min_version" | \
328 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
329 LDOWN[]_min_minor_version=`echo "$LDOWN[]_min_version" | \
330 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
331 LDOWN[]_min_micro_version=`echo "$LDOWN[]_min_version" | \
332 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
334 m4_popdef([LIBCONFIG_CFLAGS])dnl
335 m4_popdef([LIBCONFIG_LIBS])dnl
336 m4_popdef([LIBCONFIG_VERSION])dnl
337 ])# _AC_PATH_LIB_CHECK
340 # _AC_PATH_LIB_FINI(ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
341 # -------------------------------------------------------
342 # Finish: report errors and define/substitute variables. Run any
343 # user-supplied code for success or failure. Restore defaults.
344 AC_DEFUN([_AC_PATH_LIB_FINI],
345 [dnl define variables and run extra code
346 UP[]_CFLAGS="$CACHE[]_cflags"
347 UP[]_LIBS="$CACHE[]_libs"
348 UP[]_VERSION="$CACHE[]_version"
349 AC_SUBST(UP[]_CFLAGS)dnl
350 AC_SUBST(UP[]_LIBS)dnl
351 AC_SUBST(UP[]_VERSION)dnl
352 # Run code which depends upon the test result.
353 if test x$CACHE[]_present = xyes ; then
354 m4_if([$1], , :, [$1])
356 # Restore saved variables if test fails
357 UP[]_CFLAGS="$ac_save_[]UP[]_CFLAGS"
358 UP[]_LIBS="$ac_save_[]UP[]_LIBS"
359 UP[]_VERSION="$ac_save_[]UP[]_VERSION"
360 m4_if([$2], , :, [$2])
363 AC_PATH_LIB_CHECK_REGISTER_DEFAULTS
364 AC_PATH_LIB_PKGCONFIG
365 ])# _AC_PATH_LIB_FINI
370 ## -------------------- ##
371 ## 3. Integrity checks. ##
372 ## -------------------- ##
375 # _AC_PATH_LIB_CHECK_TESTS(MINIMUM-VERSION)
376 # -----------------------------------------
377 # Now check if the installed UP is sufficiently new. (Also sanity
378 # checks the results of DOWN-config to some extent
379 AC_DEFUN([_AC_PATH_LIB_CHECK_TESTS],
380 [AC_CACHE_CHECK([for UP - m4_if([$1], ,
382 [version >= $LDOWN[]_min_version])],
384 [CACHE[]_present="$LDOWN[]_present_avoidcache"
385 if test x$CACHE[]_present = xyes -a x$LDOWN[]_test_enabled = xyes -a \
386 x$LDOWN[]_version_test_enabled = xyes ; then
387 m4_default([_AC_PATH_LIB_CHECK_TEST_COMPILE],
388 [_AC_PATH_LIB_CHECK_TEST_COMPILE],
389 [_AC_PATH_LIB_CHECK_TEST_COMPILE_DEFAULT])
391 m4_default([_AC_PATH_LIB_CHECK_VERSION],
392 [_AC_PATH_LIB_CHECK_VERSION],
393 [_AC_PATH_LIB_CHECK_VERSION_DEFAULT])
394 # If the user allowed it, try linking with the library
395 if test x$LDOWN[]_test_enabled = xyes ; then
396 _AC_PATH_LIB_CHECK_LINK(, [
398 if test x$LDOWN[]_version_test_error = xyes ; then
401 AC_PATH_LIB_ERROR([The test program failed to compile or link. See the file])
402 AC_PATH_LIB_ERROR([config.log for the exact error that occured. This usually])
403 AC_PATH_LIB_ERROR([means UP was not installed, was incorrectly installed])
404 AC_PATH_LIB_ERROR([or that you have moved UP since it was installed. In])
405 AC_PATH_LIB_ERROR([the latter case, you may want to edit the $LDOWN[]_config])
406 AC_PATH_LIB_ERROR([script: $UP[]_CONFIG])
411 ])# _AC_PATH_LIB_CHECK_TESTS
414 # _AC_PATH_LIB_CHECK_TEST_COMPILE_DEFAULT
415 # ---------------------------------------
416 # Check if the installed UP is sufficiently new. (Also sanity checks
417 # the results of DOWN-config to some extent. The test program must
418 # compile, link and run sucessfully
419 AC_DEFUN([_AC_PATH_LIB_CHECK_TEST_COMPILE],
420 [m4_pushdef([RUNLOG], run.[]DOWN[]test)dnl
421 m4_pushdef([MAJOR], _AC_PATH_LIB_VERSION_PREFIX[]_AC_PATH_LIB_VERSION_MAJOR[]_AC_PATH_LIB_VERSION_SUFFIX)dnl
422 m4_pushdef([MINOR], _AC_PATH_LIB_VERSION_PREFIX[]_AC_PATH_LIB_VERSION_MINOR[]_AC_PATH_LIB_VERSION_SUFFIX)dnl
423 m4_pushdef([MICRO], _AC_PATH_LIB_VERSION_PREFIX[]_AC_PATH_LIB_VERSION_MICRO[]_AC_PATH_LIB_VERSION_SUFFIX)dnl
424 m4_pushdef([DEFMAJOR], _AC_PATH_LIB_DEFVERSION_PREFIX[]_AC_PATH_LIB_DEFVERSION_MAJOR[]_AC_PATH_LIB_DEFVERSION_SUFFIX)dnl
425 m4_pushdef([DEFMINOR], _AC_PATH_LIB_DEFVERSION_PREFIX[]_AC_PATH_LIB_DEFVERSION_MINOR[]_AC_PATH_LIB_DEFVERSION_SUFFIX)dnl
426 m4_pushdef([DEFMICRO], _AC_PATH_LIB_DEFVERSION_PREFIX[]_AC_PATH_LIB_DEFVERSION_MICRO[]_AC_PATH_LIB_DEFVERSION_SUFFIX)dnl
427 ac_save_CFLAGS="$CFLAGS"
429 CFLAGS="$CFLAGS $UP[]_CFLAGS"
430 LIBS="$UP[]_LIBS $LIBS"
433 #include <$]LDOWN[_header>
438 * XXX FIXME Francesco:
439 * This is a pigsty patch for undefined strdup (defined in string.h).
440 * Maybe we should look for strdup() or wrapping it using functions
441 * like malloc && strcpy().
448 int major, minor, micro;
452 if ((errorlog = fopen("]ERRORLOG[", "w")) == NULL) {
456 system ("touch ]RUNLOG[");
458 /* HP/UX 9 (%@#!) writes to sscanf strings */
459 tmp_version = strdup("$]LDOWN[_min_version");
463 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
464 fprintf(errorlog, "*** %s: bad version string\n", "$]LDOWN[_min_version");
468 if ((]MAJOR[ != $]LDOWN[_config_major_version) ||
469 (]MINOR[ != $]LDOWN[_config_minor_version) ||
470 (]MICRO[ != $]LDOWN[_config_micro_version))
472 fprintf(errorlog, "*** '$]UP[_CONFIG ]LIBCONFIG_VERSION[' returned %d.%d.%d, but \n", \
473 $]LDOWN[_config_major_version, $]LDOWN[_config_minor_version, \
474 $]LDOWN[_config_micro_version);
475 fprintf(errorlog, "*** ]UP[ (%d.%d.%d) was found!\n", \
476 ]MAJOR[, ]MINOR[, ]MICRO[);
477 fprintf(errorlog, "***\n");
478 fprintf(errorlog, "*** If $]LDOWN[_config was correct, then it is best to remove\n");
479 fprintf(errorlog, "*** the old version of ]UP[. You may also be able to\n");
480 fprintf(errorlog, "*** fix the error by modifying your LD_LIBRARY_PATH enviroment\n");
481 fprintf(errorlog, "*** variable, or by editing /etc/ld.so.conf. Make sure you have\n");
482 fprintf(errorlog, "*** run ldconfig if that is required on your system.\n");
483 fprintf(errorlog, "*** If $]LDOWN[_config was wrong, set the environment\n");
484 fprintf(errorlog, "*** variable ]UP[_CONFIG to point to the correct copy of\n");
485 fprintf(errorlog, "*** $]LDOWN[_config, and remove the file config.cache\n");
486 fprintf(errorlog, "*** before re-running configure.\n");
488 #if defined (]DEFMAJOR[) && defined (]DEFMINOR[) && defined (]DEFMICRO[)
489 else if ((]MAJOR[ != ]DEFMAJOR[) ||
490 (]MINOR[ != ]DEFMINOR[) ||
491 (]MICRO[ != ]DEFMICRO[))
493 fprintf(errorlog, "*** ]UP[ header files (version %d.%d.%d) do not match\n",
494 ]DEFMAJOR[, ]DEFMINOR[, ]DEFMICRO[);
495 fprintf(errorlog, "*** library (version %d.%d.%d)\n",
496 ]MAJOR[, ]MINOR[, ]MICRO[);
498 #endif /* defined (]DEFMAJOR[) ... */
501 if ((]MAJOR[ > major) ||
502 ((]MAJOR[ == major) && (]MINOR[ > minor)) ||
503 ((]MAJOR[ == major) && (]MINOR[ == minor) && (]MICRO[ >= micro)))
509 fprintf(errorlog, "*** An old version of ]UP[ (%d.%d.%d) was found.\n",
510 ]MAJOR[, ]MINOR[, ]MICRO[);
511 fprintf(errorlog, "*** You need a version of ]UP[ newer than %d.%d.%d.\n",
512 major, minor, micro);
513 /*fprintf(errorlog, "*** The latest version of ]UP[ is always available from ftp://ftp.my.site\n");*/
514 fprintf(errorlog, "***\n");
515 fprintf(errorlog, "*** If you have already installed a sufficiently new version, this\n");
516 fprintf(errorlog, "*** error probably means that the wrong copy of the $]LDOWN[_config\n");
517 fprintf(errorlog, "*** shell script is being found. The easiest way to fix this is to\n");
518 fprintf(errorlog, "*** remove the old version of ]UP[, but you can also set the\n");
519 fprintf(errorlog, "*** ]UP[_CONFIG environment variable to point to the correct\n");
520 fprintf(errorlog, "*** copy of $]LDOWN[_config. (In this case, you will have to\n");
521 fprintf(errorlog, "*** modify your LD_LIBRARY_PATH environment variable, or edit\n");
522 fprintf(errorlog, "*** /etc/ld.so.conf so that the correct libraries are found at\n");
523 fprintf(errorlog, "*** run-time.)\n");
528 ],, [CACHE[]_present="no"],
529 [AC_PATH_LIB_ERROR([cross compiling; assumed OK.])])
530 CFLAGS="$ac_save_CFLAGS"
533 if test -f RUNLOG ; then
535 elif test x$LDOWN[]_version_test_enabled = xyes ; then
536 AC_PATH_LIB_ERROR([Could not run UP test program, checking why...])
538 _AC_PATH_LIB_CHECK_LINK(dnl
539 [AC_PATH_LIB_ERROR([The test program compiled, but did not run. This usually])
540 AC_PATH_LIB_ERROR([means that the run-time linker is not finding UP or])
541 AC_PATH_LIB_ERROR([finding the wrong version of UP. If it is not finding])
542 AC_PATH_LIB_ERROR([UP, you will need to set your LD_LIBRARY_PATH environment])
543 AC_PATH_LIB_ERROR([variable, or edit /etc/ld.so.conf to point to the installed])
544 AC_PATH_LIB_ERROR([location. Also, make sure you have run ldconfig if that is])
545 AC_PATH_LIB_ERROR([required on your system.])
547 AC_PATH_LIB_ERROR([If you have an old version installed, it is best to remove])
548 AC_PATH_LIB_ERROR([it, although you may also be able to get things to work by])
549 AC_PATH_LIB_ERROR([modifying LD_LIBRARY_PATH])
551 [AC_PATH_LIB_ERROR([The test program failed to compile or link. See the file])
552 AC_PATH_LIB_ERROR([config.log for the exact error that occured. This usually])
553 AC_PATH_LIB_ERROR([means UP was incorrectly installed or that you have])
554 AC_PATH_LIB_ERROR([moved UP since it was installed. In the latter case,])
555 AC_PATH_LIB_ERROR([you may want to edit the $LDOWN[]_config script:])
556 AC_PATH_LIB_ERROR([$UP[]_CONFIG])
560 m4_popdef([RUNLOG])dnl
561 m4_popdef([MAJOR])dnl
562 m4_popdef([MINOR])dnl
563 m4_popdef([MICRO])dnl
564 m4_popdef([DEFMAJOR])dnl
565 m4_popdef([DEFMINOR])dnl
566 m4_popdef([DEFMICRO])dnl
567 ])# _AC_PATH_LIB_CHECK_TEST_COMPILE_DEFAULT
570 # _AC_PATH_LIB_CHECK_VERSION_DEFAULT
571 # ----------------------------------
572 # Check that the library version (config) is greater than or equal to
573 # the requested (minimum) version.
574 AC_DEFUN([_AC_PATH_LIB_CHECK_VERSION],
576 [if test x$LDOWN[]_present_avoidcache = xyes ; then
578 "$LDOWN[]_config_major_version" -lt "$LDOWN[]_min_major_version" -o \
579 "$LDOWN[]_config_major_version" -eq "$LDOWN[]_min_major_version" -a \
580 "$LDOWN[]_config_minor_version" -lt "$LDOWN[]_min_minor_version" -o \
581 "$LDOWN[]_config_major_version" -eq "$LDOWN[]_min_major_version" -a \
582 "$LDOWN[]_config_minor_version" -eq "$LDOWN[]_min_minor_version" -a \
583 "$LDOWN[]_config_micro_version" -lt "$LDOWN[]_min_micro_version" ; then
585 LDOWN[]_version_test_error="yes"
586 AC_PATH_LIB_ERROR([$UP[]_CONFIG --version' returned $LDOWN[]_config_major_version.$LDOWN[]_config_minor_version.$LDOWN[]_config_micro_version, but])
587 AC_PATH_LIB_ERROR([UP (>= $LDOWN[]_min_version) was needed.])
589 AC_PATH_LIB_ERROR([If $]LDOWN[_config was wrong, set the environment])
590 AC_PATH_LIB_ERROR([variable ]UP[_CONFIG to point to the correct copy of])
591 AC_PATH_LIB_ERROR([$]LDOWN[_config, and remove the file config.cache])
592 AC_PATH_LIB_ERROR([before re-running configure.])
594 CACHE[]_present="yes"
597 ])# _AC_PATH_LIB_CHECK_VERSION_DEFAULT
600 # _AC_PATH_LIB_CHECK_LINK_DEFAULT(SUCCESS, FAIL)
601 # ----------------------------------------------
602 # Check if the library will link successfully. If specified, run
603 # SUCCESS or FAIL on success or failure
604 AC_DEFUN([_AC_PATH_LIB_CHECK_LINK],
605 [ac_save_CFLAGS="$CFLAGS"
607 CFLAGS="$CFLAGS $UP[]_CFLAGS"
608 LIBS="$LIBS $UP[]_LIBS"
609 AC_TRY_LINK([ #include <stdio.h> ], ,
610 [m4_if([$1], , :, [$1])],
611 [m4_if([$2], , :, [$2])])
612 CFLAGS="$ac_save_CFLAGS"
614 ])# _AC_PATH_LIB_CHECK_LINK_DEFAULT
619 ## ------------------- ##
620 ## 4. Error reporting. ##
621 ## ------------------- ##
624 # AC_PATH_LIB_ERROR(MESSAGE)
625 # --------------------------
626 # Print an error message, MESSAGE, to the error log.
627 AC_DEFUN([AC_PATH_LIB_ERROR],
628 [echo '*** m4_if([$1], , , [$1])' >>ERRORLOG])
631 # _AC_PATH_LIB_ERROR_DUMP
632 # -----------------------
633 # Print the error log (after main AC_CACHE_CHECK completes).
634 AC_DEFUN([_AC_PATH_LIB_ERROR_DUMP],
635 [if test -f ERRORLOG ; then
643 ## ------------------ ##
644 ## 5. Feature macros. ##
645 ## ------------------ ##
648 # AC_PATH_LIB_PKGCONFIG
649 # ---------------------
650 # Enable pkgconfig support in libconfig script (default).
651 AC_DEFUN([AC_PATH_LIB_PKGCONFIG],
652 [m4_define([AC_PATH_LIB_USEPKGCONFIG], [true])
656 # AC_PATH_LIB_LIBCONFIG
657 # ---------------------
658 # Disable pkgconfig support in libconfig script.
659 AC_DEFUN([AC_PATH_LIB_LIBCONFIG],
660 [m4_define([AC_PATH_LIB_USEPKGCONFIG], [false])
664 # AC_PATH_LIB_REGISTER (MACRO, REPLACEMENT)
665 # -----------------------------------------
666 # Register a macro to replace the default checks. Use the REPLACEMENT
667 # macro for the check macro MACRO.
669 # Possible MACROs are:
670 # _AC_PATH_LIB_CHECK_COMPILE and
671 # _AC_PATH_LIB_CHECK_VERSION
672 # You should make sure that replacement macros use the same arguments
673 # (if any), and do error logging in the same manner and behave in the
674 # same way as the original.
676 # Non-default header names may be specified, as well as version
677 # variable names in the library itself (needed for
678 # _AC_PATH_LIB_CHECK_COMPILE):
679 # _AC_PATH_LIB_HEADER
680 # _AC_PATH_LIB_VERSION_PREFIX (default library_)
681 # _AC_PATH_LIB_VERSION_MAJOR (default major)
682 # _AC_PATH_LIB_VERSION_MINOR (default minor)
683 # _AC_PATH_LIB_VERSION_MICRO (default micro)
684 # _AC_PATH_LIB_VERSION_SUFFIX (default _version)
685 # _AC_PATH_LIB_DEFVERSION_PREFIX (default LIBRARY_)
686 # _AC_PATH_LIB_DEFVERSION_MAJOR (default MAJOR)
687 # _AC_PATH_LIB_DEFVERSION_MINOR (default MINOR)
688 # _AC_PATH_LIB_DEFVERSION_MICRO (default MICRO)
689 # _AC_PATH_LIB_DEFVERSION_SUFFIX (default _VERSION)
690 # For example, library_major_version.
691 AC_DEFUN([AC_PATH_LIB_REGISTER],
692 [m4_define([$1], [$2])])
695 # AC_PATH_LIB_CHECK_REGISTER_DEFAULTS
696 # -----------------------------------
697 # Restore the default check macros.
698 AC_DEFUN([AC_PATH_LIB_CHECK_REGISTER_DEFAULTS],
699 [_AC_PATH_LIB_CHECK_REGISTER_DEFAULTS([_AC_PATH_LIB_CHECK_COMPILE],
700 [_AC_PATH_LIB_CHECK_VERSION],
701 [_AC_PATH_LIB_HEADER],
702 [_AC_PATH_LIB_VERSION_PREFIX],
703 [_AC_PATH_LIB_VERSION_MAJOR],
704 [_AC_PATH_LIB_VERSION_MINOR],
705 [_AC_PATH_LIB_VERSION_MICRO],
706 [_AC_PATH_LIB_VERSION_SUFFIX],
707 [_AC_PATH_LIB_DEFVERSION_PREFIX],
708 [_AC_PATH_LIB_DEFVERSION_MAJOR],
709 [_AC_PATH_LIB_DEFVERSION_MINOR],
710 [_AC_PATH_LIB_DEFVERSION_MICRO],
711 [_AC_PATH_LIB_DEFVERSION_SUFFIX])
712 ])# AC_PATH_LIB_CHECK_REGISTER_DEFAULTS
715 # _AC_PATH_LIB_CHECK_REGISTER_DEFAULTS(MACROs ...)
716 # ------------------------------------------------
718 AC_DEFUN([AC_PATH_LIB_CHECK_REGISTER_DEFAULTS],
722 AC_PATH_LIB_CHECK_REGISTER_DEFAULTS(m4_shift($@))