1# Process this file with autoconf to produce a configure script, like so: 2# 3# aclocal -I .. -I ../config && autoconf && autoheader && automake 4 5AC_PREREQ(2.64) 6AC_INIT(libssp, 1.0) 7AC_CONFIG_SRCDIR(ssp.c) 8AC_CANONICAL_SYSTEM 9ACX_NONCANONICAL_TARGET 10 11AM_INIT_AUTOMAKE([no-dist]) 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 25 26GCC_NO_EXECUTABLES 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 44m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) 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 65# Add CET specific flags if CET is enabled 66GCC_CET_FLAGS(CET_FLAGS) 67XCFLAGS="$XCFLAGS $CET_FLAGS" 68AC_SUBST(XCFLAGS) 69 70AC_MSG_CHECKING([whether hidden visibility is supported]) 71AC_TRY_COMPILE([ 72void __attribute__((visibility ("hidden"))) bar (void) {}],, 73[ssp_hidden=yes],[ssp_hidden=no]) 74AC_MSG_RESULT($ssp_hidden) 75if test x$ssp_hidden = xyes; then 76 AC_DEFINE([HAVE_HIDDEN_VISIBILITY],[1],[__attribute__((visibility ("hidden"))) supported]) 77fi 78 79AC_MSG_CHECKING([whether symbol versioning is supported]) 80AC_ARG_ENABLE(symvers, 81AS_HELP_STRING([--disable-symvers], 82 [disable symbol versioning for libssp]), 83ssp_use_symver=$enableval, 84ssp_use_symver=yes) 85if test "x$ssp_use_symver" != xno; then 86 if test x$gcc_no_link = xyes; then 87 # If we cannot link, we cannot build shared libraries, so do not use 88 # symbol versioning. 89 ssp_use_symver=no 90 else 91 save_LDFLAGS="$LDFLAGS" 92 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map" 93 cat > conftest.map <<EOF 94FOO_1.0 { 95 global: *foo*; bar; local: *; 96}; 97EOF 98 AC_TRY_LINK([int foo;],[],[ssp_use_symver=gnu],[ssp_use_symver=no]) 99 if test x$ssp_use_symver = xno; then 100 case "$target_os" in 101 solaris2*) 102 LDFLAGS="$save_LDFLAGS" 103 LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map" 104 # Sun ld cannot handle wildcards and treats all entries as undefined. 105 cat > conftest.map <<EOF 106FOO_1.0 { 107 global: foo; local: *; 108}; 109EOF 110 AC_TRY_LINK([int foo;],[],[ssp_use_symver=sun],[ssp_use_symver=no]) 111 ;; 112 esac 113 fi 114 LDFLAGS="$save_LDFLAGS" 115 fi 116fi 117AC_MSG_RESULT($ssp_use_symver) 118AM_CONDITIONAL(LIBSSP_USE_SYMVER, [test "x$ssp_use_symver" != xno]) 119AM_CONDITIONAL(LIBSSP_USE_SYMVER_GNU, [test "x$ssp_use_symver" = xgnu]) 120AM_CONDITIONAL(LIBSSP_USE_SYMVER_SUN, [test "x$ssp_use_symver" = xsun]) 121 122AC_CHECK_HEADERS(alloca.h malloc.h paths.h syslog.h string.h unistd.h fcntl.h stdio.h limits.h) 123 124if test x$gcc_no_link = xyes; then 125 # Presume the ISO C functions are available; add target-specific 126 # configuration here if required. 127 AC_DEFINE(HAVE_STRNCPY) 128 AC_DEFINE(HAVE_STRNCAT) 129else 130 AC_CHECK_FUNCS(memmove mempcpy strncpy strncat) 131fi 132 133AC_MSG_CHECKING([whether vsnprintf is usable]) 134AC_RUN_IFELSE(AC_LANG_PROGRAM([ 135#include <stdarg.h> 136#include <string.h> 137#include <stdio.h> 138int foo (char *buf, size_t n, const char *fmt, ...) 139{ 140 va_list ap; 141 int ret; 142 va_start (ap, fmt); 143 ret = vsnprintf (buf, n, fmt, ap); 144 va_end (ap); 145 return ret; 146}], 147[char buf@<:@8@:>@; memset (buf, 'A', sizeof (buf)); 148 if (foo (buf, 4, ".%s.", "CDEFG") != 7) 149 return 1; 150 return memcmp (buf, ".CD\0AAAA", sizeof (buf)) != 0;]), 151[ssp_have_usable_vsnprintf=define], 152[ssp_have_usable_vsnprintf=undef], 153[ssp_have_usable_vsnprintf=undef]) 154if test "x$ssp_have_usable_vsnprintf" = xdefine; then 155 AC_MSG_RESULT(yes) 156 AC_DEFINE([HAVE_USABLE_VSNPRINTF],[1],[vsnprintf is present and works]) 157else 158 AC_MSG_RESULT(no) 159fi 160AC_SUBST(ssp_have_usable_vsnprintf) 161 162AM_PROG_LIBTOOL 163ACX_LT_HOST_FLAGS 164AC_SUBST(enable_shared) 165AC_SUBST(enable_static) 166 167# Calculate toolexeclibdir 168# Also toolexecdir, though it's only used in toolexeclibdir 169case ${version_specific_libs} in 170 yes) 171 # Need the gcc compiler version to know where to install libraries 172 # and header files if --enable-version-specific-runtime-libs option 173 # is selected. 174 toolexecdir='$(libdir)/gcc/$(target_alias)' 175 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)' 176 ;; 177 no) 178 if test -n "$with_cross_host" && 179 test x"$with_cross_host" != x"no"; then 180 # Install a library built with a cross compiler in tooldir, not libdir. 181 toolexecdir='$(exec_prefix)/$(target_alias)' 182 toolexeclibdir='$(toolexecdir)/lib' 183 else 184 toolexecdir='$(libdir)/gcc-lib/$(target_alias)' 185 toolexeclibdir='$(libdir)' 186 fi 187 multi_os_directory=`$CC -print-multi-os-directory` 188 case $multi_os_directory in 189 .) ;; # Avoid trailing /. 190 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; 191 esac 192 ;; 193esac 194AC_SUBST(toolexecdir) 195AC_SUBST(toolexeclibdir) 196 197if test ${multilib} = yes; then 198 multilib_arg="--enable-multilib" 199else 200 multilib_arg= 201fi 202 203# Determine what GCC version number to use in filesystem paths. 204GCC_BASE_VER 205 206AC_CONFIG_FILES([Makefile ssp/ssp.h]) 207AC_OUTPUT 208