configure.ac 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. # Process this file with autoconf to produce a configure script.
  2. # Copyright (C) 1994-2022 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_INIT(package-unused, version-unused,, libobjc)
  21. AC_CONFIG_SRCDIR([objc/objc.h])
  22. GCC_TOPLEV_SUBDIRS
  23. # We need the following definitions because AC_PROG_LIBTOOL relies on them
  24. PACKAGE=libobjc
  25. # Version is pulled out to make it a bit easier to change using sed.
  26. VERSION=4:0:0
  27. AC_SUBST(VERSION)
  28. # This works around the fact that libtool configuration may change LD
  29. # for this particular configuration, but some shells, instead of
  30. # keeping the changes in LD private, export them just because LD is
  31. # exported.
  32. ORIGINAL_LD_FOR_MULTILIBS=$LD
  33. # -------
  34. # Options
  35. # -------
  36. # We use these options to decide which functions to include.
  37. AC_ARG_WITH(target-subdir,
  38. [ --with-target-subdir=SUBDIR
  39. configuring in a subdirectory])
  40. AC_ARG_WITH(cross-host,
  41. [ --with-cross-host=HOST configuring with a cross compiler])
  42. AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
  43. AC_ARG_ENABLE(version-specific-runtime-libs,
  44. [ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ],
  45. [case "$enableval" in
  46. yes) version_specific_libs=yes ;;
  47. no) version_specific_libs=no ;;
  48. *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
  49. esac],
  50. [version_specific_libs=no])
  51. AC_MSG_RESULT($version_specific_libs)
  52. # -----------
  53. # Directories
  54. # -----------
  55. # Find the rest of the source tree framework.
  56. AM_ENABLE_MULTILIB(, ..)
  57. AC_CANONICAL_SYSTEM
  58. ACX_NONCANONICAL_TARGET
  59. # Export source directory.
  60. # These need to be absolute paths, yet at the same time need to
  61. # canonicalize only relative paths, because then amd will not unmount
  62. # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
  63. case $srcdir in
  64. [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
  65. *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
  66. esac
  67. AC_SUBST(glibcpp_srcdir)
  68. GCC_WITH_TOOLEXECLIBDIR
  69. # Calculate toolexeclibdir
  70. # Also toolexecdir, though it's only used in toolexeclibdir
  71. case ${version_specific_libs} in
  72. yes)
  73. # Need the gcc compiler version to know where to install libraries
  74. # and header files if --enable-version-specific-runtime-libs option
  75. # is selected.
  76. toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
  77. toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
  78. ;;
  79. no)
  80. if test -n "$with_cross_host" &&
  81. test x"$with_cross_host" != x"no"; then
  82. # Install a library built with a cross compiler in tooldir, not libdir.
  83. toolexecdir='$(exec_prefix)/$(target_noncanonical)'
  84. case ${with_toolexeclibdir} in
  85. no)
  86. toolexeclibdir='$(toolexecdir)/lib'
  87. ;;
  88. *)
  89. toolexeclibdir=${with_toolexeclibdir}
  90. ;;
  91. esac
  92. else
  93. toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
  94. toolexeclibdir='$(libdir)'
  95. fi
  96. multi_os_directory=`$CC -print-multi-os-directory`
  97. case $multi_os_directory in
  98. .) ;; # Avoid trailing /.
  99. *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
  100. esac
  101. ;;
  102. esac
  103. AC_SUBST(toolexecdir)
  104. AC_SUBST(toolexeclibdir)
  105. # Figure out if we want to name the include directory and the
  106. # library name changes differently.
  107. includedirname=include
  108. libsuffix=
  109. case "${host}" in
  110. *-darwin*)
  111. # Darwin is the only target so far that needs a different include directory.
  112. includedirname=include-gnu-runtime
  113. libsuffix=-gnu
  114. ;;
  115. esac
  116. AC_SUBST(includedirname)
  117. AC_SUBST(libsuffix)
  118. AC_CONFIG_HEADERS(config.h)
  119. # --------
  120. # Programs
  121. # --------
  122. GCC_NO_EXECUTABLES
  123. # We must force CC to /not/ be a precious variable; otherwise
  124. # the wrong, non-multilib-adjusted value will be used in multilibs.
  125. # As a side effect, we have to subst CFLAGS ourselves.
  126. m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
  127. m4_define([_AC_ARG_VAR_PRECIOUS],[])
  128. AC_PROG_CC
  129. m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
  130. # extra LD Flags which are required for targets
  131. ACX_LT_HOST_FLAGS
  132. case "${host}" in
  133. *-darwin*)
  134. # Darwin needs -single_module when linking libobjc
  135. extra_ldflags_libobjc='$(lt_host_flags) -Wl,-single_module'
  136. ;;
  137. *-cygwin*|*-mingw*)
  138. # Tell libtool to build DLLs on Windows
  139. extra_ldflags_libobjc='$(lt_host_flags)'
  140. ;;
  141. esac
  142. AC_SUBST(extra_ldflags_libobjc)
  143. # Add CET specific flags if CET is enabled
  144. GCC_CET_FLAGS(CET_FLAGS)
  145. XCFLAGS="$XCFLAGS $CET_FLAGS"
  146. AC_SUBST(CFLAGS)
  147. AC_SUBST(XCFLAGS)
  148. AC_CHECK_TOOL(AS, as)
  149. AC_CHECK_TOOL(AR, ar)
  150. AC_CHECK_TOOL(RANLIB, ranlib, :)
  151. AC_PROG_INSTALL
  152. AM_MAINTAINER_MODE
  153. # Enable Win32 DLL on MS Windows - FIXME
  154. AC_LIBTOOL_WIN32_DLL
  155. AC_PROG_LIBTOOL
  156. AM_PROG_CC_C_O
  157. AC_PROG_MAKE_SET
  158. # -------
  159. # Headers
  160. # -------
  161. # Sanity check for the cross-compilation case:
  162. AC_CHECK_HEADER(stdio.h,:,
  163. [AC_MSG_ERROR([Can't find stdio.h.
  164. You must have a usable C system for the target already installed, at least
  165. including headers and, preferably, the library, before you can configure
  166. the Objective C runtime system. If necessary, install gcc now with
  167. \`LANGUAGES=c', then the target library, then build with \`LANGUAGES=objc'.])])
  168. AC_HEADER_STDC
  169. AC_CHECK_HEADERS(sched.h)
  170. # -----------
  171. # Miscellanea
  172. # -----------
  173. # Check if we have thread-local storage
  174. GCC_CHECK_TLS
  175. gt_BITFIELD_TYPE_MATTERS
  176. # -----------
  177. # boehm-gc
  178. # -----------
  179. AC_ARG_ENABLE(objc-gc,
  180. [AS_HELP_STRING([--enable-objc-gc],
  181. [enable use of Boehm's garbage collector with the
  182. GNU Objective-C runtime])],,enable_objc_gc=no)
  183. AC_ARG_WITH([target-bdw-gc],
  184. [AS_HELP_STRING([--with-target-bdw-gc=PATHLIST],
  185. [specify prefix directory for installed bdw-gc package.
  186. Equivalent to --with-target-bdw-gc-include=PATH/include
  187. plus --with-target-bdw-gc-lib=PATH/lib])])
  188. AC_ARG_WITH([target-bdw-gc-include],
  189. [AS_HELP_STRING([--with-target-bdw-gc-include=PATHLIST],
  190. [specify directories for installed bdw-gc include files])])
  191. AC_ARG_WITH([target-bdw-gc-lib],
  192. [AS_HELP_STRING([--with-target-bdw-gc-lib=PATHLIST],
  193. [specify directories for installed bdw-gc library])])
  194. case "$enable_objc_gc" in
  195. no)
  196. use_bdw_gc=no
  197. ;;
  198. *)
  199. AC_MSG_CHECKING([for bdw garbage collector])
  200. if test "x$with_target_bdw_gc$with_target_bdw_gc_include$with_target_bdw_gc_lib" = x; then
  201. dnl no bdw-gw options, assuming bdw-gc in default locations
  202. BDW_GC_CFLAGS=
  203. BDW_GC_LIBS="-lgc"
  204. else
  205. dnl bdw-gw options passed by configure flags
  206. if test "x$with_target_bdw_gc_include" = x && test "x$with_target_bdw_gc_lib" != x; then
  207. AC_MSG_ERROR([found --with-target-bdw-gc-lib but --with-target-bdw-gc-include missing])
  208. elif test "x$with_target_bdw_gc_include" != x && test "x$with_target_bdw_gc_lib" = x; then
  209. AC_MSG_ERROR([found --with-target-bdw-gc-include but --with-target-bdw-gc-lib missing])
  210. else
  211. AC_MSG_RESULT([using paths configured with --with-target-bdw-gc options])
  212. fi
  213. mldir=`${CC-gcc} --print-multi-directory 2>/dev/null`
  214. bdw_val=
  215. if test "x$with_target_bdw_gc" != x; then
  216. for i in `echo $with_target_bdw_gc | tr ',' ' '`; do
  217. case "$i" in
  218. *=*) sd=${i%%=*}; d=${i#*=} ;;
  219. *) sd=.; d=$i ;;
  220. esac
  221. if test "$mldir" = "$sd"; then
  222. bdw_val=$d
  223. fi
  224. done
  225. if test "x$bdw_val" = x; then
  226. AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc])
  227. fi
  228. bdw_inc_dir="$bdw_val/include"
  229. bdw_lib_dir="$bdw_val/lib"
  230. fi
  231. bdw_val=
  232. if test "x$with_target_bdw_gc_include" != x; then
  233. for i in `echo $with_target_bdw_gc_include | tr ',' ' '`; do
  234. case "$i" in
  235. *=*) sd=${i%%=*}; d=${i#*=} ;;
  236. *) sd=.; d=$i; fallback=$i ;;
  237. esac
  238. if test "$mldir" = "$sd"; then
  239. bdw_val=$d
  240. fi
  241. done
  242. if test "x$bdw_val" = x && test "x$bdw_inc_dir" = x && test "x$fallback" != x; then
  243. bdw_inc_dir="$fallback"
  244. elif test "x$bdw_val" = x; then
  245. AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc-include])
  246. else
  247. bdw_inc_dir="$bdw_val"
  248. fi
  249. fi
  250. bdw_val=
  251. if test "x$with_target_bdw_gc_lib" != x; then
  252. for i in `echo $with_target_bdw_gc_lib | tr ',' ' '`; do
  253. case "$i" in
  254. *=*) sd=${i%%=*}; d=${i#*=} ;;
  255. *) sd=.; d=$i ;;
  256. esac
  257. if test "$mldir" = "$sd"; then
  258. bdw_val=$d
  259. fi
  260. done
  261. if test "x$bdw_val" = x; then
  262. AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc-lib])
  263. fi
  264. bdw_lib_dir="$bdw_val"
  265. fi
  266. if test "x$bdw_inc_dir" = x; then
  267. AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc-include])
  268. fi
  269. if test "x$bdw_lib_dir" = x; then
  270. AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc-lib])
  271. fi
  272. BDW_GC_CFLAGS="-I$bdw_inc_dir"
  273. if test -f $bdw_lib_dir/libgc.la; then
  274. BDW_GC_LIBS="$bdw_lib_dir/libgc.la"
  275. else
  276. BDW_GC_LIBS="-L$bdw_lib_dir -lgc"
  277. fi
  278. AC_MSG_RESULT([found])
  279. fi
  280. case "$BDW_GC_LIBS" in
  281. *libgc.la)
  282. use_bdw_gc=yes
  283. ;;
  284. *)
  285. AC_MSG_CHECKING([for system boehm-gc])
  286. save_CFLAGS=$CFLAGS
  287. save_LIBS=$LIBS
  288. CFLAGS="$CFLAGS $BDW_GC_CFLAGS"
  289. LIBS="$LIBS $BDW_GC_LIBS"
  290. dnl the link test is not good enough for ARM32 multilib detection,
  291. dnl first check to link, then to run
  292. AC_LINK_IFELSE(
  293. [AC_LANG_PROGRAM([#include <gc/gc.h>],[GC_init()])],
  294. [
  295. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  296. #include <gc/gc.h>
  297. int main() {
  298. GC_init();
  299. return 0;
  300. }
  301. ]])],
  302. [system_bdw_gc_found=yes],
  303. [system_bdw_gc_found=no],
  304. dnl assume no system boehm-gc for cross builds ...
  305. [system_bdw_gc_found=no]
  306. )
  307. ],
  308. [system_bdw_gc_found=no])
  309. CFLAGS=$save_CFLAGS
  310. LIBS=$save_LIBS
  311. if test x$enable_objc_gc = xauto && test x$system_bdw_gc_found = xno; then
  312. AC_MSG_WARN([system bdw-gc not found, not building libobjc_gc])
  313. use_bdw_gc=no
  314. elif test x$enable_objc_gc = xyes && test x$system_bdw_gc_found = xno; then
  315. AC_MSG_ERROR([system bdw-gc required but not found])
  316. else
  317. use_bdw_gc=yes
  318. AC_MSG_RESULT([found])
  319. fi
  320. esac
  321. esac
  322. if test "$use_bdw_gc" = no; then
  323. OBJC_GCFLAGS=''
  324. OBJC_BOEHM_GC=''
  325. OBJC_BOEHM_GC_INCLUDES=''
  326. OBJC_BOEHM_GC_LIBS=''
  327. else
  328. OBJC_GCFLAGS='-DOBJC_WITH_GC=1'
  329. OBJC_BOEHM_GC='libobjc_gc$(libsuffix).la'
  330. OBJC_BOEHM_GC_INCLUDES=$BDW_GC_CFLAGS
  331. OBJC_BOEHM_GC_LIBS=$BDW_GC_LIBS
  332. fi
  333. AC_SUBST(OBJC_GCFLAGS)
  334. AC_SUBST(OBJC_BOEHM_GC)
  335. AC_SUBST(OBJC_BOEHM_GC_INCLUDES)
  336. AC_SUBST(OBJC_BOEHM_GC_LIBS)
  337. # Determine what GCC version number to use in filesystem paths.
  338. GCC_BASE_VER
  339. # ------
  340. # Output
  341. # ------
  342. if test ${multilib} = yes; then
  343. multilib_arg="--enable-multilib"
  344. else
  345. multilib_arg=
  346. fi
  347. AC_CONFIG_FILES([Makefile])
  348. AC_OUTPUT