@@ -1015,39 +1015,101 @@ case "$enable_capabilities" in
1015
1015
esac
1016
1016
1017
1017
1018
+ # $1: libnl-3 search path
1019
+ htop_try_link_libnl3 () {
1020
+ htop_save_LDFLAGS=$LDFLAGS
1021
+ htop_save_LIBS=$LIBS
1022
+
1023
+ LIBS="-lnl-3 $LIBS"
1024
+ if test "x$1" != x; then
1025
+ # New library path searched after what user has specified
1026
+ LDFLAGS="$LDFLAGS -L$1"
1027
+ fi
1028
+ AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ [
1029
+ /* struct nl_sock* nl_socket_alloc(void); */
1030
+ void* nl_socket_alloc(void);
1031
+ ] ] , [ [
1032
+ void* sock = nl_socket_alloc();
1033
+ ] ] ) ] ,
1034
+ [ htop_libnl3_link_succeed=yes] ,
1035
+ [ htop_libnl3_link_succeed=no] )
1036
+
1037
+ LDFLAGS=$htop_save_LDFLAGS
1038
+ LIBS=$htop_save_LIBS
1039
+ } # htop_try_link_libnl3
1040
+
1018
1041
AC_ARG_ENABLE ( [ delayacct] ,
1019
1042
[ AS_HELP_STRING ( [ --enable-delayacct] ,
1020
- [ enable Linux delay accounting support; requires pkg-config, libnl-3 and libnl-genl-3 @<:@ default=check@:>@ ] ) ] ,
1043
+ [ enable Linux delay accounting support; requires libnl-3 and libnl-genl-3 @<:@ default=check@:>@ ] ) ] ,
1021
1044
[ ] ,
1022
1045
[ enable_delayacct=check] )
1023
1046
case "$enable_delayacct" in
1024
- no)
1047
+ no|yes )
1025
1048
;;
1026
1049
check)
1027
1050
if test "$my_htop_platform" != linux; then
1028
1051
enable_delayacct=no
1029
1052
elif test "$enable_static" = yes; then
1030
1053
enable_delayacct=no
1031
- else
1032
- old_CFLAGS="$CFLAGS"
1033
- CFLAGS="$CFLAGS -I/usr/include/libnl3"
1034
- AC_CHECK_HEADERS ( [ netlink/attr.h netlink/handlers.h netlink/msg.h] , [ enable_delayacct=yes] , [ enable_delayacct=no] )
1035
- CFLAGS="$old_CFLAGS"
1036
1054
fi
1037
1055
;;
1038
- yes)
1039
- old_CFLAGS="$CFLAGS"
1040
- CFLAGS="$CFLAGS -I/usr/include/libnl3"
1041
- AC_CHECK_HEADERS ( [ netlink/attr.h netlink/handlers.h netlink/msg.h] , [ ] , [ AC_MSG_ERROR ( [ can not find required header files netlink/attr.h, netlink/handlers.h, netlink/msg.h] ) ] )
1042
- CFLAGS="$old_CFLAGS"
1043
- ;;
1044
1056
*)
1045
1057
AC_MSG_ERROR ( [ bad value '$enable_delayacct' for --enable-delayacct] )
1046
1058
;;
1047
1059
esac
1060
+
1061
+ case "$enable_delayacct" in
1062
+ check|yes)
1063
+ if test "x${LIBNL3_CFLAGS+y}" = x; then
1064
+ m4_ifdef ( [ PKG_PROG_PKG_CONFIG] , [
1065
+ PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [ ] , [ LIBNL3_CFLAGS="-I/usr/include/libnl3"] )
1066
+ ] , [
1067
+ LIBNL3_CFLAGS="-I/usr/include/libnl3"
1068
+ ] )
1069
+ fi
1070
+
1071
+ htop_save_CFLAGS=$CFLAGS
1072
+ # New include path searched after what user has specified
1073
+ CFLAGS="$CFLAGS $LIBNL3_CFLAGS"
1074
+ AC_CHECK_HEADERS ( [ netlink/attr.h netlink/handlers.h netlink/msg.h] ,
1075
+ [ ] ,
1076
+ [ if test "$enable_delayacct" = yes; then
1077
+ AC_MSG_ERROR ( [ can not find required header files netlink/attr.h, netlink/handlers.h, netlink/msg.h] )
1078
+ fi
1079
+ enable_delayacct=no] )
1080
+ CFLAGS=$htop_save_CFLAGS
1081
+
1082
+ if test "$enable_delayacct" != no; then
1083
+ AC_MSG_CHECKING ( [ the search path of libnl-3] )
1084
+
1085
+ htop_libnl3_link_succeed=no
1086
+ htop_try_link_libnl3 "$LIBNL3_LIBDIR"
1087
+ if test "$htop_libnl3_link_succeed${LIBNL3_LIBDIR+y}" = no && test "x$PKG_CONFIG" != x; then
1088
+ LIBNL3_LIBDIR=`$PKG_CONFIG --variable=libdir libnl-3.0 2>/dev/null`
1089
+ if test "x$LIBNL3_LIBDIR" != x; then
1090
+ htop_try_link_libnl3 "$LIBNL3_LIBDIR"
1091
+ fi
1092
+ fi
1093
+
1094
+ if test "x$LIBNL3_LIBDIR" = x; then
1095
+ AC_MSG_RESULT ( [ (default)] )
1096
+ else
1097
+ # The path must end with a slash
1098
+ LIBNL3_LIBDIR=`echo "x$LIBNL3_LIBDIR" | sed 's/^x//; s|/*$|/|'`
1099
+ AC_MSG_RESULT ( [ $LIBNL3_LIBDIR] )
1100
+ fi
1101
+ AC_DEFINE_UNQUOTED ( [ LIBNL3_LIBDIR] , [ "$LIBNL3_LIBDIR"] , [ libnl-3 search path; use the default search paths if empty] )
1102
+ if test "$htop_libnl3_link_succeed" = no; then
1103
+ AC_MSG_WARN ( [ libnl-3 binary currently not present; will be needed in htop runtime for delay accounting support] )
1104
+ fi
1105
+
1106
+ enable_delayacct=yes
1107
+ fi
1108
+ ;;
1109
+ esac
1048
1110
if test "$enable_delayacct" = yes; then
1049
1111
AC_DEFINE ( [ HAVE_DELAYACCT] , [ 1] , [ Define if delay accounting support should be enabled.] )
1050
- AM_CFLAGS="$AM_CFLAGS -I/usr/include/libnl3 "
1112
+ AM_CFLAGS="$AM_CFLAGS $LIBNL3_CFLAGS "
1051
1113
fi
1052
1114
AM_CONDITIONAL([ HAVE_DELAYACCT] , [ test "$enable_delayacct" = yes] )
1053
1115
0 commit comments