summaryrefslogtreecommitdiff
path: root/tests/erlang.at
blob: e914b5d4c09a40387ae92e1a36f906dafc4e6384 (plain)
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
#							-*- 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])])