re PR ada/88191 (ada bootstrap failure on alpha-linux-gnu ("SIGSYS" not declared...
[official-gcc.git] / libphobos / m4 / autoconf.m4
blobf46a7809f4361362b56021c62ad6ff2019549344
2 # Minimal autoconf support for the D language.
3 # Adapted from the Go language support files.
6 # ------------------- #
7 # Language selection.
8 # ------------------- #
10 # AC_LANG(D)
11 # -----------
12 AC_LANG_DEFINE([D], [d], [GDC], [GDC], [],
13 [ac_ext=d
14 ac_compile='$GDC -c $GDCFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
15 ac_link='$GDC -o conftest$ac_exeext $GDCFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
16 ac_compiler_gnu=yes
19 # AC_LANG_D
20 # ----------
21 AU_DEFUN([AC_LANG_D], [AC_LANG(D)])
23 # ------------------- #
24 # Producing programs.
25 # ------------------- #
27 # AC_LANG_PROGRAM(D)([PROLOGUE], [BODY])
28 # ---------------------------------------
29 m4_define([AC_LANG_PROGRAM(D)],
30 [module mod;
33 extern(C) int main() {
34   $2
35 }])
37 # _AC_LANG_IO_PROGRAM(D)
38 # -----------------------
39 # Produce source that performs I/O.
40 m4_define([_AC_LANG_IO_PROGRAM(D)],
41 [AC_LANG_PROGRAM([import core.stdc.stdio;],
42 [FILE *f = fopen ("conftest.out", "w");
43  return ferror (f) || fclose (f) != 0;
44 ])])
46 # AC_LANG_CALL(D)(PROLOGUE, FUNCTION)
47 # ------------------------------------
48 # TODO: Avoid conflicting decl of main?
49 # Used by AC_SEARCH_LIBS.
50 m4_define([AC_LANG_CALL(D)],
51 [AC_LANG_PROGRAM([$1 extern(C) int $2();], [$2(); return 0;])])
53 # AC_LANG_FUNC_LINK_TRY(D)(FUNCTION)
54 # -----------------------------------
55 # Try to link a program which calls FUNCTION.
56 # This only works for extern(C) functions.
57 m4_define([AC_LANG_FUNC_LINK_TRY(D)],
58 [AC_LANG_PROGRAM([extern(C) int $1();], [return $1();])])
60 # AC_LANG_BOOL_COMPILE_TRY(D)(PROLOGUE, EXPRESSION)
61 # --------------------------------------------------
62 # Return a program which is valid if EXPRESSION is nonzero.
63 # Probably not that useful for D, we can extract any information
64 # we need using CTFE.
65 m4_define([AC_LANG_BOOL_COMPILE_TRY(D)],
66 [AC_LANG_PROGRAM([$1],
67 [static assert($2); return 0;])])
69 # AC_LANG_INT_SAVE(D)(PROLOGUE, EXPRESSION)
70 # ------------------------------------------
71 m4_define([AC_LANG_INT_SAVE(D)],
72 [AC_LANG_PROGRAM([$1
73 import core.stdc.stdio, core.stdc.stdlib;
76   FILE *f = fopen ("conftest.val", "w");
77   if (! f)
78     return 1;
79   if (($2) < 0)
80     {
81       fprintf (f, "%ld", $2);
82     }
83   else
84     {
85       fprintf (f, "%lu", $2);
86     }
87   /* Do not output a trailing newline, as this causes \r\n confusion
88      on some platforms.  */
89   return ferror (f) || fclose (f) != 0;
90 ])])
92 # ---------------------- #
93 # Looking for compilers. #
94 # ---------------------- #
96 # AC_LANG_COMPILER(D)
97 # --------------------
98 AC_DEFUN([AC_LANG_COMPILER(D)],
99 [AC_REQUIRE([AC_PROG_GDC])])
101 # AC_PROG_GDC
102 # ----------
103 AN_MAKEVAR([GDC], [AC_PROG_GDC])
104 AN_PROGRAM([gdc], [AC_PROG_GDC])
105 AC_DEFUN([AC_PROG_GDC],
106 [AC_LANG_PUSH(D)dnl
107 AC_ARG_VAR([GDC],     [D compiler command])dnl
108 AC_ARG_VAR([GDCFLAGS],  [D compiler flags])dnl
109 _AC_ARG_VAR_LDFLAGS()dnl
110 m4_ifval([$1],
111       [AC_CHECK_TOOLS(GDC, [$1])],
112 [AC_CHECK_TOOL(GDC, gdc)
113 if test -z "$GDC"; then
114   if test -n "$ac_tool_prefix"; then
115     AC_CHECK_PROG(GDC, [${ac_tool_prefix}gdc], [$ac_tool_prefix}gdc])
116   fi
118 if test -z "$GDC"; then
119   AC_CHECK_PROG(GDC, gdc, gdc, , , false)
123 # Provide some information about the compiler.
124 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
125 set X $ac_compile
126 ac_compiler=$[2]
127 _AC_DO_LIMIT([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
128 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
129 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
130 AC_LANG_POP(D)dnl
131 ])# AC_PROG_D