1 AC_INIT([LTO plugin for ld], 0.1,,[lto-plugin])
4 AM_INIT_AUTOMAKE([foreign no-dist])
7 [AS_HELP_STRING([--with-libiberty=PATH],
8 [specify the directory where to find libiberty [../libiberty]])],
9 [], with_libiberty=../libiberty)
10 AC_SUBST(with_libiberty)
11 AC_USE_SYSTEM_EXTENSIONS
14 ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_lto_plugin_warn_cflags])
16 # The plug-in depends on pthreads
19 # Check whether -static-libgcc is supported.
20 saved_LDFLAGS="$LDFLAGS"
21 LDFLAGS="$LDFLAGS -static-libgcc"
22 AC_MSG_CHECKING([for -static-libgcc])
23 AC_LINK_IFELSE([AC_LANG_SOURCE([
24 int main() {}])], [have_static_libgcc=yes], [have_static_libgcc=no])
25 AC_MSG_RESULT($have_static_libgcc);
26 LDFLAGS="$saved_LDFLAGS"
27 # Need -Wc to get it through libtool.
28 if test "x$have_static_libgcc" = xyes; then
29 ac_lto_plugin_ldflags="-Wc,-static-libgcc"
31 AC_SUBST(ac_lto_plugin_ldflags)
33 GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
34 AC_SUBST(CET_HOST_FLAGS)
36 if test x"$host_subdir" = x.; then
39 gcc_build_dir=../../$host_subdir/gcc
41 AC_SUBST(gcc_build_dir)
43 # Used for constructing correct paths for offload compilers.
45 real_target_noncanonical=${target_noncanonical}
46 if test x"$enable_as_accelerator_for" != x; then
47 accel_dir_suffix=/accel/${target_noncanonical}
48 real_target_noncanonical=${enable_as_accelerator_for}
50 AC_SUBST(accel_dir_suffix)
51 AC_SUBST(real_target_noncanonical)
53 # Determine what GCC version number to use in filesystem paths.
56 AC_MSG_CHECKING([whether symbol versioning is supported])
57 lto_plugin_use_symver=no
58 if test x$gcc_no_link = xyes; then
59 # If we cannot link, we cannot build shared libraries, so do not use
61 lto_plugin_use_symver=no
63 save_LDFLAGS="$LDFLAGS"
64 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
65 cat > conftest.map <<EOF
67 global: *foo*; bar; local: *;
70 AC_TRY_LINK([int foo;],[],[lto_plugin_use_symver=gnu],[lto_plugin_use_symver=no])
71 if test x$lto_plugin_use_symver = xno; then
74 LDFLAGS="$save_LDFLAGS"
75 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
76 # Sun ld cannot handle wildcards and treats all entries as undefined.
77 cat > conftest.map <<EOF
79 global: foo; local: *;
82 AC_TRY_LINK([int foo;],[],[lto_plugin_use_symver=sun],[lto_plugin_use_symver=no])
86 LDFLAGS="$save_LDFLAGS"
88 AC_MSG_RESULT($lto_plugin_use_symver)
89 AM_CONDITIONAL(LTO_PLUGIN_USE_SYMVER, [test "x$lto_plugin_use_symver" != xno])
90 AM_CONDITIONAL(LTO_PLUGIN_USE_SYMVER_GNU, [test "x$lto_plugin_use_symver" = xgnu])
91 AM_CONDITIONAL(LTO_PLUGIN_USE_SYMVER_SUN, [test "x$lto_plugin_use_symver" = xsun])
93 # Check for thread headers.
94 AC_CHECK_HEADER(pthread.h,
95 [AC_DEFINE(HAVE_PTHREAD_H, 1, [Define to 1 if pthread.h is present.])])
99 AC_SUBST(target_noncanonical)
103 AC_CONFIG_FILES(Makefile)
104 AC_CONFIG_HEADERS(config.h)