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