1 # Process this file with autoconf to produce a configure script, like so:
3 # aclocal -I .. -I ../config && autoconf && autoheader && automake
7 AC_CONFIG_SRCDIR(ssp.c)
9 ACX_NONCANONICAL_TARGET
11 AM_INIT_AUTOMAKE([no-dist])
13 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
14 AC_ARG_ENABLE(version-specific-runtime-libs,
15 [ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ],
17 yes) version_specific_libs=yes ;;
18 no) version_specific_libs=no ;;
19 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
21 [version_specific_libs=no])
22 AC_MSG_RESULT($version_specific_libs)
28 AM_ENABLE_MULTILIB(, ..)
30 target_alias=${target_alias-$host_alias}
31 AC_SUBST(target_alias)
33 AC_CONFIG_HEADERS(config.h)
36 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
37 # We must force CC to /not/ be precious variables; otherwise
38 # the wrong, non-multilib-adjusted value will be used in multilibs.
39 # As a side effect, we have to subst CFLAGS ourselves.
41 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
42 m4_define([_AC_ARG_VAR_PRECIOUS],[])
44 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
48 if test "x$GCC" != "xyes"; then
49 AC_MSG_ERROR([libssp must be built with GCC])
53 AC_MSG_CHECKING([whether -fstack-protector works])
55 CFLAGS="$CFLAGS -fstack-protector -Werror"
57 void __attribute__((noinline)) bar (char *x)
59 __builtin_memset (x, 0, 64);
60 }],[char buf[64]; bar (buf);],
65 AC_MSG_CHECKING([whether hidden visibility is supported])
67 void __attribute__((visibility ("hidden"))) bar (void) {}],,
68 [ssp_hidden=yes],[ssp_hidden=no])
69 AC_MSG_RESULT($ssp_hidden)
70 if test x$ssp_hidden = xyes; then
71 AC_DEFINE([HAVE_HIDDEN_VISIBILITY],[1],[__attribute__((visibility ("hidden"))) supported])
74 AC_MSG_CHECKING([whether symbol versioning is supported])
75 if test x$gcc_no_link = xyes; then
76 # If we cannot link, we cannot build shared libraries, so do not use
80 save_LDFLAGS="$LDFLAGS"
81 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
82 cat > conftest.map <<EOF
84 global: *foo*; bar; local: *;
87 AC_TRY_LINK([int foo;],[],[ssp_use_symver=gnu],[ssp_use_symver=no])
88 if test x$ssp_use_symver = xno; then
91 LDFLAGS="$save_LDFLAGS"
92 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
93 # Sun ld cannot handle wildcards and treats all entries as undefined.
94 cat > conftest.map <<EOF
96 global: foo; local: *;
99 AC_TRY_LINK([int foo;],[],[ssp_use_symver=sun],[ssp_use_symver=no])
103 LDFLAGS="$save_LDFLAGS"
105 AC_MSG_RESULT($ssp_use_symver)
106 AM_CONDITIONAL(LIBSSP_USE_SYMVER, [test "x$ssp_use_symver" != xno])
107 AM_CONDITIONAL(LIBSSP_USE_SYMVER_GNU, [test "x$ssp_use_symver" = xgnu])
108 AM_CONDITIONAL(LIBSSP_USE_SYMVER_SUN, [test "x$ssp_use_symver" = xsun])
110 AC_CHECK_HEADERS(alloca.h malloc.h paths.h syslog.h string.h unistd.h fcntl.h stdio.h limits.h)
112 if test x$gcc_no_link = xyes; then
113 # Presume the ISO C functions are available; add target-specific
114 # configuration here if required.
115 AC_DEFINE(HAVE_STRNCPY)
116 AC_DEFINE(HAVE_STRNCAT)
118 AC_CHECK_FUNCS(memmove mempcpy strncpy strncat)
121 AC_MSG_CHECKING([whether vsnprintf is usable])
122 AC_RUN_IFELSE(AC_LANG_PROGRAM([
126 int foo (char *buf, size_t n, const char *fmt, ...)
131 ret = vsnprintf (buf, n, fmt, ap);
135 [char buf@<:@8@:>@; memset (buf, 'A', sizeof (buf));
136 if (foo (buf, 4, ".%s.", "CDEFG") != 7)
138 return memcmp (buf, ".CD\0AAAA", sizeof (buf)) != 0;]),
139 [ssp_have_usable_vsnprintf=define],
140 [ssp_have_usable_vsnprintf=undef],
141 [ssp_have_usable_vsnprintf=undef])
142 if test "x$ssp_have_usable_vsnprintf" = xdefine; then
144 AC_DEFINE([HAVE_USABLE_VSNPRINTF],[1],[vsnprintf is present and works])
148 AC_SUBST(ssp_have_usable_vsnprintf)
151 AC_SUBST(enable_shared)
152 AC_SUBST(enable_static)
154 # Calculate toolexeclibdir
155 # Also toolexecdir, though it's only used in toolexeclibdir
156 case ${version_specific_libs} in
158 # Need the gcc compiler version to know where to install libraries
159 # and header files if --enable-version-specific-runtime-libs option
161 toolexecdir='$(libdir)/gcc/$(target_alias)'
162 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
165 if test -n "$with_cross_host" &&
166 test x"$with_cross_host" != x"no"; then
167 # Install a library built with a cross compiler in tooldir, not libdir.
168 toolexecdir='$(exec_prefix)/$(target_alias)'
169 toolexeclibdir='$(toolexecdir)/lib'
171 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
172 toolexeclibdir='$(libdir)'
174 multi_os_directory=`$CC -print-multi-os-directory`
175 case $multi_os_directory in
176 .) ;; # Avoid trailing /.
177 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
181 AC_SUBST(toolexecdir)
182 AC_SUBST(toolexeclibdir)
184 if test ${multilib} = yes; then
185 multilib_arg="--enable-multilib"
190 AC_CONFIG_FILES([Makefile ssp/ssp.h])