Merged revisions 129343 via svnmerge from
[asterisk/asterisk.git] / main / editline / configure.in
1 dnl 
2 dnl Process this file with autoconf to produce a configure script.
3 dnl 
4 AC_INIT(Makefile.in)
5
6 dnl If CFLAGS isn't defined and using gcc, set CFLAGS to something reasonable.
7 dnl Otherwise, just prevent autoconf from molesting CFLAGS.
8 CFLAGS=$CFLAGS
9 AC_PROG_CC
10 if test "x$CFLAGS" = "x" ; then
11   no_CFLAGS="yes"
12 fi
13 if test "x$no_CFLAGS" = "xyes" -a "x$GCC" = "xyes" ; then
14         CFLAGS="-Wall -pipe -g3"
15 fi
16 A_CFLAGS=""
17 AC_SUBST(A_CFLAGS)
18 S_CFLAGS="-fPIC -DPIC"
19 AC_SUBST(S_CFLAGS)
20 AC_PROG_CPP
21 AC_PROG_AWK
22
23 dnl Platform-specific settings.  The ABI can probably be determined
24 dnl programmatically, but doing so is error-prone, which makes it generally
25 dnl not worth the trouble.
26 AC_CANONICAL_HOST
27 case "${host}" in
28   *-*-darwin*)
29         CFLAGS="$CFLAGS -fno-common -no-cpp-precomp"
30         ABI="macho"
31         ;;
32   *-*-freebsd*)
33         ABI="elf"
34         ;;
35   *-*-linux* | *cygwin*)
36         if echo ${host} | grep -q cygwin ; then \
37                 echo "cygwin detected"; \
38                 S_CFLAGS=""; \
39                 echo "/* cygdef.h. Generated automatically by configure. */ 
40 #ifndef _CYGDEF_H_
41 #define _CYGDEF_H_ 1
42 #include <sys/ioctl.h>
43 #define __linux__ 1
44  
45
46 typedef void (*sig_t)(int);
47  
48
49 #endif /* _CYGDEF_H_ */" > cygdef.h; \
50         echo "
51  #define CYGWIN 1
52 " > confdefs.h; \
53         fi
54         ABI="elf"
55         ;;
56   *-*-netbsd*)
57         AC_MSG_CHECKING(ABI)
58         AC_EGREP_CPP(yes,
59 [#ifdef __ELF__
60   yes
61 #endif
62 ],
63                      ABI="elf",
64                      ABI="aout")
65         AC_MSG_RESULT($ABI)
66         ;;
67   *-*-solaris2*)
68         ABI="elf"
69         AC_DEFINE(SUNOS)
70         ;;
71   *)
72         AC_MSG_RESULT(Unsupported operating system: ${host})
73         ABI="elf"
74         ;;
75 esac
76
77 AC_PROG_INSTALL
78 AC_PROG_RANLIB
79 AC_PATH_PROG(AR, ar, , $PATH)
80
81 dnl Search for termcap access routines in termcap, tinfo, curses, and ncurses.
82 AC_CHECK_LIB(termcap, tgetent, , \
83   AC_CHECK_LIB(tinfo, tgetent, , \
84     AC_CHECK_LIB(curses, tgetent, , \
85       AC_CHECK_LIB(ncurses, tgetent, , \
86         AC_MSG_ERROR(termcap support not found)))))
87
88 dnl Use termcap.h if it exists; otherwise we need both term.h and [n]curses.h.
89 AC_CHECK_HEADERS(termcap.h, , \
90   AC_CHECK_HEADERS(term.h, , \
91     AC_MSG_RESULT(Need term.h since termcap.h is missing))
92   AC_CHECK_HEADERS(curses.h, , \
93     AC_CHECK_HEADERS(ncurses.h, , \
94       AC_MSG_RESULT(Need curses.h or ncurses.h))))
95
96 AC_CHECK_HEADERS(sys/cdefs.h vis.h)
97
98 AC_CHECK_FUNCS(issetugid)
99 AC_CHECK_FUNCS(fgetln, , CCSRCS="$CCSRCS np/fgetln.c")
100 AC_CHECK_FUNCS(strvis, , CCSRCS="$CCSRCS np/vis.c")
101 AC_CHECK_FUNCS(strunvis, , CCSRCS="$CCSRCS np/unvis.c")
102
103 AC_EGREP_CPP(yes,
104 [#include <sys/cdefs.h>
105 #ifdef __RCSID
106   yes
107 #endif
108 ], , [CPPFLAGS="$CPPFLAGS '-D__RCSID(x)='"])
109
110 AC_EGREP_CPP(yes,
111 [#include <sys/cdefs.h>
112 #ifdef __COPYRIGHT
113   yes
114 #endif
115 ], , [CPPFLAGS="$CPPFLAGS '-D__COPYRIGHT(x)='"])
116
117 AC_EGREP_CPP(yes,
118 [#include <sys/cdefs.h>
119 #ifdef __RENAME
120   yes
121 #endif
122 ], , [CPPFLAGS="$CPPFLAGS '-D__RENAME(x)='"])
123
124 AC_EGREP_CPP(yes,
125 [#include <sys/cdefs.h>
126 #ifdef _DIAGASSERT
127   yes
128 #endif
129 ], , [CPPFLAGS="$CPPFLAGS '-D_DIAGASSERT(x)='"])
130
131 dnl Enable readline compatibility by default.
132 AC_ARG_ENABLE(readline, [  --disable-readline      Disable readline compatibility],
133 if test "x$enable_readline" != "xyes" ; then
134   enable_readline="no"
135 fi
136 ,
137 enable_readline="yes"
138 )
139
140 dnl Optionally enable debugging.
141 AC_ARG_ENABLE(debug, [  --enable-debug          Enable debugging code],
142 if test "x$enable_debug" != "xyes" ; then
143   enable_debug="no"
144 fi
145 ,
146 enable_debug="no"
147 )
148 if test "x$enable_debug" = "xyes" ; then
149   CPPFLAGS="$CPPFLAGS -DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG"
150   CPPFLAGS="$CPPFLAGS -DDEBUG_REFRESH -DDEBUG_PASTE"
151 else
152   CFLAGS="$CFLAGS -O"
153 fi
154
155
156 dnl 
157 dnl File lists.  This is done here instead of in the Makefile in order to avoid
158 dnl the need for conditionals.
159 dnl 
160
161 dnl .c files.
162 ACSRCS="common.c emacs.c vi.c"
163 BCSRCS="chared.c el.c hist.c key.c map.c parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c"
164 CCSRCS="$CCSRCS history.c tokenizer.c"
165
166 dnl Generated .c files.
167 AGCSRCS="fcns.c help.c"
168 BGCSRCS="editline.c"
169
170 dnl .h files.
171 HDRS="chared.h el.h hist.h key.h map.h parse.h prompt.h refresh.h search.h sig.h sys.h term.h tokenizer.h tty.h"
172
173 dnl Installed .h files.
174 IHDRS="histedit.h"
175
176 dnl Installed headers for readline compatibility.
177 IHDR_LINKS=
178
179 dnl Generated .h files.
180 AGHDRS="common.h emacs.h vi.h"
181 BGHDRS="fcns.h help.h"
182
183 dnl Header installation directories.
184 HDR_DIRS="include"
185
186 dnl Man pages.
187 MAN3="editline.3"
188 MAN5="editrc.5"
189
190 MAN3_LINKS=
191 for i in  el_init.3 el_end.3 el_reset.3 el_gets.3 el_getc.3 el_push.3 \
192           el_parse.3 el_set.3 el_get.3 el_source.3 el_resize.3 el_line.3 \
193           el_insertstr.3 el_deletestr.3 history_init.3 history_end.3 \
194           history.3 ; do
195   MAN3_LINKS="$MAN3_LINKS editline.3 $i"
196 done
197
198 dnl Man page installation directories.
199 MAN_DIRS="man/man3 man/man5"
200
201 dnl Library settings.
202 LIB_DIRS="lib"
203 LIB_MAJOR="2"
204 LIB_MINOR="6"
205 LIB_A="libedit.a"
206 LIB_A_LINKS=
207
208 if test "x$ABI" = "xelf" ; then
209   LIB_S="libedit.so.$LIB_MAJOR"
210   LIB_S_LINK="libedit.so"
211   LIB_S_LINKS="$LIB_S $LIB_S_LINK"
212   S_LDFLAGS="-shared"
213 elif test "x$ABI" = "xaout" ; then
214   LIB_S="libedit.so.$LIB_MAJOR.$LIB_MINOR"
215   LIB_S_LINKS=
216   S_LDFLAGS="-shared"
217 elif test "x$ABI" = "xmacho" ; then
218   S_LDFLAGS="-shared"
219   LIB_S="libedit.$LIB_MAJOR.dylib"
220   LIB_S_LINK="libedit.dylib"
221   LIB_S_LINKS="$LIB_S $LIB_S_LINK"
222   if test "x$prefix" = "xNONE" ; then
223     S_LDFLAGS="-undefined suppress -flat_namespace -dynamiclib -compatibility_version $LIB_MAJOR -current_version $LIB_MAJOR -install_name /usr/local/lib/$LIB_S"
224   else
225     S_LDFLAGS="-undefined suppress -flat_namespace -dynamiclib -compatibility_version $LIB_MAJOR -current_version $LIB_MAJOR -install_name $prefix/lib/$LIB_S"
226   fi
227 fi
228
229 dnl Test program.
230 TEST="TEST/test"
231 TCSRCS="TEST/test.c"
232
233 dnl Add files to the lists if readline compatibility is enabled.
234 if test "x$enable_readline" = "xyes" ; then
235   CCSRCS="$CCSRCS readline.c"
236   IHDRS="$IHDRS readline/readline.h"
237   IHDR_LINKS="readline.h readline/history.h"
238   HDR_DIRS="$HDR_DIRS include/readline"
239   LIB_A_LINKS="$LIB_A_LINKS libedit.a libreadline.a"
240   if test "x$ABI" = "xelf" ; then
241     LIB_S_LINKS="$LIB_S_LINKS $LIB_S_LINK libreadline.so"
242   elif test "x$ABI" = "xaout" ; then
243     LIB_S_LINKS="$LIB_S_LINKS $LIB_S libreadline.so.$LIB_MAJOR.$LIB_MINOR"
244   elif test "x$ABI" = "xmacho" ; then
245     LIB_S_LINKS="$LIB_S_LINKS $LIB_S_LINK libreadline.dylib"
246   fi
247 fi
248
249 AC_SUBST(ACSRCS)
250 AC_SUBST(BCSRCS)
251 AC_SUBST(CCSRCS)
252 AC_SUBST(AGCSRCS)
253 AC_SUBST(BGCSRCS)
254 AC_SUBST(HDRS)
255 AC_SUBST(IHDRS)
256 AC_SUBST(IHDR_LINKS)
257 AC_SUBST(AGHDRS)
258 AC_SUBST(BGHDRS)
259 AC_SUBST(HDR_DIRS)
260 AC_SUBST(MAN3)
261 AC_SUBST(MAN5)
262 AC_SUBST(MAN3_LINKS)
263 AC_SUBST(MAN_DIRS)
264 AC_SUBST(LIB_DIRS)
265 AC_SUBST(LIB_VER)
266 AC_SUBST(LIB_A)
267 AC_SUBST(LIB_A_LINKS)
268 AC_SUBST(LIB_S)
269 AC_SUBST(LIB_S_LINKS)
270 AC_SUBST(S_LDFLAGS)
271 AC_SUBST(TEST)
272 AC_SUBST(TCSRCS)
273
274 AC_CONFIG_HEADER(config.h)
275 AC_OUTPUT([Makefile makelist])
276