Skip to content

Commit

Permalink
Build: configure: Use AC_SEARCH_LIBS for basic libraries.
Browse files Browse the repository at this point in the history
* Get rid of the check for getopt_long, which is no longer used
  anywhere.

* Use AC_SEARCH_LIBS for finding libdl, but because that macro always
  adds the result of the test to $LIBS, we have to use a trick: save
  $LIBS, search for libdl, set $DL_LIBS to the result, and then restore
  $LIBS.

* Change LIBADD_DL to DL_LIBS for future consistency.

* Get rid of the "Where is dlopen?" block.  I think AC_SEARCH_LIBS makes
  this unnecessary.

* libcrmcommon links against socket and is used by everything, so we can
  just simply call AC_SEARCH_LIBS for it.

Related T876
  • Loading branch information
clumens committed Oct 17, 2024
1 parent e843252 commit 60cc1fd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
23 changes: 10 additions & 13 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1007,11 +1007,17 @@ AC_SUBST([GETOPT_PATH])
dnl ===============================================
dnl Libraries
dnl ===============================================
AC_CHECK_LIB(socket, socket) dnl -lsocket
AC_CHECK_LIB(c, dlopen) dnl if dlopen is in libc...
AC_CHECK_LIB(dl, dlopen) dnl -ldl (for Linux)
AC_SEARCH_LIBS([socket], [socket])

save_LIBS="$LIBS"
DL_LIBS=""
LIBS=""
AC_SEARCH_LIBS([dlopen], [dl],
[test "$ac_cv_search_dlopen" = "none required" || DL_LIBS="$LIBS"])
AC_SUBST(DL_LIBS)
LIBS="$save_LIBS"

AC_CHECK_LIB(rt, sched_getscheduler) dnl -lrt (for Tru64)
AC_CHECK_LIB(gnugetopt, getopt_long) dnl -lgnugetopt ( if available )
AC_CHECK_LIB(pam, pam_start) dnl -lpam (if available)

PKG_CHECK_MODULES([UUID], [uuid],
Expand All @@ -1032,15 +1038,6 @@ PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.42.0],
# Check whether high-resolution sleep function is available
AC_CHECK_FUNCS([nanosleep usleep])

#
# Where is dlopen?
#
AS_IF([test x"$ac_cv_lib_c_dlopen" = x"yes"],
[LIBADD_DL=""],
[test x"$ac_cv_lib_dl_dlopen" = x"yes"],
[LIBADD_DL=-ldl],
[LIBADD_DL=${lt_cv_dlopen_libs}])

PKG_CHECK_MODULES(LIBXML2, [libxml-2.0 >= 2.9.2],
[CPPFLAGS="${CPPFLAGS} ${LIBXML2_CFLAGS}"
LIBS="${LIBS} ${LIBXML2_LIBS}"])
Expand Down
4 changes: 1 addition & 3 deletions lib/common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ libcrmcommon_la_LDFLAGS = -version-info 47:1:13
libcrmcommon_la_CFLAGS = $(CFLAGS_HARDENED_LIB)
libcrmcommon_la_LDFLAGS += $(LDFLAGS_HARDENED_LIB)

libcrmcommon_la_LIBADD = @LIBADD_DL@

# If configured with --with-profiling or --with-coverage, BUILD_PROFILING will
# be set and -fno-builtin will be added to the CFLAGS. However, libcrmcommon
# uses the fabs() function which is normally supplied by gcc as one of its
# builtins. Therefore we need to explicitly link against libm here or the
# tests won't link.
if BUILD_PROFILING
libcrmcommon_la_LIBADD += -lm
libcrmcommon_la_LIBADD = -lm
endif

## Library sources (*must* use += format for bumplibs)
Expand Down
1 change: 1 addition & 0 deletions lib/fencing/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ libstonithd_la_LDFLAGS += $(LDFLAGS_HARDENED_LIB)

libstonithd_la_LIBADD = $(top_builddir)/lib/services/libcrmservice.la
libstonithd_la_LIBADD += $(top_builddir)/lib/common/libcrmcommon.la
libstonithd_la_LIBADD += @DL_LIBS@

## Library sources (*must* use += format for bumplibs)
libstonithd_la_SOURCES = st_actions.c
Expand Down
2 changes: 1 addition & 1 deletion lib/pacemaker-fencing.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Requires.private: glib-2.0 libxml-2.0
Conflicts:
Cflags: -I${includedir}
Libs: -L${libdir} -l${sub}
Libs.private:
Libs.private: @DL_LIBS@
2 changes: 1 addition & 1 deletion lib/pacemaker.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ Requires.private: glib-2.0 libxslt libxml-2.0 uuid gnutls
Conflicts:
Cflags: -I${includedir}
Libs: -L${libdir} -l${sub}
Libs.private: @LIBADD_DL@ -lbz2
Libs.private: -lbz2

0 comments on commit 60cc1fd

Please sign in to comment.