configure.ac 5.7 KB

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