Lines 756-758
Link Here
|
756 |
Usually this means the macro was only invoked conditionally.]) |
756 |
Usually this means the macro was only invoked conditionally.]) |
757 |
fi])]) |
757 |
fi])]) |
758 |
|
758 |
|
|
|
759 |
# |
760 |
# Makros from http://ac-archive.sourceforge.net |
761 |
# These makros should be used while the ac-archive ebuild is still |
762 |
# masked in Portage |
763 |
# |
764 |
# Used makros: |
765 |
# - ax_path_bdb v1.1 |
766 |
# - ax_compare_versio v1.1 |
767 |
# |
768 |
# The Makros are under this License: |
769 |
# Every Autoconf macro presented on this web site is free software; |
770 |
# you can redistribute it and/or modify it under the terms of the |
771 |
# GNU General Public License as published by the Free Software |
772 |
# Foundation; either version 2, or (at your option) any later version. |
773 |
# |
774 |
# They are distributed in the hope that they will be useful, but |
775 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
776 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
777 |
# GNU General Public License for more details. (You should have |
778 |
# received a copy of the GNU General Public License along with this |
779 |
# program; if not, write to the Free Software Foundation, Inc., |
780 |
# 59 Temple Place -- Suite 330, Boston, MA 02111-1307, USA.) |
781 |
# |
782 |
# As a special exception, the Free Software Foundation gives |
783 |
# unlimited permission to copy, distribute and modify the configure |
784 |
# scripts that are the output of Autoconf. You need not follow the |
785 |
# terms of the GNU General Public License when using or distributing |
786 |
# such scripts, even though portions of the text of Autoconf appear |
787 |
# in them. The GNU General Public License (GPL) does govern all other |
788 |
# use of the material that constitutes the Autoconf program. |
789 |
# |
790 |
# Certain portions of the Autoconf source text are designed to be |
791 |
# copied (in certain cases, depending on the input) into the output |
792 |
# of Autoconf. We call these the "data" portions. The rest of the |
793 |
# Autoconf source text consists of comments plus executable code that |
794 |
# decides which of the data portions to output in any given case. We |
795 |
# call these comments and executable code the "non-data" portions. |
796 |
# Autoconf never copies any of the non-data portions into its output. |
797 |
# |
798 |
# This special exception to the GPL applies to versions of Autoconf |
799 |
# released by the Free Software Foundation. When you make and distribute |
800 |
# a modified version of Autoconf, you may extend this special exception |
801 |
# to the GPL to apply to your modified version as well, *unless* your |
802 |
# modified version has the potential to copy into its output some of the |
803 |
# text that was the non-data portion of the version that you started |
804 |
# with. (In other words, unless your change moves or copies text from |
805 |
# the non-data portions to the data portions.) If your modification has |
806 |
# such potential, you must delete any notice of this special exception |
807 |
# to the GPL from your modified version. |
808 |
# |
809 |
# |
810 |
|
811 |
|
812 |
dnl ######################################################################### |
813 |
AC_DEFUN([AX_COMPARE_VERSION], [ |
814 |
# Used to indicate true or false condition |
815 |
ax_compare_version=false |
816 |
|
817 |
# Convert the two version strings to be compared into a format that |
818 |
# allows a simple string comparison. The end result is that a version |
819 |
# string of the form 1.12.5-r617 will be converted to the form |
820 |
# 0001001200050617. In other words, each number is zero padded to four |
821 |
# digits, and non digits are removed. |
822 |
AS_VAR_PUSHDEF([A],[ax_compare_version_A]) |
823 |
A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ |
824 |
-e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ |
825 |
-e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ |
826 |
-e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ |
827 |
-e 's/[[^0-9]]//g'` |
828 |
|
829 |
AS_VAR_PUSHDEF([B],[ax_compare_version_B]) |
830 |
B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ |
831 |
-e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ |
832 |
-e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ |
833 |
-e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ |
834 |
-e 's/[[^0-9]]//g'` |
835 |
|
836 |
dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary |
837 |
dnl # then the first line is used to determine if the condition is true. |
838 |
dnl # The sed right after the echo is to remove any indented white space. |
839 |
m4_case(m4_tolower($2), |
840 |
[lt],[ |
841 |
ax_compare_version=`echo "x$A |
842 |
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` |
843 |
], |
844 |
[gt],[ |
845 |
ax_compare_version=`echo "x$A |
846 |
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` |
847 |
], |
848 |
[le],[ |
849 |
ax_compare_version=`echo "x$A |
850 |
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` |
851 |
], |
852 |
[ge],[ |
853 |
ax_compare_version=`echo "x$A |
854 |
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` |
855 |
],[ |
856 |
dnl Split the operator from the subversion count if present. |
857 |
m4_bmatch(m4_substr($2,2), |
858 |
[0],[ |
859 |
# A count of zero means use the length of the shorter version. |
860 |
# Determine the number of characters in A and B. |
861 |
ax_compare_version_len_A=`echo "$A" | awk '{print(length)}'` |
862 |
ax_compare_version_len_B=`echo "$B" | awk '{print(length)}'` |
863 |
|
864 |
# Set A to no more than B's length and B to no more than A's length. |
865 |
A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` |
866 |
B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` |
867 |
], |
868 |
[[0-9]+],[ |
869 |
# A count greater than zero means use only that many subversions |
870 |
A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` |
871 |
B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` |
872 |
], |
873 |
[.+],[ |
874 |
AC_WARNING( |
875 |
[illegal OP numeric parameter: $2]) |
876 |
],[]) |
877 |
|
878 |
# Pad zeros at end of numbers to make same length. |
879 |
ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" |
880 |
B="$B`echo $A | sed 's/./0/g'`" |
881 |
A="$ax_compare_version_tmp_A" |
882 |
|
883 |
# Check for equality or inequality as necessary. |
884 |
m4_case(m4_tolower(m4_substr($2,0,2)), |
885 |
[eq],[ |
886 |
test "x$A" = "x$B" && ax_compare_version=true |
887 |
], |
888 |
[ne],[ |
889 |
test "x$A" != "x$B" && ax_compare_version=true |
890 |
],[ |
891 |
AC_WARNING([illegal OP parameter: $2]) |
892 |
]) |
893 |
]) |
894 |
|
895 |
AS_VAR_POPDEF([A])dnl |
896 |
AS_VAR_POPDEF([B])dnl |
897 |
|
898 |
dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. |
899 |
if test "$ax_compare_version" = "true" ; then |
900 |
m4_ifvaln([$4],[$4],[:])dnl |
901 |
m4_ifvaln([$5],[else $5])dnl |
902 |
fi |
903 |
]) dnl AX_COMPARE_VERSION |
904 |
|
905 |
|
906 |
dnl ######################################################################### |
907 |
AC_DEFUN([AX_PATH_BDB], [ |
908 |
dnl # Used to indicate success or failure of this function. |
909 |
ax_path_bdb_ok=no |
910 |
|
911 |
# Add --with-bdb-dir option to configure. |
912 |
AC_ARG_WITH([bdb-dir], |
913 |
[AC_HELP_STRING([--with-bdb-dir=DIR], |
914 |
[Berkeley DB installation directory])]) |
915 |
|
916 |
# Check if --with-bdb-dir was specified. |
917 |
if test "x$with_bdb_dir" = "x" ; then |
918 |
# No option specified, so just search the system. |
919 |
AX_PATH_BDB_NO_OPTIONS([$1], [HIGHEST], [ |
920 |
ax_path_bdb_ok=yes |
921 |
]) |
922 |
else |
923 |
# Set --with-bdb-dir option. |
924 |
ax_path_bdb_INC="$with_bdb_dir/include" |
925 |
ax_path_bdb_LIB="$with_bdb_dir/lib" |
926 |
|
927 |
dnl # Save previous environment, and modify with new stuff. |
928 |
ax_path_bdb_save_CPPFLAGS="$CPPFLAGS" |
929 |
CPPFLAGS="-I$ax_path_bdb_INC $CPPFLAGS" |
930 |
|
931 |
ax_path_bdb_save_LDFLAGS=$LDFLAGS |
932 |
LDFLAGS="-L$ax_path_bdb_LIB $LDFLAGS" |
933 |
|
934 |
# Check for specific header file db.h |
935 |
AC_MSG_CHECKING([db.h presence in $ax_path_bdb_INC]) |
936 |
if test -f "$ax_path_bdb_INC/db.h" ; then |
937 |
AC_MSG_RESULT([yes]) |
938 |
# Check for library |
939 |
AX_PATH_BDB_NO_OPTIONS([$1], [ENVONLY], [ |
940 |
ax_path_bdb_ok=yes |
941 |
BDB_CPPFLAGS="-I$ax_path_bdb_INC" |
942 |
BDB_LDFLAGS="-L$ax_path_bdb_LIB" |
943 |
]) |
944 |
else |
945 |
AC_MSG_RESULT([no]) |
946 |
AC_MSG_NOTICE([no usable Berkeley DB not found]) |
947 |
fi |
948 |
|
949 |
dnl # Restore the environment. |
950 |
CPPFLAGS="$ax_path_bdb_save_CPPFLAGS" |
951 |
LDFLAGS="$ax_path_bdb_save_LDFLAGS" |
952 |
|
953 |
fi |
954 |
|
955 |
dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND. |
956 |
if test "$ax_path_bdb_ok" = "yes" ; then |
957 |
m4_ifvaln([$2],[$2],[:])dnl |
958 |
m4_ifvaln([$3],[else $3])dnl |
959 |
fi |
960 |
|
961 |
]) dnl AX_PATH_BDB |
962 |
|
963 |
dnl ######################################################################### |
964 |
dnl Check for berkeley DB of at least MINIMUM-VERSION on system. |
965 |
dnl |
966 |
dnl The OPTION argument determines how the checks occur, and can be one of: |
967 |
dnl |
968 |
dnl HIGHEST - Check both the environment and the default installation |
969 |
dnl directories for Berkeley DB and choose the version that |
970 |
dnl is highest. (default) |
971 |
dnl ENVFIRST - Check the environment first, and if no satisfactory |
972 |
dnl library is found there check the default installation |
973 |
dnl directories for Berkeley DB which is /usr/local/BerkeleyDB* |
974 |
dnl ENVONLY - Check the current environment only. |
975 |
dnl |
976 |
dnl Requires AX_PATH_BDB_PATH_GET_VERSION, AX_PATH_BDB_PATH_FIND_HIGHEST, |
977 |
dnl AX_PATH_BDB_ENV_CONFIRM_LIB, AX_PATH_BDB_ENV_GET_VERSION, and |
978 |
dnl AX_COMPARE_VERSION macros. |
979 |
dnl |
980 |
dnl Result: sets ax_path_bdb_no_options_ok to yes or no |
981 |
dnl sets BDB_LIBS, BDB_CPPFLAGS, BDB_LDFLAGS, BDB_VERSION |
982 |
dnl |
983 |
dnl AX_PATH_BDB_NO_OPTIONS([MINIMUM-VERSION], [OPTION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
984 |
AC_DEFUN([AX_PATH_BDB_NO_OPTIONS], [ |
985 |
dnl # Used to indicate success or failure of this function. |
986 |
ax_path_bdb_no_options_ok=no |
987 |
|
988 |
# Values to add to environment to use Berkeley DB. |
989 |
BDB_VERSION='' |
990 |
BDB_LIBS='' |
991 |
BDB_CPPFLAGS='' |
992 |
BDB_LDFLAGS='' |
993 |
|
994 |
# Check cross compilation here. |
995 |
if test "x$cross_compiling" = "xyes" ; then |
996 |
# If cross compiling, can't use AC_RUN_IFELSE so do these tests. |
997 |
# The AC_PREPROC_IFELSE confirms that db.h is preprocessable, |
998 |
# and extracts the version number from it. |
999 |
AC_MSG_CHECKING([for db.h]) |
1000 |
|
1001 |
AS_VAR_PUSHDEF([HEADER_VERSION],[ax_path_bdb_no_options_HEADER_VERSION])dnl |
1002 |
HEADER_VERSION='' |
1003 |
AC_PREPROC_IFELSE([ |
1004 |
AC_LANG_SOURCE([[ |
1005 |
#include <db.h> |
1006 |
AX_PATH_BDB_STUFF DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH |
1007 |
]]) |
1008 |
],[ |
1009 |
# Extract version from preprocessor output. |
1010 |
HEADER_VERSION=`eval "$ac_cpp conftest.$ac_ext" 2> /dev/null \ |
1011 |
| grep AX_PATH_BDB_STUFF | sed 's/[[^0-9,]]//g;s/,/./g;1q'` |
1012 |
],[]) |
1013 |
|
1014 |
if test "x$HEADER_VERSION" = "x" ; then |
1015 |
AC_MSG_RESULT([no]) |
1016 |
else |
1017 |
AC_MSG_RESULT([$HEADER_VERSION]) |
1018 |
|
1019 |
# Check that version is high enough. |
1020 |
AX_COMPARE_VERSION([$HEADER_VERSION],[ge],[$1],[ |
1021 |
# get major and minor version numbers |
1022 |
AS_VAR_PUSHDEF([MAJ],[ax_path_bdb_no_options_MAJOR])dnl |
1023 |
MAJ=`echo $HEADER_VERSION | sed 's,\..*,,'` |
1024 |
AS_VAR_PUSHDEF([MIN],[ax_path_bdb_no_options_MINOR])dnl |
1025 |
MIN=`echo $HEADER_VERSION | sed 's,^[[0-9]]*\.,,;s,\.[[0-9]]*$,,'` |
1026 |
|
1027 |
dnl # Save LIBS. |
1028 |
ax_path_bdb_no_options_save_LIBS="$LIBS" |
1029 |
|
1030 |
# Check that we can link with the library. |
1031 |
AC_SEARCH_LIBS([db_version], |
1032 |
[db db-$MAJ.$MIN db$MAJ.$MIN db$MAJ$MIN db-$MAJ db$MAJ],[ |
1033 |
# Sucessfully found library. |
1034 |
ax_path_bdb_no_options_ok=yes |
1035 |
BDB_VERSION=$HEADER_VERSION |
1036 |
|
1037 |
# Extract library from LIBS |
1038 |
ax_path_bdb_no_options_LEN=` \ |
1039 |
echo "x$ax_path_bdb_no_options_save_LIBS" \ |
1040 |
| awk '{print(length)}'` |
1041 |
BDB_LIBS=`echo "x$LIBS " \ |
1042 |
| sed "s/.\{$ax_path_bdb_no_options_LEN\}\$//;s/^x//;s/ //g"` |
1043 |
],[]) |
1044 |
|
1045 |
dnl # Restore LIBS |
1046 |
LIBS="$ax_path_bdb_no_options_save_LIBS" |
1047 |
|
1048 |
AS_VAR_POPDEF([MAJ])dnl |
1049 |
AS_VAR_POPDEF([MIN])dnl |
1050 |
]) |
1051 |
fi |
1052 |
|
1053 |
AS_VAR_POPDEF([HEADER_VERSION])dnl |
1054 |
else |
1055 |
# Not cross compiling. |
1056 |
# Check version of Berkeley DB in the current environment. |
1057 |
AX_PATH_BDB_ENV_GET_VERSION([ |
1058 |
AX_COMPARE_VERSION([$ax_path_bdb_env_get_version_VERSION],[ge],[$1],[ |
1059 |
# Found acceptable version in current environment. |
1060 |
ax_path_bdb_no_options_ok=yes |
1061 |
BDB_VERSION="$ax_path_bdb_env_get_version_VERSION" |
1062 |
BDB_LIBS="$ax_path_bdb_env_get_version_LIBS" |
1063 |
]) |
1064 |
]) |
1065 |
|
1066 |
# Determine if we need to search /usr/local/BerkeleyDB* |
1067 |
ax_path_bdb_no_options_DONE=no |
1068 |
if test "x$2" = "xENVONLY" ; then |
1069 |
ax_path_bdb_no_options_DONE=yes |
1070 |
elif test "x$2" = "xENVFIRST" ; then |
1071 |
ax_path_bdb_no_options_DONE=$ax_path_bdb_no_options_ok |
1072 |
fi |
1073 |
|
1074 |
if test "$ax_path_bdb_no_options_DONE" = "no" ; then |
1075 |
# Check for highest in /usr/local/BerkeleyDB* |
1076 |
AX_PATH_BDB_PATH_FIND_HIGHEST([ |
1077 |
if test "$ax_path_bdb_no_options_ok" = "yes" ; then |
1078 |
# If we already have an acceptable version use this if higher. |
1079 |
AX_COMPARE_VERSION( |
1080 |
[$ax_path_bdb_path_find_highest_VERSION],[gt],[$BDB_VERSION]) |
1081 |
else |
1082 |
# Since we didn't have an acceptable version check if this one is. |
1083 |
AX_COMPARE_VERSION( |
1084 |
[$ax_path_bdb_path_find_highest_VERSION],[ge],[$1]) |
1085 |
fi |
1086 |
]) |
1087 |
|
1088 |
dnl # If result from _AX_COMPARE_VERSION is true we want this version. |
1089 |
if test "$ax_compare_version" = "true" ; then |
1090 |
ax_path_bdb_no_options_ok=yes |
1091 |
BDB_LIBS="-ldb" |
1092 |
BDB_CPPFLAGS="-I$ax_path_bdb_path_find_highest_DIR/include" |
1093 |
BDB_LDFLAGS="-L$ax_path_bdb_path_find_highest_DIR/lib" |
1094 |
BDB_VERSION="$ax_path_bdb_path_find_highest_VERSION" |
1095 |
fi |
1096 |
fi |
1097 |
fi |
1098 |
|
1099 |
dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND. |
1100 |
if test "$ax_path_bdb_no_options_ok" = "yes" ; then |
1101 |
AC_MSG_NOTICE([using Berkeley DB version $BDB_VERSION]) |
1102 |
AC_DEFINE([HAVE_DB_H],[1], |
1103 |
[Define to 1 if you have the <db.h> header file.]) |
1104 |
m4_ifvaln([$3],[$3])dnl |
1105 |
else |
1106 |
AC_MSG_NOTICE([no Berkeley DB version $1 or higher found]) |
1107 |
m4_ifvaln([$4],[$4])dnl |
1108 |
fi |
1109 |
]) dnl AX_PATH_BDB_NO_OPTIONS |
1110 |
|
1111 |
dnl ######################################################################### |
1112 |
dnl Check the default installation directory for Berkeley DB which is |
1113 |
dnl of the form /usr/local/BerkeleyDB* for the highest version. |
1114 |
dnl |
1115 |
dnl Result: sets ax_path_bdb_path_find_highest_ok to yes or no, |
1116 |
dnl sets ax_path_bdb_path_find_highest_VERSION to version, |
1117 |
dnl sets ax_path_bdb_path_find_highest_DIR to directory. |
1118 |
dnl |
1119 |
dnl AX_PATH_BDB_PATH_FIND_HIGHEST([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
1120 |
AC_DEFUN([AX_PATH_BDB_PATH_FIND_HIGHEST], [ |
1121 |
dnl # Used to indicate success or failure of this function. |
1122 |
ax_path_bdb_path_find_highest_ok=no |
1123 |
|
1124 |
AS_VAR_PUSHDEF([VERSION],[ax_path_bdb_path_find_highest_VERSION])dnl |
1125 |
VERSION='' |
1126 |
|
1127 |
ax_path_bdb_path_find_highest_DIR='' |
1128 |
|
1129 |
# find highest verison in default install directory for Berkeley DB |
1130 |
AS_VAR_PUSHDEF([CURDIR],[ax_path_bdb_path_find_highest_CURDIR])dnl |
1131 |
AS_VAR_PUSHDEF([CUR_VERSION],[ax_path_bdb_path_get_version_VERSION])dnl |
1132 |
|
1133 |
for CURDIR in `ls -d /usr/local/BerkeleyDB* 2> /dev/null` |
1134 |
do |
1135 |
AX_PATH_BDB_PATH_GET_VERSION([$CURDIR],[ |
1136 |
AX_COMPARE_VERSION([$CUR_VERSION],[gt],[$VERSION],[ |
1137 |
ax_path_bdb_path_find_highest_ok=yes |
1138 |
ax_path_bdb_path_find_highest_DIR="$CURDIR" |
1139 |
VERSION="$CUR_VERSION" |
1140 |
]) |
1141 |
]) |
1142 |
done |
1143 |
|
1144 |
AS_VAR_POPDEF([VERSION])dnl |
1145 |
AS_VAR_POPDEF([CUR_VERSION])dnl |
1146 |
AS_VAR_POPDEF([CURDIR])dnl |
1147 |
|
1148 |
dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND. |
1149 |
if test "$ax_path_bdb_path_find_highest_ok" = "yes" ; then |
1150 |
m4_ifvaln([$1],[$1],[:])dnl |
1151 |
m4_ifvaln([$2],[else $2])dnl |
1152 |
fi |
1153 |
|
1154 |
]) dnl AX_PATH_BDB_PATH_FIND_HIGHEST |
1155 |
|
1156 |
dnl ######################################################################### |
1157 |
dnl Checks for Berkeley DB in specified directory's lib and include |
1158 |
dnl subdirectories. |
1159 |
dnl |
1160 |
dnl Result: sets ax_path_bdb_path_get_version_ok to yes or no, |
1161 |
dnl sets ax_path_bdb_path_get_version_VERSION to version. |
1162 |
dnl |
1163 |
dnl AX_PATH_BDB_PATH_GET_VERSION(BDB-DIR, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
1164 |
AC_DEFUN([AX_PATH_BDB_PATH_GET_VERSION], [ |
1165 |
dnl # Used to indicate success or failure of this function. |
1166 |
ax_path_bdb_path_get_version_ok=no |
1167 |
|
1168 |
# Indicate status of checking for Berkeley DB header. |
1169 |
AC_MSG_CHECKING([in $1/include for db.h]) |
1170 |
ax_path_bdb_path_get_version_got_header=no |
1171 |
test -f "$1/include/db.h" && ax_path_bdb_path_get_version_got_header=yes |
1172 |
AC_MSG_RESULT([$ax_path_bdb_path_get_version_got_header]) |
1173 |
|
1174 |
# Indicate status of checking for Berkeley DB library. |
1175 |
AC_MSG_CHECKING([in $1/lib for library -ldb]) |
1176 |
|
1177 |
ax_path_bdb_path_get_version_VERSION='' |
1178 |
|
1179 |
if test -d "$1/include" && test -d "$1/lib" && |
1180 |
test "$ax_path_bdb_path_get_version_got_header" = "yes" ; then |
1181 |
dnl # save and modify environment |
1182 |
ax_path_bdb_path_get_version_save_CPPFLAGS="$CPPFLAGS" |
1183 |
CPPFLAGS="-I$1/include $CPPFLAGS" |
1184 |
|
1185 |
ax_path_bdb_path_get_version_save_LIBS="$LIBS" |
1186 |
LIBS="$LIBS -ldb" |
1187 |
|
1188 |
ax_path_bdb_path_get_version_save_LDFLAGS="$LDFLAGS" |
1189 |
LDFLAGS="-L$1/lib $LDFLAGS" |
1190 |
|
1191 |
# Compile and run a program that compares the version defined in |
1192 |
# the header file with a version defined in the library function |
1193 |
# db_version. |
1194 |
AC_RUN_IFELSE([ |
1195 |
AC_LANG_SOURCE([[ |
1196 |
#include <stdio.h> |
1197 |
#include <db.h> |
1198 |
int main(int argc,char **argv) |
1199 |
{ |
1200 |
int major,minor,patch; |
1201 |
db_version(&major,&minor,&patch); |
1202 |
if (argc > 1) |
1203 |
printf("%d.%d.%d\n",DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH); |
1204 |
if (DB_VERSION_MAJOR == major && DB_VERSION_MINOR == minor && |
1205 |
DB_VERSION_PATCH == patch) |
1206 |
return 0; |
1207 |
else |
1208 |
return 1; |
1209 |
} |
1210 |
]]) |
1211 |
],[ |
1212 |
# Program compiled and ran, so get version by adding argument. |
1213 |
ax_path_bdb_path_get_version_VERSION=`./conftest$ac_exeext x` |
1214 |
ax_path_bdb_path_get_version_ok=yes |
1215 |
],[],[]) |
1216 |
|
1217 |
dnl # restore environment |
1218 |
CPPFLAGS="$ax_path_bdb_path_get_version_save_CPPFLAGS" |
1219 |
LIBS="$ax_path_bdb_path_get_version_save_LIBS" |
1220 |
LDFLAGS="$ax_path_bdb_path_get_version_save_LDFLAGS" |
1221 |
fi |
1222 |
|
1223 |
dnl # Finally, execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND. |
1224 |
if test "$ax_path_bdb_path_get_version_ok" = "yes" ; then |
1225 |
AC_MSG_RESULT([$ax_path_bdb_path_get_version_VERSION]) |
1226 |
m4_ifvaln([$2],[$2])dnl |
1227 |
else |
1228 |
AC_MSG_RESULT([no]) |
1229 |
m4_ifvaln([$3],[$3])dnl |
1230 |
fi |
1231 |
]) dnl AX_PATH_BDB_PATH_GET_VERSION |
1232 |
|
1233 |
############################################################################# |
1234 |
dnl Checks if version of library and header match specified version. |
1235 |
dnl Only meant to be used by AX_PATH_BDB_ENV_GET_VERSION macro. |
1236 |
dnl |
1237 |
dnl Requires AX_COMPARE_VERSION macro. |
1238 |
dnl |
1239 |
dnl Result: sets ax_path_bdb_env_confirm_lib_ok to yes or no. |
1240 |
dnl |
1241 |
dnl AX_PATH_BDB_ENV_CONFIRM_LIB(VERSION, [LIBNAME]) |
1242 |
AC_DEFUN([AX_PATH_BDB_ENV_CONFIRM_LIB], [ |
1243 |
dnl # Used to indicate success or failure of this function. |
1244 |
ax_path_bdb_env_confirm_lib_ok=no |
1245 |
|
1246 |
dnl # save and modify environment to link with library LIBNAME |
1247 |
ax_path_bdb_env_confirm_lib_save_LIBS="$LIBS" |
1248 |
LIBS="$LIBS $2" |
1249 |
|
1250 |
# Compile and run a program that compares the version defined in |
1251 |
# the header file with a version defined in the library function |
1252 |
# db_version. |
1253 |
AC_RUN_IFELSE([ |
1254 |
AC_LANG_SOURCE([[ |
1255 |
#include <stdio.h> |
1256 |
#include <db.h> |
1257 |
int main(int argc,char **argv) |
1258 |
{ |
1259 |
int major,minor,patch; |
1260 |
db_version(&major,&minor,&patch); |
1261 |
if (argc > 1) |
1262 |
printf("%d.%d.%d\n",DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH); |
1263 |
if (DB_VERSION_MAJOR == major && DB_VERSION_MINOR == minor && |
1264 |
DB_VERSION_PATCH == patch) |
1265 |
return 0; |
1266 |
else |
1267 |
return 1; |
1268 |
} |
1269 |
]]) |
1270 |
],[ |
1271 |
# Program compiled and ran, so get version by giving an argument, |
1272 |
# which will tell the program to print the output. |
1273 |
ax_path_bdb_env_confirm_lib_VERSION=`./conftest$ac_exeext x` |
1274 |
|
1275 |
# If the versions all match up, indicate success. |
1276 |
AX_COMPARE_VERSION([$ax_path_bdb_env_confirm_lib_VERSION],[eq],[$1],[ |
1277 |
ax_path_bdb_env_confirm_lib_ok=yes |
1278 |
]) |
1279 |
],[],[]) |
1280 |
|
1281 |
dnl # restore environment |
1282 |
LIBS="$ax_path_bdb_env_confirm_lib_save_LIBS" |
1283 |
|
1284 |
]) dnl AX_PATH_BDB_ENV_CONFIRM_LIB |
1285 |
|
1286 |
############################################################################# |
1287 |
dnl Finds the version and library name for Berkeley DB in the |
1288 |
dnl current environment. Tries many different names for library. |
1289 |
dnl |
1290 |
dnl Requires AX_PATH_BDB_ENV_CONFIRM_LIB macro. |
1291 |
dnl |
1292 |
dnl Result: set ax_path_bdb_env_get_version_ok to yes or no, |
1293 |
dnl set ax_path_bdb_env_get_version_VERSION to the version found, |
1294 |
dnl and ax_path_bdb_env_get_version_LIBNAME to the library name. |
1295 |
dnl |
1296 |
dnl AX_PATH_BDB_ENV_GET_VERSION([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
1297 |
AC_DEFUN([AX_PATH_BDB_ENV_GET_VERSION], [ |
1298 |
dnl # Used to indicate success or failure of this function. |
1299 |
ax_path_bdb_env_get_version_ok=no |
1300 |
|
1301 |
ax_path_bdb_env_get_version_VERSION='' |
1302 |
ax_path_bdb_env_get_version_LIBS='' |
1303 |
|
1304 |
AS_VAR_PUSHDEF([HEADER_VERSION],[ax_path_bdb_env_get_version_HEADER_VERSION])dnl |
1305 |
AS_VAR_PUSHDEF([TEST_LIBNAME],[ax_path_bdb_env_get_version_TEST_LIBNAME])dnl |
1306 |
|
1307 |
# Indicate status of checking for Berkeley DB library. |
1308 |
AC_MSG_CHECKING([for db.h]) |
1309 |
|
1310 |
# Compile and run a program that determines the Berkeley DB version |
1311 |
# in the header file db.h. |
1312 |
HEADER_VERSION='' |
1313 |
AC_RUN_IFELSE([ |
1314 |
AC_LANG_SOURCE([[ |
1315 |
#include <stdio.h> |
1316 |
#include <db.h> |
1317 |
int main(int argc,char **argv) |
1318 |
{ |
1319 |
if (argc > 1) |
1320 |
printf("%d.%d.%d\n",DB_VERSION_MAJOR,DB_VERSION_MINOR,DB_VERSION_PATCH); |
1321 |
return 0; |
1322 |
} |
1323 |
]]) |
1324 |
],[ |
1325 |
# Program compiled and ran, so get version by adding an argument. |
1326 |
HEADER_VERSION=`./conftest$ac_exeext x` |
1327 |
AC_MSG_RESULT([$HEADER_VERSION]) |
1328 |
],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no])]) |
1329 |
|
1330 |
# Have header version, so try to find corresponding library. |
1331 |
# Looks for library names in the order: |
1332 |
# nothing, db, db-X.Y, dbX.Y, dbXY, db-X, dbX |
1333 |
# and stops when it finds the first one that matches the version |
1334 |
# of the header file. |
1335 |
if test "x$HEADER_VERSION" != "x" ; then |
1336 |
AC_MSG_CHECKING([for library containing Berkeley DB $HEADER_VERSION]) |
1337 |
|
1338 |
AS_VAR_PUSHDEF([MAJOR],[ax_path_bdb_env_get_version_MAJOR])dnl |
1339 |
AS_VAR_PUSHDEF([MINOR],[ax_path_bdb_env_get_version_MINOR])dnl |
1340 |
|
1341 |
# get major and minor version numbers |
1342 |
MAJOR=`echo $HEADER_VERSION | sed 's,\..*,,'` |
1343 |
MINOR=`echo $HEADER_VERSION | sed 's,^[[0-9]]*\.,,;s,\.[[0-9]]*$,,'` |
1344 |
|
1345 |
# see if it is already specified in LIBS |
1346 |
TEST_LIBNAME='' |
1347 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
1348 |
|
1349 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then |
1350 |
# try format "db" |
1351 |
TEST_LIBNAME='-ldb' |
1352 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
1353 |
fi |
1354 |
|
1355 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then |
1356 |
# try format "db-X.Y" |
1357 |
TEST_LIBNAME="-ldb-${MAJOR}.$MINOR" |
1358 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
1359 |
fi |
1360 |
|
1361 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then |
1362 |
# try format "dbX.Y" |
1363 |
TEST_LIBNAME="-ldb${MAJOR}.$MINOR" |
1364 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
1365 |
fi |
1366 |
|
1367 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then |
1368 |
# try format "dbXY" |
1369 |
TEST_LIBNAME="-ldb$MAJOR$MINOR" |
1370 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
1371 |
fi |
1372 |
|
1373 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then |
1374 |
# try format "db-X" |
1375 |
TEST_LIBNAME="-ldb-$MAJOR" |
1376 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
1377 |
fi |
1378 |
|
1379 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "no" ; then |
1380 |
# try format "dbX" |
1381 |
TEST_LIBNAME="-ldb$MAJOR" |
1382 |
AX_PATH_BDB_ENV_CONFIRM_LIB([$HEADER_VERSION], [$TEST_LIBNAME]) |
1383 |
fi |
1384 |
|
1385 |
dnl # Found a valid library. |
1386 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "yes" ; then |
1387 |
if test "x$TEST_LIBNAME" = "x" ; then |
1388 |
AC_MSG_RESULT([none required]) |
1389 |
else |
1390 |
AC_MSG_RESULT([$TEST_LIBNAME]) |
1391 |
fi |
1392 |
ax_path_bdb_env_get_version_VERSION="$HEADER_VERSION" |
1393 |
ax_path_bdb_env_get_version_LIBS="$TEST_LIBNAME" |
1394 |
ax_path_bdb_env_get_version_ok=yes |
1395 |
else |
1396 |
AC_MSG_RESULT([no]) |
1397 |
fi |
1398 |
|
1399 |
AS_VAR_POPDEF([MAJOR])dnl |
1400 |
AS_VAR_POPDEF([MINOR])dnl |
1401 |
fi |
1402 |
|
1403 |
AS_VAR_POPDEF([HEADER_VERSION])dnl |
1404 |
AS_VAR_POPDEF([TEST_LIBNAME])dnl |
1405 |
|
1406 |
dnl # Execute ACTION-IF-FOUND / ACTION-IF-NOT-FOUND. |
1407 |
if test "$ax_path_bdb_env_confirm_lib_ok" = "yes" ; then |
1408 |
m4_ifvaln([$1],[$1],[:])dnl |
1409 |
m4_ifvaln([$2],[else $2])dnl |
1410 |
fi |
1411 |
|
1412 |
]) dnl BDB_ENV_GET_VERSION |
1413 |
|
1414 |
############################################################################# |
1415 |
|
1416 |
|