1 # Configure script for libgm2.
2 # Copyright (C) 2013-2024 Free Software Foundation, Inc.
4 # This file is part of GCC.
6 # GCC is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
11 # GCC is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GCC; see the file COPYING3. If not see
18 # <http://www.gnu.org/licenses/>.
20 # Configure looks for the existence of this file to auto-config each language.
21 # We define several parameters used by configure:
23 # Process this file with autoreconf to produce a configure script.
25 AC_INIT(package-unused, version-unused,,libgm2)
26 AC_CONFIG_SRCDIR(Makefile.am)
27 # AC_CONFIG_MACRO_DIR([config])
28 AC_CONFIG_HEADER(config.h)
30 libtool_VERSION=20:0:0
31 AC_SUBST(libtool_VERSION)
33 AM_ENABLE_MULTILIB(, ..)
37 AC_USE_SYSTEM_EXTENSIONS
39 # Do not delete or change the following two lines. For why, see
40 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
42 target_alias=${target_alias-$host_alias}
43 AC_SUBST(target_alias)
45 if test "$build" != "$host"; then
46 # We are being configured with some form of cross compiler.
47 GLIBCXX_IS_NATIVE=false
48 case "$host","$target" in
49 # Darwin crosses can use the host system's libraries and headers,
50 # because of the fat library support. Of course, it must be the
51 # same version of Darwin on both sides. Allow the user to
52 # just say --target=foo-darwin without a version number to mean
53 # "the version on this system".
54 *-*-darwin*,*-*-darwin*)
55 hostos=`echo $host | sed 's/.*-darwin/darwin/'`
56 targetos=`echo $target | sed 's/.*-darwin/darwin/'`
57 if test $hostos = $targetos || test $targetos = darwin ; then
58 GLIBCXX_IS_NATIVE=true
67 GLIBCXX_IS_NATIVE=true
70 # Runs configure.host, and assorted other critical bits. Sets
71 # up critical shell variables.
74 # For gettimeofday support.
75 GLIBCXX_CHECK_GETTIMEOFDAY
77 # For clock_gettime, nanosleep and sched_yield support.
78 GLIBCXX_ENABLE_LIBSTDCXX_TIME
80 AM_INIT_AUTOMAKE([1.15.1 no-define foreign no-dist -Wall -Wno-portability])
82 AH_TEMPLATE(PACKAGE, [Name of package])
83 AH_TEMPLATE(VERSION, [Version number of package])
85 AC_ARG_WITH(cross-host,
86 [ --with-cross-host=HOST Configuring with a cross compiler])
88 # Checks for header files.
92 AC_CHECK_HEADER([math.h],
93 [AC_DEFINE([HAVE_MATH_H], [1], [have math.h])])
95 AC_CHECK_HEADERS(getopt.h limits.h stddef.h string.h strings.h \
97 fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \
98 sys/resource.h sys/param.h sys/times.h sys/stat.h \
100 sys/wait.h sys/ioctl.h errno.h sys/errno.h \
101 pwd.h direct.h dirent.h signal.h malloc.h langinfo.h \
102 pthread.h stdarg.h stdio.h sys/types.h termios.h \
103 netinet/in.h netdb.h sys/uio.h sys/stat.h wchar.h)
106 ACX_NONCANONICAL_HOST
107 ACX_NONCANONICAL_TARGET
110 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
111 AC_ARG_ENABLE(version-specific-runtime-libs,
112 [ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ],
113 [case "$enableval" in
114 yes) version_specific_libs=yes ;;
115 no) version_specific_libs=no ;;
116 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
118 [version_specific_libs=no])
119 AC_MSG_RESULT($version_specific_libs)
122 [ --with-slibdir=DIR shared libraries in DIR [LIBDIR]],
123 slibdir="$with_slibdir",
124 if test "${version_specific_libs}" = yes; then
125 slibdir='$(libsubdir)'
126 elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
127 slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
133 # Command-line options.
134 # Very limited version of AC_MAINTAINER_MODE.
135 AC_ARG_ENABLE([maintainer-mode],
136 [AC_HELP_STRING([--enable-maintainer-mode],
137 [enable make rules and dependencies not useful (and
138 sometimes confusing) to the casual installer])],
139 [case ${enable_maintainer_mode} in
142 *) AC_MSG_ERROR([--enable-maintainer-mode must be yes or no]) ;;
144 maintainer_mode=${enableval}],
151 # Calculate toolexeclibdir
152 # Also toolexecdir, though it's only used in toolexeclibdir
153 case ${version_specific_libs} in
155 # Need the gcc compiler version to know where to install libraries
156 # and header files if --enable-version-specific-runtime-libs option
158 toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
159 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
162 if test -n "$with_cross_host" &&
163 test x"$with_cross_host" != x"no"; then
164 # Install a library built with a cross compiler in tooldir, not libdir.
165 toolexecdir='$(exec_prefix)/$(target_noncanonical)'
166 toolexeclibdir='$(toolexecdir)/lib'
168 toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
169 toolexeclibdir='$(libdir)'
171 multi_os_directory=`$CC -print-multi-os-directory`
172 case $multi_os_directory in
173 .) ;; # Avoid trailing /.
174 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
179 AC_SUBST(toolexecdir)
180 AC_SUBST(toolexeclibdir)
182 AH_TEMPLATE(PACKAGE, [Name of package])
183 AH_TEMPLATE(VERSION, [Version number of package])
187 # Check the compiler.
188 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
189 # We must force CC to /not/ be precious variables; otherwise
190 # the wrong, non-multilib-adjusted value will be used in multilibs.
191 # As a side effect, we have to subst CFLAGS ourselves.
193 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
194 m4_define([_AC_ARG_VAR_PRECIOUS],[])
198 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
202 # In order to override CFLAGS_FOR_TARGET, all of our special flags go
203 # in XCFLAGS. But we need them in CFLAGS during configury. So put them
204 # in both places for now and restore CFLAGS at the end of config.
205 save_CFLAGS="$CFLAGS"
207 # Find other programs we need.
208 AC_CHECK_TOOL(AR, ar)
209 AC_CHECK_TOOL(NM, nm)
210 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
218 AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
220 AC_SUBST(enable_shared)
221 AC_SUBST(enable_static)
223 if test "${multilib}" = "yes"; then
224 multilib_arg="--enable-multilib"
229 AC_CHECK_TYPES([struct timezone, struct stat, struct timespec, struct timeval, struct tm])
231 # Check if struct tm contains the tm_gmtoff field.
232 AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
233 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
239 [ac_cv_struct_tm_gmtoff=yes],
240 [ac_cv_struct_tm_gmtoff=no]
244 if (test "$ac_cv_struct_tm_gmtoff" = "yes"); then
245 AC_MSG_CHECKING([m2 front end detects struct tm with the tm_gmtoff field.])
246 AC_DEFINE(HAVE_TM_TM_GMTOFF, 1, [Define if struct tm has a tm_gmtoff field.])
250 # Check the compiler.
251 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
252 # We must force CC to /not/ be precious variables; otherwise
253 # the wrong, non-multilib-adjusted value will be used in multilibs.
254 # As a side effect, we have to subst CFLAGS ourselves.
256 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
257 m4_define([_AC_ARG_VAR_PRECIOUS],[])
259 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
263 AC_DEFUN([GM2_UNDEF],[
264 $as_echo "#undef HAVE_$1" >>confdefs.h
267 AC_DEFUN([GM2_CHECK_LIB],[
268 AC_MSG_CHECKING([m2 front end checking $1 library for $2])
269 if test x$gcc_no_link != xyes; then
270 AC_CHECK_LIB([$1],[$2],[AC_DEFINE([HAVE_$3],[1],[found $2])],[GM2_UNDEF([$3],[$2])])
272 if test "x$[ac_cv_lib_$1_$2]" = xyes; then
273 AC_DEFINE([HAVE_$3],[1],[lib$1 includes $2])
274 elif test "x$[ac_cv_func_$2]" = xyes; then
275 AC_DEFINE([HAVE_$3],[1],[function $2 exists])
282 GM2_CHECK_LIB([c],[access],[ACCESS])
283 GM2_CHECK_LIB([c],[brk],[BRK])
284 GM2_CHECK_LIB([c],[cfmakeraw],[CFMAKERAW])
285 GM2_CHECK_LIB([c],[clock_gettime],[CLOCK_GETTIME])
286 GM2_CHECK_LIB([c],[clock_settime],[CLOCK_SETTIME])
287 GM2_CHECK_LIB([c],[close],[CLOSE])
288 GM2_CHECK_LIB([c],[ctime],[CTIME])
289 GM2_CHECK_LIB([c],[creat],[CREAT])
290 GM2_CHECK_LIB([c],[daylight],[DAYLIGHT])
291 GM2_CHECK_LIB([c],[dup],[DUP])
292 GM2_CHECK_LIB([c],[execve],[EXECVE])
293 GM2_CHECK_LIB([c],[exit],[EXIT])
294 GM2_CHECK_LIB([c],[fcntl],[FCNTL])
295 GM2_CHECK_LIB([c],[fstat],[FSTAT])
296 GM2_CHECK_LIB([c],[getdents],[GETDENTS])
297 GM2_CHECK_LIB([c],[getgid],[GETGID])
298 GM2_CHECK_LIB([c],[getopt_long],[GETOPT_LONG])
299 GM2_CHECK_LIB([c],[getopt_long_only],[GETOPT_LONG_ONLY])
300 GM2_CHECK_LIB([c],[getpid],[GETPID])
301 GM2_CHECK_LIB([c],[gettimeofday],[GETTIMEOFDAY])
302 GM2_CHECK_LIB([c],[getuid],[GETUID])
303 GM2_CHECK_LIB([c],[ioctl],[IOCTL])
304 GM2_CHECK_LIB([c],[kill],[KILL])
305 GM2_CHECK_LIB([c],[link],[LINK])
306 GM2_CHECK_LIB([c],[lseek],[LSEEK])
307 GM2_CHECK_LIB([c],[open],[OPEN])
308 GM2_CHECK_LIB([c],[pause],[PAUSE])
309 GM2_CHECK_LIB([c],[pipe],[PIPE])
310 GM2_CHECK_LIB([c],[rand],[RAND])
311 GM2_CHECK_LIB([c],[read],[READ])
312 GM2_CHECK_LIB([c],[select],[SELECT])
313 GM2_CHECK_LIB([c],[setitimer],[SETITIMER])
314 GM2_CHECK_LIB([c],[setgid],[SETGID])
315 GM2_CHECK_LIB([c],[settimeofday],[SETTIMEOFDAY])
316 GM2_CHECK_LIB([c],[setuid],[SETUID])
317 GM2_CHECK_LIB([c],[stat],[STAT])
318 GM2_CHECK_LIB([c],[strsignal],[STRSIGNAL])
319 GM2_CHECK_LIB([c],[strtod],[STRTOD])
320 GM2_CHECK_LIB([c],[strtold],[STRTOLD])
321 GM2_CHECK_LIB([c],[times],[TIMES])
322 GM2_CHECK_LIB([c],[timezone],[TIMEZONE])
323 GM2_CHECK_LIB([c],[tzname],[TZNAME])
324 GM2_CHECK_LIB([c],[unlink],[UNLINK])
325 GM2_CHECK_LIB([c],[wait],[WAIT])
326 GM2_CHECK_LIB([c],[write],[WRITE])
328 GM2_CHECK_LIB([m],[exp10],[EXP10])
329 GM2_CHECK_LIB([m],[exp10f],[EXP10F])
330 GM2_CHECK_LIB([m],[exp10l],[EXP10L])
331 GM2_CHECK_LIB([m],[signbit],[SIGNBIT])
332 GM2_CHECK_LIB([m],[signbitf],[SIGNBITF])
333 GM2_CHECK_LIB([m],[signbitl],[SIGNBITL])
335 AC_CHECK_DECLS([getenv])
337 AC_MSG_NOTICE([libgm2 has finished checking target libc and libm contents.])
339 # We test the host here and later on check the target.
341 # All known M2_HOST_OS values. This is the union of all host operating systems
344 M2_SUPPORTED_HOST_OS="aix freebsd hurd linux netbsd openbsd solaris windows darwin"
349 *-*-darwin*) M2_HOST_OS=darwin ;;
350 *-*-freebsd*) M2_HOST_OS=freebsd ;;
351 *-*-linux*) M2_HOST_OS=linux ;;
352 *-*-netbsd*) M2_HOST_OS=netbsd ;;
353 *-*-openbsd*) M2_HOST_OS=openbsd ;;
354 *-*-solaris2*) M2_HOST_OS=solaris ;;
355 *-*-aix*) M2_HOST_OS=aix ;;
356 *-*-gnu*) M2_HOST_OS=hurd ;;
362 *-*-darwin*) M2_TARGET_OS=darwin ;;
363 *-*-freebsd*) M2_TARGET_OS=freebsd ;;
364 *-*-linux*) M2_TARGET_OS=linux ;;
365 *-*-netbsd*) M2_TARGET_OS=netbsd ;;
366 *-*-openbsd*) M2_TARGET_OS=openbsd ;;
367 *-*-solaris2*) M2_TARGET_OS=solaris ;;
368 *-*-aix*) M2_TARGET_OS=aix ;;
369 *-*-gnu*) M2_TARGET_OS=hurd ;;
373 if test x${M2_HOST_OS} = xunknown; then
374 AC_MSG_NOTICE([unsupported host, will build a minimal m2 library])
380 AC_MSG_NOTICE([m2 library will be built on ${M2_HOST_OS}])
387 CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
388 AC_SUBST(CC_FOR_BUILD)
390 # Propagate GM2_FOR_TARGET into Makefiles
391 GM2_FOR_TARGET=${GM2_FOR_TARGET:-gcc}
392 AC_SUBST(GM2_FOR_TARGET)
394 # Now we check the target as long as it is a supported host.
395 # For some embedded targets we choose minimal runtime system which is
396 # just enough to satisfy the linker targetting raw metal.
397 if test x${M2_HOST_OS} != xunknown; then
398 AC_MSG_NOTICE([m2 library building for target ${target}])
401 avr25*-*-* | avr31*-*-* | avr35*-*-* | avr4*-*-* | avr5*-*-* | avr51*-*-* | avr6*-*-*)
408 avrxmega2*-*-* | avrxmega4*-*-* | avrxmega5*-*-* | avrxmega6*-*-* | avrxmega7*-*-*)
431 # GM2_MSG_RESULT issue a query message from the first parameter and a boolean result
432 # in the second parameter is printed as a "yes" or "no".
434 AC_DEFUN([GM2_MSG_RESULT],[
435 AC_MSG_CHECKING([$1])
436 if test x${$2} = xtrue; then
443 if test x${M2_HOST_OS} = xunknown; then
444 AC_MSG_NOTICE([m2 front end will only build minimal Modula-2 runtime library on this host])
446 GM2_MSG_RESULT([m2 front end will build PIM libraries:],[BUILD_PIMLIB])
447 GM2_MSG_RESULT([m2 front end will build ISO libraries:],[BUILD_ISOLIB])
448 GM2_MSG_RESULT([m2 front end will build coroutine libraries:],[BUILD_CORLIB])
449 GM2_MSG_RESULT([m2 front end will build Logitech compatability libraries:],[BUILD_LOGLIB])
452 AM_CONDITIONAL([BUILD_PIMLIB], [test x$BUILD_PIMLIB = xtrue])
453 AM_CONDITIONAL([BUILD_ISOLIB], [test x$BUILD_ISOLIB = xtrue])
454 AM_CONDITIONAL([BUILD_CORLIB], [test x$BUILD_CORLIB = xtrue])
455 AM_CONDITIONAL([BUILD_LOGLIB], [test x$BUILD_LOGLIB = xtrue])
456 AM_CONDITIONAL([TARGET_DARWIN], [test x$M2_TARGET_OS = xdarwin])
458 # Determine what GCC version number to use in filesystem paths.
461 AC_CONFIG_SRCDIR([Makefile.am])
462 AC_CONFIG_FILES([Makefile])
464 AC_CONFIG_FILES(AC_FOREACH([DIR], [libm2min libm2pim libm2iso libm2cor libm2log], [DIR/Makefile ]),
465 [ cat > vpsed$$ << \_EOF
466 s!`test -f '$<' || echo '$(srcdir)/'`!!
468 sed -f vpsed$$ $ac_file > tmp$$
471 echo 'MULTISUBDIR =' >> $ac_file
473 . ${multi_basedir}/config-ml.in
474 AS_UNSET([ml_norecursion])
477 AC_MSG_NOTICE([libgm2 has been configured.])