configure.ac 12.4 KB
Newer Older
1
2
3
4
# Configuration for GNU nano - a small and user-friendly text editor
#
# Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
#
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
5
# GNU nano is free software; you can redistribute it and/or modify
6
7
8
9
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
10
# GNU nano is distributed in the hope that it will be useful,
11
12
13
14
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
16
# along with GNU nano; if not, write to the Free Software
17
18
19
# Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
20
# $Id$
21

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
22
AC_INIT([GNU nano], [1.3.2-cvs], [nano-devel@gnu.org], [nano])
Jordi Mallach's avatar
Jordi Mallach committed
23
AC_CONFIG_SRCDIR([src/nano.c])
24
AM_INIT_AUTOMAKE
25
AM_CONFIG_HEADER([config.h:config.h.in])
26

Jordi Mallach's avatar
Jordi Mallach committed
27
AC_PREREQ(2.52)
Chris Allegretta's avatar
Chris Allegretta committed
28
29
30
31

dnl Checks for programs.
AC_PROG_CC
AC_ISC_POSIX
Jordi Mallach's avatar
Jordi Mallach committed
32
AC_SYS_LARGEFILE
Chris Allegretta's avatar
Chris Allegretta committed
33

34
35
36
37
dnl Internationalization macros.
AM_GNU_GETTEXT_VERSION(0.11.5)
AM_GNU_GETTEXT([external], [need-ngettext])

Chris Allegretta's avatar
Chris Allegretta committed
38
39
dnl Checks for header files.
AC_HEADER_STDC
40
AC_CHECK_HEADERS(fcntl.h getopt.h libintl.h limits.h regex.h termio.h termios.h unistd.h)
41
42
43
44
45
AC_CHECK_HEADER(regex.h,
    AC_MSG_CHECKING([for broken regexec])
    AC_TRY_RUN([
#include <sys/types.h>
#include <regex.h>
46
int main(void) { regex_t reg; size_t n = 1; regmatch_t r; regcomp(&reg, "\\<", 0); regexec(&reg, "", n, &r, 0); regfree(&reg); return 0; }],
47
	AC_MSG_RESULT(no),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
48
	AC_MSG_RESULT(yes); AC_DEFINE(BROKEN_REGEXEC, 1, [Define this if your regexec() function segfaults when passed an empty string under certain conditions.])
49
50
    )
)
Chris Allegretta's avatar
Chris Allegretta committed
51
52

dnl options
Chris Allegretta's avatar
Chris Allegretta committed
53
54
55
AC_ARG_ENABLE(debug, 
[  --enable-debug          Enable debugging (disabled by default)],
 [if test x$enableval = xyes; then
56
    AC_DEFINE(DEBUG, 1, [Define this to enable nano debug messages and assert warnings.])
Chris Allegretta's avatar
Chris Allegretta committed
57
58
59
60
    debug_support=yes
 fi])

if test "$debug_support" != "yes"; then
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
61
    AC_DEFINE(NDEBUG, 1, [Shut up the assert warnings :-)])
Chris Allegretta's avatar
Chris Allegretta committed
62
63
fi

64
65
66
67
68
69
70
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
71
AC_ARG_ENABLE(tiny,
72
[  --enable-tiny           Disable features for the sake of size],
Chris Allegretta's avatar
Chris Allegretta committed
73
[if test x$enableval = xyes; then
74
    AC_DEFINE(NANO_SMALL, 1, [Define this to make the nano executable as small as possible.]) tiny_support=yes
75
    AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in (crappy) file browser.]) 
76
77
    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
78
79
    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).]) 
80
81
    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
82
83
 fi])

84
85
86
87
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.])
88
89
 fi])

90
91
92
93
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.])
94
95
 fi])

96
97
98
99
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.]) 
100
101
 fi])

102
103
AC_ARG_ENABLE(mouse,
[  --disable-mouse         Disable mouse support (and -m flag)],
104
 [if test x$enableval != xyes; then
105
    AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse functions.])
106
107
 fi])

108
109
AC_ARG_ENABLE(operatingdir,
[  --disable-operatingdir  Disable setting of operating directory (chroot of sorts)],
110
 [if test x$enableval != xyes; then
111
    AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable setting of the operating directory (chroot of sorts).])
112
113
 fi])

114
AC_ARG_ENABLE(speller,
115
[  --disable-speller       Disable spell checker function],
116
 [if test x$enableval != xyes; then
117
    AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the use(full|less) spelling functions.])
118
119
 fi])

120
121
AC_ARG_ENABLE(tabcomp,
[  --disable-tabcomp       Disable tab completion code for a smaller binary],
122
 [if test x$enableval != xyes; then
123
    AC_DEFINE(DISABLE_TABCOMP, 1, [Define to disable the tab completion code Chris worked so hard on!]) 
Chris Allegretta's avatar
Chris Allegretta committed
124
125
 fi])

126
AC_ARG_ENABLE(wrapping,
127
[  --disable-wrapping      Disable all wrapping of text (and -w flag)],
128
 [if test x$enableval != xyes; then
129
    AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable any and all text wrapping.])
130
131
 fi])

132
133
134
135
136
137
AC_ARG_ENABLE(wrapping-as-root,
[  --disable-wrapping-as-root  Disable wrapping of text as root by default],
 [if test x$enableval != xyes; then
    AC_DEFINE(DISABLE_ROOTWRAP, 1, [Define this to disable wrapping as root by default.])
 fi])

138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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
156
157
 fi])

158
159
160
161
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
162
163
 fi])

164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
AC_ARG_ENABLE(all,
[  --enable-all            Enable ALL extra nano functionality (kitchen sink option)],
[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_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.]) multibuffer_support=yes
    AC_DEFINE(NANO_EXTRA, 1, [Define this to enable the extra stuff.]) extra_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])

180
AC_MSG_CHECKING([whether to use slang])
Chris Allegretta's avatar
Chris Allegretta committed
181
182
183
184
185
186
187
188
189
190
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)

191
192
193
194
195
	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
196
197

	AC_CHECK_HEADER(slcurses.h,
198
	    AC_MSG_CHECKING([for SLtt_initialize in -lslang])
199
200
	    _libs=$LIBS
	    LIBS="$LIBS -lslang"
201
202
203
	    AC_TRY_RUN([
#include <stdio.h>
#include <slcurses.h>
204
int main(void) { SLtt_initialize(NULL); return 0; }],
205
		[AC_MSG_RESULT(yes)
206
		AC_DEFINE(USE_SLANG, 1, [Define to use the slang wrappers for curses instead of native curses.])
207
208
209
210
211
212
213
		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], [
214
215
216
		AC_MSG_RESULT(no)
		# We might need the term library
		for termlib in ncurses curses termcap terminfo termlib; do
217
		    AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
218
219
220
		    test -n "$tcap" && break
		done

221
		AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
222
		LIBS="$LIBS $tcap"
223
224
225
		AC_TRY_RUN([
#include <stdio.h>
#include <slcurses.h>
226
int main(void) { SLtt_initialize(NULL); return 0; }],
227
		    [AC_MSG_RESULT(yes)
228
		    AC_DEFINE(USE_SLANG, 1, [Define to use the slang wrappers for curses instead of native curses.])
229
230
231
232
233
234
235
236
237
		    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
238
		    AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
239
		    LIBS="$LIBS -lm"
240
241
242
		    AC_TRY_RUN([
#include <stdio.h>
#include <slcurses.h>
243
int main(void) { SLtt_initialize(NULL); return 0; }],
244
			[AC_MSG_RESULT(yes)
245
			AC_DEFINE(USE_SLANG, 1, [Define to use the slang wrappers for curses instead of native curses.])
246
247
248
249
250
251
252
			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],
253
254
255
256
			[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
257
258
259
260
261
262
263
	    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
]))

264
265
	test "${_libs+set}" = "set" && LIBS=$_libs

266
267
268
	if test "$with_slang" != "yes"; then
	    LDFLAGS=${_ldflags}
	fi
Chris Allegretta's avatar
Chris Allegretta committed
269
	;;
270
    esac], [AC_MSG_RESULT(no)])
Chris Allegretta's avatar
Chris Allegretta committed
271
272

dnl Checks for functions
273
AC_CHECK_FUNCS(snprintf vsnprintf strcasecmp strncasecmp)
Chris Allegretta's avatar
Chris Allegretta committed
274
275
if test "x$ac_cv_func_snprintf" = "xno" -o "xac_cv_func_vsnprintf" = "xno"
then
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
276
277
278
	AM_PATH_GLIB_2_0(2.0.0,,
	    [AM_PATH_GLIB(1.2.4,,
		[AC_MSG_ERROR([
Chris Allegretta's avatar
Chris Allegretta committed
279
280
*** snprintf() and/or vsnprintf() not found.  GLIB not found either.
*** You need both snprintf() and vsnprintf().  Alternatively you can
281
*** install the GLIB library which can be found at ftp://ftp.gtk.org/.])],
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
282
		glib)])
Chris Allegretta's avatar
Chris Allegretta committed
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
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)
298
    AC_CHECK_LIB(ncurses, tgetent, [CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses])
Chris Allegretta's avatar
Chris Allegretta committed
299
300
301
302
fi

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

Chris Allegretta's avatar
Chris Allegretta committed
306
307
308
# Fallback for PDCurses and less useful curses libs...
if eval "test x$CURSES_LIB_NAME = x"
then
309
    AC_CHECK_LIB(curses, initscr, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses])
Chris Allegretta's avatar
Chris Allegretta committed
310
311
fi

Chris Allegretta's avatar
Chris Allegretta committed
312
313
if eval "test x$CURSES_LIB_NAME = x"
then
314
    AC_CHECK_LIB(termcap, tgetent, [CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap])
Chris Allegretta's avatar
Chris Allegretta committed
315
316
317
318
319
320
321
322
323
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
324
    AC_MSG_RESULT([Using $CURSES_LIB_NAME as the termcap library])
Chris Allegretta's avatar
Chris Allegretta committed
325
326
327
fi


328
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.]))
329
if test x$slang_support != xyes; then
330
331
    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.]))
332
333
fi

Chris Allegretta's avatar
Chris Allegretta committed
334
335
336
dnl Parse any configure options

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

Chris Allegretta's avatar
Chris Allegretta committed
338
339
AC_SUBST(CURSES_LIB)

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
340
if test "x$GLIB_CFLAGS" != "x"
Chris Allegretta's avatar
Chris Allegretta committed
341
then
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
342
	CFLAGS="$CFLAGS $GLIB_CFLAGS"
Chris Allegretta's avatar
Chris Allegretta committed
343
fi
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
344
if test "x$GLIB_LIBS" != "x"
Chris Allegretta's avatar
Chris Allegretta committed
345
then
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
346
	LDFLAGS="$LDFLAGS $GLIB_LIBS"
Chris Allegretta's avatar
Chris Allegretta committed
347
348
fi

Jordi Mallach's avatar
Jordi Mallach committed
349
350
351
352
353
354
355
356
357
358
359
360
AC_CONFIG_FILES([
Makefile
doc/Makefile
doc/man/Makefile
doc/man/fr/Makefile
doc/texinfo/Makefile
m4/Makefile
po/Makefile.in
src/Makefile
nano.spec
])

Jordi Mallach's avatar
Jordi Mallach committed
361
AC_OUTPUT