configure.ac 10.7 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)
Chris Allegretta's avatar
Chris Allegretta committed
6
AM_INIT_AUTOMAKE(nano, 1.1.11-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)
Jordi Mallach's avatar
Jordi Mallach committed
9
ALL_LINGUAS="es de fr it id fi hu ca cs gl uk ru sv nn nl da pl nb ms pt_BR"
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 getopt.h libintl.h limits.h termio.h termios.h regex.h unistd.h)
Chris Allegretta's avatar
Chris Allegretta committed
19
20

dnl options
Chris Allegretta's avatar
Chris Allegretta committed
21
22
23
24
25
26
27
28
29
30
31
AC_ARG_ENABLE(debug, 
[  --enable-debug          Enable debugging (disabled by default)],
 [if test x$enableval = xyes; then
    AC_DEFINE(DEBUG, 1, [Define this to enable nano debug messages and assert warnings.]) 
    debug_support=yes
 fi])

if test "$debug_support" != "yes"; then
    AC_DEFINE(NDEBUG, 1, [Shut up the assert warnings :-)]) 
fi

32
33
34
35
36
37
38
AC_ARG_ENABLE(extra,
[  --enable-extra          Enable extra (optional) functions, including easter eggs],
[if test x$enableval = xyes; then
    AC_DEFINE(NANO_EXTRA, 1, [Define this to enable the extra stuff.]) extra_support=yes
    AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.]) multibuffer_support=yes
 fi])

Chris Allegretta's avatar
Chris Allegretta committed
39
AC_ARG_ENABLE(tiny,
40
[  --enable-tiny           Disable features for the sake of size
Chris Allegretta's avatar
Chris Allegretta committed
41
42
                          (currently disables detailed help and i18n)],
[if test x$enableval = xyes; then
43
    AC_DEFINE(NANO_SMALL, 1, [Define this to make the nano executable as small as possible.]) tiny_support=yes
44
    AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in (crappy) file browser.]) 
45
46
    AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the ^G help menu.]) 
    AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routine.]) 
Chris Allegretta's avatar
Chris Allegretta committed
47
48
    AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse functions.]) 
    AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable setting of the operating directory (chroot of sorts).]) 
49
50
    AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the use(full|less) spelling functions.]) 
    AC_DEFINE(DISABLE_TABCOMP, 1, [Define to disable the tab completion code Chris worked so hard on!]) 
Chris Allegretta's avatar
Chris Allegretta committed
51
52
 fi])

53
54
55
56
AC_ARG_ENABLE(browser,
[  --disable-browser       Disable mini file browser],
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in (crappy) file browser.])
57
58
 fi])

59
60
61
62
AC_ARG_ENABLE(help,
[  --disable-help          Disable help function (^G)],
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the ^G help menu.])
63
64
 fi])

65
66
67
68
AC_ARG_ENABLE(justify,
[  --disable-justify       Disable justify/unjustify function],
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routine.]) 
69
70
 fi])

71
72
AC_ARG_ENABLE(mouse,
[  --disable-mouse         Disable mouse support (and -m flag)],
73
 [if test x$enableval != xyes; then
74
    AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse functions.])
75
76
 fi])

77
78
AC_ARG_ENABLE(operatingdir,
[  --disable-operatingdir  Disable setting of operating directory (chroot of sorts)],
79
 [if test x$enableval != xyes; then
80
    AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable setting of the operating directory (chroot of sorts).])
81
82
 fi])

83
AC_ARG_ENABLE(speller,
84
[  --disable-speller       Disable spell checker function],
85
 [if test x$enableval != xyes; then
86
    AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the use(full|less) spelling functions.])
87
88
 fi])

89
90
AC_ARG_ENABLE(tabcomp,
[  --disable-tabcomp       Disable tab completion code for a smaller binary],
91
 [if test x$enableval != xyes; then
92
    AC_DEFINE(DISABLE_TABCOMP, 1, [Define to disable the tab completion code Chris worked so hard on!]) 
Chris Allegretta's avatar
Chris Allegretta committed
93
94
 fi])

95
AC_ARG_ENABLE(wrapping,
96
[  --disable-wrapping      Disable all wrapping of text (and -w flag)],
97
 [if test x$enableval != xyes; then
98
    AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable any and all text wrapping.])
99
100
 fi])

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
AC_ARG_ENABLE(color,
[  --enable-color          Enable color and syntax highlighting],
[if test x$enableval = xyes; then
    AC_DEFINE(ENABLE_NANORC, 1, [Define this to use the .nanorc file.]) nanorc_support=yes
    AC_DEFINE(ENABLE_COLOR, 1, [Define this to have syntax highlighting, requires ENABLE_NANORC too!]) color_support=yes
    AC_MSG_WARN([

***********************************************************************
*** WARNING: Color support is far from perfect, but functional.     ***
*** Be careful with syntax in your .nanorc or nano may malfunction. ***
***********************************************************************
])
fi])

AC_ARG_ENABLE(multibuffer,
[  --enable-multibuffer    Enable multiple file buffers],
[if test x$enableval = xyes; then
    AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.]) multibuffer_support=yes
119
120
 fi])

121
122
123
124
AC_ARG_ENABLE(nanorc,
[  --enable-nanorc         Enable use of .nanorc file],
[if test x$enableval = xyes; then
    AC_DEFINE(ENABLE_NANORC, 1, [Define this to use the .nanorc file.]) nanorc_support=yes
125
126
 fi])

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

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

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

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

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

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

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

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

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

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


276
AC_CHECK_LIB([$CURSES_LIB_NAME], use_default_colors, AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors command.]))
277
if test x$slang_support != xyes; then
278
279
    AC_CHECK_LIB([$CURSES_LIB_NAME], wresize, AC_DEFINE(HAVE_WRESIZE, 1, [Define this if you have the wresize function in your ncurses-type library.]))
    AC_CHECK_LIB([$CURSES_LIB_NAME], resizeterm, AC_DEFINE(HAVE_RESIZETERM, 1, [Define this if you have the resizeterm function in your ncurses-type library.]))
Chris Allegretta's avatar
Chris Allegretta committed
280

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

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

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

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

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