2 # Minimal autoconf support for the D language.
3 # Adapted from the Go language support files.
6 # ------------------- #
8 # ------------------- #
12 AC_LANG_DEFINE([D], [d], [GDC], [GDC], [],
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'
21 AU_DEFUN([AC_LANG_D], [AC_LANG(D)])
23 # ------------------- #
25 # ------------------- #
27 # AC_LANG_PROGRAM(D)([PROLOGUE], [BODY])
28 # ---------------------------------------
29 m4_define([AC_LANG_PROGRAM(D)],
33 extern(C) int main() {
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;
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
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)],
73 import core.stdc.stdio, core.stdc.stdlib;
76 FILE *f = fopen ("conftest.val", "w");
81 fprintf (f, "%ld", $2);
85 fprintf (f, "%lu", $2);
87 /* Do not output a trailing newline, as this causes \r\n confusion
89 return ferror (f) || fclose (f) != 0;
92 # ---------------------- #
93 # Looking for compilers. #
94 # ---------------------- #
97 # --------------------
98 AC_DEFUN([AC_LANG_COMPILER(D)],
99 [AC_REQUIRE([AC_PROG_GDC])])
103 AN_MAKEVAR([GDC], [AC_PROG_GDC])
104 AN_PROGRAM([gdc], [AC_PROG_GDC])
105 AC_DEFUN([AC_PROG_GDC],
107 AC_ARG_VAR([GDC], [D compiler command])dnl
108 AC_ARG_VAR([GDCFLAGS], [D compiler flags])dnl
109 _AC_ARG_VAR_LDFLAGS()dnl
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])
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])
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