configure.ac 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. # Process this file with autoconf to produce a configure script.
  2. # Copyright (C) 2006-2022 Free Software Foundation, Inc.
  3. #
  4. # GCC is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 3, or (at your option)
  7. # any later version.
  8. #
  9. # GCC is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with GCC; see the file COPYING3. If not see
  16. # <http://www.gnu.org/licenses/>.
  17. # This requires that you have your environment set-up to use explicit
  18. # versions of automake and autoconf.
  19. #
  20. # export ACLOCAL=/usr/bin/aclocal-1.15
  21. # export AUTOMAKE=/usr/bin/automake-1.15
  22. # export AUTOM4TE=/usr/bin/autom4te2.69
  23. # export AUTOCONF=/usr/bin/autoconf2.69
  24. #
  25. # autoreconf2.69
  26. #
  27. AC_INIT(package-unused, version-unused,, libphobos)
  28. AC_CONFIG_SRCDIR(libdruntime/gcc/attribute.d)
  29. AC_CONFIG_HEADERS(config.h)
  30. AM_ENABLE_MULTILIB(, ..)
  31. AC_CANONICAL_SYSTEM
  32. AC_USE_SYSTEM_EXTENSIONS
  33. target_alias=${target_alias-$target}
  34. AC_SUBST(target_alias)
  35. # 1.11.1: Require that version of automake.
  36. # foreign: Don't require README, INSTALL, NEWS, etc.
  37. # no-define: Don't define PACKAGE and VERSION.
  38. # no-dependencies: Don't generate automatic dependencies.
  39. # (because it breaks when using bootstrap-lean, since some of the
  40. # headers are gone at "make install" time).
  41. # subdir-objects: Build objects in sub-directories.
  42. # -Wall: Issue all automake warnings.
  43. # -Wno-portability: Don't warn about constructs supported by GNU make.
  44. # (because GCC requires GNU make anyhow).
  45. # -Wno-override: Overrides used in testsuite.
  46. AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies subdir-objects -Wall -Wno-portability -Wno-override])
  47. m4_rename([_AC_ARG_VAR_PRECIOUS],[glibd_PRECIOUS])
  48. m4_define([_AC_ARG_VAR_PRECIOUS],[])
  49. AM_PROG_AS
  50. AC_PROG_CC
  51. AC_PROG_GDC
  52. WITH_LOCAL_DRUNTIME([GDC_CHECK_COMPILE], [])
  53. m4_rename_force([glibd_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
  54. AC_SUBST(CFLAGS)
  55. AM_MAINTAINER_MODE
  56. AC_PROG_RANLIB
  57. AC_PROG_INSTALL
  58. AC_PROG_MAKE_SET
  59. # Add CET specific flags if CET is enabled
  60. GCC_CET_FLAGS(CET_FLAGS)
  61. AC_SUBST(CET_FLAGS)
  62. # To ensure that runtime code for CET is compiled in, add in D version flags.
  63. AS_IF([test x$enable_cet = xyes], [
  64. CET_DFLAGS="$CET_FLAGS -fversion=CET"
  65. DCFG_ENABLE_CET=true
  66. ], [
  67. CET_DFLAGS=
  68. DCFG_ENABLE_CET=false
  69. ])
  70. AC_SUBST(CET_DFLAGS)
  71. AC_SUBST(DCFG_ENABLE_CET)
  72. # This should be inherited in the recursive make, but ensure it is defined.
  73. test "$AR" || AR=ar
  74. AC_SUBST(AR)
  75. CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
  76. AC_SUBST(CC_FOR_BUILD)
  77. AC_SUBST(CFLAGS_FOR_BUILD)
  78. # Enable libtool
  79. LT_INIT(dlopen)
  80. AM_PROG_LIBTOOL
  81. WITH_LOCAL_DRUNTIME([LT_LANG([D])], [])
  82. AC_SUBST(enable_shared)
  83. AC_SUBST(enable_static)
  84. # libtool variables for Phobos shared and position-independent compiles.
  85. #
  86. # Use phobos_lt_pic_flag to designate the automake variable
  87. # used to encapsulate the default libtool approach to creating objects
  88. # with position-independent code. Default: -prefer-pic.
  89. #
  90. # Use phobos_compiler_shared_flag to designate the compile-time flags for
  91. # creating shared objects. Default: -fversion=Shared.
  92. #
  93. # Use phobos_compiler_pic_flag to designate the compile-time flags for
  94. # creating position-independent objects. This varies with the target
  95. # hardware and operating system, but is often: -fPIC.
  96. #
  97. # The distinction between pic and shared compilation flags is not present in
  98. # libtool, and so we make it here. How it is handled is that in shared
  99. # compilations the `lt_prog_compiler_pic_D' variable is used to instead
  100. # ensure that conditional compilation of shared runtime code is compiled in.
  101. if test "$enable_shared" = yes; then
  102. phobos_lt_pic_flag="-prefer-pic"
  103. phobos_compiler_pic_flag="$lt_prog_compiler_pic_D"
  104. phobos_compiler_shared_flag="-fversion=Shared"
  105. else
  106. phobos_lt_pic_flag=
  107. phobos_compiler_pic_flag=
  108. phobos_compiler_shared_flag=
  109. fi
  110. AC_SUBST(phobos_lt_pic_flag)
  111. AC_SUBST(phobos_compiler_pic_flag)
  112. AC_SUBST(phobos_compiler_shared_flag)
  113. # Override the libtool's pic_flag and pic_mode.
  114. # Do this step after AM_PROG_LIBTOOL, but before AC_OUTPUT.
  115. # NB: this impacts --with-pic and --without-pic.
  116. lt_prog_compiler_pic_D="$phobos_compiler_pic_flag $phobos_compiler_shared_flag"
  117. pic_mode='default'
  118. # Determine what GCC version number to use in filesystem paths.
  119. GCC_BASE_VER
  120. # libphobos/libdruntime specific options and feature detection
  121. DRUNTIME_CONFIGURE
  122. DRUNTIME_MULTILIB
  123. DRUNTIME_WERROR
  124. DRUNTIME_SECTION_FLAGS
  125. DRUNTIME_CPU_SOURCES
  126. DRUNTIME_OS_SOURCES
  127. DRUNTIME_OS_THREAD_MODEL
  128. DRUNTIME_OS_ARM_EABI_UNWINDER
  129. DRUNTIME_OS_MINFO_BRACKETING
  130. DRUNTIME_OS_DLPI_TLS_MODID
  131. DRUNTIME_OS_LINK_SPEC
  132. DRUNTIME_LIBRARIES_CLIB
  133. WITH_LOCAL_DRUNTIME([
  134. AC_LANG_PUSH([D])
  135. AC_SEARCH_LIBS([malloc], [c])
  136. AC_SEARCH_LIBS([pthread_create], [pthread])
  137. AC_SEARCH_LIBS([cosf], [m])
  138. AC_SEARCH_LIBS([clock_gettime], [rt])
  139. DRUNTIME_ENABLE_ATOMIC_BUILTINS
  140. AC_LANG_POP([D])
  141. ], [-nophoboslib])
  142. DRUNTIME_LIBRARIES_ATOMIC
  143. DRUNTIME_LIBRARIES_BACKTRACE
  144. DRUNTIME_LIBRARIES_DLOPEN
  145. DRUNTIME_LIBRARIES_NET
  146. DRUNTIME_LIBRARIES_UCONTEXT
  147. DRUNTIME_LIBRARIES_ZLIB
  148. DRUNTIME_INSTALL_DIRECTORIES
  149. AC_MSG_CHECKING([for --enable-libphobos])
  150. AC_ARG_ENABLE(libphobos,
  151. [AS_HELP_STRING([--enable-libphobos], [Enable libphobos])])
  152. AC_MSG_RESULT($enable_libphobos)
  153. AC_MSG_CHECKING([for --with-libphobos-druntime-only])
  154. AC_ARG_WITH(libphobos-druntime-only,
  155. AS_HELP_STRING([--with-libphobos-druntime-only={yes,no,auto}],
  156. [build only the druntime library (default: auto)]),,
  157. [with_libphobos_druntime_only=auto])
  158. AC_MSG_RESULT($with_libphobos_druntime_only)
  159. case "$with_libphobos_druntime_only" in
  160. yes|no|auto) ;;
  161. *) AC_MSG_ERROR([Invalid argument for --with-libphobos-druntime-only]) ;;
  162. esac
  163. # See if supported.
  164. unset LIBPHOBOS_SUPPORTED
  165. unset LIBDRUNTIME_ONLY
  166. AC_MSG_CHECKING([for host support for libphobos])
  167. . ${srcdir}/configure.tgt
  168. case ${host} in
  169. x86_64-*-solaris2.* | i?86-*-solaris2.*)
  170. # 64-bit D execution fails with Solaris ld without -z relax=transtls support.
  171. if test "$druntime_ld_gld" = "no" && test "$druntime_ld_relax_transtls" = "no"; then
  172. LIBPHOBOS_SUPPORTED=no
  173. fi
  174. ;;
  175. esac
  176. AC_MSG_RESULT($LIBPHOBOS_SUPPORTED)
  177. # Decide if it's usable.
  178. case $LIBPHOBOS_SUPPORTED:$enable_libphobos in
  179. *:no) use_libphobos=no ;;
  180. *:yes) use_libphobos=yes ;;
  181. yes:*) use_libphobos=yes ;;
  182. *:*) use_libphobos=no ;;
  183. esac
  184. AM_CONDITIONAL(ENABLE_LIBPHOBOS, test x$use_libphobos = xyes)
  185. # Decide if only libdruntime should be built.
  186. case $LIBDRUNTIME_ONLY:$with_libphobos_druntime_only in
  187. *:no) only_libdruntime=no ;;
  188. *:yes) only_libdruntime=yes ;;
  189. yes:*) only_libdruntime=yes ;;
  190. *:*) only_libdruntime=no ;;
  191. esac
  192. AM_CONDITIONAL(ENABLE_LIBDRUNTIME_ONLY, test x$only_libdruntime = xyes)
  193. # Enable expensive internal checks
  194. AC_ARG_ENABLE(libphobos-checking,
  195. [AS_HELP_STRING([[--enable-libphobos-checking[=LIST]]],
  196. [enable expensive run-time checks. With LIST,
  197. enable only specific categories of checks.
  198. Categories are: yes,no,all,none,release.
  199. Flags are: assert or other strings])],
  200. [ac_checking_flags="${enableval}"],[ac_checking_flags=release])
  201. IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS,"
  202. for check in release $ac_checking_flags
  203. do
  204. case $check in
  205. # These set all the flags to specific states
  206. yes|all) RELEASE_FLAG="-fno-release" ; ASSERT_FLAG= ;;
  207. no|none|release) RELEASE_FLAG="-frelease" ; ASSERT_FLAG= ;;
  208. # These enable particular checks
  209. assert) ASSERT_FLAG="-fassert" ;;
  210. # Accept
  211. *) ;;
  212. esac
  213. done
  214. IFS="$ac_save_IFS"
  215. CHECKING_DFLAGS="$RELEASE_FLAG $ASSERT_FLAG"
  216. AC_SUBST(CHECKING_DFLAGS)
  217. # Add drtbegin.o/drtend.o to startfile/endfile specs in libgphobos.spec
  218. if test "$DCFG_MINFO_BRACKETING" = "false"; then
  219. DRTSTUFF_SPEC=$srcdir/src/drtstuff.spec
  220. else
  221. DRTSTUFF_SPEC=/dev/null
  222. fi
  223. AC_SUBST_FILE(DRTSTUFF_SPEC)
  224. # Add dependencies for libgphobos.spec file
  225. SPEC_PHOBOS_DEPS="$LIBS"
  226. AC_SUBST(SPEC_PHOBOS_DEPS)
  227. # Libdruntime / phobos soname version
  228. libtool_VERSION=3:0:0
  229. AC_SUBST(libtool_VERSION)
  230. # Set default flags (after DRUNTIME_WERROR!)
  231. if test -z "$GDCFLAGS"; then
  232. GDCFLAGS="-g -O2"
  233. fi
  234. AC_SUBST(GDCFLAGS)
  235. WARN_DFLAGS="-Wall $WERROR_FLAG"
  236. AC_SUBST(WARN_DFLAGS)
  237. # Sanity check for the cross-compilation case:
  238. AC_CHECK_HEADER(stdio.h,:,
  239. [AC_MSG_ERROR([cannot find stdio.h.])])
  240. AC_CONFIG_FILES(Makefile)
  241. AC_CONFIG_FILES(libdruntime/gcc/config.d libdruntime/gcc/libbacktrace.d)
  242. AC_CONFIG_FILES(src/libgphobos.spec)
  243. AC_CONFIG_FILES([testsuite/testsuite_flags],[chmod +x testsuite/testsuite_flags])
  244. # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
  245. # that multilib installs will end up installed in the correct place.
  246. # The testsuite needs it for multilib-aware ABI baseline files.
  247. # To work around this not being passed down from config-ml.in ->
  248. # srcdir/Makefile.am -> srcdir/{src,libdruntime,...}/Makefile.am, manually
  249. # append it here. Only modify Makefiles that have just been created.
  250. #
  251. # Also, get rid of this simulated-VPATH thing that automake does.
  252. AC_CONFIG_FILES(AC_FOREACH([DIR], [libdruntime src testsuite], [DIR/Makefile ]),
  253. [cat > vpsed$$ << \_EOF
  254. s!`test -f '$<' || echo '$(srcdir)/'`!!
  255. _EOF
  256. sed -f vpsed$$ $ac_file > tmp$$
  257. mv tmp$$ $ac_file
  258. rm vpsed$$
  259. echo 'MULTISUBDIR =' >> $ac_file
  260. ml_norecursion=yes
  261. . ${multi_basedir}/config-ml.in
  262. AS_UNSET([ml_norecursion])
  263. ])
  264. AC_OUTPUT