-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
173 lines (140 loc) · 4.32 KB
/
configure.ac
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
############################################################################
# configure.ac
#
# Build configuration script for OCaml curses bindings.
#
# History:
#
# 2008-04-08 pjp Derived from Wyrd 1.4.4 build system.
############################################################################
# Check for a particular file from the source tree
AC_INIT(config.ml.in)
# optional arguments
AC_ARG_ENABLE(widec,
[ --enable-widec link against a wide-character-enabled ncurses)],
[try_widec=$enable_widec], [try_widec=no])
# Find a C compiler
AC_PROG_CC
AC_PROG_CC_C_O
AC_PROG_RANLIB
ORIG_LIBS="$LIBS"
ORIG_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CURSES_INCLUDE $ORIG_CPPFLAGS"
# Non-required headers.
AC_CHECK_HEADERS([termios.h sys/ioctl.h windows.h])
# Check for ncurses, and test a number of different locations for the header
AC_MSG_CHECKING(for working ncurses library)
if test "$try_widec" != "no"
then
LIBS="-lncursesw $ORIG_LIBS"
AC_TRY_LINK(
[#include <ncursesw/curses.h>], [initscr(); use_default_colors()],
[CURSES_LIB=-lncursesw
AC_DEFINE(CURSES_HEADER, <ncursesw/curses.h>, [Defined to ncurses header file])])
fi
if test -z "$CURSES_LIB"
then
LIBS="-lncurses $ORIG_LIBS"
AC_TRY_LINK(
[#include <ncurses/curses.h>], [initscr(); use_default_colors()],
[CURSES_LIB=-lncurses
AC_DEFINE(CURSES_HEADER, <ncurses/curses.h>, [Defined to ncurses header file])],
[
LIBS="-lncurses $ORIG_LIBS"
AC_TRY_LINK(
[#include <ncurses.h>], [initscr(); use_default_colors()],
[CURSES_LIB=-lncurses
AC_DEFINE(CURSES_HEADER, <ncurses.h>, [Defined to ncurses header file])],
[
LIBS="-lcurses $ORIG_LIBS"
AC_TRY_LINK(
[#include <curses.h>], [initscr(); use_default_colors()],
[CURSES_LIB=-lcurses
AC_DEFINE(CURSES_HEADER, <curses.h>, [Defined to ncurses header file])],
[
LIBS="-lncurses $ORIG_LIBS"
AC_TRY_LINK(
[#include <curses.h>], [initscr(); use_default_colors()],
[CURSES_LIB=-lcurses
AC_DEFINE(CURSES_HEADER, <curses.h>, [Defined to ncurses header file])],
[
LIBS="-lpdcurses $ORIG_LIBS"
AC_TRY_LINK(
[#include <curses.h>], [initscr(); use_default_colors()],
[CURSES_LIB=-lpdcurses
AC_DEFINE(PDCURSES, 1, [Define if this is PDCurses])
AC_DEFINE(CURSES_HEADER, <curses.h>, [Defined to pdcurses header file])],
) ]) ]) ]) ])
fi
if test -n "$CURSES_LIB"
then
AC_MSG_RESULT([found in $CURSES_LIB])
else
AC_MSG_ERROR([not found])
fi
# Try to locate term.h, which has a sadly nonstandardized location
AC_MSG_CHECKING(for term.h)
AC_TRY_COMPILE(
[#include <term.h>], [TERMINAL __dummy],
[TERM_H_STRING="<term.h>"
AC_DEFINE(CURSES_TERM_H, <term.h>, [Defined to ncurses term.h file])],
[
AC_TRY_COMPILE(
[#include <ncurses/term.h>], [TERMINAL __dummy],
[TERM_H_STRING="<ncurses/term.h>"
AC_DEFINE(CURSES_TERM_H, <ncurses/term.h>, [Defined to ncurses term.h file])],
[
AC_TRY_COMPILE(
[#include <curses/term.h>], [TERMINAL __dummy],
[TERM_H_STRING="<curses/term.h>"
AC_DEFINE(CURSES_TERM_H, <curses/term.h>, [Defined to ncurses term.h file])],
) ]) ])
if test -n "$TERM_H_STRING"
then
AC_MSG_RESULT([found in $TERM_H_STRING])
else
AC_MSG_ERROR([not found])
fi
# Determine whether the detected curses has wide character support
BOOL_WIDE_CURSES="false"
if test -n "$CURSES_LIB"
then
LIBS="$CURSES_LIB $ORIG_LIBS"
if test "$try_widec" != "no"
then
AC_MSG_CHECKING(for wide character support in ncurses library)
AC_TRY_LINK(
[#include <wchar.h>
#include CURSES_HEADER
],
[wchar_t wch = 0;
addnwstr(&wch, 1);],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_WIDE_CURSES, 1, [Defined if ncurses library includes wide character support])
BOOL_WIDE_CURSES="true"],
[AC_MSG_RESULT(no)])
fi
fi
# Look for some functions which aren't found in all
# curses implementations, eg. PDCurses. These are
# optional: we will substitute them where we can.
AC_CHECK_FUNCS([resizeterm resize_term])
CURSES_LIB_BASE=`expr "$CURSES_LIB" : '-l\(.*\)'`
CPPFLAGS="$ORIG_CPPFLAGS"
LIBS="$ORIG_LIBS"
# Perform substitutions
AC_SUBST(CURSES_HEADER)
AC_SUBST(CURSES_TERM_H)
AC_SUBST(CURSES_LIB)
AC_SUBST(CURSES_LIB_BASE)
AC_SUBST(BOOL_WIDE_CURSES)
AC_SUBST(DEFS)
AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
# Generate the Makefile and config module
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES(Makefile config.ml)
AC_OUTPUT
chmod a-w Makefile