Debian Codegraph @

utils/xml2pmx/xml2pmx-src/acinclude.m4

raw
1 dnl
2 dnl acinclude.m4 for OBC and friends
3 dnl
4 dnl This file is part of the Oxford Oberon-2 compiler
5 dnl Copyright (c) 2006--2020 J. M. Spivey
6 dnl All rights reserved
7 dnl
8 dnl Redistribution and use in source and binary forms, with or without
9 dnl modification, are permitted provided that the following conditions
10 dnl are met:
11 dnl
12 dnl 1. Redistributions of source code must retain the above copyright
13 dnl notice, this list of conditions and the following disclaimer.
14 dnl 2. Redistributions in binary form must reproduce the above
15 dnl copyright notice, this list of conditions and the following
16 dnl disclaimer in the documentation and/or other materials provided
17 dnl with the distribution.
18 dnl 3. The name of the author may not be used to endorse or promote products
19 dnl derived from this software without specific prior written permission.
20 dnl
21 dnl THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
22 dnl OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 dnl WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 dnl ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25 dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 dnl WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 dnl
33
34 dnl See if indexed jumps will compile
35 AC_DEFUN([AC_C_INDEXED_JUMPS],
36 [AC_CACHE_CHECK(for indexed jumps, ac_cv_c_indexed_jumps,
37 [AC_TRY_COMPILE(, [void *a[] = { &&b, &&c }; b: goto *a[1]; c:;],
38 ac_cv_c_indexed_jumps=yes, ac_cv_c_indexed_jumps=no)])
39 if test $ac_cv_c_indexed_jumps = yes; then
40 AC_DEFINE(HAVE_INDEXED_JUMPS, 1,
41 [Define if indexed jumps work.])
42 fi])
43
44 dnl See if the C compiler understands __attribute__ ((unused))
45 AC_DEFUN([AC_C_UNUSED],
46 [AC_CACHE_CHECK(for 'unused' attribute, ac_cv_unused_attr,
47 [AC_TRY_COMPILE(, [int __attribute__ ((unused)) n],
48 ac_cv_unused_attr=yes, ac_cv_unused_attr=no)])
49 if test $ac_cv_unused_attr = yes; then
50 UNUSED="__attribute__ ((unused))"
51 fi
52 AC_DEFINE_UNQUOTED(UNUSED, $UNUSED, [Attribute for unused variables])])
53
54 dnl See if the C compiler understands __attribute__ ((used))
55 AC_DEFUN([AC_C_USED],
56 [AC_CACHE_CHECK(for 'used' attribute, ac_cv_used_attr,
57 [AC_TRY_COMPILE(, [int __attribute__ ((used)) n],
58 ac_cv_used_attr=yes, ac_cv_used_attr=no)])
59 if test $ac_cv_used_attr = yes; then
60 USED="__attribute__ ((used))"
61 fi
62 AC_DEFINE_UNQUOTED(USED, $USED, [Attribute for used variables])])
63
64 dnl See if the C compiler understands __attribute__ ((noreturn))
65 AC_DEFUN([AC_C_NORETURN],
66 [AC_CACHE_CHECK(for 'noreturn' attribute, ac_cv_noreturn_attr,
67 [AC_COMPILE_IFELSE(
68 [AC_LANG_SOURCE(
69 [[void __attribute__ ((noreturn)) f(void) { while (1) ; }]])],
70 ac_cv_noreturn_attr=yes, ac_cv_noreturn_attr=no)])
71 if test $ac_cv_noreturn_attr = yes; then
72 NORETURN="__attribute__ ((noreturn))"
73 fi
74 AC_DEFINE_UNQUOTED(NORETURN, $NORETURN,
75 [Attribute for functions that don't return])])
76
77 dnl test if C compiler understands -rdynamic
78 AC_DEFUN([AC_TEST_RDYNAMIC],
79 [AC_CACHE_CHECK(if ${CC-cc} understands -rdynamic, ac_cv_rdynamic,
80 [echo 'main() { return 0; }' >conftest.c
81 if AC_TRY_COMMAND(${CC-cc} $CFLAGS -o conftest${ac_exeext} -rdynamic
82 conftest.c 2>conftest.err) \
83 && ! grep -q 'unrecognized option' conftest.err
84 then ac_cv_rdynamic=yes; else ac_cv_rdynamic=no; fi
85 rm -f conftest.c conftest.err conftest${ac_exeext}])
86 if test $ac_cv_rdynamic = yes; then $1; fi])
87
88 dnl Find the page size (check sys/param.h if this doesn't work)
89 AC_DEFUN([AC_FIND_PAGESIZE],
90 [AC_CHECK_FUNCS(getpagesize)
91 AC_CACHE_CHECK(page size, ac_cv_pagesize,
92 [AC_TRY_RUN([#include <stdio.h>
93 #ifndef HAVE_GETPAGESIZE
94 #ifdef HAVE_UNISTD_H
95 #include <unistd.h>
96 #endif
97 #ifdef _SC_PAGESIZE
98 #define getpagesize() sysconf(_SC_PAGESIZE)
99 #endif
100 #endif
101 main() {
102 FILE *f = fopen("conftestval", "w");
103 if (f == NULL) exit(1);
104 /* No newline here, in case a CRLF creeps in and cygwin chokes */
105 fprintf(f, "%d", getpagesize());
106 exit(0);
107 }], ac_cv_pagesize=`cat conftestval`,
108 ac_cv_pagesize=4096, ac_cv_pagesize=4096)])
109 AC_DEFINE_UNQUOTED(PAGESIZE, $ac_cv_pagesize, [Page size])
110 AC_SUBST(PAGESIZE, $ac_cv_pagesize)
111
112 # Compute log2(page size)
113 tmpa=1; tmpb=0
114 while test $tmpa -lt $ac_cv_pagesize; do
115 tmpa=`expr 2 \* $tmpa`; tmpb=`expr $tmpb + 1`
116 done
117 AC_DEFINE_UNQUOTED(LOG_PAGESIZE, $tmpb, [Log2 of page size])])