]> git.ipfire.org Git - thirdparty/gcc.git/blame - libssp/configure.ac
configure.ac: Check for Sun symbol versioning.
[thirdparty/gcc.git] / libssp / configure.ac
CommitLineData
77008252 1# Process this file with autoconf to produce a configure script, like so:
f2b5129c
MM
2#
3# aclocal -I .. -I ../config && autoconf && autoheader && automake
77008252 4
df58e648 5AC_PREREQ(2.64)
77008252
JJ
6AC_INIT(libssp, 1.0)
7AC_CONFIG_SRCDIR(ssp.c)
8AC_CANONICAL_SYSTEM
f2b5129c 9ACX_NONCANONICAL_TARGET
77008252 10
13917ae3 11AM_INIT_AUTOMAKE([no-dist])
77008252
JJ
12
13AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
14AC_ARG_ENABLE(version-specific-runtime-libs,
15[ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ],
16[case "$enableval" in
17 yes) version_specific_libs=yes ;;
18 no) version_specific_libs=no ;;
19 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
20 esac],
21[version_specific_libs=no])
22AC_MSG_RESULT($version_specific_libs)
23
24AM_MAINTAINER_MODE
be14fe72
JM
25
26GCC_NO_EXECUTABLES
77008252
JJ
27
28AM_ENABLE_MULTILIB(, ..)
29
30target_alias=${target_alias-$host_alias}
31AC_SUBST(target_alias)
32
33AC_CONFIG_HEADERS(config.h)
34
35AC_LANG_C
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.
40
41m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
42m4_define([_AC_ARG_VAR_PRECIOUS],[])
43AC_PROG_CC
1b3b24c2 44m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
77008252
JJ
45
46AC_SUBST(CFLAGS)
47
48if test "x$GCC" != "xyes"; then
49 AC_MSG_ERROR([libssp must be built with GCC])
50fi
51AC_PROG_CPP
52
53AC_MSG_CHECKING([whether -fstack-protector works])
54save_CFLAGS="$CFLAGS"
55CFLAGS="$CFLAGS -fstack-protector -Werror"
56AC_TRY_COMPILE([
57void __attribute__((noinline)) bar (char *x)
58{
59 __builtin_memset (x, 0, 64);
60}],[char buf[64]; bar (buf);],
61[AC_MSG_RESULT(yes)],
62[AC_MSG_RESULT(no)])
63CFLAGS="$save_CFLAGS"
64
65AC_MSG_CHECKING([whether hidden visibility is supported])
66AC_TRY_COMPILE([
67void __attribute__((visibility ("hidden"))) bar (void) {}],,
68[ssp_hidden=yes],[ssp_hidden=no])
69AC_MSG_RESULT($ssp_hidden)
70if test x$ssp_hidden = xyes; then
71 AC_DEFINE([HAVE_HIDDEN_VISIBILITY],[1],[__attribute__((visibility ("hidden"))) supported])
72fi
73
74AC_MSG_CHECKING([whether symbol versioning is supported])
be14fe72
JM
75if test x$gcc_no_link = xyes; then
76 # If we cannot link, we cannot build shared libraries, so do not use
77 # symbol versioning.
78 ssp_use_symver=no
79else
ca6d1176
RO
80 save_LDFLAGS="$LDFLAGS"
81 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
82 cat > conftest.map <<EOF
83FOO_1.0 {
84 global: *foo*; bar; local: *;
85};
86EOF
87 AC_TRY_LINK([int foo;],[],[ssp_use_symver=gnu],[ssp_use_symver=no])
88 if test x$ssp_use_symver = xno; then
89 LDFLAGS="$save_LDFLAGS"
90 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
91 # Sun ld cannot handle wildcards and treats all entries as undefined.
92 cat > conftest.map <<EOF
93FOO_1.0 {
94 global: foo; local: *;
95};
96EOF
97 AC_TRY_LINK([int foo;],[],[ssp_use_symver=sun],[ssp_use_symver=no])
98 fi
99 LDFLAGS="$save_LDFLAGS"
be14fe72 100fi
77008252 101AC_MSG_RESULT($ssp_use_symver)
ca6d1176
RO
102AM_CONDITIONAL(LIBSSP_USE_SYMVER, [test "x$ssp_use_symver" != xno])
103AM_CONDITIONAL(LIBSSP_USE_SYMVER_GNU, [test "x$ssp_use_symver" = xgnu])
104AM_CONDITIONAL(LIBSSP_USE_SYMVER_SUN, [test "x$ssp_use_symver" = xsun])
77008252 105
266aa805 106AC_CHECK_HEADERS(alloca.h malloc.h paths.h syslog.h string.h unistd.h fcntl.h stdio.h limits.h)
77008252 107
be14fe72
JM
108if test x$gcc_no_link = xyes; then
109 # Presume the ISO C functions are available; add target-specific
110 # configuration here if required.
111 AC_DEFINE(HAVE_STRNCPY)
112 AC_DEFINE(HAVE_STRNCAT)
113else
ca6d1176 114 AC_CHECK_FUNCS(memmove mempcpy strncpy strncat)
be14fe72 115fi
77008252
JJ
116
117AC_MSG_CHECKING([whether vsnprintf is usable])
118AC_RUN_IFELSE(AC_LANG_PROGRAM([
119#include <stdarg.h>
120#include <string.h>
121#include <stdio.h>
122int foo (char *buf, size_t n, const char *fmt, ...)
123{
124 va_list ap;
125 int ret;
126 va_start (ap, fmt);
127 ret = vsnprintf (buf, n, fmt, ap);
128 va_end (ap);
129 return ret;
130}],
131[char buf@<:@8@:>@; memset (buf, 'A', sizeof (buf));
132 if (foo (buf, 4, ".%s.", "CDEFG") != 7)
133 return 1;
134 return memcmp (buf, ".CD\0AAAA", sizeof (buf)) != 0;]),
135[ssp_have_usable_vsnprintf=define],
136[ssp_have_usable_vsnprintf=undef],
137[ssp_have_usable_vsnprintf=undef])
138if test "x$ssp_have_usable_vsnprintf" = xdefine; then
139 AC_MSG_RESULT(yes)
140 AC_DEFINE([HAVE_USABLE_VSNPRINTF],[1],[vsnprintf is present and works])
141else
142 AC_MSG_RESULT(no)
143fi
144AC_SUBST(ssp_have_usable_vsnprintf)
145
146AM_PROG_LIBTOOL
147AC_SUBST(enable_shared)
148AC_SUBST(enable_static)
149
150# Calculate toolexeclibdir
151# Also toolexecdir, though it's only used in toolexeclibdir
152case ${version_specific_libs} in
153 yes)
154 # Need the gcc compiler version to know where to install libraries
155 # and header files if --enable-version-specific-runtime-libs option
156 # is selected.
157 toolexecdir='$(libdir)/gcc/$(target_alias)'
158 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
159 ;;
160 no)
161 if test -n "$with_cross_host" &&
162 test x"$with_cross_host" != x"no"; then
163 # Install a library built with a cross compiler in tooldir, not libdir.
164 toolexecdir='$(exec_prefix)/$(target_alias)'
165 toolexeclibdir='$(toolexecdir)/lib'
166 else
167 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
168 toolexeclibdir='$(libdir)'
169 fi
170 multi_os_directory=`$CC -print-multi-os-directory`
171 case $multi_os_directory in
172 .) ;; # Avoid trailing /.
173 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
174 esac
175 ;;
176esac
177AC_SUBST(toolexecdir)
178AC_SUBST(toolexeclibdir)
179
180if test ${multilib} = yes; then
181 multilib_arg="--enable-multilib"
182else
183 multilib_arg=
184fi
185
186AC_CONFIG_FILES([Makefile ssp/ssp.h])
187AC_OUTPUT