Debian Codegraph @

libphobos/configure.ac

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