build: do not hardcode -lrt
Depending on libc implementation, various -lrt functions can be implemented either in -lc or in -lrt. For example, starting with glibc-2.17 the clock_* suite of functions is available directly in -lc. Check whether clock_* and mq_* suites of functions are provided by -lrt or by the main C library, do not link with -lrt unnecessarily. This change affects only tests yet, but this is going to be more important as soon as strace starts using clock_gettime. * configure.ac (AC_SEARCH_LIBS): Check for clock_gettime and mq_open in -lrt. (AC_SUBST): Add clock_LIBS and mq_LIBS. * tests/Makefile.am (mq_LDADD): Replace -lrt with $(mq_LIBS). (threads_execve_LDADD, times_LDADD): Replace -lrt with $(clock_LIBS).
This commit is contained in:
parent
a51d9f9647
commit
85b35818db
19
configure.ac
19
configure.ac
@ -809,6 +809,25 @@ if test "x$ac_cv_lib_dl_dladdr" = xyes; then
|
||||
fi
|
||||
AC_SUBST(dl_LIBS)
|
||||
|
||||
saved_LIBS="$LIBS"
|
||||
AC_SEARCH_LIBS([clock_gettime], [rt])
|
||||
LIBS="$saved_LIBS"
|
||||
case "$ac_cv_search_clock_gettime" in
|
||||
no) AC_MSG_FAILURE([failed to find clock_gettime]) ;;
|
||||
-l*) clock_LIBS="$ac_cv_search_clock_gettime" ;;
|
||||
*) clock_LIBS= ;;
|
||||
esac
|
||||
AC_SUBST(clock_LIBS)
|
||||
|
||||
saved_LIBS="$LIBS"
|
||||
AC_SEARCH_LIBS([mq_open], [rt])
|
||||
LIBS="$saved_LIBS"
|
||||
case "$ac_cv_search_mq_open" in
|
||||
-l*) mq_LIBS="$ac_cv_search_mq_open" ;;
|
||||
*) mq_LIBS= ;;
|
||||
esac
|
||||
AC_SUBST(mq_LIBS)
|
||||
|
||||
AC_PATH_PROG([PERL], [perl])
|
||||
|
||||
AC_CHECK_TOOL([READELF], [readelf])
|
||||
|
@ -172,7 +172,7 @@ fstatat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
|
||||
ftruncate64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
|
||||
lstat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
|
||||
mmap64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
|
||||
mq_LDADD = -lrt $(LDADD)
|
||||
mq_LDADD = $(mq_LIBS) $(LDADD)
|
||||
newfstatat_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
|
||||
pc_LDADD = $(dl_LIBS) $(LDADD)
|
||||
pread64_pwrite64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
|
||||
@ -181,8 +181,8 @@ preadv_pwritev_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
|
||||
pwritev_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
|
||||
stat64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
|
||||
statfs_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
|
||||
threads_execve_LDADD = -lrt -lpthread $(LDADD)
|
||||
times_LDADD = -lrt $(LDADD)
|
||||
threads_execve_LDADD = -lpthread $(clock_LIBS) $(LDADD)
|
||||
times_LDADD = $(clock_LIBS) $(LDADD)
|
||||
truncate64_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
|
||||
uio_CPPFLAGS = $(AM_CPPFLAGS) -D_FILE_OFFSET_BITS=64
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user