autoconf/tests/erlang.at
2023-01-20 23:41:13 -06:00

118 lines
3.5 KiB
Plaintext

# -*- Autotest -*-
# Macros tested in acerlang.at:
# AC_ERLANG_PATH_ERL
# AC_ERLANG_PATH_ERLC
# AC_ERLANG_SUBST_ERTS_VER
# AU::AC_LANG_ERLANG
AT_BANNER([Erlang low level compiling and utility macros.])
# Copyright (C) 2009-2017, 2020-2023 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Since the macros which compile are required by most tests, check
# them first. But remember that looking for a compiler is even more
# primitive, so check those first.
## ----------------- ##
## Erlang Compiler. ##
## ----------------- ##
AT_CHECK_MACRO([Erlang basic compilation],
[[AC_LANG([Erlang])
AC_CACHE_CHECK([whether erlc works], [ac_cv_erlang_erlc_works],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [halt(0)])],
[ac_cv_erlang_erlc_works=yes],
[ac_cv_erlang_erlc_works=no])])
if test $ac_cv_erlang_erlc_works = no; then
AC_MSG_ERROR([could not compile a test Erlang module])
fi
# To keep AT_CHECK_MACRO happy, we lie and say that erl does work
# when cross compiling.
AC_CACHE_CHECK([whether erl works], [ac_cv_erlang_erl_works],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([], [halt(0)])],
[ac_cv_erlang_erl_works=yes],
[ac_cv_erlang_erl_works=no],
[ac_cv_erlang_erl_works=yes])])
if test $ac_cv_erlang_erl_works = no; then
AC_MSG_ERROR([could not run a test Erlang module])
fi
]])
## ---------------------- ##
## Erlang lib detection. ##
## ---------------------- ##
AT_CHECK_MACRO([AC_ERLANG_CHECK_LIB],
[[AC_ERLANG_CHECK_LIB([stdlib])
if test "$ERLANG_LIB_DIR_stdlib" = "not found"; then
AC_MSG_ERROR([failed to find the Erlang stdlib])
fi
## Test that the lib path detection really detected a directory:
if test ! -d "$ERLANG_LIB_DIR_stdlib"; then
AC_MSG_ERROR([incorrect ERLANG_LIB_DIR_stdlib variable])
fi
]])
## --------------------------- ##
## Erlang root dir detection. ##
## --------------------------- ##
AT_CHECK_MACRO([AC_ERLANG_SUBST_ROOT_DIR],
[[AC_ERLANG_SUBST_ROOT_DIR
## Test that the root path detection really detected a directory:
if test ! -d "$ERLANG_ROOT_DIR"; then
AC_MSG_ERROR([incorrect ERLANG_ROOT_DIR variable])
fi
]])
## -------------------------- ##
## Erlang lib dir detection. ##
## -------------------------- ##
AT_CHECK_MACRO([AC_ERLANG_SUBST_LIB_DIR],
[[AC_ERLANG_SUBST_LIB_DIR
## Test that the lib path detection really detected a directory:
if test ! -d "$ERLANG_LIB_DIR"; then
AC_MSG_ERROR([incorrect ERLANG_LIB_DIR variable])
fi
]],
[AT_KEYWORDS([Erlang])])
## ---------------------------------- ##
## Erlang install lib dir detection. ##
## ---------------------------------- ##
AT_CHECK_MACRO([AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR],
[[AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR([test_blah], [1.24-b])
## Test that the generated directory name is well-formed:
if test `echo "$ERLANG_INSTALL_LIB_DIR_test_blah" | sed -e 's/^.*\///'` \
!= "test_blah-1.24-b"; then
AC_MSG_ERROR([incorrect ERLANG_INSTALL_LIB_DIR_test_blah variable])
fi
]],
[AT_KEYWORDS([Erlang])])