📄 acinclude.m4
字号:
[m4_define([_AC_PATH_LIB_DEFVERSION_MICRO], [MICRO]) ])ifdef([_AC_PATH_LIB_DEFVERSION_SUFFIX],, [m4_define([_AC_PATH_LIB_DEFVERSION_SUFFIX], [_VERSION]) ])])# _AC_PATH_LIB_DEFAULTS# _AC_PATH_LIB_OPTIONS# --------------------# configure options.AC_DEFUN([_AC_PATH_LIB_OPTIONS],[m4_if(AC_PATH_LIB_USEPKGCONFIG, [true], ,[AC_ARG_WITH(DOWN-prefix, AC_HELP_STRING([--with-DOWN-prefix=PFX], [prefix where UP is installed (optional)]), [LDOWN[]_config_prefix="$withval"], [LDOWN[]_config_prefix=""])dnlAC_ARG_WITH(DOWN-exec-prefix, AC_HELP_STRING([--with-DOWN-exec-prefix=PFX], [exec-prefix where UP is installed (optional)]), [LDOWN[]_config_exec_prefix="$withval"], [LDOWN[]_config_exec_prefix=""])dnl])AC_ARG_ENABLE(DOWN[]test, AC_HELP_STRING([--disable-DOWN[]test], [do not try to compile and run a test UP program]), [LDOWN[]_test_enabled="no"], [LDOWN[]_test_enabled="yes"])dnl])# _AC_PATH_LIB_OPTIONS# _AC_PATH_LIB_CHECK(LIBRARY, MINIMUM-VERSION, MODULES)# -----------------------------------------------------# Obtain library CFLAGS, LIBS and VERSION information. Cache results,# but set avoidcache to no if config program is not available. Break# up available and minumum version into major, minor and micro version# numbers.AC_DEFUN([_AC_PATH_LIB_CHECK],[# Set up LIBRARY-config script parametersm4_if([$3], , , [LDOWN[]_config_args="$LDOWN[]_config_args $3"])LDOWN[]_min_version=`echo "$2" | sed -e 's/ -nocheck//'`m4_if([$2], , ,[if test "$LDOWN[]_min_version" = "$2" ; then LDOWN[]_version_test_enabled="yes" fi])m4_if(AC_PATH_LIB_USEPKGCONFIG, [true],[LDOWN[]_config_args="$1 $LDOWN[]_config_args"],[ if test x$LDOWN[]_config_exec_prefix != x ; then LDOWN[]_config_args="$LDOWN[]_config_args --exec-prefix=$LDOWN[]_config_exec_prefix" fi if test x$LDOWN[]_config_prefix != x ; then LDOWN[]_config_args="$LDOWN[]_config_args --prefix=$LDOWN[]_config_prefix" fi])dnl set --version for libconfig or --modversion for pkgconfigm4_if(AC_PATH_LIB_USEPKGCONFIG, [true], [AC_PATH_PROG(PKG_CONFIG, pkg-config, no) if test x$PKG_CONFIG != xno ; then if pkg-config --atleast-pkgconfig-version 0.7 ; then : else AC_PATH_LIB_ERROR([A new enough version of pkg-config was not found:]) AC_PATH_LIB_ERROR([version 0.7 or better required.]) AC_PATH_LIB_ERROR([See http://pkgconfig.sourceforge.net]) PKG_CONFIG=no fi fi UP[]_CONFIG="$PKG_CONFIG" LDOWN[]_config="pkg-config" m4_pushdef([LIBCONFIG_CFLAGS], [--cflags]) m4_pushdef([LIBCONFIG_LIBS], [--libs]) m4_pushdef([LIBCONFIG_VERSION], [--modversion]) ], [AC_PATH_PROG(UP[]_CONFIG, $LDOWN[]_config, no) m4_pushdef([LIBCONFIG_CFLAGS], [--cflags]) m4_pushdef([LIBCONFIG_LIBS], [--libs]) m4_pushdef([LIBCONFIG_VERSION], [--version]) if test x$UP[]_CONFIG = xno ; then AC_PATH_LIB_ERROR([The $LDOWN[]_config script installed by UP could not be found.]) AC_PATH_LIB_ERROR([If UP was installed in PREFIX, make sure PREFIX/bin is in]) AC_PATH_LIB_ERROR([your path, or set the UP[]_CONFIG environment variable to the]) AC_PATH_LIB_ERROR([full path to $LDOWN[]_config.]) fi ])if test x$UP[]_CONFIG = xno ; then LDOWN[]_present_avoidcache="no"else LDOWN[]_present_avoidcache="yes" AC_CACHE_CHECK([for UP CFLAGS], [CACHE[]_cflags], [CACHE[]_cflags=`$UP[]_CONFIG $LDOWN[]_config_args LIBCONFIG_CFLAGS`]) AC_CACHE_CHECK([for UP LIBS], [CACHE[]_libs], [CACHE[]_libs=`$UP[]_CONFIG $LDOWN[]_config_args LIBCONFIG_LIBS`]) AC_CACHE_CHECK([for UP VERSION], [CACHE[]_version], [CACHE[]_version=`$UP[]_CONFIG $LDOWN[]_config_args LIBCONFIG_VERSION`]) UP[]_CFLAGS="$CACHE[]_cflags" UP[]_LIBS="$CACHE[]_libs" UP[]_VERSION="$CACHE[]_version" LDOWN[]_config_major_version=`echo "$CACHE[]_version" | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` LDOWN[]_config_minor_version=`echo "$CACHE[]_version" | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` LDOWN[]_config_micro_version=`echo "$CACHE[]_version" | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` LDOWN[]_min_major_version=`echo "$LDOWN[]_min_version" | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` LDOWN[]_min_minor_version=`echo "$LDOWN[]_min_version" | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` LDOWN[]_min_micro_version=`echo "$LDOWN[]_min_version" | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`fim4_popdef([LIBCONFIG_CFLAGS])dnlm4_popdef([LIBCONFIG_LIBS])dnlm4_popdef([LIBCONFIG_VERSION])dnl])# _AC_PATH_LIB_CHECK# _AC_PATH_LIB_FINI(ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)# -------------------------------------------------------# Finish: report errors and define/substitute variables. Run any# user-supplied code for success or failure. Restore defaults.AC_DEFUN([_AC_PATH_LIB_FINI],[dnl define variables and run extra codeUP[]_CFLAGS="$CACHE[]_cflags"UP[]_LIBS="$CACHE[]_libs"UP[]_VERSION="$CACHE[]_version"AC_SUBST(UP[]_CFLAGS)dnlAC_SUBST(UP[]_LIBS)dnlAC_SUBST(UP[]_VERSION)dnl# Run code which depends upon the test result.if test x$CACHE[]_present = xyes ; then m4_if([$1], , :, [$1])else# Restore saved variables if test fails UP[]_CFLAGS="$ac_save_[]UP[]_CFLAGS" UP[]_LIBS="$ac_save_[]UP[]_LIBS" UP[]_VERSION="$ac_save_[]UP[]_VERSION" m4_if([$2], , :, [$2])fidnl Restore defaultsAC_PATH_LIB_CHECK_REGISTER_DEFAULTSAC_PATH_LIB_PKGCONFIG])# _AC_PATH_LIB_FINI## -------------------- #### 3. Integrity checks. #### -------------------- ### _AC_PATH_LIB_CHECK_TESTS(MINIMUM-VERSION)# -----------------------------------------# Now check if the installed UP is sufficiently new. (Also sanity# checks the results of DOWN-config to some extentAC_DEFUN([_AC_PATH_LIB_CHECK_TESTS],[AC_CACHE_CHECK([for UP - m4_if([$1], , [any version], [version >= $LDOWN[]_min_version])], [CACHE[]_present],[CACHE[]_present="$LDOWN[]_present_avoidcache"if test x$CACHE[]_present = xyes -a x$LDOWN[]_test_enabled = xyes -a \ x$LDOWN[]_version_test_enabled = xyes ; then m4_default([_AC_PATH_LIB_CHECK_TEST_COMPILE], [_AC_PATH_LIB_CHECK_TEST_COMPILE], [_AC_PATH_LIB_CHECK_TEST_COMPILE_DEFAULT])else m4_default([_AC_PATH_LIB_CHECK_VERSION], [_AC_PATH_LIB_CHECK_VERSION], [_AC_PATH_LIB_CHECK_VERSION_DEFAULT])# If the user allowed it, try linking with the library if test x$LDOWN[]_test_enabled = xyes ; then _AC_PATH_LIB_CHECK_LINK(, [ CACHE[]_present="no" if test x$LDOWN[]_version_test_error = xyes ; then AC_PATH_LIB_ERROR fi AC_PATH_LIB_ERROR([The test program failed to compile or link. See the file]) AC_PATH_LIB_ERROR([config.log for the exact error that occured. This usually]) AC_PATH_LIB_ERROR([means UP was not installed, was incorrectly installed]) AC_PATH_LIB_ERROR([or that you have moved UP since it was installed. In]) AC_PATH_LIB_ERROR([the latter case, you may want to edit the $LDOWN[]_config]) AC_PATH_LIB_ERROR([script: $UP[]_CONFIG]) ]) fifi])dnl end tests])# _AC_PATH_LIB_CHECK_TESTS# _AC_PATH_LIB_CHECK_TEST_COMPILE_DEFAULT# ---------------------------------------# Check if the installed UP is sufficiently new. (Also sanity checks# the results of DOWN-config to some extent. The test program must# compile, link and run sucessfullyAC_DEFUN([_AC_PATH_LIB_CHECK_TEST_COMPILE],[m4_pushdef([RUNLOG], run.[]DOWN[]test)dnlm4_pushdef([MAJOR], _AC_PATH_LIB_VERSION_PREFIX[]_AC_PATH_LIB_VERSION_MAJOR[]_AC_PATH_LIB_VERSION_SUFFIX)dnlm4_pushdef([MINOR], _AC_PATH_LIB_VERSION_PREFIX[]_AC_PATH_LIB_VERSION_MINOR[]_AC_PATH_LIB_VERSION_SUFFIX)dnlm4_pushdef([MICRO], _AC_PATH_LIB_VERSION_PREFIX[]_AC_PATH_LIB_VERSION_MICRO[]_AC_PATH_LIB_VERSION_SUFFIX)dnlm4_pushdef([DEFMAJOR], _AC_PATH_LIB_DEFVERSION_PREFIX[]_AC_PATH_LIB_DEFVERSION_MAJOR[]_AC_PATH_LIB_DEFVERSION_SUFFIX)dnlm4_pushdef([DEFMINOR], _AC_PATH_LIB_DEFVERSION_PREFIX[]_AC_PATH_LIB_DEFVERSION_MINOR[]_AC_PATH_LIB_DEFVERSION_SUFFIX)dnlm4_pushdef([DEFMICRO], _AC_PATH_LIB_DEFVERSION_PREFIX[]_AC_PATH_LIB_DEFVERSION_MICRO[]_AC_PATH_LIB_DEFVERSION_SUFFIX)dnl ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $UP[]_CFLAGS" LIBS="$UP[]_LIBS $LIBS" rm -f RUNLOG AC_TRY_RUN([#include <$]LDOWN[_header>#include <stdio.h>#include <stdlib.h>/* * XXX FIXME Francesco: * This is a pigsty patch for undefined strdup (defined in string.h). * Maybe we should look for strdup() or wrapping it using functions * like malloc && strcpy(). */#include <string.h>intmain (){ int major, minor, micro; char *tmp_version; FILE *errorlog; if ((errorlog = fopen("]ERRORLOG[", "w")) == NULL) { exit(1); } system ("touch ]RUNLOG["); /* HP/UX 9 (%@#!) writes to sscanf strings */ tmp_version = strdup("$]LDOWN[_min_version"); if (!tmp_version) { exit(1); } if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { fprintf(errorlog, "*** %s: bad version string\n", "$]LDOWN[_min_version"); exit(1); } if ((]MAJOR[ != $]LDOWN[_config_major_version) || (]MINOR[ != $]LDOWN[_config_minor_version) || (]MICRO[ != $]LDOWN[_config_micro_version)) { fprintf(errorlog, "*** '$]UP[_CONFIG ]LIBCONFIG_VERSION[' returned %d.%d.%d, but \n", \ $]LDOWN[_config_major_version, $]LDOWN[_config_minor_version, \ $]LDOWN[_config_micro_version); fprintf(errorlog, "*** ]UP[ (%d.%d.%d) was found!\n", \ ]MAJOR[, ]MINOR[, ]MICRO[); fprintf(errorlog, "***\n"); fprintf(errorlog, "*** If $]LDOWN[_config was correct, then it is best to remove\n"); fprintf(errorlog, "*** the old version of ]UP[. You may also be able to\n"); fprintf(errorlog, "*** fix the error by modifying your LD_LIBRARY_PATH enviroment\n"); fprintf(errorlog, "*** variable, or by editing /etc/ld.so.conf. Make sure you have\n"); fprintf(errorlog, "*** run ldconfig if that is required on your system.\n"); fprintf(errorlog, "*** If $]LDOWN[_config was wrong, set the environment\n"); fprintf(errorlog, "*** variable ]UP[_CONFIG to point to the correct copy of\n"); fprintf(errorlog, "*** $]LDOWN[_config, and remove the file config.cache\n"); fprintf(errorlog, "*** before re-running configure.\n"); }#if defined (]DEFMAJOR[) && defined (]DEFMINOR[) && defined (]DEFMICRO[) else if ((]MAJOR[ != ]DEFMAJOR[) || (]MINOR[ != ]DEFMINOR[) || (]MICRO[ != ]DEFMICRO[)) { fprintf(errorlog, "*** ]UP[ header files (version %d.%d.%d) do not match\n", ]DEFMAJOR[, ]DEFMINOR[, ]DEFMICRO[); fprintf(errorlog, "*** library (version %d.%d.%d)\n", ]MAJOR[, ]MINOR[, ]MICRO[); }#endif /* defined (]DEFMAJOR[) ... */ else { if ((]MAJOR[ > major) || ((]MAJOR[ == major) && (]MINOR[ > minor)) || ((]MAJOR[ == major) && (]MINOR[ == minor) && (]MICRO[ >= micro))) { return 0; } else { fprintf(errorlog, "*** An old version of ]UP[ (%d.%d.%d) was found.\n", ]MAJOR[, ]MINOR[, ]MICRO[); fprintf(errorlog, "*** You need a version of ]UP[ newer than %d.%d.%d.\n", major, minor, micro); /*fprintf(errorlog, "*** The latest version of ]UP[ is always available from ftp://ftp.my.site\n");*/ fprintf(errorlog, "***\n"); fprintf(errorlog, "*** If you have already installed a sufficiently new version, this\n"); fprintf(errorlog, "*** error probably means that the wrong copy of the $]LDOWN[_config\n"); fprintf(errorlog, "*** shell script is being found. The easiest way to fix this is to\n"); fprintf(errorlog, "*** remove the old version of ]UP[, but you can also set the\n"); fprintf(errorlog, "*** ]UP[_CONFIG environment variable to point to the correct\n"); fprintf(errorlog, "*** copy of $]LDOWN[_config. (In this case, you will have to\n"); fprintf(errorlog, "*** modify your LD_LIBRARY_PATH environment variable, or edit\n"); fprintf(errorlog, "*** /etc/ld.so.conf so that the correct libraries are found at\n"); fprintf(errorlog, "*** run-time.)\n"); } } return 1;}],, [CACHE[]_present="no"], [AC_PATH_LIB_ERROR([cross compiling; assumed OK.])]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS"if test -f RUNLOG ; then :elif test x$LDOWN[]_version_test_enabled = xyes ; then AC_PATH_LIB_ERROR([Could not run UP test program, checking why...]) AC_PATH_LIB_ERROR _AC_PATH_LIB_CHECK_LINK(dnl [AC_PATH_LIB_ERROR([The test program compiled, but did not run. This usually]) AC_PATH_LIB_ERROR([means that the run-time linker is not finding UP or]) AC_PATH_LIB_ERROR([finding the wrong version of UP. If it is not finding]) AC_PATH_LIB_ERROR([UP, you will need to set your LD_LIBRARY_PATH environment]) AC_PATH_LIB_ERROR([variable, or edit /etc/ld.so.conf to point to the installed]) AC_PATH_LIB_ERROR([location. Also, make sure you have run ldconfig if that is]) AC_PATH_LIB_ERROR([required on your system.])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -