configure.in 7.12 KB
Newer Older
1
# $Id$
Chris Allegretta's avatar
Chris Allegretta committed
2
3
dnl Process this file with autoconf to produce a configure script.
AC_INIT(nano.c)
Chris Allegretta's avatar
Chris Allegretta committed
4
AM_INIT_AUTOMAKE(nano, 1.0.1-cvs)
Chris Allegretta's avatar
Chris Allegretta committed
5
AM_CONFIG_HEADER(config.h:config.h.in)
6
ALL_LINGUAS="es de fr it id fi hu ca cs"
Chris Allegretta's avatar
Chris Allegretta committed
7
8
9
10
11
12
13

dnl Checks for programs.
AC_PROG_CC
AC_ISC_POSIX

dnl Checks for header files.
AC_HEADER_STDC
14
AC_CHECK_HEADERS(fcntl.h unistd.h malloc.h termios.h termio.h limits.h getopt.h regex.h)
Chris Allegretta's avatar
Chris Allegretta committed
15
16
17
18
19
20
21

dnl options
AC_ARG_ENABLE(tiny,
[  --enable-tiny           Disables features for the sake of size
                          (currently disables detailed help and i18n)],
[if test x$enableval = xyes; then
    AC_DEFINE(NANO_SMALL) tiny_support=yes
22
23
24
25
26
    AC_DEFINE(DISABLE_TABCOMP) 
    AC_DEFINE(DISABLE_SPELLER) 
    AC_DEFINE(DISABLE_HELP) 
    AC_DEFINE(DISABLE_JUSTIFY) 
    AC_DEFINE(DISABLE_BROWSER) 
Chris Allegretta's avatar
Chris Allegretta committed
27
28
 fi])

29
30
31
32
33
34
AC_ARG_ENABLE(extra,
[  --enable-extra          Enable extra (optional) functions, including easter eggs],
[if test x$enableval = xyes; then
    AC_DEFINE(NANO_EXTRA) extra_support=yes
 fi])

35
36
37
38
39
40
AC_ARG_ENABLE(tabcomp,
[  --disable-tabcomp       Disables tab completion code for a smaller binary],
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_TABCOMP) 
 fi])

41
42
43
44
45
46
AC_ARG_ENABLE(justify,
[  --disable-justify       Disable justify/unjustify function],
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_JUSTIFY) 
 fi])

47
AC_ARG_ENABLE(speller,
48
49
[  --disable-speller       Disables spell checker function],
 [if test x$enableval != xyes; then
50
    AC_DEFINE(DISABLE_SPELLER) 
51
52
 fi])

53
54
55
56
57
58
AC_ARG_ENABLE(help,
[  --disable-help          Disables help function (^G)],
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_HELP) 
 fi])

Chris Allegretta's avatar
Chris Allegretta committed
59
AC_ARG_ENABLE(browser,
60
61
62
[  --disable-browser       Disables mini file browser],
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_BROWSER)
Chris Allegretta's avatar
Chris Allegretta committed
63
64
 fi])

65
66
67
68
69
70
AC_ARG_ENABLE(wrapping,
[  --disable-wrapping      Disables all wrapping of text (and -w flag)],
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_WRAPPING)
 fi])

71
AC_MSG_CHECKING([whether to use slang])
Chris Allegretta's avatar
Chris Allegretta committed
72
73
74
75
76
77
78
79
80
81
CURSES_LIB_NAME=""
AC_ARG_WITH(slang,
[  --with-slang[=DIR]      Use the slang library instead of curses],
[    case "$with_slang" in
    no)
	AC_MSG_RESULT(no)
	;;
    *)
	AC_MSG_RESULT(yes)

82
83
84
85
86
	if test "$with_slang" != "yes"; then
	    # Add additional search path
	    LDFLAGS="-L$with_slang/lib $LDFLAGS"
	    CPPFLAGS="-I$with_slang/include $CPPFLAGS"
	fi
Chris Allegretta's avatar
Chris Allegretta committed
87
88

	AC_CHECK_HEADER(slcurses.h,
89
	    AC_MSG_CHECKING([for SLtt_initialize in -lslang])
90
91
	    _libs=$LIBS
	    LIBS="$LIBS -lslang"
92
93
94
95
	    AC_TRY_RUN([
#include <stdio.h>
#include <slcurses.h>
int main () { SLtt_initialize (NULL); return 0; }],
96
		[AC_MSG_RESULT(yes)
97
98
99
100
101
102
103
104
		AC_DEFINE(USE_SLANG)
		slang_support=yes
		if test "$with_slang" != "yes"; then
		    CURSES_LIB="-L${with_slang}/lib -lslang"
		else
		    CURSES_LIB="-lslang"
		fi
		CURSES_LIB_NAME=slang], [
105
106
107
		AC_MSG_RESULT(no)
		# We might need the term library
		for termlib in ncurses curses termcap terminfo termlib; do
108
		    AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
109
110
111
		    test -n "$tcap" && break
		done

112
		AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
113
		LIBS="$LIBS $tcap"
114
115
116
117
		AC_TRY_RUN([
#include <stdio.h>
#include <slcurses.h>
int main () { SLtt_initialize (NULL); return 0; }],
118
119
120
121
122
123
124
125
126
127
128
		    [AC_MSG_RESULT(yes)
		    AC_DEFINE(USE_SLANG)
		    slang_support=yes
		    if test "$with_slang" != "yes"; then
			CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
		    else
			CURSES_LIB="-lslang $tcap"
		    fi
		    CURSES_LIB_NAME=slang], [
		    AC_MSG_RESULT(no)
		    # We might need the math library
129
		    AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
130
		    LIBS="$LIBS -lm"
131
132
133
134
		    AC_TRY_RUN([
#include <stdio.h>
#include <slcurses.h>
int main () { SLtt_initialize (NULL); return 0; }],
135
136
137
138
139
140
141
142
143
			[AC_MSG_RESULT(yes)
			AC_DEFINE(USE_SLANG)
			slang_support=yes
			if test "$with_slang" != "yes"; then
			    CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
			else
			    CURSES_LIB="-lslang $tcap -lm"
			fi
			CURSES_LIB_NAME=slang],
144
145
146
147
			[AC_MSG_RESULT(no)],
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
AC_MSG_WARN([*** Can not use slang when cross-compiling]))], 
AC_MSG_WARN([*** Can not use slang when cross-compiling])),
Chris Allegretta's avatar
Chris Allegretta committed
148
149
150
151
152
153
154
	    AC_MSG_ERROR([
*** The header file slcurses.h was not found. If you wish to use
*** slang support this header file is required. Please either
*** install a version of slang that includes the slcurses.h file or
*** do not call the configure script with --with-slang
]))

155
156
	test "${_libs+set}" = "set" && LIBS=$_libs

157
158
159
	if test "$with_slang" != "yes"; then
	    LDFLAGS=${_ldflags}
	fi
Chris Allegretta's avatar
Chris Allegretta committed
160
	;;
161
    esac], [AC_MSG_RESULT(no)])
Chris Allegretta's avatar
Chris Allegretta committed
162
163
164
165
166
167

dnl Checks for functions
AC_CHECK_FUNCS(snprintf vsnprintf)
if test "x$ac_cv_func_snprintf" = "xno" -o "xac_cv_func_vsnprintf" = "xno"
then
	AM_PATH_GLIB(1.2.4,,
168
	    [AC_MSG_ERROR([
Chris Allegretta's avatar
Chris Allegretta committed
169
170
*** snprintf() and/or vsnprintf() not found.  GLIB not found either.
*** You need both snprintf() and vsnprintf().  Alternatively you can
171
*** install the GLIB library which can be found at ftp://ftp.gtk.org/.])],
Chris Allegretta's avatar
Chris Allegretta committed
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
	    glib)
	glib_cflags=`$GLIB_CONFIG --cflags glib`
	glib_libs=`$GLIB_CONFIG --libs glib`
fi

dnl Checks for typedefs, structures, and compiler characteristics.

dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(getopt_long)

dnl Checks for libraries.


if eval "test x$CURSES_LIB_NAME = x"
then
    AC_CHECK_HEADERS(curses.h ncurses.h)
190
    AC_CHECK_LIB(ncurses, tgetent, [CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses])
Chris Allegretta's avatar
Chris Allegretta committed
191
192
193
194
fi

if eval "test x$CURSES_LIB_NAME = x"
then
195
    AC_CHECK_LIB(curses, tgetent, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses])
Chris Allegretta's avatar
Chris Allegretta committed
196
197
fi

Chris Allegretta's avatar
Chris Allegretta committed
198
199
200
# Fallback for PDCurses and less useful curses libs...
if eval "test x$CURSES_LIB_NAME = x"
then
201
    AC_CHECK_LIB(curses, initscr, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses])
Chris Allegretta's avatar
Chris Allegretta committed
202
203
fi

Chris Allegretta's avatar
Chris Allegretta committed
204
205
if eval "test x$CURSES_LIB_NAME = x"
then
206
    AC_CHECK_LIB(termcap, tgetent, [CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap])
Chris Allegretta's avatar
Chris Allegretta committed
207
208
209
210
211
212
213
214
215
fi

if eval "test x$CURSES_LIB_NAME = x"
then
    AC_MSG_WARN([
*** No termcap lib available, consider getting the official ncurses
*** distribution from ftp://ftp.gnu.org/pub/gnu/ncurses if you get
*** errors compiling nano.])
else
216
    AC_MSG_RESULT([Using $CURSES_LIB_NAME as the termcap library])
Chris Allegretta's avatar
Chris Allegretta committed
217
218
219
fi


220
if test x$slang_support != xyes; then
221
    AC_CHECK_LIB([$CURSES_LIB_NAME], wresize, [AC_DEFINE(HAVE_WRESIZE)])
222
    AC_CHECK_LIB([$CURSES_LIB_NAME], resizeterm, [AC_DEFINE(HAVE_RESIZETERM)])
Chris Allegretta's avatar
Chris Allegretta committed
223

224
    # Taken from aumix (can't tell form the variable name?)
225
    AC_CACHE_CHECK([for private member _use_keypad in WINDOW],
226
227
    aumix_cv_struct_window_usekeypad,
    [AC_TRY_COMPILE([#ifdef HAVE_NCURSES_H
228
229
230
231
#include <ncurses.h>
#else
#include <curses.h>
#endif], [WINDOW w; w._use_keypad;],
232
    aumix_cv_struct_window_usekeypad=yes, aumix_cv_struct_window_usekeypad=no)])
233
    
234
235
236
    if test $aumix_cv_struct_window_usekeypad = yes; then
	AC_DEFINE(HAVE_USEKEYPAD)
    fi
237
238
fi

Chris Allegretta's avatar
Chris Allegretta committed
239
240
241
dnl Parse any configure options

LIBS="$LIBS $CURSES_LIB"
Chris Allegretta's avatar
Chris Allegretta committed
242

Chris Allegretta's avatar
Chris Allegretta committed
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
AC_ARG_ENABLE(debug, [  --enable-debug          Enable debugging (def disabled)],)

AC_SUBST(CURSES_LIB)

if test "x$glib_cflags" != "x"
then
	CFLAGS="$CFLAGS $glib_cflags"
fi
if test "x$glib_libs" != "x"
then
	LDFLAGS="$LDFLAGS $glib_libs"
fi

dnl i18n stuff - pretty incomplete for now
AM_GNU_GETTEXT

AC_OUTPUT([Makefile intl/Makefile po/Makefile.in])