Debian Codegraph @

build-aux/m4/zw_ld_wrap.m4

raw
1 dnl Written by Zack Weinberg <zackw at panix.com> in 2018.
2 dnl To the extent possible under law, Zack Weinberg has waived all
3 dnl copyright and related or neighboring rights to this work.
4 dnl
5 dnl See https://creativecommons.org/publicdomain/zero/1.0/ for further
6 dnl details.
7 dnl
8 dnl Find out whether ld --wrap is supported.
9 AC_DEFUN([zw_PROG_LD_WRAP],
10 [AC_REQUIRE([AC_PROG_CC])
11 AC_CACHE_CHECK([for ld --wrap], [zw_cv_prog_ld_wrap],
12 [save_LDFLAGS="$LDFLAGS"
13 save_LIBS="$LIBS"
14 LDFLAGS=""
15 LIBS=""
16 AC_COMPILE_IFELSE(
17 [AC_LANG_SOURCE([[
18 extern void bar(void);
19 void foo(void) { bar(); }
20 ]])],
21 [mv conftest.$OBJEXT conftest2.$OBJEXT
22 LDFLAGS="-Wl,--wrap,bar"
23 LIBS="conftest2.$OBJEXT"
24 AC_LINK_IFELSE(
25 [AC_LANG_PROGRAM([[
26 extern void foo(void);
27 void __wrap_bar(void) {}
28 ]], [[
29 foo();
30 ]])],
31 [zw_cv_prog_ld_wrap=yes],
32 [zw_cv_prog_ld_wrap=no])
33 rm -f conftest2.$OBJEXT
34 ],
35 [zw_cv_prog_ld_wrap=no])
36 LDFLAGS="$save_LDFLAGS"
37 LIBS="$save_LIBS"])
38 if test x$zw_cv_prog_ld_wrap = xyes; then
39 have_ld_wrap=yes
40 AC_DEFINE([HAVE_LD_WRAP], 1,
41 [Define to 1 if -Wl,--wrap,SYMBOL can be used to intercept
42 calls to SYMBOL at link time.])
43 else
44 have_ld_wrap=no
45 fi
46 AM_CONDITIONAL([HAVE_LD_WRAP], [test $have_ld_wrap = yes])
47 ])