configure.ac 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. # Process this file with autoconf to produce a configure script.
  2. # Copyright (C) 1994-2015 Free Software Foundation, Inc.
  3. # Originally contributed by Dave Love (d.love@dl.ac.uk).
  4. #
  5. #This file is part of GCC.
  6. #
  7. #GCC is free software; you can redistribute it and/or modify
  8. #it under the terms of the GNU General Public License as published by
  9. #the Free Software Foundation; either version 3, or (at your option)
  10. #any later version.
  11. #
  12. #GCC is distributed in the hope that it will be useful,
  13. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. #GNU General Public License for more details.
  16. #
  17. #You should have received a copy of the GNU General Public License
  18. #along with GCC; see the file COPYING3. If not see
  19. #<http://www.gnu.org/licenses/>.
  20. AC_PREREQ(2.64)
  21. AC_INIT(package-unused, version-unused,, libobjc)
  22. AC_CONFIG_SRCDIR([objc/objc.h])
  23. GCC_TOPLEV_SUBDIRS
  24. # We need the following definitions because AC_PROG_LIBTOOL relies on them
  25. PACKAGE=libobjc
  26. # Version is pulled out to make it a bit easier to change using sed.
  27. VERSION=4:0:0
  28. AC_SUBST(VERSION)
  29. # This works around the fact that libtool configuration may change LD
  30. # for this particular configuration, but some shells, instead of
  31. # keeping the changes in LD private, export them just because LD is
  32. # exported.
  33. ORIGINAL_LD_FOR_MULTILIBS=$LD
  34. # -------
  35. # Options
  36. # -------
  37. # We use these options to decide which functions to include.
  38. AC_ARG_WITH(target-subdir,
  39. [ --with-target-subdir=SUBDIR
  40. configuring in a subdirectory])
  41. AC_ARG_WITH(cross-host,
  42. [ --with-cross-host=HOST configuring with a cross compiler])
  43. AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
  44. AC_ARG_ENABLE(version-specific-runtime-libs,
  45. [ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ],
  46. [case "$enableval" in
  47. yes) version_specific_libs=yes ;;
  48. no) version_specific_libs=no ;;
  49. *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
  50. esac],
  51. [version_specific_libs=no])
  52. AC_MSG_RESULT($version_specific_libs)
  53. AC_ARG_ENABLE(objc-gc,
  54. [ --enable-objc-gc enable the use of Boehm's garbage collector with
  55. the GNU Objective-C runtime.],
  56. [case $enable_objc_gc in
  57. no)
  58. OBJC_GCFLAGS=''
  59. OBJC_BOEHM_GC=''
  60. OBJC_BOEHM_GC_INCLUDES=''
  61. ;;
  62. *)
  63. OBJC_GCFLAGS='-DOBJC_WITH_GC=1'
  64. OBJC_BOEHM_GC='libobjc_gc$(libsuffix).la'
  65. OBJC_BOEHM_GC_INCLUDES='-I$(top_srcdir)/../boehm-gc/include -I../boehm-gc/include'
  66. ;;
  67. esac],
  68. [OBJC_GCFLAGS=''; OBJC_BOEHM_GC=''; OBJC_BOEHM_GC_INCLUDES=''])
  69. AC_SUBST(OBJC_GCFLAGS)
  70. AC_SUBST(OBJC_BOEHM_GC)
  71. AC_SUBST(OBJC_BOEHM_GC_INCLUDES)
  72. # -----------
  73. # Directories
  74. # -----------
  75. # Find the rest of the source tree framework.
  76. AM_ENABLE_MULTILIB(, ..)
  77. AC_CANONICAL_SYSTEM
  78. ACX_NONCANONICAL_TARGET
  79. # Export source directory.
  80. # These need to be absolute paths, yet at the same time need to
  81. # canonicalize only relative paths, because then amd will not unmount
  82. # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
  83. case $srcdir in
  84. [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
  85. *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
  86. esac
  87. AC_SUBST(glibcpp_srcdir)
  88. # Calculate toolexeclibdir
  89. # Also toolexecdir, though it's only used in toolexeclibdir
  90. case ${version_specific_libs} in
  91. yes)
  92. # Need the gcc compiler version to know where to install libraries
  93. # and header files if --enable-version-specific-runtime-libs option
  94. # is selected.
  95. toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
  96. toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
  97. ;;
  98. no)
  99. if test -n "$with_cross_host" &&
  100. test x"$with_cross_host" != x"no"; then
  101. # Install a library built with a cross compiler in tooldir, not libdir.
  102. toolexecdir='$(exec_prefix)/$(target_noncanonical)'
  103. toolexeclibdir='$(toolexecdir)/lib'
  104. else
  105. toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
  106. toolexeclibdir='$(libdir)'
  107. fi
  108. multi_os_directory=`$CC -print-multi-os-directory`
  109. case $multi_os_directory in
  110. .) ;; # Avoid trailing /.
  111. *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
  112. esac
  113. ;;
  114. esac
  115. AC_SUBST(toolexecdir)
  116. AC_SUBST(toolexeclibdir)
  117. # Figure out if we want to name the include directory and the
  118. # library name changes differently.
  119. includedirname=include
  120. libsuffix=
  121. case "${host}" in
  122. *-darwin*)
  123. # Darwin is the only target so far that needs a different include directory.
  124. includedirname=include-gnu-runtime
  125. libsuffix=-gnu
  126. ;;
  127. esac
  128. AC_SUBST(includedirname)
  129. AC_SUBST(libsuffix)
  130. AC_CONFIG_HEADERS(config.h)
  131. # --------
  132. # Programs
  133. # --------
  134. GCC_NO_EXECUTABLES
  135. # We must force CC to /not/ be a precious variable; otherwise
  136. # the wrong, non-multilib-adjusted value will be used in multilibs.
  137. # As a side effect, we have to subst CFLAGS ourselves.
  138. m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
  139. m4_define([_AC_ARG_VAR_PRECIOUS],[])
  140. AC_PROG_CC
  141. m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
  142. # extra LD Flags which are required for targets
  143. ACX_LT_HOST_FLAGS
  144. case "${host}" in
  145. *-darwin*)
  146. # Darwin needs -single_module when linking libobjc
  147. extra_ldflags_libobjc='$(lt_host_flags) -Wl,-single_module'
  148. ;;
  149. *-cygwin*|*-mingw*)
  150. # Tell libtool to build DLLs on Windows
  151. extra_ldflags_libobjc='$(lt_host_flags)'
  152. ;;
  153. esac
  154. AC_SUBST(extra_ldflags_libobjc)
  155. AC_SUBST(CFLAGS)
  156. AC_CHECK_TOOL(AS, as)
  157. AC_CHECK_TOOL(AR, ar)
  158. AC_CHECK_TOOL(RANLIB, ranlib, :)
  159. AC_PROG_INSTALL
  160. AM_MAINTAINER_MODE
  161. # Enable Win32 DLL on MS Windows - FIXME
  162. AC_LIBTOOL_WIN32_DLL
  163. AC_PROG_LIBTOOL
  164. AM_PROG_CC_C_O
  165. AC_PROG_MAKE_SET
  166. # -------
  167. # Headers
  168. # -------
  169. # Sanity check for the cross-compilation case:
  170. AC_CHECK_HEADER(stdio.h,:,
  171. [AC_MSG_ERROR([Can't find stdio.h.
  172. You must have a usable C system for the target already installed, at least
  173. including headers and, preferably, the library, before you can configure
  174. the Objective C runtime system. If necessary, install gcc now with
  175. \`LANGUAGES=c', then the target library, then build with \`LANGUAGES=objc'.])])
  176. AC_HEADER_STDC
  177. AC_CHECK_HEADERS(sched.h)
  178. # -----------
  179. # Miscellanea
  180. # -----------
  181. # Check if we have thread-local storage
  182. GCC_CHECK_TLS
  183. AC_MSG_CHECKING([for exception model to use])
  184. AC_LANG_PUSH(C)
  185. AC_ARG_ENABLE(sjlj-exceptions,
  186. AS_HELP_STRING([--enable-sjlj-exceptions],
  187. [force use of builtin_setjmp for exceptions]),
  188. [:],
  189. [dnl Botheration. Now we've got to detect the exception model.
  190. dnl Link tests against libgcc.a are problematic since -- at least
  191. dnl as of this writing -- we've not been given proper -L bits for
  192. dnl single-tree newlib and libgloss.
  193. dnl
  194. dnl This is what AC_TRY_COMPILE would do if it didn't delete the
  195. dnl conftest files before we got a change to grep them first.
  196. cat > conftest.$ac_ext << EOF
  197. [#]line __oline__ "configure"
  198. @interface Frob
  199. @end
  200. @implementation Frob
  201. @end
  202. int proc();
  203. int foo()
  204. {
  205. @try {
  206. return proc();
  207. }
  208. @catch (Frob* ex) {
  209. return 0;
  210. }
  211. }
  212. EOF
  213. old_CFLAGS="$CFLAGS"
  214. dnl work around that we don't have Objective-C support in autoconf
  215. CFLAGS="-x objective-c -fgnu-runtime -fobjc-exceptions -S"
  216. if AC_TRY_EVAL(ac_compile); then
  217. if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
  218. enable_sjlj_exceptions=yes
  219. elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
  220. enable_sjlj_exceptions=no
  221. fi
  222. fi
  223. CFLAGS="$old_CFLAGS"
  224. rm -f conftest*])
  225. if test x$enable_sjlj_exceptions = xyes; then
  226. AC_DEFINE(SJLJ_EXCEPTIONS, 1,
  227. [Define if the compiler is configured for setjmp/longjmp exceptions.])
  228. ac_exception_model_name=sjlj
  229. elif test x$enable_sjlj_exceptions = xno; then
  230. ac_exception_model_name="call frame"
  231. else
  232. AC_MSG_ERROR([unable to detect exception model])
  233. fi
  234. AC_LANG_POP(C)
  235. AC_MSG_RESULT($ac_exception_model_name)
  236. # ------
  237. # Output
  238. # ------
  239. if test ${multilib} = yes; then
  240. multilib_arg="--enable-multilib"
  241. else
  242. multilib_arg=
  243. fi
  244. AC_CONFIG_FILES([Makefile])
  245. AC_OUTPUT