Add hppa*-*-hpux* to targets which do not support split DWARF
[official-gcc.git] / libgm2 / configure.ac
bloba550a994854584b44478fe3c9d8ab706056cdfe4
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)
9 # any later version.
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=19:0:0
31 AC_SUBST(libtool_VERSION)
33 AM_ENABLE_MULTILIB(, ..)
35 GCC_NO_EXECUTABLES
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
41 AC_CANONICAL_SYSTEM
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
59         fi
60         ;;
62       *)
63         GCC_NO_EXECUTABLES
64         ;;
65   esac
66 else
67   GLIBCXX_IS_NATIVE=true
70 # Runs configure.host, and assorted other critical bits.  Sets
71 # up critical shell variables.
72 GLIBCXX_CONFIGURE
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.
89 AC_HEADER_STDC
90 AC_HEADER_SYS_WAIT
91 AC_CHECK_HEADER([math.h],
92                [AC_DEFINE([HAVE_MATH_H], [1], [have math.h])])
94 AC_CHECK_HEADERS(getopt.h limits.h stddef.h string.h strings.h \
95                  stdlib.h time.h \
96                  fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \
97                  sys/resource.h sys/param.h sys/times.h sys/stat.h \
98                  sys/socket.h \
99                  sys/wait.h sys/ioctl.h errno.h sys/errno.h \
100                  pwd.h direct.h dirent.h signal.h malloc.h langinfo.h \
101                  pthread.h stdarg.h stdio.h sys/types.h termios.h \
102                  netinet/in.h netdb.h sys/uio.h sys/stat.h wchar.h)
104 AC_CANONICAL_HOST
105 ACX_NONCANONICAL_HOST
106 ACX_NONCANONICAL_TARGET
107 GCC_TOPLEV_SUBDIRS
109 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
110 AC_ARG_ENABLE(version-specific-runtime-libs,
111 [  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
112 [case "$enableval" in
113  yes) version_specific_libs=yes ;;
114  no)  version_specific_libs=no ;;
115  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
116  esac],
117 [version_specific_libs=no])
118 AC_MSG_RESULT($version_specific_libs)
120 AC_ARG_WITH(slibdir,
121 [  --with-slibdir=DIR      shared libraries in DIR [LIBDIR]],
122 slibdir="$with_slibdir",
123 if test "${version_specific_libs}" = yes; then
124   slibdir='$(libsubdir)'
125 elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
126   slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
127 else
128   slibdir='$(libdir)'
130 AC_SUBST(slibdir)
132 # Command-line options.
133 # Very limited version of AC_MAINTAINER_MODE.
134 AC_ARG_ENABLE([maintainer-mode],
135   [AC_HELP_STRING([--enable-maintainer-mode],
136                  [enable make rules and dependencies not useful (and
137                   sometimes confusing) to the casual installer])],
138   [case ${enable_maintainer_mode} in
139      yes) MAINT='' ;;
140      no) MAINT='#' ;;
141      *) AC_MSG_ERROR([--enable-maintainer-mode must be yes or no]) ;;
142    esac
143    maintainer_mode=${enableval}],
144   [MAINT='#'])
145 AC_SUBST([MAINT])dnl
147 toolexecdir=no
148 toolexeclibdir=no
150 # Calculate toolexeclibdir
151 # Also toolexecdir, though it's only used in toolexeclibdir
152 case ${version_specific_libs} in
153   yes)
154     # Need the gcc compiler version to know where to install libraries
155     # and header files if --enable-version-specific-runtime-libs option
156     # is selected.
157     toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
158     toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
159     ;;
160   no)
161     if test -n "$with_cross_host" &&
162        test x"$with_cross_host" != x"no"; then
163       # Install a library built with a cross compiler in tooldir, not libdir.
164       toolexecdir='$(exec_prefix)/$(target_noncanonical)'
165       toolexeclibdir='$(toolexecdir)/lib'
166     else
167       toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
168       toolexeclibdir='$(libdir)'
169     fi
170     multi_os_directory=`$CC -print-multi-os-directory`
171     case $multi_os_directory in
172       .) ;; # Avoid trailing /.
173       *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
174     esac
175     ;;
176 esac
178 AC_SUBST(toolexecdir)
179 AC_SUBST(toolexeclibdir)
181 AH_TEMPLATE(PACKAGE, [Name of package])
182 AH_TEMPLATE(VERSION, [Version number of package])
184 AM_MAINTAINER_MODE
186 # Check the compiler.
187 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
188 # We must force CC to /not/ be precious variables; otherwise
189 # the wrong, non-multilib-adjusted value will be used in multilibs.
190 # As a side effect, we have to subst CFLAGS ourselves.
192 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
193 m4_define([_AC_ARG_VAR_PRECIOUS],[])
194 AC_PROG_CC
195 AC_PROG_CXX
196 AM_PROG_AS
197 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
199 AC_SUBST(CFLAGS)
201 # In order to override CFLAGS_FOR_TARGET, all of our special flags go
202 # in XCFLAGS.  But we need them in CFLAGS during configury.  So put them
203 # in both places for now and restore CFLAGS at the end of config.
204 save_CFLAGS="$CFLAGS"
206 # Find other programs we need.
207 AC_CHECK_TOOL(AR, ar)
208 AC_CHECK_TOOL(NM, nm)
209 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
210 AC_PROG_MAKE_SET
211 AC_PROG_INSTALL
213 AM_PROG_LIBTOOL
214 LT_INIT
215 AC_LIBTOOL_DLOPEN
217 AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
219 AC_SUBST(enable_shared)
220 AC_SUBST(enable_static)
222 if test "${multilib}" = "yes"; then
223   multilib_arg="--enable-multilib"
224 else
225   multilib_arg=
228 AC_CHECK_TYPES([struct timezone, struct stat, struct timespec, struct timeval, struct tm])
230 # Check if struct tm contains the tm_gmtoff field.
231 AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
232   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
233       #include <time.h>
234     ], [
235       struct tm tm;
236       tm.tm_gmtoff = 1;
237     ])],
238     [ac_cv_struct_tm_gmtoff=yes],
239     [ac_cv_struct_tm_gmtoff=no]
240   )
243 if (test "$ac_cv_struct_tm_gmtoff" = "yes"); then
244   AC_MSG_CHECKING([m2 front end detects struct tm with the tm_gmtoff field.])
245   AC_DEFINE(HAVE_TM_TM_GMTOFF, 1, [Define if struct tm has a tm_gmtoff field.])
248 AC_LANG_C
249 # Check the compiler.
250 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
251 # We must force CC to /not/ be precious variables; otherwise
252 # the wrong, non-multilib-adjusted value will be used in multilibs.
253 # As a side effect, we have to subst CFLAGS ourselves.
255 m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
256 m4_define([_AC_ARG_VAR_PRECIOUS],[])
257 AC_PROG_CC
258 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
260 AC_SUBST(CFLAGS)
262 AC_DEFUN([GM2_UNDEF],[
263   $as_echo "#undef HAVE_$1" >>confdefs.h
266 AC_DEFUN([GM2_CHECK_LIB],[
267   AC_MSG_CHECKING([m2 front end checking $1 library for $2])
268   if test x$gcc_no_link != xyes; then
269     AC_CHECK_LIB([$1],[$2],[AC_DEFINE([HAVE_$3],[1],[found $2])],[GM2_UNDEF([$3],[$2])])
270   else
271     if test "x$[ac_cv_lib_$1_$2]" = xyes; then
272       AC_DEFINE([HAVE_$3],[1],[lib$1 includes $2])
273     elif test "x$[ac_cv_func_$2]" = xyes; then
274       AC_DEFINE([HAVE_$3],[1],[function $2 exists])
275     else
276       GM2_UNDEF([$3],[$2])
277     fi
278   fi
281 GM2_CHECK_LIB([c],[access],[ACCESS])
282 GM2_CHECK_LIB([c],[brk],[BRK])
283 GM2_CHECK_LIB([c],[cfmakeraw],[CFMAKERAW])
284 GM2_CHECK_LIB([c],[clock_gettime],[CLOCK_GETTIME])
285 GM2_CHECK_LIB([c],[clock_settime],[CLOCK_SETTIME])
286 GM2_CHECK_LIB([c],[close],[CLOSE])
287 GM2_CHECK_LIB([c],[ctime],[CTIME])
288 GM2_CHECK_LIB([c],[creat],[CREAT])
289 GM2_CHECK_LIB([c],[daylight],[DAYLIGHT])
290 GM2_CHECK_LIB([c],[dup],[DUP])
291 GM2_CHECK_LIB([c],[execve],[EXECVE])
292 GM2_CHECK_LIB([c],[exit],[EXIT])
293 GM2_CHECK_LIB([c],[fcntl],[FCNTL])
294 GM2_CHECK_LIB([c],[fstat],[FSTAT])
295 GM2_CHECK_LIB([c],[getdents],[GETDENTS])
296 GM2_CHECK_LIB([c],[getgid],[GETGID])
297 GM2_CHECK_LIB([c],[getopt_long],[GETOPT_LONG])
298 GM2_CHECK_LIB([c],[getopt_long_only],[GETOPT_LONG_ONLY])
299 GM2_CHECK_LIB([c],[getpid],[GETPID])
300 GM2_CHECK_LIB([c],[gettimeofday],[GETTIMEOFD])
301 GM2_CHECK_LIB([c],[getuid],[GETUID])
302 GM2_CHECK_LIB([c],[ioctl],[IOCTL])
303 GM2_CHECK_LIB([c],[kill],[KILL])
304 GM2_CHECK_LIB([c],[link],[LINK])
305 GM2_CHECK_LIB([c],[lseek],[LSEEK])
306 GM2_CHECK_LIB([c],[open],[OPEN])
307 GM2_CHECK_LIB([c],[pause],[PAUSE])
308 GM2_CHECK_LIB([c],[pipe],[PIPE])
309 GM2_CHECK_LIB([c],[rand],[RAND])
310 GM2_CHECK_LIB([c],[read],[READ])
311 GM2_CHECK_LIB([c],[select],[SELECT])
312 GM2_CHECK_LIB([c],[setitimer],[SETITIMER])
313 GM2_CHECK_LIB([c],[setgid],[SETGID])
314 GM2_CHECK_LIB([c],[setuid],[SETUID])
315 GM2_CHECK_LIB([c],[stat],[STAT])
316 GM2_CHECK_LIB([c],[strsignal],[STRSIGNAL])
317 GM2_CHECK_LIB([c],[strtod],[STRTOD])
318 GM2_CHECK_LIB([c],[strtold],[STRTOLD])
319 GM2_CHECK_LIB([c],[times],[TIMES])
320 GM2_CHECK_LIB([c],[timezone],[TIMEZONE])
321 GM2_CHECK_LIB([c],[tzname],[TZNAME])
322 GM2_CHECK_LIB([c],[unlink],[UNLINK])
323 GM2_CHECK_LIB([c],[wait],[WAIT])
324 GM2_CHECK_LIB([c],[write],[WRITE])
326 GM2_CHECK_LIB([m],[signbit],[SIGNBIT])
327 GM2_CHECK_LIB([m],[signbitf],[SIGNBITF])
328 GM2_CHECK_LIB([m],[signbitl],[SIGNBITL])
330 AC_MSG_NOTICE([libgm2 has finished checking target libc and libm contents.])
332 # We test the host here and later on check the target.
334 # All known M2_HOST_OS values.  This is the union of all host operating systems
335 # supported by gm2.
337 M2_SUPPORTED_HOST_OS="aix freebsd hurd linux netbsd openbsd solaris windows darwin"
339 M2_HOST_OS=unknown
341 case ${host} in
342   *-*-darwin*)   M2_HOST_OS=darwin ;;
343   *-*-freebsd*)  M2_HOST_OS=freebsd ;;
344   *-*-linux*)    M2_HOST_OS=linux ;;
345   *-*-netbsd*)   M2_HOST_OS=netbsd ;;
346   *-*-openbsd*)  M2_HOST_OS=openbsd ;;
347   *-*-solaris2*) M2_HOST_OS=solaris ;;
348   *-*-aix*)      M2_HOST_OS=aix ;;
349   *-*-gnu*)      M2_HOST_OS=hurd ;;
350 esac
352 M2_TARGET_OS=unknown
354 case ${target} in
355   *-*-darwin*)   M2_TARGET_OS=darwin ;;
356   *-*-freebsd*)  M2_TARGET_OS=freebsd ;;
357   *-*-linux*)    M2_TARGET_OS=linux ;;
358   *-*-netbsd*)   M2_TARGET_OS=netbsd ;;
359   *-*-openbsd*)  M2_TARGET_OS=openbsd ;;
360   *-*-solaris2*) M2_TARGET_OS=solaris ;;
361   *-*-aix*)      M2_TARGET_OS=aix ;;
362   *-*-gnu*)      M2_TARGET_OS=hurd ;;
363 esac
365 # M2_HOST_OS=unknown
366 if test x${M2_HOST_OS} = xunknown; then
367    AC_MSG_NOTICE([unsupported host, will build a minimal m2 library])
368    BUILD_PIMLIB=false
369    BUILD_ISOLIB=false
370    BUILD_CORLIB=false
371    BUILD_LOGLIB=false
372 else
373    AC_MSG_NOTICE([m2 library will be built on ${M2_HOST_OS}])
374    BUILD_PIMLIB=true
375    BUILD_ISOLIB=true
376    BUILD_CORLIB=true
377    BUILD_LOGLIB=true
380 CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
381 AC_SUBST(CC_FOR_BUILD)
383 # Propagate GM2_FOR_TARGET into Makefiles
384 GM2_FOR_TARGET=${GM2_FOR_TARGET:-gcc}
385 AC_SUBST(GM2_FOR_TARGET)
387 # Now we check the target as long as it is a supported host.
388 # For some embedded targets we choose minimal runtime system which is
389 # just enough to satisfy the linker targetting raw metal.
390 if test x${M2_HOST_OS} != xunknown; then
391 AC_MSG_NOTICE([m2 library building for target ${target}])
392 case "$target" in
394   avr25*-*-* | avr31*-*-* | avr35*-*-* | avr4*-*-* | avr5*-*-* | avr51*-*-* | avr6*-*-*)
395   BUILD_PIMLIB=false
396   BUILD_ISOLIB=false
397   BUILD_CORLIB=false
398   BUILD_LOGLIB=false
399   ;;
401   avrxmega2*-*-* | avrxmega4*-*-* | avrxmega5*-*-* | avrxmega6*-*-* | avrxmega7*-*-*)
402   BUILD_PIMLIB=false
403   BUILD_ISOLIB=false
404   BUILD_CORLIB=false
405   BUILD_LOGLIB=false
406   ;;
408   avr3-*-*)
409   BUILD_PIMLIB=true
410   BUILD_ISOLIB=true
411   BUILD_CORLIB=true
412   BUILD_LOGLIB=true
413   ;;
414   esp32-*-*)
415   BUILD_PIMLIB=false
416   BUILD_ISOLIB=false
417   BUILD_CORLIB=false
418   BUILD_LOGLIB=false
419   ;;
421 esac
424 # GM2_MSG_RESULT issue a query message from the first parameter and a boolean result
425 # in the second parameter is printed as a "yes" or "no".
427 AC_DEFUN([GM2_MSG_RESULT],[
428    AC_MSG_CHECKING([$1])
429    if test x${$2} = xtrue; then
430       AC_MSG_RESULT([yes])
431    else
432       AC_MSG_RESULT([no])
433    fi
436 if test x${M2_HOST_OS} = xunknown; then
437    AC_MSG_NOTICE([m2 front end will only build minimal Modula-2 runtime library on this host])
438 else
439    GM2_MSG_RESULT([m2 front end will build PIM libraries:],[BUILD_PIMLIB])
440    GM2_MSG_RESULT([m2 front end will build ISO libraries:],[BUILD_ISOLIB])
441    GM2_MSG_RESULT([m2 front end will build coroutine libraries:],[BUILD_CORLIB])
442    GM2_MSG_RESULT([m2 front end will build Logitech compatability libraries:],[BUILD_LOGLIB])
445 AM_CONDITIONAL([BUILD_PIMLIB], [test x$BUILD_PIMLIB = xtrue])
446 AM_CONDITIONAL([BUILD_ISOLIB], [test x$BUILD_ISOLIB = xtrue])
447 AM_CONDITIONAL([BUILD_CORLIB], [test x$BUILD_CORLIB = xtrue])
448 AM_CONDITIONAL([BUILD_LOGLIB], [test x$BUILD_LOGLIB = xtrue])
449 AM_CONDITIONAL([TARGET_DARWIN], [test x$M2_TARGET_OS = xdarwin])
451 # Determine what GCC version number to use in filesystem paths.
452 GCC_BASE_VER
454 AC_CONFIG_SRCDIR([Makefile.am])
455 AC_CONFIG_FILES([Makefile])
457 AC_CONFIG_FILES(AC_FOREACH([DIR], [libm2min libm2pim libm2iso libm2cor libm2log], [DIR/Makefile ]),
458  [ cat > vpsed$$ << \_EOF
459 s!`test -f '$<' || echo '$(srcdir)/'`!!
460 _EOF
461    sed -f vpsed$$ $ac_file > tmp$$
462    mv tmp$$ $ac_file
463    rm vpsed$$
464    echo 'MULTISUBDIR =' >> $ac_file
465    ml_norecursion=yes
466    . ${multi_basedir}/config-ml.in
467    AS_UNSET([ml_norecursion])
470 AC_MSG_NOTICE([libgm2 has been configured.])
472 AC_OUTPUT