@@ -1033,6 +1033,29 @@ case "$enable_capabilities" in
1033
1033
esac
1034
1034
1035
1035
1036
+ # $1: libnl-3 search path
1037
+ htop_try_link_libnl3 () {
1038
+ htop_save_LDFLAGS=$LDFLAGS
1039
+ htop_save_LIBS=$LIBS
1040
+
1041
+ LIBS="-lnl-3 $LIBS"
1042
+ if test "x$1" != x; then
1043
+ # New library path searched after what user has specified
1044
+ LDFLAGS="$LDFLAGS -L$1"
1045
+ fi
1046
+ AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ [
1047
+ /* struct nl_sock* nl_socket_alloc(void); */
1048
+ void* nl_socket_alloc(void);
1049
+ ] ] , [ [
1050
+ void* sock = nl_socket_alloc();
1051
+ ] ] ) ] ,
1052
+ [ htop_libnl3_link_succeed=yes] ,
1053
+ [ htop_libnl3_link_succeed=no] )
1054
+
1055
+ LDFLAGS=$htop_save_LDFLAGS
1056
+ LIBS=$htop_save_LIBS
1057
+ } # htop_try_link_libnl3
1058
+
1036
1059
AC_ARG_ENABLE ( [ delayacct] ,
1037
1060
[ AS_HELP_STRING ( [ --enable-delayacct] ,
1038
1061
[ enable Linux delay accounting support; requires libnl-3 and libnl-genl-3 @<:@ default=check@:>@ ] ) ] ,
@@ -1061,19 +1084,41 @@ case "$enable_delayacct" in
1061
1084
LIBNL3_CFLAGS="-I/usr/include/libnl3"
1062
1085
] )
1063
1086
1064
- old_CFLAGS=" $CFLAGS"
1087
+ htop_save_CFLAGS= $CFLAGS
1065
1088
# New include path searched after what user has specified
1066
1089
CFLAGS="$CFLAGS $LIBNL3_CFLAGS"
1067
1090
AC_CHECK_HEADERS ( [ netlink/attr.h netlink/handlers.h netlink/msg.h] ,
1068
1091
[ ] ,
1069
1092
[ if test "$enable_delayacct" = yes; then
1070
1093
AC_MSG_ERROR ( [ can not find required header files netlink/attr.h, netlink/handlers.h, netlink/msg.h] )
1071
1094
fi
1072
- enable_delayacct=no
1073
- break] )
1074
- CFLAGS="$old_CFLAGS"
1095
+ enable_delayacct=no] )
1096
+ CFLAGS=$htop_save_CFLAGS
1075
1097
1076
1098
if test "$enable_delayacct" != no; then
1099
+ AC_MSG_CHECKING ( [ the search path of libnl-3] )
1100
+
1101
+ htop_libnl3_link_succeed=no
1102
+ htop_try_link_libnl3 "$LIBNL3_LIBDIR"
1103
+ if test "$htop_libnl3_link_succeed$LIBNL3_LIBDIR" = no && test "x$PKG_CONFIG" != x; then
1104
+ LIBNL3_LIBDIR=`$PKG_CONFIG --variable=libdir libnl-3.0 2>/dev/null`
1105
+ if test "x$LIBNL3_LIBDIR" != x; then
1106
+ htop_try_link_libnl3 "$LIBNL3_LIBDIR"
1107
+ fi
1108
+ fi
1109
+
1110
+ if test "x$LIBNL3_LIBDIR" = x; then
1111
+ AC_MSG_RESULT ( [ (default)] )
1112
+ else
1113
+ # The path must end with a slash
1114
+ LIBNL3_LIBDIR=`echo "x$LIBNL3_LIBDIR" | sed 's/^x//; s|/*$|/|'`
1115
+ AC_MSG_RESULT ( [ $LIBNL3_LIBDIR] )
1116
+ fi
1117
+ AC_DEFINE_UNQUOTED ( [ LIBNL3_LIBDIR] , [ "$LIBNL3_LIBDIR"] , [ libnl-3 search path; use the default search paths if empty] )
1118
+ if test "$htop_libnl3_link_succeed" = no; then
1119
+ AC_MSG_WARN ( [ libnl-3 binary currently not present; will be needed in htop runtime for delay accounting support] )
1120
+ fi
1121
+
1077
1122
enable_delayacct=yes
1078
1123
fi
1079
1124
;;
0 commit comments