configure.ac 22.6 KB
Newer Older
1
2
# Configuration for GNU nano - a small and user-friendly text editor
#
3
4
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
# 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc.
5
#
6
7
# GNU nano is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
8
# Free Software Foundation; either version 3, or (at your option) any
9
# later version.
10
#
11
12
13
14
# GNU nano is distributed in the hope that it will be useful, 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.
15
16
#
# You should have received a copy of the GNU General Public License
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
17
# along with GNU nano; if not, write to the Free Software
18
19
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
# USA.
20
#
21
# $Id$
22

23
AC_INIT([GNU nano], [2.5.3-svn], [nano-devel@gnu.org], [nano])
Jordi Mallach's avatar
Jordi Mallach committed
24
AC_CONFIG_SRCDIR([src/nano.c])
25
AC_CANONICAL_HOST
26
AM_INIT_AUTOMAKE
27
AC_CONFIG_HEADERS([config.h])
28

29
30
31
dnl Make sure the ONCE macros are available.

AC_PREREQ(2.61)
Chris Allegretta's avatar
Chris Allegretta committed
32
33

dnl Checks for programs.
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
34

35
AC_GNU_SOURCE
Chris Allegretta's avatar
Chris Allegretta committed
36
AC_PROG_CC
37
AC_PROG_LN_S
Chris Allegretta's avatar
Chris Allegretta committed
38
AC_ISC_POSIX
Jordi Mallach's avatar
Jordi Mallach committed
39
AC_SYS_LARGEFILE
40
PKG_PROG_PKG_CONFIG
Chris Allegretta's avatar
Chris Allegretta committed
41

42
dnl Internationalization macros.
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
43

44
45
AM_GNU_GETTEXT_VERSION(0.11.5)
AM_GNU_GETTEXT([external], [need-ngettext])
46
AM_CONDITIONAL(USE_NLS, test x$USE_NLS = xyes)
47

48
49
50
51
52
dnl Data location.

pkgdatadir=${datadir}/${PACKAGE}
AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])

Chris Allegretta's avatar
Chris Allegretta committed
53
dnl Checks for header files.
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
54

55
AC_CHECK_HEADERS(getopt.h libintl.h limits.h regex.h sys/param.h wchar.h wctype.h stdarg.h)
Chris Allegretta's avatar
Chris Allegretta committed
56

57
58
dnl Checks for options.

59
60
61
62
63
64
65
66
67
68
69
70
AC_ARG_ENABLE(browser,
AS_HELP_STRING([--disable-browser], [Disable built-in file browser]))
if test "x$enable_browser" = xno; then
    AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in file browser.])
fi

AC_ARG_ENABLE(color,
AS_HELP_STRING([--disable-color], [Disable color and syntax highlighting]))
if test "x$enable_nanorc" = xno; then
    if test "x$enable_color" = xyes; then
	AC_MSG_ERROR([--enable-color cannot work with --disable-nanorc])
    else
71
	# Disabling nanorc silently disables color support.
72
73
74
	enable_color=no
    fi
fi
75
76
77
78
if test "x$enable_color" = xno; then
    AC_DEFINE(DISABLE_COLOR, 1, [Define this to disable syntax highlighting.])
else
    if test x$ac_cv_header_regex_h != xyes; then
79
	AC_MSG_ERROR([
80
81
82
83
84
85
*** The header file regex.h was not found.  If you wish to have
*** color support, this header file is required.  Please either
*** install C libraries that include the regex.h file, or call
*** the configure script with --disable-color.])
    else
	color_support=yes
86
87
    fi
fi
88
89

AC_ARG_ENABLE(extra,
90
AS_HELP_STRING([--disable-extra], [Disable extra features, currently only easter eggs]))
91
92
if test "x$enable_extra" = xno; then
    AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.])
93
fi
94

95
AC_ARG_ENABLE(help,
96
97
AS_HELP_STRING([--disable-help], [Disable help functions]))
if test "x$enable_help" = xno; then
98
    AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the help text display.])
99
fi
100

101
102
103
104
105
106
AC_ARG_ENABLE(histories,
AS_HELP_STRING([--disable-histories], [Disable search and position histories]))
if test "x$enable_histories" = xno; then
    AC_DEFINE(DISABLE_HISTORIES, 1, [Define this to disable search and position histories.])
fi

107
AC_ARG_ENABLE(justify,
108
109
AS_HELP_STRING([--disable-justify], [Disable justify/unjustify functions]))
if test "x$enable_justify" = xno; then
110
    AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routines.])
111
fi
112

113
114
115
AC_ARG_ENABLE(libmagic,
AS_HELP_STRING([--disable-libmagic], [Disable detection of file types via libmagic]))

116
AC_ARG_ENABLE(mouse,
117
118
AS_HELP_STRING([--disable-mouse], [Disable mouse support (and -m flag)]))
if test "x$enable_mouse" = xno; then
119
    AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse support.])
120
fi
121

122
123
AC_ARG_ENABLE(multibuffer,
AS_HELP_STRING([--disable-multibuffer], [Disable multiple file buffers]))
124
125
if test "x$enable_multibuffer" = xno; then
    AC_DEFINE(DISABLE_MULTIBUFFER, 1, [Define this to disable multiple file buffers.])
126
127
128
129
fi

AC_ARG_ENABLE(nanorc,
AS_HELP_STRING([--disable-nanorc], [Disable use of .nanorc files]))
130
131
132
if test "x$enable_nanorc" = xno; then
    AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
else
133
134
135
    nanorc_support=yes
fi

136
AC_ARG_ENABLE(operatingdir,
137
138
AS_HELP_STRING([--disable-operatingdir], [Disable setting of operating directory (chroot of sorts)]))
if test "x$enable_operatingdir" = xno; then
139
    AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of the operating directory (chroot of sorts).])
140
fi
141

142
AC_ARG_ENABLE(speller,
143
144
AS_HELP_STRING([--disable-speller], [Disable spell checker functions]))
if test "x$enable_speller" = xno; then
145
    AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell checker functions.])
146
fi
147

148
AC_ARG_ENABLE(tabcomp,
149
150
AS_HELP_STRING([--disable-tabcomp], [Disable tab completion functions]))
if test "x$enable_tabcomp" = xno; then
151
    AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for files and search strings.])
152
fi
Chris Allegretta's avatar
Chris Allegretta committed
153

154
AC_ARG_ENABLE(wrapping,
155
156
AS_HELP_STRING([--disable-wrapping], [Disable all wrapping of text (and -w flag)]))
if test "x$enable_wrapping" = xno; then
157
    AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all text wrapping.])
158
fi
159

160
AC_ARG_ENABLE(wrapping-as-root,
161
162
AS_HELP_STRING([--disable-wrapping-as-root], [Disable wrapping of text as root by default]))
if test "x$enable_wrapping_as_root" = xno; then
163
    AC_DEFINE(DISABLE_ROOTWRAPPING, 1, [Define this to disable text wrapping as root by default.])
164
fi
165

166
167
168
169
170
171
172
173
174
175
176
177
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Enable debugging (disabled by default)]))
if test "x$enable_debug" = xyes; then
    AC_DEFINE(DEBUG, 1, [Define this to enable debug messages and assert warnings.])
else
    AC_DEFINE(NDEBUG, 1, [Shut up assert warnings :-)])
fi

AC_ARG_ENABLE(tiny,
AS_HELP_STRING([--enable-tiny], [Disable features for the sake of size]))
if test "x$enable_tiny" = xyes; then
    AC_DEFINE(NANO_TINY, 1, [Define this to make the nano executable as small as possible.])
178
179
180
    if test "x$enable_browser" != xyes; then
	AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in file browser.])
    fi
181
182
183
    if test "x$enable_color" != xyes; then
	AC_DEFINE(DISABLE_COLOR, 1, [Define this to disable syntax highlighting.])
	color_support=no
184
185
186
187
    else
	if test "x$enable_nanorc" != xyes; then
	    AC_MSG_ERROR([--enable-color with --enable-tiny cannot work without --enable-nanorc])
	fi
188
    fi
189
    if test "x$enable_extra" != xyes; then
190
191
	AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.])
    fi
192
193
194
    if test "x$enable_help" != xyes; then
	AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the help text display.])
    fi
195
196
197
    if test "x$enable_histories" != xyes; then
	AC_DEFINE(DISABLE_HISTORIES, 1, [Define this to disable search and position histories.])
    fi
198
199
200
    if test "x$enable_justify" != xyes; then
	AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routines.])
    fi
201
202
203
    if test "x$enable_libmagic" != xyes; then
	enable_libmagic=no
    fi
204
205
206
207
    if test "x$enable_mouse" != xyes; then
	AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse support.])
    fi
    if test "x$enable_multibuffer" != xyes; then
208
209
	AC_DEFINE(DISABLE_MULTIBUFFER, 1, [Define this to disable multiple file buffers.])
    fi
210
211
212
    if test "x$enable_nanorc" != xyes; then
	AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
    fi
213
214
215
216
217
218
219
220
221
222
223
224
    if test "x$enable_operatingdir" != xyes; then
	AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of the operating directory (chroot of sorts).])
    fi
    if test "x$enable_speller" != xyes; then
	AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell checker functions.])
    fi
    if test "x$enable_tabcomp" != xyes; then
	AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for files and search strings.])
    fi
    if test "x$enable_wrapping" != xyes; then
	AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all text wrapping.])
    fi
225
226
fi

227
228
AM_CONDITIONAL(USE_COLOR, test x$color_support = xyes)
AM_CONDITIONAL(USE_NANORC, test x$nanorc_support = xyes)
229

230
AC_MSG_CHECKING([whether to enable UTF-8 support])
231
AC_ARG_ENABLE(utf8, AS_HELP_STRING([--enable-utf8], [Enable UTF-8 support]))
232
AC_MSG_RESULT(${enable_utf8:-auto})
233

234
235
236
237
238
239
240
AC_ARG_ENABLE(altrcname,
AS_HELP_STRING([--enable-altrcname], [Specify an alternate rcfile name (default: .nanorc)]),
[if test x$enableval != no; then
    AC_DEFINE_UNQUOTED(RCFILE_NAME, "$enableval", [Specify an alternate rcfile name (default: .nanorc).]) rcfilename=$enableval
fi])


241
242
243
AC_MSG_CHECKING([whether to use slang])
CURSES_LIB_NAME=""
AC_ARG_WITH(slang,
244
AS_HELP_STRING([--with-slang[=DIR]], [Use the slang library instead of curses]),
245
246
247
248
249
250
251
252
[    case "$with_slang" in
    no)
	AC_MSG_RESULT(no)
	;;
    *)
	AC_MSG_RESULT(yes)

	if test x$with_slang != xyes; then
253
	    # Add additional search path.
254
255
256
257
	    LDFLAGS="-L$with_slang/lib $LDFLAGS"
	    CPPFLAGS="-I$with_slang/include $CPPFLAGS"
	fi

258
	if test "x$enable_utf8" != xno; then
259
260
261
262
263
264
265
266
267
268
269
270
	    AC_CHECK_HEADER(slcurses.h,
		AC_MSG_CHECKING([for SLutf8_enable in -lslang])
		_libs=$LIBS
		LIBS="$LIBS -lslang"
		AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
    SLutf8_enable(1);
    return 0;
}],
		    [AC_MSG_RESULT(yes)
271
		    AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
272
273
274
275
276
277
278
279
280
		    CURSES_LIB_WIDE=yes
		    if test x$with_slang != xyes; then
			CURSES_LIB="-L${with_slang}/lib -lslang"
		    else
			CURSES_LIB="-lslang"
		    fi
		    CURSES_LIB_NAME=slang],
		    [AC_MSG_RESULT(no)

281
		    # We might need the term library.
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
		    for termlib in ncurses curses termcap terminfo termlib; do
			AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
			test -n "$tcap" && break
		    done

		    AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap])
		    LIBS="$LIBS $tcap"
		    AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
    SLutf8_enable(1);
    return 0;
}],
			[AC_MSG_RESULT(yes)
297
			AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
298
299
300
301
302
303
304
305
306
			CURSES_LIB_WIDE=yes
			if test x$with_slang != xyes; then
			    CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
			else
			    CURSES_LIB="-lslang $tcap"
			fi
			CURSES_LIB_NAME=slang],
			[AC_MSG_RESULT(no)

307
			# We might need the math library.
308
309
310
311
312
313
314
315
316
317
			AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap -lm])
			LIBS="$LIBS -lm"
			AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
    SLutf8_enable(1);
    return 0;
}],
			    [AC_MSG_RESULT(yes)
318
			    AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
			    CURSES_LIB_WIDE=yes
			    if test x$with_slang != xyes; then
				CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
			    else
				CURSES_LIB="-lslang $tcap -lm"
			    fi
			    CURSES_LIB_NAME=slang],
			    [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])),
	    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.]))
	fi

	if eval "test x$CURSES_LIB_NAME = x"; then
338
	    # Reset libs if the above slang tests failed.
339
	    if test "x$enable_utf8" != xno; then
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
		LIBS=$_libs
	    fi

	    AC_CHECK_HEADER(slcurses.h,
		AC_MSG_CHECKING([for SLtt_initialize in -lslang])
		_libs=$LIBS
		LIBS="$LIBS -lslang"
		AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
    SLtt_initialize(NULL);
    return 0;
}],
		    [AC_MSG_RESULT(yes)
355
		    AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
356
357
358
359
360
361
362
363
		    if test x$with_slang != xyes; then
			CURSES_LIB="-L${with_slang}/lib -lslang"
		    else
			CURSES_LIB="-lslang"
		    fi
		    CURSES_LIB_NAME=slang],
		    [AC_MSG_RESULT(no)

364
		    # We might need the term library.
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
		    for termlib in ncurses curses termcap terminfo termlib; do
			AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
			test -n "$tcap" && break
		    done

		    AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
		    LIBS="$LIBS $tcap"
		    AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
    SLtt_initialize(NULL);
    return 0;
}],
			[AC_MSG_RESULT(yes)
380
			AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
381
382
383
384
385
386
387
388
			if test x$with_slang != xyes; then
			    CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
			else
			    CURSES_LIB="-lslang $tcap"
			fi
			CURSES_LIB_NAME=slang],
			[AC_MSG_RESULT(no)

389
			# We might need the math library.
390
391
392
393
394
395
396
397
398
399
			AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
			LIBS="$LIBS -lm"
			AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
    SLtt_initialize(NULL);
    return 0;
}],
			    [AC_MSG_RESULT(yes)
400
			    AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
			    if test x$with_slang != xyes; then
				CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
			    else
				CURSES_LIB="-lslang $tcap -lm"
			    fi
			    CURSES_LIB_NAME=slang],
			    [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])),
	    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.]))
	fi

	if test "${_libs+set}" = "set"; then
	    LIBS=$_libs
	fi

	if test x$with_slang != xyes; then
	    LDFLAGS=${_ldflags}
	fi
	;;
    esac], [AC_MSG_RESULT(no)])

428

429
430
dnl Checks for functions.

431
AC_CHECK_FUNCS(getdelim getline isblank strcasecmp strcasestr strncasecmp strnlen snprintf vsnprintf)
432

433
if test "x$enable_utf8" != xno; then
434
    AC_CHECK_FUNCS(iswalnum iswblank iswpunct iswspace nl_langinfo mblen mbstowcs mbtowc wctomb wcwidth)
435
436
fi

437
438
439
440
441
442
443
444
445
if test x$ac_cv_func_snprintf = xno; then
    AM_PATH_GLIB_2_0(2.0.0,,
	AC_MSG_ERROR([
*** snprintf() not found.  GLIB 2.x not found either.
*** You should install the GLIB 2.x library which can
*** be found at http://ftp.gtk.org/.]),
	glib)
fi

446
if test x$ac_cv_func_vsnprintf = xno; then
447
448
    AM_PATH_GLIB_2_0(2.0.0,,
	AC_MSG_ERROR([
449
450
451
*** vsnprintf() not found.  GLIB 2.x not found either.
*** You should install the GLIB 2.x library which can
*** be found at http://ftp.gtk.org/.]),
452
	glib)
Chris Allegretta's avatar
Chris Allegretta committed
453
454
455
456
fi

dnl Checks for typedefs, structures, and compiler characteristics.

457
dnl Checks for available flags.
458

459
460
AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"], [], [])

Chris Allegretta's avatar
Chris Allegretta committed
461
dnl Checks for library functions.
462

Chris Allegretta's avatar
Chris Allegretta committed
463
464
465
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(getopt_long)
466

Chris Allegretta's avatar
Chris Allegretta committed
467
dnl Checks for libraries.
468

469
if eval "test x$CURSES_LIB_NAME = x"; then
470
    if test "x$enable_utf8" != xno; then
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
	PKG_CHECK_MODULES([NCURSESW], [ncursesw], [
	    CURSES_LIB=$NCURSESW_LIBS
	    CPPFLAGS="$NCURSESW_CFLAGS $CPPFLAGS"
	    CURSES_LIB_NAME=ncursesw
	    CURSES_LIB_WIDE=yes
	], [:])
    else
	PKG_CHECK_MODULES([NCURSES], [ncurses], [
	    CURSES_LIB=$NCURSES_LIBS
	    CPPFLAGS="$NCURSES_CFLAGS $CPPFLAGS"
	    CURSES_LIB_NAME=ncurses
	], [:])
    fi
fi

486
if eval "test x$CURSES_LIB_NAME = x"; then
487
    AC_CHECK_HEADERS(ncurses.h)
488

489
    if test "x$enable_utf8" != xno; then
490
491
492
493
494
495
496
497
498
499
500
	OLDLIBS="$LIBS"
	AC_CHECK_TOOL(NCURSESW_CONFIG, ncursesw5-config, no)
	if test "x$NCURSESW_CONFIG" != xno; then
	    CURSES_LIB=`$NCURSESW_CONFIG --libs`
	    LIBS="$CURSES_LIB $LIBS"
	    CPPFLAGS="`$NCURSESW_CONFIG --cflags` $CPPFLAGS"
	    AC_CHECK_LIB(ncursesw, get_wch, [CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
	else
	    AC_CHECK_LIB(ncursesw, get_wch, [CURSES_LIB="-lncursesw" CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
	fi
	LIBS="$OLDLIBS"
501
502
    fi

503
    if eval "test x$CURSES_LIB_NAME = x"; then
504
	AC_CHECK_LIB(ncurses, initscr, [CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses])
505
    fi
Chris Allegretta's avatar
Chris Allegretta committed
506
507
fi

508
if eval "test x$CURSES_LIB_NAME = x"; then
509
    AC_CHECK_HEADERS(curses.h)
510

511
    if test "x$enable_utf8" != xno; then
512
	AC_CHECK_LIB(curses, get_wch, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses CURSES_LIB_WIDE=yes])
513
514
    fi

515
    if eval "test x$CURSES_LIB_NAME = x"; then
516
	AC_CHECK_LIB(curses, initscr, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses])
517
    fi
Chris Allegretta's avatar
Chris Allegretta committed
518
519
fi

520
if eval "test x$CURSES_LIB_NAME = x"; then
Chris Allegretta's avatar
Chris Allegretta committed
521
    AC_MSG_WARN([
522
*** No curses lib available.  Consider getting the official ncurses
Chris Allegretta's avatar
Chris Allegretta committed
523
524
525
*** distribution from ftp://ftp.gnu.org/pub/gnu/ncurses if you get
*** errors compiling nano.])
else
526
    AC_MSG_RESULT([Using $CURSES_LIB_NAME as the curses library])
Chris Allegretta's avatar
Chris Allegretta committed
527
528
fi

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
529
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.]))
530
AC_CHECK_LIB([$CURSES_LIB_NAME], key_defined, AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() command.]))
531

532
dnl Parse any configure options.
Chris Allegretta's avatar
Chris Allegretta committed
533
534

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

Chris Allegretta's avatar
Chris Allegretta committed
536
537
AC_SUBST(CURSES_LIB)

538
if test "x$GLIB_CFLAGS" != "x"; then
539
    CFLAGS="$CFLAGS $GLIB_CFLAGS"
Chris Allegretta's avatar
Chris Allegretta committed
540
fi
541
if test "x$GLIB_LIBS" != "x"; then
542
    LDFLAGS="$LDFLAGS $GLIB_LIBS"
Chris Allegretta's avatar
Chris Allegretta committed
543
544
fi

545
if test "x$enable_utf8" != xno && \
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
546
547
548
549
    test x$CURSES_LIB_WIDE = xyes && \
    test x$ac_cv_func_iswalnum = xyes && \
    test x$ac_cv_func_iswpunct = xyes && \
    (test x$ac_cv_func_iswblank = xyes || test x$ac_cv_func_iswspace = xyes) && \
550
    test x$ac_cv_func_nl_langinfo = xyes && \
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
551
552
553
554
555
    test x$ac_cv_func_mblen = xyes && \
    test x$ac_cv_func_mbstowcs = xyes && \
    test x$ac_cv_func_mbtowc = xyes && \
    test x$ac_cv_func_wctomb = xyes && \
    test x$ac_cv_func_wcwidth = xyes; then
556
	AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support (a wide curses library, iswalnum(), iswpunct(), iswblank() or iswspace(), nl_langinfo, mblen(), mbstowcs(), mbtowc(), wctomb(), and wcwidth()).])
557
else
558
    if test "x$enable_utf8" = xyes; then
559
560
561
	AC_MSG_ERROR([
*** UTF-8 support was requested, but insufficient UTF-8 support was
*** detected in your curses and/or C libraries.  Please verify that your
562
563
564
*** slang was built with UTF-8 support or your curses was built with
*** wide character support, and that your C library was built with wide
*** character support.])
565
    elif test "x$enable_utf8" != xno; then
566
567
	AC_MSG_WARN([
*** Insufficient UTF-8 support was detected in your curses and/or C
568
569
570
571
*** libraries.  If you want UTF-8 support, please verify that your slang
*** was built with UTF-8 support or your curses was built with wide
*** character support, and that your C library was built with wide
*** character support.])
572
    fi
573
574
fi

575
576
577
578
579
580
581
582
583
584
585
586
587
AC_CACHE_CHECK([for enhanced regular expression flag], nano_cv_flag_reg_extended,
	       [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <regex.h>]],
						   [[
						     #ifndef REG_ENHANCED
						     error: No REG_ENHANCED support!
						     #endif
						   ]])],
				  [nano_cv_flag_reg_extended="REG_EXTENDED | REG_ENHANCED"],
				  [nano_cv_flag_reg_extended="REG_EXTENDED"])])

AC_DEFINE_UNQUOTED(NANO_REG_EXTENDED, $nano_cv_flag_reg_extended,
		   [Flag(s) to use to get the full range of extended regular expressions])

588
if test x$color_support = xyes; then
589
	# Now check for the end-of-word boundary support (/< and />).
590
	AC_MSG_CHECKING([for GNU-style word boundary regex support])
591
592

	AC_ARG_WITH(wordbounds,
593
        AS_HELP_STRING([--with-wordbounds], [Use GNU-style word boundary delimiters]),
594
595
596
597
598
599
600
	[ case "$with_wordbounds" in
	    no)
		AC_MSG_RESULT(no)
		;;
	    *)
		AC_MSG_RESULT(yes)
		# We explicitly don't check if the user forced the option, because
601
602
603
604
605
		# this is needed for cross compilers and we can't test the target.
		AC_DEFINE(GNU_WORDBOUNDS, 1, [Define this if the system supports GNU-style word boundaries in regexes.]) gnu_wordbounds=yes,
		;;
	  esac
	], [
606
	    AC_TRY_RUN([
607
608
609
610
611
612
613
614
615
616
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <regex.h>
int main(void)
{
    regex_t r;
    size_t nmatch;
    regmatch_t pmatch;

617
    if (regcomp(&r, "\\\\>", $nano_cv_flag_reg_extended|REG_NOSUB))
618
	return 1;
619
    if (regexec(&r, "word boundary", nmatch, &pmatch, 0))
620
	return 1;
621
622
    return 0;
}],
623
	    AC_MSG_RESULT(yes)
624
	    AC_DEFINE(GNU_WORDBOUNDS, 1, [Define this if the system supports GNU-style word boundaries in regexes.]) gnu_wordbounds=yes,
625
626
627
628
629
	    AC_MSG_RESULT(no),
	    AC_MSG_WARN([*** Can't check for GNU-style word boundary support when cross-compiling])
	)
])

630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
#    if test x$CURSES_LIB_NAME = xcurses; then
	AC_MSG_CHECKING([whether _XOPEN_SOURCE_EXTENDED is needed])
	AC_TRY_RUN([
#include <curses.h>
int main(void)
{
    int testcolor = COLOR_WHITE;
    return 0;
}], AC_MSG_RESULT(no),
        AC_TRY_RUN([
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED 1
#endif
#include <curses.h>
int main(void)
{
    int testcolor = COLOR_WHITE;
    return 0;
}],
	AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support])
	AC_MSG_RESULT(yes),
	AC_MSG_RESULT(not sure)
	AC_MSG_WARN([*** Couldn't successfully compile basic color test with or without _XOPEN_SOURCE_EXTENDED])
	AC_MSG_WARN([*** This build may not compile. Consider configuring with --disable-color or installing ncurses])),
	AC_MSG_WARN([*** Can't check need for _XOPEN_SOURCE_EXTENDED when cross-compiling]))
655
656
#    fi
fi
657

658
659
660
661
662
663
664
665
AC_MSG_CHECKING([whether LINES and COLS can be redefined])
AC_TRY_RUN([
#include <curses.h>
int main(void)
{
    LINES = 80;
    COLS = 25;
    return 0;
666
}],
667
AC_DEFINE(REDEFINING_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug])
668
669
670
671
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no),
AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))

672
AS_IF([test "x$enable_libmagic" != "xno"], [
673
  AC_CHECK_HEADERS([magic.h])
674
  AC_CHECK_LIB(magic, magic_open)
675
  AC_CHECK_HEADERS([zlib.h])
676
  AC_CHECK_LIB(z, inflate)
677
])
678

679
# Check for groff html support.
680
681
AC_MSG_CHECKING([for HTML support in groff])
groff -t -mandoc -Thtml </dev/null >/dev/null
682
683
684
685
if test $? -ne 0 ; then
    AC_MSG_RESULT([no])
    AC_MSG_WARN([*** Will not generate HTML version of man pages  ***
*** Consider installing a newer version of groff with HTML support ***])
686
687
    groff_html_support=no
else
688
    AC_MSG_RESULT([yes])
689
690
691
692
    groff_html_support=yes
fi
AM_CONDITIONAL(GROFF_HTML, test x$groff_html_support = xyes)

693
694
695
696
# Check for the availability of makeinfo.
AC_CHECK_PROG(haveit, makeinfo, yes, no)
AM_CONDITIONAL(HAVE_MAKEINFO, test x$haveit = xyes)

697

Jordi Mallach's avatar
Jordi Mallach committed
698
699
700
AC_CONFIG_FILES([
Makefile
doc/Makefile
701
doc/nanorc.sample
Jordi Mallach's avatar
Jordi Mallach committed
702
703
doc/man/Makefile
doc/man/fr/Makefile
704
doc/syntax/Makefile
Jordi Mallach's avatar
Jordi Mallach committed
705
706
707
708
709
710
711
doc/texinfo/Makefile
m4/Makefile
po/Makefile.in
src/Makefile
nano.spec
])

Jordi Mallach's avatar
Jordi Mallach committed
712
AC_OUTPUT