-
-
Notifications
You must be signed in to change notification settings - Fork 542
Use pkg-config to discover libnl-3 #1637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -961,14 +961,16 @@ case "$enable_delayacct" in | |||||
| enable_delayacct=no | ||||||
| else | ||||||
| old_CFLAGS="$CFLAGS" | ||||||
| CFLAGS="$CFLAGS -I/usr/include/libnl3" | ||||||
| htop_config_cflags=`$PKG_CONFIG --cflags libnl-3.0 2>/dev/null` || continue | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAICS, this should be
Suggested change
|
||||||
| CFLAGS="$CFLAGS $htop_config_cflags" | ||||||
| AC_CHECK_HEADERS([netlink/attr.h netlink/handlers.h netlink/msg.h], [enable_delayacct=yes], [enable_delayacct=no]) | ||||||
| CFLAGS="$old_CFLAGS" | ||||||
| fi | ||||||
| ;; | ||||||
| yes) | ||||||
| old_CFLAGS="$CFLAGS" | ||||||
| CFLAGS="$CFLAGS -I/usr/include/libnl3" | ||||||
| htop_config_cflags=`$PKG_CONFIG --cflags libnl-3.0 2>/dev/null` || continue | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here …
Suggested change
|
||||||
| CFLAGS="$CFLAGS $htop_config_cflags" | ||||||
| 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])]) | ||||||
| CFLAGS="$old_CFLAGS" | ||||||
| ;; | ||||||
|
|
@@ -978,7 +980,10 @@ case "$enable_delayacct" in | |||||
| esac | ||||||
| if test "$enable_delayacct" = yes; then | ||||||
| AC_DEFINE([HAVE_DELAYACCT], [1], [Define if delay accounting support should be enabled.]) | ||||||
| AM_CFLAGS="$AM_CFLAGS -I/usr/include/libnl3" | ||||||
| htop_config_cflags=`$PKG_CONFIG --cflags libnl-3.0 2>/dev/null` | ||||||
| AM_CFLAGS="$AM_CFLAGS $htop_config_cflags" | ||||||
| libdir_libnl=`$PKG_CONFIG --variable=libdir libnl-3.0 2>/dev/null` | ||||||
|
Comment on lines
+983
to
+985
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Failure to read these should result in a proper error message generated, or a warning notifying of a fallback to |
||||||
| AC_DEFINE_UNQUOTED([LIBDIR_LIBNL], ["$libdir_libnl"], [Path to the libnl-3 libraries]) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Um. A small question (maybe this is bike shedding). I would vote for
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other places like for hwloc use |
||||||
| fi | ||||||
| AM_CONDITIONAL([HAVE_DELAYACCT], [test "$enable_delayacct" = yes]) | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,17 +78,17 @@ static int load_libnl(void) { | |
| if (libnlHandle && libnlGenlHandle) | ||
| return 0; | ||
|
|
||
| libnlHandle = dlopen("libnl-3.so", RTLD_LAZY); | ||
| libnlHandle = dlopen(LIBDIR_LIBNL "/libnl-3.so", RTLD_LAZY); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed a slash is used here unconditionally. Normally for libraries it's better to load them from default search paths rather than forcing a directory prefix at compile time. I know the directory is grabbed from |
||
| if (!libnlHandle) { | ||
| libnlHandle = dlopen("libnl-3.so.200", RTLD_LAZY); | ||
| libnlHandle = dlopen(LIBDIR_LIBNL "/libnl-3.so.200", RTLD_LAZY); | ||
| if (!libnlHandle) { | ||
| goto dlfailure; | ||
| } | ||
| } | ||
|
|
||
| libnlGenlHandle = dlopen("libnl-genl-3.so", RTLD_LAZY); | ||
| libnlGenlHandle = dlopen(LIBDIR_LIBNL "/libnl-genl-3.so", RTLD_LAZY); | ||
| if (!libnlGenlHandle) { | ||
| libnlGenlHandle = dlopen("libnl-genl-3.so.200", RTLD_LAZY); | ||
| libnlGenlHandle = dlopen(LIBDIR_LIBNL "/libnl-genl-3.so.200", RTLD_LAZY); | ||
| if (!libnlGenlHandle) { | ||
| goto dlfailure; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish some quality improvements to the check:
pkg-configcall fails?PKG_CHECK_MODULESmacro as in the old code?PKG_CHECK_MODULES, then the variableLIBNL3_CFLAGSwould be defined automatically to allow that user override. Otherwise, maybe you can define it yourself? (AC_ARG_VAR([LIBNL3_CFLAGS], [C compiler flags for libnl3, overriding pkg-config]))There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case the
AC_CHECK_HEADERSfails like it would have done before sincehtop_config_cflagsis empty and the headers aren't found. ButPKG_CHECK_MODULESshould take care of that.I used the current style since that is used to discover
ncursesin the same file. I agree thatPKG_CHECK_MODULESis the better solution and will change the code accordingly.Yes, makes sense. I will add this. And also introduce the variable
LIBNL3_LIBDIR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason the
ncursesdetection code doesn't usePKG_CHECK_MODULESis thatncursesmay come with many different library names (as well as.pcfile names), so the code has to implement fallbacks.