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