summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 9e5442d2e94502c721304d947a9c34fea172e3ad (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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
dnl $LAAS: configure.ac 2010/01/21 17:25:50 mallet $
dnl
dnl configure.in --
dnl	process this file with autoconf to produce a configure script.
dnl

AC_REVISION($LAAS: configure.ac 2010/01/21 17:25:50 mallet $)

AC_INIT([eltclsh],[1.11.99],[openrobots@laas.fr])
AC_PREREQ(2.59)

AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADER(config.h)

AC_CANONICAL_HOST

dnl --- config.h stuff --------------------------------------------------
dnl
AH_TOP([
#ifndef H_ELTCLSH_CONFIG
#define H_ELTCLSH_CONFIG
])

AH_VERBATIM(__RCSID,[
#ifndef __RCSID
#ifdef __GNUC__
#define __RCSID(id) static const char rcsid[] __attribute__((__unused__)) = id
#else
#define __RCSID(id) static const char rcsid[] = id
#endif /* __GNUC__ */
#endif
])

AH_BOTTOM([
#endif /* H_ELTCLSH_CONFIG */
])


dnl --- name of the interpreters ----------------------------------------
ELTCLSH=eltclsh
ELWISH=elwish
ELPKG=eltclsh
AC_SUBST(ELTCLSH)
AC_SUBST(ELWISH)
AC_SUBST(ELPKG)


dnl Checks for headers --------------------------------------------------
dnl
AC_CHECK_HEADERS(sys/cdefs.h)


dnl --- checks for programs ---------------------------------------------
dnl
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)

AC_PROG_MAKE_SET
AC_PROG_CC

ROBOT_CFLAGS

ROBOT_PROG_MKDEP


dnl try to find an eltclsh for the host machine
if test "x${cross_compiling}" = "xyes"; then
   AC_PATH_PROG(HOST_ELTCLSH, eltclsh, [:],	${PATH})
else
   HOST_ELTCLSH=
fi
AC_SUBST(HOST_ELTCLSH)


dnl --- checks for typedefs ---------------------------------------------
dnl
AC_TYPE_SIGNAL

dnl --- strl* -----------------------------------------------------------
dnl
AC_REPLACE_FUNCS(strlcat strlcpy)

dnl --- check for extra includes or lib dirs ----------------------------
dnl
withval=""
AC_ARG_WITH(includes,
	[  --with-includes=DIR     search include DIR for optional packages])
for ac_dir in NONE $withval ; do\
   if test "x$ac_dir" != "xNONE"; then
	if test ! -d $ac_dir; then
		AC_MSG_RESULT([Warning: directory $ac_dir does not exist])
	else
		AC_MSG_RESULT([adding $ac_dir to include search path])
		extra_include="$extra_include $ac_dir"
	fi
   fi
done

withval=""
AC_ARG_WITH(libraries,
	[  --with-libraries=DIR    search library DIR for optional packages])
for ac_dir in NONE $withval ; do \
   if test "x$ac_dir" != "xNONE"; then
	if test ! -d $ac_dir; then
		AC_MSG_RESULT([Warning: directory $ac_dir does not exist])
	else
		AC_MSG_RESULT([adding $ac_dir to library search path])
		extra_lib="$extra_lib $ac_dir"
	fi
   fi
done


dnl --- checks for libraries --------------------------------------------
dnl
AC_PATH_XTRA
ROBOT_LIB_TCL
ROBOT_LIB_TK

AC_SEARCH_LIBS([tputs], [termcap ncurses])
AC_SEARCH_LIBS([ceil], [m])

dnl libedit
AC_LANG_C
ac_tmp_cppflags=$CPPFLAGS
ac_tmp_ldflags=$LDFLAGS
ac_tmp_libs=$LIBS

AC_MSG_CHECKING([for libedit headers])

AC_TRY_LINK([#include <histedit.h>], [int a = EL_GETCFN],
[
  AC_MSG_RESULT([found])
  EL_CPPFLAGS=
],
[
  for ac_dir in \
	$prefix/include		\
	$extra_include		\
	/usr/local/include	\
	/usr/include		\
	; \
  do
  if test -r "$ac_dir/histedit.h"; then
    CPPFLAGS="${ac_tmp_cppflags} -I$ac_dir"
    AC_TRY_LINK([#include <histedit.h>], [int a = EL_GETCFN], [], [continue])
    ac_edit_header=$ac_dir
    break
  fi
  done
  if test "x$ac_edit_header" = "x"; then
    AC_MSG_RESULT([not found (fatal)])
    AC_MSG_RESULT([Please use --with-includes to specify a valid path to your libedit headers]) 
    AC_MSG_RESULT([Also, make sure you have the EL_GETCFN function.]) 
    exit 2;
  fi
  AC_MSG_RESULT([$ac_edit_header])
  EL_CPPFLAGS="-I$ac_edit_header"
])

AC_MSG_CHECKING([for libedit library])

AC_TRY_LINK([#include <histedit.h>], [el_set(0, EL_GETCFN)],
[
  AC_MSG_RESULT([found])
  EL_LIB_SPEC="-ledit $LIBS"
],
[
  for ac_dir in \
	$exec_prefix/lib	\
	$prefix/lib		\
	$extra_lib		\
	/usr/local/lib		\
	/usr/lib		\
	; \
  do
  if test -d $ac_dir; then
    LDFLAGS="-L$ac_dir ${ac_tmp_ldflags}"
    LIBS="-ledit ${ac_tmp_libs}"
    AC_TRY_LINK([#include <histedit.h>], [el_set(0, EL_GETCFN)],
		[], [continue])
    ac_edit_lib=$ac_dir
    break
  fi
  done
  if test "x$ac_edit_lib" = "x"; then
    AC_MSG_RESULT([not found (fatal)])
    AC_MSG_ERROR([Please use --with-libraries to specify a valid path to your libedit library], 2) 
  fi
  AC_MSG_RESULT([$ac_edit_lib])

  EL_LIB_SPEC="-L$ac_edit_lib -ledit ${ac_tmp_libs}"
])

CPPFLAGS="$ac_tmp_cppflags"
LDFLAGS="$ac_tmp_ldflags"
LIBS="$ac_tmp_libs"

AC_SUBST(EL_CPPFLAGS)
AC_SUBST(EL_LIB_SPEC)

dnl --- create the Makefiles --------------------------------------------
dnl

AC_OUTPUT(eltclsh.pc config.mk Makefile src/Makefile tcl/Makefile)