resetting manifest requested domain to floor
[platform/upstream/cscope.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT
3 AC_CONFIG_SRCDIR([src/crossref.c])
4 AM_INIT_AUTOMAKE(cscope, 15.8a)
5 AC_CONFIG_HEADERS([config.h:config.h.in])
6 AC_PREREQ(2.59)
7 AC_CANONICAL_HOST
8
9 dnl User specification of lexer
10 dnl AC_CHECK_LEXER
11 dnl User specification of yacc
12 dnl AC_CHECK_YACC
13
14 dnl Checks for programs.
15 AC_PROG_INSTALL
16 AC_PROG_CC
17 AM_PROG_CC_C_O
18 AC_EXEEXT
19 AM_PROG_LEX
20 AM_CONDITIONAL(USING_LEX, test "x$LEX" = "xlex")
21 if test "x$LEX" = "xlex" ; then AC_DEFINE(USING_LEX, 1, 
22    [Define this if the scanner is run through lex, not flex])
23 fi
24 AC_PROG_YACC
25
26 dnl === BEGIN CURSES CHECK
27 dnl Curses detection: Munged from Midnight Commander's configure.in
28 dnl
29 dnl What it does:
30 dnl =============
31 dnl
32 dnl - Determine which version of curses is installed on your system
33 dnl   and set the -I/-L/-l compiler entries and add a few preprocessor
34 dnl   symbols 
35 dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that
36 dnl   @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in
37 dnl   Makefile.in's
38 dnl - Modify the following configure variables (these are the only
39 dnl   curses.m4 variables you can access from within configure.in)
40 dnl   CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if
41 dnl                       an ncurses.h that's been renamed to curses.h
42 dnl                       is found.
43 dnl   CURSES_LIBS       - sets -L and -l's appropriately
44 dnl   CFLAGS            - if --with-sco, add -D_SVID3 
45 dnl   has_curses        - exports result of tests to rest of configure
46 dnl
47 dnl Usage:
48 dnl ======
49 dnl 1) Add lines indicated below to acconfig.h
50 dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in
51 dnl 3) Instead of #include <curses.h> you should use the following to
52 dnl    properly locate ncurses or curses header file
53 dnl
54 dnl    #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
55 dnl    #include <ncurses.h>
56 dnl    #else
57 dnl    #include <curses.h>
58 dnl    #endif
59 dnl
60 dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags
61 dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS
62 dnl
63 dnl Notes with automake:
64 dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
65 dnl   configure.in
66 dnl - your Makefile.am can look something like this
67 dnl   -----------------------------------------------
68 dnl   INCLUDES= blah blah blah $(CURSES_INCLUDEDIR) 
69 dnl   if HAS_CURSES
70 dnl   CURSES_TARGETS=name_of_curses_prog
71 dnl   endif
72 dnl   bin_PROGRAMS = other_programs $(CURSES_TARGETS)
73 dnl   other_programs_SOURCES = blah blah blah
74 dnl   name_of_curses_prog_SOURCES = blah blah blah
75 dnl   other_programs_LDADD = blah
76 dnl   name_of_curses_prog_LDADD = blah $(CURSES_LIBS)
77 dnl   -----------------------------------------------
78 dnl
79 dnl
80 dnl The following lines should be added to acconfig.h:
81 dnl ==================================================
82 dnl
83 dnl /*=== Curses version detection defines ===*/
84 dnl /* Found some version of curses that we're going to use */
85 dnl #undef HAS_CURSES
86 dnl    
87 dnl /* Use SunOS SysV curses? */
88 dnl #undef USE_SUNOS_CURSES
89 dnl 
90 dnl /* Use old BSD curses - not used right now */
91 dnl #undef USE_BSD_CURSES
92 dnl 
93 dnl /* Use SystemV curses? */
94 dnl #undef USE_SYSV_CURSES
95 dnl 
96 dnl /* Use Ncurses? */
97 dnl #undef USE_NCURSES
98 dnl 
99 dnl /* If you Curses does not have color define this one */
100 dnl #undef NO_COLOR_CURSES
101 dnl 
102 dnl /* Define if you want to turn on SCO-specific code */
103 dnl #undef SCO_FLAVOR
104 dnl 
105 dnl /* Set to reflect version of ncurses *
106 dnl  *   0 = version 1.*
107 dnl  *   1 = version 1.9.9g
108 dnl  *   2 = version 4.0/4.1 */
109 dnl #undef NCURSES_970530
110 dnl
111 dnl /*=== End new stuff for acconfig.h ===*/
112 dnl 
113
114
115 AC_DEFUN([AC_CHECK_CURSES],[
116         search_ncurses=true
117         screen_manager=""
118         has_curses=false
119
120         CFLAGS=${CFLAGS--O}
121
122         AC_SUBST(CURSES_LIBS)
123         AC_SUBST(CURSES_INCLUDEDIR)
124
125         AC_ARG_WITH(sco,
126           [  --with-sco              Use this to turn on SCO-specific code],[
127           if test x$withval = xyes; then
128                 AC_DEFINE(SCO_FLAVOR, 1, [Define if you want to turn on SCO-specific code])
129                 CFLAGS="$CFLAGS -D_SVID3"
130           fi
131         ])
132
133         AC_ARG_WITH(sunos-curses,
134           [  --with-sunos-curses     Used to force SunOS 4.x curses],[
135           if test x$withval = xyes; then
136                 AC_USE_SUNOS_CURSES
137           fi
138         ])
139
140         AC_ARG_WITH(osf1-curses,
141           [  --with-osf1-curses      Used to force OSF/1 curses],[
142           if test x$withval = xyes; then
143                 AC_USE_OSF1_CURSES
144           fi
145         ])
146
147         AC_ARG_WITH(vcurses,
148           [  --with-vcurses[=incdir] Used to force SysV curses],
149           if test x$withval != xyes; then
150                 CURSES_INCLUDEDIR="-I$withval"
151           fi
152           AC_USE_SYSV_CURSES
153         )
154
155         AC_ARG_WITH(ncurses,
156           [  --with-ncurses[=dir]  Compile with ncurses/locate base dir],
157           if test x$withval = xno ; then
158                 search_ncurses=false
159           elif test x$withval != xyes ; then
160                 CURSES_LIBS="$LIBS -L$withval/lib -lncurses"
161                 CURSES_INCLUDEDIR="-I$withval/include"
162                 search_ncurses=false
163                 screen_manager="ncurses"
164                 AC_DEFINE(USE_NCURSES, 1, [Use Ncurses?])
165                 AC_DEFINE(HAS_CURSES, 1, [Found some version of curses that we're going to use])
166                 has_curses=true
167           fi
168         )
169
170         if $search_ncurses
171         then
172                 AC_SEARCH_NCURSES()
173         fi
174
175
176 ])
177
178
179 AC_DEFUN([AC_USE_SUNOS_CURSES], [
180         search_ncurses=false
181         screen_manager="SunOS 4.x /usr/5include curses"
182         AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
183         AC_DEFINE(USE_SUNOS_CURSES, 1, [Use SunOS SysV curses?])
184         AC_DEFINE(HAS_CURSES)
185         has_curses=true
186         AC_DEFINE(NO_COLOR_CURSES, 1, [If your Curses does not have color define this one])
187         AC_DEFINE(USE_SYSV_CURSES, 1, [Use SystemV curses?])
188         CURSES_INCLUDEDIR="-I/usr/5include"
189         CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
190         AC_MSG_RESULT(Please note that some screen refreshs may fail)
191 ])
192
193 AC_DEFUN([AC_USE_OSF1_CURSES], [
194        AC_MSG_RESULT(Using OSF1 curses)
195        search_ncurses=false
196        screen_manager="OSF1 curses"
197        AC_DEFINE(HAS_CURSES)
198        has_curses=true
199        AC_DEFINE(NO_COLOR_CURSES)
200        AC_DEFINE(USE_SYSV_CURSES)
201        CURSES_LIBS="-lcurses"
202 ])
203
204 AC_DEFUN([AC_USE_SYSV_CURSES], [
205         AC_MSG_RESULT(Using SysV curses)
206         AC_DEFINE(HAS_CURSES)
207         has_curses=true
208         AC_DEFINE(USE_SYSV_CURSES)
209         search_ncurses=false
210         screen_manager="SysV/curses"
211         CURSES_LIBS="-lcurses"
212 ])
213
214 dnl AC_ARG_WITH(bsd-curses,
215 dnl [--with-bsd-curses         Used to compile with bsd curses, not very fancy],
216 dnl     search_ncurses=false
217 dnl     screen_manager="Ultrix/cursesX"
218 dnl     if test $system = ULTRIX
219 dnl     then
220 dnl         THIS_CURSES=cursesX
221 dnl        else
222 dnl         THIS_CURSES=curses
223 dnl     fi
224 dnl
225 dnl     CURSES_LIBS="-l$THIS_CURSES -ltermcap"
226 dnl     AC_DEFINE(HAS_CURSES)
227 dnl     has_curses=true
228 dnl     AC_DEFINE(USE_BSD_CURSES)
229 dnl     AC_MSG_RESULT(Please note that some screen refreshs may fail)
230 dnl     AC_MSG_WARN([Use of the bsdcurses extension has some])
231 dnl     AC_MSG_WARN([display/input problems.])
232 dnl     AC_MSG_WARN([Reconsider using xcurses])
233 dnl)
234
235         
236 dnl
237 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
238 dnl
239 AC_DEFUN([AC_NCURSES], [
240     if $search_ncurses
241     then
242         if test -f $1/$2
243         then
244             AC_MSG_RESULT(Found ncurses on $1/$2)
245             CURSES_LIBS="$3"
246             CURSES_INCLUDEDIR="$4"
247             search_ncurses=false
248             screen_manager=$5
249             AC_DEFINE(HAS_CURSES)
250             has_curses=true
251             AC_DEFINE(USE_NCURSES)
252         fi
253     fi
254 ])
255
256 AC_DEFUN([AC_SEARCH_NCURSES], [
257     AS_MESSAGE(checking "location of ncurses.h file"...)
258
259     AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
260     AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
261     AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
262     AC_NCURSES(/usr/local/include/ncurses, ncurses.h, -L/usr/local/lib -L/usr/local/lib/ncurses -lncurses, -I/usr/local/include/ncurses, "ncurses on /usr/local/include/ncurses")
263
264     AC_NCURSES(/usr/local/include/ncurses, curses.h, -L/usr/local/lib -lncurses, -I/usr/local/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/local/.../ncurses")
265
266     AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
267
268     dnl
269     dnl We couldn't find ncurses, try SysV curses
270     dnl
271     if $search_ncurses 
272     then
273         AC_EGREP_HEADER(init_color, curses.h,
274             AC_USE_SYSV_CURSES)
275         AC_EGREP_CPP(USE_NCURSES,[
276 #include <curses.h>
277 #ifdef __NCURSES_H
278 #undef USE_NCURSES
279 USE_NCURSES
280 #endif
281 ],[
282         CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
283         AC_DEFINE(HAS_CURSES)
284         has_curses=true
285         AC_DEFINE(USE_NCURSES)
286         search_ncurses=false
287         screen_manager="ncurses installed as curses"
288 ])
289     fi
290
291     dnl
292     dnl Try SunOS 4.x /usr/5{lib,include} ncurses
293     dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
294     dnl should be replaced by a more fine grained selection routine
295     dnl
296     if $search_ncurses
297     then
298         if test -f /usr/5include/curses.h
299         then
300             AC_USE_SUNOS_CURSES
301         fi
302     else
303         # check for ncurses version, to properly ifdef mouse-fix
304         AC_MSG_CHECKING(for ncurses version)
305         ncurses_version=unknown
306 cat > conftest.$ac_ext <<EOF
307 [#]line __oline__ "configure"
308 #include "confdefs.h"
309 #ifdef RENAMED_NCURSES
310 #include <curses.h>
311 #else
312 #include <ncurses.h>
313 #endif
314 #undef VERSION
315 VERSION:NCURSES_VERSION
316 EOF
317         if (eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD() |
318   egrep "VERSION:" >conftest.out 2>&1; then
319 changequote(,)dnl
320             ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'`
321 changequote([,])dnl
322         fi
323         rm -rf conftest*
324         AC_MSG_RESULT($ncurses_version)
325         case "$ncurses_version" in
326 changequote(,)dnl
327         4.[01])
328 changequote([,])dnl
329             AC_DEFINE(NCURSES_970530,2,
330         [Set to reflect version of ncurses: 
331         0 = version 1.*
332         1 = version 1.9.9g
333         2 = version 4.0/4.1])
334             ;;
335         1.9.9g)
336             AC_DEFINE(NCURSES_970530,1)
337             ;;
338         1*)
339             AC_DEFINE(NCURSES_970530,0)
340             ;;
341         esac
342     fi
343 ])
344 dnl === END CURSES CHECK
345
346 AC_CHECK_CURSES
347 AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true)
348
349 dnl Checks for libraries.
350 dnl Replace `main' with a function in -lcurses:
351 dnl AC_CHECK_LIB(curses, main)
352
353 AC_CHECK_HEADER(regex.h, [], [
354   AC_MSG_ERROR([necessary header <regex.h> not found])
355 ])
356
357 dnl Cygwin is a bit peculiar: it has the regcomp() functions, but in a
358 dnl separate library, so we have to check for that:
359 AC_CHECK_LIB(regex, regcomp)
360
361 dnl Check for a GNOME installation
362
363 AC_DEFUN([AC_CHECK_GNOME],[
364         has_gnome=false
365         AC_CHECK_PROG(gnome1, gnome-config, true)       
366         AC_CHECK_PROG(gnome2, pkg-config, true)
367
368         if test x$gnome1 = xtrue; then
369           has_gnome=true
370         fi
371
372         if test x$gnome2 = xtrue; then
373           has_gnome=true
374         fi
375         
376         AM_CONDITIONAL(USING_GNOME2, pkg-config --exists gtk+-2.0)
377         AM_CONDITIONAL(HAS_GNOME, test "$has_gnome" = true)
378         AM_CONDITIONAL(GNOME_LINUX, test "$host_os" = Linux)
379 ])
380
381 AC_CHECK_GNOME
382 dnl Checks for header files.
383 AC_HEADER_DIRENT
384 AC_HEADER_STDC
385 AC_CHECK_HEADERS(fcntl.h sys/window.h sys/termios.h unistd.h signal.h floss.h io.h)
386
387 dnl Checks for typedefs, structures, and compiler characteristics.
388 AC_C_CONST
389 AC_TYPE_MODE_T
390 AC_TYPE_PID_T
391 AC_TYPE_SIZE_T
392 AC_CHECK_TYPE(sighandler_t,[],[],[
393 #ifdef HAVE_SIGNAL_H
394 # include <signal.h>
395 #endif])
396 dnl This test was ripped from gnuplot's configure.in:
397 AC_MSG_CHECKING(for sigsetjmp)
398 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <setjmp.h>]], [[jmp_buf env; sigsetjmp(env, 1);]])],[AC_MSG_RESULT(yes)
399    AC_DEFINE(HAVE_SIGSETJMP,1,
400              [ Define if we have sigsetjmp(). ])],[AC_MSG_RESULT(no)])
401
402 dnl Checks for library functions.
403 AC_TYPE_SIGNAL
404 AC_CHECK_FUNCS(strchr memcpy memset setmode _setmode)
405 AC_CHECK_FUNCS(getcwd regcmp regcomp strerror lstat)
406 AC_CHECK_FUNCS(fixkeypad getopt_long)
407 HW_FUNC_SNPRINTF
408 HW_FUNC_VSNPRINTF
409 HW_FUNC_ASPRINTF
410 HW_FUNC_VASPRINTF
411
412 case "$host_os" in
413         linux*)
414                 AC_DEFINE(Linux, 1, [We're using some variant of Linux])
415         ;;
416         netbsd*|freebsd*|darwin*)
417                 AC_DEFINE(BSD, 1, [We're using a BSD-flavoured Unix])
418         ;;
419 esac
420
421 AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile contrib/Makefile])
422 AC_OUTPUT