1 # Configure script for libgm2.
2 # Copyright (C) 2013-2023 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=18: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
81 AM_INIT_AUTOMAKE([1.15.1 no-define foreign no-dist -Wall -Wno-portability])
83 AH_TEMPLATE(PACKAGE, [Name of package])
84 AH_TEMPLATE(VERSION, [Version number of package])
86 AC_ARG_WITH(cross-host,
87 [ --with-cross-host=HOST Configuring with a cross compiler])
89 # Checks for header files.
92 AC_CHECK_HEADER([math.h],
93 [AC_DEFINE([HAVE_MATH_H], [1], [have math.h])])
95 AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.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)
107 ACX_NONCANONICAL_HOST
108 ACX_NONCANONICAL_TARGET
111 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
112 AC_ARG_ENABLE(version-specific-runtime-libs,
113 [ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ],
114 [case "$enableval" in
115 yes) version_specific_libs=yes ;;
116 no) version_specific_libs=no ;;
117 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
119 [version_specific_libs=no])
120 AC_MSG_RESULT($version_specific_libs)
123 [ --with-slibdir=DIR shared libraries in DIR [LIBDIR]],
124 slibdir="$with_slibdir",
125 if test "${version_specific_libs}" = yes; then
126 slibdir='$(libsubdir)'
127 elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
128 slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
134 # Command-line options.
135 # Very limited version of AC_MAINTAINER_MODE.
136 AC_ARG_ENABLE([maintainer-mode],
137 [AC_HELP_STRING([--enable-maintainer-mode],
138 [enable make rules and dependencies not useful (and
139 sometimes confusing) to the casual installer])],
140 [case ${enable_maintainer_mode} in
143 *) AC_MSG_ERROR([--enable-maintainer-mode must be yes or no]) ;;
145 maintainer_mode=${enableval}],
152 # Calculate toolexeclibdir
153 # Also toolexecdir, though it's only used in toolexeclibdir
154 case ${version_specific_libs} in
156 # Need the gcc compiler version to know where to install libraries
157 # and header files if --enable-version-specific-runtime-libs option
159 toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
160 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
163 if test -n "$with_cross_host" &&
164 test x"$with_cross_host" != x"no"; then
165 # Install a library built with a cross compiler in tooldir, not libdir.
166 toolexecdir='$(exec_prefix)/$(target_noncanonical)'
167 toolexeclibdir='$(toolexecdir)/lib'
169 toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
170 toolexeclibdir='$(libdir)'
172 multi_os_directory=`$CC -print-multi-os-directory`
173 case $multi_os_directory in
174 .) ;; # Avoid trailing /.
175 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
180 AC_SUBST(toolexecdir)
181 AC_SUBST(toolexeclibdir)
183 AH_TEMPLATE(PACKAGE, [Name of package])
184 AH_TEMPLATE(VERSION, [Version number of package])
188 # Check the compiler.
189 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
190 # We must force CC to /not/ be precious variables; otherwise
191 # the wrong, non-multilib-adjusted value will be used in multilibs.
192 # As a side effect, we have to subst CFLAGS ourselves.
194 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
195 m4_define([_AC_ARG_VAR_PRECIOUS],[])
199 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
203 # In order to override CFLAGS_FOR_TARGET, all of our special flags go
204 # in XCFLAGS. But we need them in CFLAGS during configury. So put them
205 # in both places for now and restore CFLAGS at the end of config.
206 save_CFLAGS="$CFLAGS"
208 # Find other programs we need.
209 AC_CHECK_TOOL(AR, ar)
210 AC_CHECK_TOOL(NM, nm)
211 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
217 AC_SUBST(enable_shared)
218 AC_SUBST(enable_static)
220 if test "${multilib}" = "yes"; then
221 multilib_arg="--enable-multilib"
226 AC_CHECK_TYPES([struct timezone, struct stat, struct timespec, struct timeval, struct tm])
228 # Check if struct tm contains the tm_gmtoff field.
229 AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
230 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
236 [ac_cv_struct_tm_gmtoff=yes],
237 [ac_cv_struct_tm_gmtoff=no]
241 if (test "$ac_cv_struct_tm_gmtoff" = "yes"); then
242 AC_MSG_CHECKING([m2 front end detects struct tm with the tm_gmtoff field.])
243 AC_DEFINE(HAVE_TM_TM_GMTOFF, 1, [Define if struct tm has a tm_gmtoff field.])
247 # Check the compiler.
248 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
249 # We must force CC to /not/ be precious variables; otherwise
250 # the wrong, non-multilib-adjusted value will be used in multilibs.
251 # As a side effect, we have to subst CFLAGS ourselves.
253 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
254 m4_define([_AC_ARG_VAR_PRECIOUS],[])
256 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
260 AC_DEFUN([GM2_UNDEF],[
261 $as_echo "#undef HAVE_$1" >>confdefs.h
264 AC_DEFUN([GM2_CHECK_LIB],[
265 AC_MSG_CHECKING([m2 front end checking $1 library for $2])
266 if test x$gcc_no_link != xyes; then
267 AC_CHECK_LIB([$1],[$2],[AC_DEFINE([HAVE_$3],[1],[found $2])],[GM2_UNDEF([$3],[$2])])
269 if test "x$[ac_cv_lib_$1_$2]" = xyes; then
270 AC_DEFINE([HAVE_$3],[1],[lib$1 includes $2])
271 elif test "x$[ac_cv_func_$2]" = xyes; then
272 AC_DEFINE([HAVE_$3],[1],[function $2 exists])
279 GM2_CHECK_LIB([c],[access],[ACCESS])
280 GM2_CHECK_LIB([c],[brk],[BRK])
281 GM2_CHECK_LIB([c],[cfmakeraw],[CFMAKERAW])
282 GM2_CHECK_LIB([c],[clock_gettime],[CLOCK_GETTIME])
283 GM2_CHECK_LIB([c],[clock_settime],[CLOCK_SETTIME])
284 GM2_CHECK_LIB([c],[close],[CLOSE])
285 GM2_CHECK_LIB([c],[ctime],[CTIME])
286 GM2_CHECK_LIB([c],[creat],[CREAT])
287 GM2_CHECK_LIB([c],[daylight],[DAYLIGHT])
288 GM2_CHECK_LIB([c],[dup],[DUP])
289 GM2_CHECK_LIB([c],[execve],[EXECVE])
290 GM2_CHECK_LIB([c],[exit],[EXIT])
291 GM2_CHECK_LIB([c],[fcntl],[FCNTL])
292 GM2_CHECK_LIB([c],[fstat],[FSTAT])
293 GM2_CHECK_LIB([c],[getdents],[GETDENTS])
294 GM2_CHECK_LIB([c],[getgid],[GETGID])
295 GM2_CHECK_LIB([c],[getpid],[GETPID])
296 GM2_CHECK_LIB([c],[gettimeofday],[GETTIMEOFD])
297 GM2_CHECK_LIB([c],[getuid],[GETUID])
298 GM2_CHECK_LIB([c],[ioctl],[IOCTL])
299 GM2_CHECK_LIB([c],[kill],[KILL])
300 GM2_CHECK_LIB([c],[link],[LINK])
301 GM2_CHECK_LIB([c],[lseek],[LSEEK])
302 GM2_CHECK_LIB([c],[open],[OPEN])
303 GM2_CHECK_LIB([c],[pause],[PAUSE])
304 GM2_CHECK_LIB([c],[pipe],[PIPE])
305 GM2_CHECK_LIB([c],[rand],[RAND])
306 GM2_CHECK_LIB([c],[read],[READ])
307 GM2_CHECK_LIB([c],[select],[SELECT])
308 GM2_CHECK_LIB([c],[setitimer],[SETITIMER])
309 GM2_CHECK_LIB([c],[setgid],[SETGID])
310 GM2_CHECK_LIB([c],[setuid],[SETUID])
311 GM2_CHECK_LIB([c],[stat],[STAT])
312 GM2_CHECK_LIB([c],[strsignal],[STRSIGNAL])
313 GM2_CHECK_LIB([c],[strtod],[STRTOD])
314 GM2_CHECK_LIB([c],[strtold],[STRTOLD])
315 GM2_CHECK_LIB([c],[times],[TIMES])
316 GM2_CHECK_LIB([c],[timezone],[TIMEZONE])
317 GM2_CHECK_LIB([c],[tzname],[TZNAME])
318 GM2_CHECK_LIB([c],[unlink],[UNLINK])
319 GM2_CHECK_LIB([c],[wait],[WAIT])
320 GM2_CHECK_LIB([c],[write],[WRITE])
322 GM2_CHECK_LIB([m],[signbit],[SIGNBIT])
323 GM2_CHECK_LIB([m],[signbitf],[SIGNBITF])
324 GM2_CHECK_LIB([m],[signbitl],[SIGNBITL])
326 AC_MSG_NOTICE([libgm2 has finished checking target libc and libm contents.])
328 # We test the host here and later on check the target.
330 # All known M2_HOST_OS values. This is the union of all host operating systems
333 M2_SUPPORTED_HOST_OS="aix freebsd hurd linux netbsd openbsd solaris windows darwin"
338 *-*-darwin*) M2_HOST_OS=darwin ;;
339 *-*-freebsd*) M2_HOST_OS=freebsd ;;
340 *-*-linux*) M2_HOST_OS=linux ;;
341 *-*-netbsd*) M2_HOST_OS=netbsd ;;
342 *-*-openbsd*) M2_HOST_OS=openbsd ;;
343 *-*-solaris2*) M2_HOST_OS=solaris ;;
344 *-*-aix*) M2_HOST_OS=aix ;;
345 *-*-gnu*) M2_HOST_OS=hurd ;;
351 *-*-darwin*) M2_TARGET_OS=darwin ;;
352 *-*-freebsd*) M2_TARGET_OS=freebsd ;;
353 *-*-linux*) M2_TARGET_OS=linux ;;
354 *-*-netbsd*) M2_TARGET_OS=netbsd ;;
355 *-*-openbsd*) M2_TARGET_OS=openbsd ;;
356 *-*-solaris2*) M2_TARGET_OS=solaris ;;
357 *-*-aix*) M2_TARGET_OS=aix ;;
358 *-*-gnu*) M2_TARGET_OS=hurd ;;
362 if test x${M2_HOST_OS} = xunknown; then
363 AC_MSG_NOTICE([unsupported host, will build a minimal m2 library])
369 AC_MSG_NOTICE([m2 library will be built on ${M2_HOST_OS}])
376 CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
377 AC_SUBST(CC_FOR_BUILD)
379 # Propagate GM2_FOR_TARGET into Makefiles
380 GM2_FOR_TARGET=${GM2_FOR_TARGET:-gcc}
381 AC_SUBST(GM2_FOR_TARGET)
383 # Now we check the target as long as it is a supported host.
384 # For some embedded targets we choose minimal runtime system which is
385 # just enough to satisfy the linker targetting raw metal.
386 if test x${M2_HOST_OS} != xunknown; then
387 AC_MSG_NOTICE([m2 library building for target ${target}])
390 avr25*-*-* | avr31*-*-* | avr35*-*-* | avr4*-*-* | avr5*-*-* | avr51*-*-* | avr6*-*-*)
397 avrxmega2*-*-* | avrxmega4*-*-* | avrxmega5*-*-* | avrxmega6*-*-* | avrxmega7*-*-*)
420 # GM2_MSG_RESULT issue a query message from the first parameter and a boolean result
421 # in the second parameter is printed as a "yes" or "no".
423 AC_DEFUN([GM2_MSG_RESULT],[
424 AC_MSG_CHECKING([$1])
425 if test x${$2} = xtrue; then
432 if test x${M2_HOST_OS} = xunknown; then
433 AC_MSG_NOTICE([m2 front end will only build minimal Modula-2 runtime library on this host])
435 GM2_MSG_RESULT([m2 front end will build PIM libraries:],[BUILD_PIMLIB])
436 GM2_MSG_RESULT([m2 front end will build ISO libraries:],[BUILD_ISOLIB])
437 GM2_MSG_RESULT([m2 front end will build coroutine libraries:],[BUILD_CORLIB])
438 GM2_MSG_RESULT([m2 front end will build Logitech compatability libraries:],[BUILD_LOGLIB])
441 AM_CONDITIONAL([BUILD_PIMLIB], [test x$BUILD_PIMLIB = xtrue])
442 AM_CONDITIONAL([BUILD_ISOLIB], [test x$BUILD_ISOLIB = xtrue])
443 AM_CONDITIONAL([BUILD_CORLIB], [test x$BUILD_CORLIB = xtrue])
444 AM_CONDITIONAL([BUILD_LOGLIB], [test x$BUILD_LOGLIB = xtrue])
445 AM_CONDITIONAL([TARGET_DARWIN], [test x$M2_TARGET_OS = xdarwin])
447 # Determine what GCC version number to use in filesystem paths.
450 AC_CONFIG_SRCDIR([Makefile.am])
451 AC_CONFIG_FILES([Makefile])
453 AC_CONFIG_FILES(AC_FOREACH([DIR], [libm2min libm2pim libm2iso libm2cor libm2log], [DIR/Makefile ]),
454 [ cat > vpsed$$ << \_EOF
455 s!`test -f '$<' || echo '$(srcdir)/'`!!
457 sed -f vpsed$$ $ac_file > tmp$$
460 echo 'MULTISUBDIR =' >> $ac_file
462 . ${multi_basedir}/config-ml.in
463 AS_UNSET([ml_norecursion])
466 AC_MSG_NOTICE([libgm2 has been configured.])