@@ -127,6 +127,29 @@ AC_DEFUN(AC_LBL_C_INIT,
127
127
fi
128
128
] )
129
129
130
+ dnl
131
+ dnl Save the values of various variables that affect compilation and
132
+ dnl linking, and that we don't ourselves modify persistently; done
133
+ dnl before a test involving compiling or linking is done, so that we
134
+ dnl can restore those variables after the test is done.
135
+ dnl
136
+ AC_DEFUN ( AC_LBL_SAVE_CHECK_STATE ,
137
+ [
138
+ save_CFLAGS="$CFLAGS"
139
+ save_LIBS="$LIBS"
140
+ save_LDFLAGS="$LDFLAGS"
141
+ ] )
142
+
143
+ dnl
144
+ dnl Restore the values of variables saved by AC_LBL_SAVE_CHECK_STATE.
145
+ dnl
146
+ AC_DEFUN ( AC_LBL_RESTORE_CHECK_STATE ,
147
+ [
148
+ CFLAGS="$save_CFLAGS"
149
+ LIBS="$save_LIBS"
150
+ LDFLAGS="$save_LDFLAGS"
151
+ ] )
152
+
130
153
dnl
131
154
dnl Check whether the compiler option specified as the second argument
132
155
dnl is supported by the compiler and, if so, add it to the macro
@@ -372,7 +395,6 @@ AC_DEFUN(AC_LBL_LIBPCAP,
372
395
# We didn't find a local libpcap.
373
396
# Look for an installed pkg-config.
374
397
#
375
- AC_PATH_TOOL ( PKG_CONFIG , pkg-config )
376
398
if test -n "$PKG_CONFIG" ; then
377
399
#
378
400
# We have it. Are there .pc files for libpcap?
@@ -860,3 +882,266 @@ AC_DEFUN(AC_LBL_LIBRARY_NET, [
860
882
] , - lnsl )
861
883
] )
862
884
] )
885
+
886
+ m4_ifndef ( [ AC_CONFIG_MACRO_DIRS] , [ m4_defun([ _AM_CONFIG_MACRO_DIRS] , [ ] )m4_defun([ AC_CONFIG_MACRO_DIRS] , [ _AM_CONFIG_MACRO_DIRS($@ )] )] )
887
+ dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
888
+ dnl serial 11 (pkg-config-0.29)
889
+ dnl
890
+ dnl Copyright © 2004 Scott James Remnant <[email protected] >.
891
+ dnl Copyright © 2012-2015 Dan Nicholson <[email protected] >
892
+ dnl
893
+ dnl This program is free software; you can redistribute it and/or modify
894
+ dnl it under the terms of the GNU General Public License as published by
895
+ dnl the Free Software Foundation; either version 2 of the License, or
896
+ dnl (at your option) any later version.
897
+ dnl
898
+ dnl This program is distributed in the hope that it will be useful, but
899
+ dnl WITHOUT ANY WARRANTY; without even the implied warranty of
900
+ dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
901
+ dnl General Public License for more details.
902
+ dnl
903
+ dnl You should have received a copy of the GNU General Public License
904
+ dnl along with this program; if not, write to the Free Software
905
+ dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
906
+ dnl 02111-1307, USA.
907
+ dnl
908
+ dnl As a special exception to the GNU General Public License, if you
909
+ dnl distribute this file as part of a program that contains a
910
+ dnl configuration script generated by Autoconf, you may include it under
911
+ dnl the same distribution terms that you use for the rest of that
912
+ dnl program.
913
+
914
+ dnl PKG_PREREQ(MIN-VERSION)
915
+ dnl -----------------------
916
+ dnl Since: 0.29
917
+ dnl
918
+ dnl Verify that the version of the pkg-config macros are at least
919
+ dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
920
+ dnl installed version of pkg-config, this checks the developer's version
921
+ dnl of pkg.m4 when generating configure.
922
+ dnl
923
+ dnl To ensure that this macro is defined, also add:
924
+ dnl m4_ifndef([PKG_PREREQ],
925
+ dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
926
+ dnl
927
+ dnl See the "Since" comment for each macro you use to see what version
928
+ dnl of the macros you require.
929
+ m4_defun([ PKG_PREREQ] ,
930
+ [ m4_define ( [ PKG_MACROS_VERSION] , [ 0.29] )
931
+ m4_if ( m4_version_compare ( PKG_MACROS_VERSION , [ $1 ] ) , - 1 ,
932
+ [ m4_fatal ( [ pkg.m4 version $1 or higher is required but ] PKG_MACROS_VERSION [ found] ) ] )
933
+ ] )dnl PKG_PREREQ
934
+
935
+ dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
936
+ dnl ----------------------------------
937
+ dnl Since: 0.16
938
+ dnl
939
+ dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
940
+ dnl first found in the path. Checks that the version of pkg-config found
941
+ dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.17.0 is
942
+ dnl used since that's the first version where --static was supported.
943
+ AC_DEFUN ( [ PKG_PROG_PKG_CONFIG] ,
944
+ [ m4_pattern_forbid ( [ ^_?PKG_[ A-Z_] +$] )
945
+ m4_pattern_allow ( [ ^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$] )
946
+ m4_pattern_allow ( [ ^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$] )
947
+ AC_ARG_VAR ( [ PKG_CONFIG] , [ path to pkg-config utility] )
948
+ AC_ARG_VAR ( [ PKG_CONFIG_PATH] , [ directories to add to pkg-config's search path] )
949
+ AC_ARG_VAR ( [ PKG_CONFIG_LIBDIR] , [ path overriding pkg-config's built-in search path] )
950
+
951
+ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
952
+ AC_PATH_TOOL ( [ PKG_CONFIG] , [ pkg-config] )
953
+ fi
954
+ if test -n "$PKG_CONFIG"; then
955
+ _pkg_min_version=m4_default ( [ $1 ] , [ 0.17.0] )
956
+ AC_MSG_CHECKING ( [ pkg-config is at least version $_pkg_min_version] )
957
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
958
+ AC_MSG_RESULT ( [ yes] )
959
+ else
960
+ AC_MSG_RESULT ( [ no] )
961
+ PKG_CONFIG=""
962
+ fi
963
+ fi[ ] dnl
964
+ ] ) dnl PKG_PROG_PKG_CONFIG
965
+
966
+ dnl PKG_CHECK_EXISTS(MODULE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
967
+ dnl -------------------------------------------------------------------
968
+ dnl Since: 0.18
969
+ dnl
970
+ dnl Check to see whether a particular module exists. Similar to
971
+ dnl PKG_CHECK_MODULE(), but does not set variables or print errors.
972
+ AC_DEFUN ( [ PKG_CHECK_EXISTS] ,
973
+ [
974
+ if test -n "$PKG_CONFIG" && \
975
+ AC_RUN_LOG([ $PKG_CONFIG --exists --print-errors "$1 "] ); then
976
+ m4_default ( [ $2 ] , [ :] )
977
+ m4_ifvaln ( [ $3 ] , [ else
978
+ $3 ] ) dnl
979
+ fi] )
980
+
981
+ dnl _PKG_CONFIG_WITH_FLAGS([VARIABLE], [FLAGS], [MODULE])
982
+ dnl ---------------------------------------------
983
+ dnl Internal wrapper calling pkg-config via PKG_CONFIG and, if
984
+ dnl pkg-config fails, reporting the error and quitting.
985
+ m4_define ( [ _PKG_CONFIG_WITH_FLAGS] ,
986
+ [ if test ! -n "$$1 "; then
987
+ $1 =`$PKG_CONFIG $2 "$3 " 2>/dev/null`
988
+ if test "x$?" != "x0"; then
989
+ #
990
+ # That failed - report an error.
991
+ # Re-run the command, telling pkg-config to print an error
992
+ # message, capture the error message, and report it.
993
+ # This causes the configuration script to fail, as it means
994
+ # the script is almost certainly doing something wrong.
995
+ #
996
+ _PKG_SHORT_ERRORS_SUPPORTED
997
+ if test $_pkg_short_errors_supported = yes; then
998
+ _pkg_error_string=`$PKG_CONFIG --short-errors --print-errors $2 "$3 " 2>&1`
999
+ else
1000
+ _pkg_error_string=`$PKG_CONFIG --print-errors $2 "$3 " 2>&1`
1001
+ fi
1002
+ AC_MSG_ERROR ( [ $PKG_CONFIG $2 "$3 " failed: $_pkg_error_string] )
1003
+ fi
1004
+ fi[ ] dnl
1005
+ ] ) dnl _PKG_CONFIG_WITH_FLAGS
1006
+
1007
+
1008
+ dnl _PKG_CONFIG([VARIABLE], [FLAGS], [MODULE])
1009
+ dnl ---------------------------------------------
1010
+ dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
1011
+ dnl pkg_failed based on the result.
1012
+ m4_define ( [ _PKG_CONFIG] ,
1013
+ [ if test -n "$$1 "; then
1014
+ pkg_cv_[ ] $1 ="$$1 "
1015
+ elif test -n "$PKG_CONFIG"; then
1016
+ PKG_CHECK_EXISTS([ $3 ] ,
1017
+ [ pkg_cv_[ ] $1 =`$PKG_CONFIG $2 "$3 " 2>/dev/null`
1018
+ test "x$?" != "x0" && pkg_failed=yes ] ,
1019
+ [ pkg_failed=yes] )
1020
+ else
1021
+ pkg_failed=untried
1022
+ fi[ ] dnl
1023
+ ] ) dnl _PKG_CONFIG
1024
+
1025
+ dnl _PKG_SHORT_ERRORS_SUPPORTED
1026
+ dnl ---------------------------
1027
+ dnl Internal check to see if pkg-config supports short errors.
1028
+ AC_DEFUN ( [ _PKG_SHORT_ERRORS_SUPPORTED] ,
1029
+ [
1030
+ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
1031
+ _pkg_short_errors_supported=yes
1032
+ else
1033
+ _pkg_short_errors_supported=no
1034
+ fi[ ] dnl
1035
+ ] ) dnl _PKG_SHORT_ERRORS_SUPPORTED
1036
+
1037
+
1038
+ dnl PKG_CHECK_MODULE(VARIABLE-PREFIX, MODULE, [ACTION-IF-FOUND],
1039
+ dnl [ACTION-IF-NOT-FOUND])
1040
+ dnl --------------------------------------------------------------
1041
+ dnl Since: 0.4.0
1042
+ AC_DEFUN ( [ PKG_CHECK_MODULE] ,
1043
+ [
1044
+ AC_MSG_CHECKING ( [ for $2 with pkg-config] )
1045
+ if test -n "$PKG_CONFIG"; then
1046
+ AC_ARG_VAR ( [ $1 ] [ _CFLAGS] , [ C compiler flags for $2 , overriding pkg-config] ) dnl
1047
+ AC_ARG_VAR ( [ $1 ] [ _LIBS] , [ linker flags for $2 , overriding pkg-config] ) dnl
1048
+ AC_ARG_VAR ( [ $1 ] [ _LIBS_STATIC] , [ static-link linker flags for $2 , overriding pkg-config] ) dnl
1049
+
1050
+ if AC_RUN_LOG([ $PKG_CONFIG --exists --print-errors "$2 "] ); then
1051
+ #
1052
+ # The package was found, so try to get its C flags and
1053
+ # libraries.
1054
+ #
1055
+ AC_MSG_RESULT ( [ found] )
1056
+ _PKG_CONFIG_WITH_FLAGS([ $1 ] [ _CFLAGS] , [ --cflags] , [ $2 ] )
1057
+ _PKG_CONFIG_WITH_FLAGS([ $1 ] [ _LIBS] , [ --libs] , [ $2 ] )
1058
+ _PKG_CONFIG_WITH_FLAGS([ $1 ] [ _LIBS_STATIC] , [ --libs --static] , [ $2 ] )
1059
+ m4_default ( [ $3 ] , [ :] )
1060
+ else
1061
+ AC_MSG_RESULT ( [ not found] )
1062
+ m4_default ( [ $4 ] , [ :] )
1063
+ fi
1064
+ else
1065
+ # No pkg-config, so obviously not found with pkg-config.
1066
+ AC_MSG_RESULT ( [ pkg-config not found] )
1067
+ m4_default ( [ $4 ] , [ :] )
1068
+ fi
1069
+ ] ) dnl PKG_CHECK_MODULE
1070
+
1071
+
1072
+ dnl PKG_CHECK_MODULE_STATIC(VARIABLE-PREFIX, MODULE, [ACTION-IF-FOUND],
1073
+ dnl [ACTION-IF-NOT-FOUND])
1074
+ dnl ---------------------------------------------------------------------
1075
+ dnl Since: 0.29
1076
+ dnl
1077
+ dnl Checks for existence of MODULE and gathers its build flags with
1078
+ dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
1079
+ dnl and VARIABLE-PREFIX_LIBS from --libs.
1080
+ AC_DEFUN ( [ PKG_CHECK_MODULE_STATIC] ,
1081
+ [
1082
+ _save_PKG_CONFIG=$PKG_CONFIG
1083
+ PKG_CONFIG="$PKG_CONFIG --static"
1084
+ PKG_CHECK_MODULE($@ )
1085
+ PKG_CONFIG=$_save_PKG_CONFIG[ ] dnl
1086
+ ] ) dnl PKG_CHECK_MODULE_STATIC
1087
+
1088
+
1089
+ dnl PKG_INSTALLDIR([DIRECTORY])
1090
+ dnl -------------------------
1091
+ dnl Since: 0.27
1092
+ dnl
1093
+ dnl Substitutes the variable pkgconfigdir as the location where a module
1094
+ dnl should install pkg-config .pc files. By default the directory is
1095
+ dnl $libdir/pkgconfig, but the default can be changed by passing
1096
+ dnl DIRECTORY. The user can override through the --with-pkgconfigdir
1097
+ dnl parameter.
1098
+ AC_DEFUN ( [ PKG_INSTALLDIR] ,
1099
+ [ m4_pushdef ( [ pkg_default] , [ m4_default ( [ $1 ] , [ '${libdir}/pkgconfig'] ) ] )
1100
+ m4_pushdef ( [ pkg_description] ,
1101
+ [ pkg-config installation directory @<:@ ] pkg_default [ @:>@ ] )
1102
+ AC_ARG_WITH ( [ pkgconfigdir] ,
1103
+ [ AS_HELP_STRING ( [ --with-pkgconfigdir] , pkg_description ) ] ,,
1104
+ [ with_pkgconfigdir=] pkg_default )
1105
+ AC_SUBST ( [ pkgconfigdir] , [ $with_pkgconfigdir] )
1106
+ m4_popdef ( [ pkg_default] )
1107
+ m4_popdef ( [ pkg_description] )
1108
+ ] ) dnl PKG_INSTALLDIR
1109
+
1110
+
1111
+ dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
1112
+ dnl --------------------------------
1113
+ dnl Since: 0.27
1114
+ dnl
1115
+ dnl Substitutes the variable noarch_pkgconfigdir as the location where a
1116
+ dnl module should install arch-independent pkg-config .pc files. By
1117
+ dnl default the directory is $datadir/pkgconfig, but the default can be
1118
+ dnl changed by passing DIRECTORY. The user can override through the
1119
+ dnl --with-noarch-pkgconfigdir parameter.
1120
+ AC_DEFUN ( [ PKG_NOARCH_INSTALLDIR] ,
1121
+ [ m4_pushdef ( [ pkg_default] , [ m4_default ( [ $1 ] , [ '${datadir}/pkgconfig'] ) ] )
1122
+ m4_pushdef ( [ pkg_description] ,
1123
+ [ pkg-config arch-independent installation directory @<:@ ] pkg_default [ @:>@ ] )
1124
+ AC_ARG_WITH ( [ noarch-pkgconfigdir] ,
1125
+ [ AS_HELP_STRING ( [ --with-noarch-pkgconfigdir] , pkg_description ) ] ,,
1126
+ [ with_noarch_pkgconfigdir=] pkg_default )
1127
+ AC_SUBST ( [ noarch_pkgconfigdir] , [ $with_noarch_pkgconfigdir] )
1128
+ m4_popdef ( [ pkg_default] )
1129
+ m4_popdef ( [ pkg_description] )
1130
+ ] ) dnl PKG_NOARCH_INSTALLDIR
1131
+
1132
+
1133
+ dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
1134
+ dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1135
+ dnl -------------------------------------------
1136
+ dnl Since: 0.28
1137
+ dnl
1138
+ dnl Retrieves the value of the pkg-config variable for the given module.
1139
+ AC_DEFUN ( [ PKG_CHECK_VAR] ,
1140
+ [
1141
+ AC_ARG_VAR ( [ $1 ] , [ value of $3 for $2 , overriding pkg-config] ) dnl
1142
+
1143
+ _PKG_CONFIG([ $1 ] , [ --variable="] [ $3 ] [ "] , [ $2 ] )
1144
+ AS_VAR_COPY ( [ $1 ] , [ pkg_cv_] [ $1 ] )
1145
+
1146
+ AS_VAR_IF ( [ $1 ] , [ ""] , [ $5 ] , [ $4 ] ) dnl
1147
+ ] ) dnl PKG_CHECK_VAR
0 commit comments