configure.ac 8.95 KB
Newer Older
1
# $Id$
Chris Allegretta's avatar
Chris Allegretta committed
2
dnl Process this file with autoconf to produce a configure script.
Jordi Mallach's avatar
Jordi Mallach committed
3
4
5
AC_INIT
AC_CONFIG_SRCDIR([nano.c])
AC_PREREQ(2.52)
6
AM_INIT_AUTOMAKE(nano, 1.1.9-cvs)
Chris Allegretta's avatar
Chris Allegretta committed
7
AM_CONFIG_HEADER(config.h:config.h.in)
Jordi Mallach's avatar
Jordi Mallach committed
8
dnl AM_ACLOCAL_INCLUDE(m4)
9
ALL_LINGUAS="es de fr it id fi hu ca cs gl uk ru sv nn nl da pl nb ms"
Chris Allegretta's avatar
Chris Allegretta committed
10
11
12
13

dnl Checks for programs.
AC_PROG_CC
AC_ISC_POSIX
Jordi Mallach's avatar
Jordi Mallach committed
14
AC_SYS_LARGEFILE
Chris Allegretta's avatar
Chris Allegretta committed
15
16
17

dnl Checks for header files.
AC_HEADER_STDC
18
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
19

Chris Allegretta's avatar
Chris Allegretta committed
20
21
22
dnl Turn off assert statements.
AC_DEFINE(NDEBUG)

Chris Allegretta's avatar
Chris Allegretta committed
23
24
dnl options
AC_ARG_ENABLE(tiny,
25
[  --enable-tiny           Disable features for the sake of size
Chris Allegretta's avatar
Chris Allegretta committed
26
27
28
                          (currently disables detailed help and i18n)],
[if test x$enableval = xyes; then
    AC_DEFINE(NANO_SMALL) tiny_support=yes
29
30
31
32
33
    AC_DEFINE(DISABLE_TABCOMP) 
    AC_DEFINE(DISABLE_SPELLER) 
    AC_DEFINE(DISABLE_HELP) 
    AC_DEFINE(DISABLE_JUSTIFY) 
    AC_DEFINE(DISABLE_BROWSER) 
34
    AC_DEFINE(DISABLE_MOUSE) 
35
    AC_DEFINE(DISABLE_OPERATINGDIR)
Chris Allegretta's avatar
Chris Allegretta committed
36
37
 fi])

38
39
40
41
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
42
    AC_DEFINE(ENABLE_MULTIBUFFER) multibuffer_support=yes
43
44
45
46
47
48
49
    AC_DEFINE(ENABLE_UNDO) undo_support=yes
 fi])

AC_ARG_ENABLE(undo,
[  --enable-undo           Enable undo support],
[if test x$enableval = xyes && test x$tiny_support != xyes; then
    AC_DEFINE(ENABLE_UNDO) undo_support=yes
50
51
 fi])

52
AC_ARG_ENABLE(multibuffer,
Chris Allegretta's avatar
Chris Allegretta committed
53
54
[  --enable-multibuffer    Enable multiple file buffers],
[if test x$enableval = xyes; then
55
    AC_DEFINE(ENABLE_MULTIBUFFER) multibuffer_support=yes
56
57
 fi])

58
59
60
61
62
63
AC_ARG_ENABLE(nanorc,
[  --enable-nanorc         Enable use of .nanorc file],
[if test x$enableval = xyes; then
    AC_DEFINE(ENABLE_NANORC) nanorc_support=yes
 fi])

64
AC_ARG_ENABLE(color,
65
[  --enable-color          Enable color and syntax highlighting],
66
67
68
[if test x$enableval = xyes; then
    AC_DEFINE(ENABLE_NANORC) nanorc_support=yes
    AC_DEFINE(ENABLE_COLOR) color_support=yes
69
70
71
72
73
74
75
76
    AC_MSG_WARN([

***********************************************************************
*** WARNING: Color support is currently BROKEN.  Don't expect it to ***
*** work AT ALL until more is implemented.                          ***
***********************************************************************
])
fi])
77

78
AC_ARG_ENABLE(tabcomp,
79
[  --disable-tabcomp       Disable tab completion code for a smaller binary],
80
81
82
83
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_TABCOMP) 
 fi])

84
85
86
87
88
89
AC_ARG_ENABLE(justify,
[  --disable-justify       Disable justify/unjustify function],
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_JUSTIFY) 
 fi])

90
AC_ARG_ENABLE(speller,
91
[  --disable-speller       Disable spell checker function],
92
 [if test x$enableval != xyes; then
93
    AC_DEFINE(DISABLE_SPELLER) 
94
95
 fi])

96
AC_ARG_ENABLE(help,
97
[  --disable-help          Disable help function (^G)],
98
99
100
101
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_HELP) 
 fi])

Chris Allegretta's avatar
Chris Allegretta committed
102
AC_ARG_ENABLE(browser,
103
[  --disable-browser       Disable mini file browser],
104
105
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_BROWSER)
Chris Allegretta's avatar
Chris Allegretta committed
106
107
 fi])

108
AC_ARG_ENABLE(wrapping,
109
[  --disable-wrapping      Disable all wrapping of text (and -w flag)],
110
111
112
113
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_WRAPPING)
 fi])

114
AC_ARG_ENABLE(mouse,
115
[  --disable-mouse         Disable mouse support (and -m flag)],
116
117
118
119
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_MOUSE)
 fi])

120
121
122
123
124
125
AC_ARG_ENABLE(operatingdir,
[  --disable-operatingdir         Disable setting of operating directory (chroot of sorts)],
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_OPERATINGDIR)
 fi])

126
AC_MSG_CHECKING([whether to use slang])
Chris Allegretta's avatar
Chris Allegretta committed
127
128
129
130
131
132
133
134
135
136
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)

137
138
139
140
141
	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
142
143

	AC_CHECK_HEADER(slcurses.h,
144
	    AC_MSG_CHECKING([for SLtt_initialize in -lslang])
145
146
	    _libs=$LIBS
	    LIBS="$LIBS -lslang"
147
148
149
150
	    AC_TRY_RUN([
#include <stdio.h>
#include <slcurses.h>
int main () { SLtt_initialize (NULL); return 0; }],
151
		[AC_MSG_RESULT(yes)
152
153
154
155
156
157
158
159
		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], [
160
161
162
		AC_MSG_RESULT(no)
		# We might need the term library
		for termlib in ncurses curses termcap terminfo termlib; do
163
		    AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
164
165
166
		    test -n "$tcap" && break
		done

167
		AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
168
		LIBS="$LIBS $tcap"
169
170
171
172
		AC_TRY_RUN([
#include <stdio.h>
#include <slcurses.h>
int main () { SLtt_initialize (NULL); return 0; }],
173
174
175
176
177
178
179
180
181
182
183
		    [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
184
		    AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
185
		    LIBS="$LIBS -lm"
186
187
188
189
		    AC_TRY_RUN([
#include <stdio.h>
#include <slcurses.h>
int main () { SLtt_initialize (NULL); return 0; }],
190
191
192
193
194
195
196
197
198
			[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],
199
200
201
202
			[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
203
204
205
206
207
208
209
	    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
]))

210
211
	test "${_libs+set}" = "set" && LIBS=$_libs

212
213
214
	if test "$with_slang" != "yes"; then
	    LDFLAGS=${_ldflags}
	fi
Chris Allegretta's avatar
Chris Allegretta committed
215
	;;
216
    esac], [AC_MSG_RESULT(no)])
Chris Allegretta's avatar
Chris Allegretta committed
217
218
219
220
221
222

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,,
223
	    [AC_MSG_ERROR([
Chris Allegretta's avatar
Chris Allegretta committed
224
225
*** snprintf() and/or vsnprintf() not found.  GLIB not found either.
*** You need both snprintf() and vsnprintf().  Alternatively you can
226
*** install the GLIB library which can be found at ftp://ftp.gtk.org/.])],
Chris Allegretta's avatar
Chris Allegretta committed
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
	    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)
245
    AC_CHECK_LIB(ncurses, tgetent, [CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses])
Chris Allegretta's avatar
Chris Allegretta committed
246
247
248
249
fi

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

Chris Allegretta's avatar
Chris Allegretta committed
253
254
255
# Fallback for PDCurses and less useful curses libs...
if eval "test x$CURSES_LIB_NAME = x"
then
256
    AC_CHECK_LIB(curses, initscr, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses])
Chris Allegretta's avatar
Chris Allegretta committed
257
258
fi

Chris Allegretta's avatar
Chris Allegretta committed
259
260
if eval "test x$CURSES_LIB_NAME = x"
then
261
    AC_CHECK_LIB(termcap, tgetent, [CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap])
Chris Allegretta's avatar
Chris Allegretta committed
262
263
264
265
266
267
268
269
270
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
271
    AC_MSG_RESULT([Using $CURSES_LIB_NAME as the termcap library])
Chris Allegretta's avatar
Chris Allegretta committed
272
273
274
fi


275
AC_CHECK_LIB([$CURSES_LIB_NAME], use_default_colors, [AC_DEFINE(HAVE_USE_DEFAULT_COLORS)])
276
if test x$slang_support != xyes; then
277
    AC_CHECK_LIB([$CURSES_LIB_NAME], wresize, [AC_DEFINE(HAVE_WRESIZE)])
278
    AC_CHECK_LIB([$CURSES_LIB_NAME], resizeterm, [AC_DEFINE(HAVE_RESIZETERM)])
Chris Allegretta's avatar
Chris Allegretta committed
279

280
    # Taken from aumix (can't tell form the variable name?)
281
    AC_CACHE_CHECK([for private member _use_keypad in WINDOW],
282
283
    aumix_cv_struct_window_usekeypad,
    [AC_TRY_COMPILE([#ifdef HAVE_NCURSES_H
284
285
286
287
#include <ncurses.h>
#else
#include <curses.h>
#endif], [WINDOW w; w._use_keypad;],
288
    aumix_cv_struct_window_usekeypad=yes, aumix_cv_struct_window_usekeypad=no)])
289
    
290
291
292
    if test $aumix_cv_struct_window_usekeypad = yes; then
	AC_DEFINE(HAVE_USEKEYPAD)
    fi
293
294
fi

Chris Allegretta's avatar
Chris Allegretta committed
295
296
297
dnl Parse any configure options

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

Chris Allegretta's avatar
Chris Allegretta committed
299
300
301
302
303
304
305
306
307
308
309
310
311
312
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
313
AM_GNU_GETTEXT([external])
Chris Allegretta's avatar
Chris Allegretta committed
314

Jordi Mallach's avatar
Jordi Mallach committed
315
AC_CONFIG_FILES([Makefile m4/Makefile po/Makefile.in nano.spec])
Jordi Mallach's avatar
Jordi Mallach committed
316
AC_OUTPUT