configure.ac 22.1 KB
Newer Older
1
# Configuration for GNU nano - a small and user-friendly text editor
2
#
3
4
# Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc.
# Copyright (C) 2014, 2017 Mike Frysinger
5
#
6
7
8
9
# 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 Free Software Foundation, either version 3 of the License,
# or (at your option) any 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
17
# along with this program.  If not, see https://www.gnu.org/licenses/.
18

19
AC_INIT([GNU nano], [3.2], [nano-devel@gnu.org], [nano])
Jordi Mallach's avatar
Jordi Mallach committed
20
AC_CONFIG_SRCDIR([src/nano.c])
21
AC_CANONICAL_HOST
22
AM_INIT_AUTOMAKE([1.14])
23
AC_CONFIG_HEADERS([config.h])
24

25
26
dnl Make sure the ONCE macros are available.

27
AC_PREREQ([2.69])
Chris Allegretta's avatar
Chris Allegretta committed
28

Mike Frysinger's avatar
Mike Frysinger committed
29
30
dnl Lie about gnulib features we don't use to speed up & shrink down.

31
gl_cv_func_printf_directive_n=yes
Mike Frysinger's avatar
Mike Frysinger committed
32
gl_cv_func_printf_infinite_long_double=yes
33
34
gl_cv_func_printf_long_double=yes
gl_cv_func_snprintf_directive_n=yes
35
gl_cv_glob_lists_symlinks=yes
Mike Frysinger's avatar
Mike Frysinger committed
36

Chris Allegretta's avatar
Chris Allegretta committed
37
dnl Checks for programs.
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
38

39
AC_GNU_SOURCE
Chris Allegretta's avatar
Chris Allegretta committed
40
AC_PROG_CC
Mike Frysinger's avatar
Mike Frysinger committed
41
42
gl_EARLY
gl_INIT
43
AC_PROG_LN_S
Chris Allegretta's avatar
Chris Allegretta committed
44
AC_ISC_POSIX
Jordi Mallach's avatar
Jordi Mallach committed
45
AC_SYS_LARGEFILE
46
PKG_PROG_PKG_CONFIG
Chris Allegretta's avatar
Chris Allegretta committed
47

48
dnl Internationalization macros.
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
49

50
AM_GNU_GETTEXT_VERSION([0.18.3])
51
AM_GNU_GETTEXT([external], [need-ngettext])
52
AM_CONDITIONAL(USE_NLS, test x$USE_NLS = xyes)
53

54
55
56
57
58
dnl Data location.

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

59
60
61
62
63
64
65
66
67
68
69
70
dnl Whether this is a git repository.

AC_MSG_CHECKING([whether building from git])
if test -d .git ; then
	AC_MSG_RESULT([yes])
	from_git=yes
else
	AC_MSG_RESULT([no])
	from_git=no
fi
AM_CONDITIONAL(BUILDING_FROM_GIT, test x$from_git = xyes)

71
dnl Checks for pkg-config and gettext when building from git.
72
73

if test x$from_git = xyes; then
74
75
	if test ! -f $(aclocal --print-ac-dir)/pkg.m4; then
		AC_MSG_ERROR([
76
77
  *** The pkg.m4 macros are missing. ***
  *** The pkg-config package needs to be installed when building from git. ***])
78
	fi
79
80
	if test "$ac_cv_path_MSGFMT" = ":"; then
		AC_MSG_ERROR([
81
82
  *** The msgfmt program is missing. ***
  *** The gettext package needs to be installed when building from git. ***])
83
84
85
	fi
fi

Chris Allegretta's avatar
Chris Allegretta committed
86
dnl Checks for header files.
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
87

88
AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
Chris Allegretta's avatar
Chris Allegretta committed
89

90
91
dnl Checks for options.

92
AC_ARG_ENABLE(browser,
93
AS_HELP_STRING([--disable-browser], [Disable the built-in file browser]))
94
if test "x$enable_tiny" = xyes; then
95
96
97
	if test "x$enable_browser" != xyes; then
		enable_browser=no
	fi
98
fi
99
if test "x$enable_browser" != xno; then
100
	AC_DEFINE(ENABLE_BROWSER, 1, [Define this to enable the built-in file browser.])
101
fi
102
103
104

AC_ARG_ENABLE(color,
AS_HELP_STRING([--disable-color], [Disable color and syntax highlighting]))
105
if test "x$enable_tiny" = xyes; then
106
107
108
109
110
111
	if test "x$enable_color" = xyes; then
		if test "x$enable_nanorc" != xyes; then
			AC_MSG_ERROR([--enable-color needs --enable-nanorc to work])
		fi
	else
		enable_color=no
112
113
	fi
fi
114
if test "x$enable_nanorc" = xno; then
115
116
117
118
119
120
	if test "x$enable_color" = xyes; then
		AC_MSG_ERROR([--enable-color cannot work with --disable-nanorc])
	else
		# Disabling nanorc silently disables color support.
		enable_color=no
	fi
121
fi
122
if test "x$enable_color" != xno; then
123
124
	AC_DEFINE(ENABLE_COLOR, 1, [Define this to have syntax highlighting.])
	color_support=yes
125
fi
126

127
AC_ARG_ENABLE(comment,
128
AS_HELP_STRING([--disable-comment], [Disable the comment/uncomment function]))
129
if test "x$enable_tiny" = xyes; then
130
131
132
133
134
	if test "x$enable_comment" = xyes; then
		AC_MSG_ERROR([--enable-comment cannot work with --enable-tiny])
	else
		enable_comment=no
	fi
135
fi
136
if test "x$enable_comment" != xno; then
137
	AC_DEFINE(ENABLE_COMMENT, 1, [Define this to enable the comment/uncomment function.])
138
fi
139

140
AC_ARG_ENABLE(extra,
141
AS_HELP_STRING([--disable-extra], [Disable the Easter egg]))
142
if test "x$enable_tiny" = xyes; then
143
144
145
	if test "x$enable_extra" != xyes; then
		enable_extra=no
	fi
146
147
fi
if test "x$enable_extra" != xno; then
148
	AC_DEFINE(ENABLE_EXTRA, 1, [Define this to have an Easter egg.])
149
fi
150

151
AC_ARG_ENABLE(help,
152
AS_HELP_STRING([--disable-help], [Disable the built-in help texts]))
153
if test "x$enable_tiny" = xyes; then
154
155
156
157
158
159
	if test "x$enable_help" = xyes; then
		if test "x$enable_multibuffer" != xyes; then
			AC_MSG_ERROR([--enable-help needs --enable-multibuffer to work])
		fi
	else
		enable_help=no
160
161
162
	fi
fi
if test "x$enable_multibuffer" = xno; then
163
164
165
166
167
168
	if test "x$enable_help" = xyes; then
		AC_MSG_ERROR([--enable-help cannot work with --disable-multibuffer])
	else
		# Disabling multibuffer silently disables the help texts.
		enable_help=no
	fi
169
fi
170
if test "x$enable_help" != xno; then
171
	AC_DEFINE(ENABLE_HELP, 1, [Define this to enable the Ctrl+G help texts.])
172
fi
173

174
175
AC_ARG_ENABLE(histories,
AS_HELP_STRING([--disable-histories], [Disable search and position histories]))
176
if test "x$enable_tiny" = xyes; then
177
178
179
	if test "x$enable_histories" != xyes; then
		enable_histories=no
	fi
180
181
fi
if test "x$enable_histories" != xno; then
182
	AC_DEFINE(ENABLE_HISTORIES, 1, [Define this to have search and position histories.])
183
184
fi

185
AC_ARG_ENABLE(justify,
186
AS_HELP_STRING([--disable-justify], [Disable the justify/unjustify functions]))
187
if test "x$enable_tiny" = xyes; then
188
189
190
	if test "x$enable_justify" != xyes; then
		enable_justify=no
	fi
191
192
fi
if test "x$enable_justify" != xno; then
193
	AC_DEFINE(ENABLE_JUSTIFY, 1, [Define this to have the routines for justifying.])
194
fi
195

196
197
198
AC_ARG_ENABLE(libmagic,
AS_HELP_STRING([--disable-libmagic], [Disable detection of file types via libmagic]))

199
200
201
AC_ARG_ENABLE(linenumbers,
AS_HELP_STRING([--disable-linenumbers], [Disable line numbering]))
if test "x$enable_tiny" = xyes; then
202
203
204
	if test "x$enable_linenumbers" != xyes; then
		enable_linenumbers=no
	fi
205
fi
206
if test "x$enable_linenumbers" != xno; then
207
	AC_DEFINE(ENABLE_LINENUMBERS, 1, [Define this to enable line numbering.])
208
fi
209

210
AC_ARG_ENABLE(mouse,
211
AS_HELP_STRING([--disable-mouse], [Disable mouse support]))
212
if test "x$enable_tiny" = xyes; then
213
214
215
	if test "x$enable_mouse" != xyes; then
		enable_mouse=no
	fi
216
fi
217
if test "x$enable_mouse" != xno; then
218
	AC_DEFINE(ENABLE_MOUSE, 1, [Define this to enable mouse support.])
219
fi
220

221
222
AC_ARG_ENABLE(multibuffer,
AS_HELP_STRING([--disable-multibuffer], [Disable multiple file buffers]))
223
if test "x$enable_tiny" = xyes; then
224
225
226
	if test "x$enable_multibuffer" != xyes; then
		enable_multibuffer=no
	fi
227
fi
228
if test "x$enable_multibuffer" != xno; then
229
	AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.])
230
fi
231
232

AC_ARG_ENABLE(nanorc,
233
AS_HELP_STRING([--disable-nanorc], [Disable the use of .nanorc files]))
234
if test "x$enable_tiny" = xyes; then
235
236
237
	if test "x$enable_nanorc" != xyes; then
		enable_nanorc=no
	fi
238
fi
239
if test "x$enable_nanorc" != xno; then
240
241
	AC_DEFINE(ENABLE_NANORC, 1, [Define this to enable the use of .nanorc files.])
	nanorc_support=yes
242
fi
243

244
AC_ARG_ENABLE(operatingdir,
245
AS_HELP_STRING([--disable-operatingdir], [Disable the setting of an operating directory]))
246
if test "x$enable_tiny" = xyes; then
247
248
249
	if test "x$enable_operatingdir" != xyes; then
		enable_operatingdir=no
	fi
250
251
fi
if test "x$enable_operatingdir" != xno; then
252
	AC_DEFINE(ENABLE_OPERATINGDIR, 1, [Define this to allow setting an operating directory (a chroot of sorts).])
253
fi
254

255
AC_ARG_ENABLE(speller,
256
AS_HELP_STRING([--disable-speller], [Disable the spell-checker functions]))
257
if test "x$enable_tiny" = xyes; then
258
259
260
	if test "x$enable_speller" != xyes; then
		enable_speller=no
	fi
261
262
fi
if test "x$enable_speller" != xno; then
263
	AC_DEFINE(ENABLE_SPELLER, 1, [Define this to have the spell-checker functions.])
264
fi
265

266
AC_ARG_ENABLE(tabcomp,
267
AS_HELP_STRING([--disable-tabcomp], [Disable the tab-completion functions]))
268
if test "x$enable_tiny" = xyes; then
269
270
271
	if test "x$enable_tabcomp" != xyes; then
		enable_tabcomp=no
	fi
272
fi
273
if test "x$enable_tabcomp" != xno; then
274
	AC_DEFINE(ENABLE_TABCOMP, 1, [Define this to have tab completion for filenames and search strings.])
275
fi
Chris Allegretta's avatar
Chris Allegretta committed
276

277
AC_ARG_ENABLE(wordcomp,
278
AS_HELP_STRING([--disable-wordcomp], [Disable the word-completion function]))
279
if test "x$enable_tiny" = xyes; then
280
281
282
283
284
	if test "x$enable_wordcomp" = xyes; then
		AC_MSG_ERROR([--enable-wordcomp cannot work with --enable-tiny])
	else
		enable_wordcomp=no
	fi
285
fi
286
if test "x$enable_wordcomp" != xno; then
287
	AC_DEFINE(ENABLE_WORDCOMPLETION, 1, [Define this to enable the word-completion function.])
288
fi
289

290
AC_ARG_ENABLE(wrapping,
291
AS_HELP_STRING([--disable-wrapping], [Disable all hard-wrapping of text]))
292
if test "x$enable_tiny" = xyes; then
293
294
295
	if test "x$enable_wrapping" != xyes; then
		enable_wrapping=no
	fi
296
297
fi
if test "x$enable_wrapping" != xno; then
298
	AC_DEFINE(ENABLE_WRAPPING, 1, [Define this to have hard text wrapping.])
299
fi
300

301
AC_ARG_ENABLE(wrapping-as-root,
302
303
AS_HELP_STRING([--disable-wrapping-as-root], [Disable wrapping of text as root by default]))
if test "x$enable_wrapping_as_root" = xno; then
304
	AC_DEFINE(DISABLE_ROOTWRAPPING, 1, [Define this to disable text wrapping as root by default.])
305
fi
306

307
308
309
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Enable debugging (disabled by default)]))
if test "x$enable_debug" = xyes; then
310
	AC_DEFINE(DEBUG, 1, [Define this to enable debug messages and abortion on failing asserts.])
311
else
312
	AC_DEFINE(NDEBUG, 1, [Shut up assert warnings :-)])
313
314
315
316
317
fi

AC_ARG_ENABLE(tiny,
AS_HELP_STRING([--enable-tiny], [Disable features for the sake of size]))
if test "x$enable_tiny" = xyes; then
318
319
320
321
	AC_DEFINE(NANO_TINY, 1, [Define this to make the nano executable as small as possible.])
	if test "x$enable_libmagic" != xyes; then
		enable_libmagic=no
	fi
322
323
fi

324
325
AM_CONDITIONAL(USE_COLOR, test x$color_support = xyes)
AM_CONDITIONAL(USE_NANORC, test x$nanorc_support = xyes)
326

327
AC_MSG_CHECKING([whether to enable UTF-8 support])
328
AC_ARG_ENABLE(utf8, AS_HELP_STRING([--enable-utf8], [Enable UTF-8 support]))
329
AC_MSG_RESULT(${enable_utf8:-auto})
330

331
332
333
AC_ARG_ENABLE(altrcname,
AS_HELP_STRING([--enable-altrcname], [Specify an alternate rcfile name (default: .nanorc)]),
[if test x$enableval != no; then
334
	AC_DEFINE_UNQUOTED(RCFILE_NAME, "$enableval", [Specify an alternate rcfile name (default: .nanorc).]) rcfilename=$enableval
335
336
337
fi])


338
339
340
AC_MSG_CHECKING([whether to use slang])
CURSES_LIB_NAME=""
AC_ARG_WITH(slang,
341
AS_HELP_STRING([--with-slang[=DIR]], [Use the slang library instead of curses]),
342
[    case "$with_slang" in
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
	no)
		AC_MSG_RESULT(no)
		;;
	*)
		AC_MSG_RESULT(yes)

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

		if test "x$enable_utf8" != xno; then
			AC_CHECK_HEADER(slcurses.h,
				AC_MSG_CHECKING([for SLutf8_enable in -lslang])
				_libs=$LIBS
				LIBS="$LIBS -lslang"
				AC_TRY_RUN([
361
362
363
#include <slcurses.h>
int main(void)
{
364
365
	SLutf8_enable(1);
	return 0;
366
}],
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
					[AC_MSG_RESULT(yes)
					AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
					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)

					# We might need the term library.
					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([
387
388
389
#include <slcurses.h>
int main(void)
{
390
391
	SLutf8_enable(1);
	return 0;
392
}],
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
						[AC_MSG_RESULT(yes)
						AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
						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)

						# We might need the math library.
						AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap -lm])
						LIBS="$LIBS -lm"
						AC_TRY_RUN([
408
409
410
#include <slcurses.h>
int main(void)
{
411
412
	SLutf8_enable(1);
	return 0;
413
}],
414
415
416
417
418
419
420
421
422
423
424
425
426
427
							[AC_MSG_RESULT(yes)
							AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
							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([
428
429
430
431
  *** The header file slcurses.h was not found.  This header file
  *** is required if you wish to use Slang support.  Please either
  *** install a version of Slang that includes the slcurses.h file
  *** or do not call the configure script with --with-slang.]))
432
		fi
433

434
435
436
437
438
439
440
441
442
443
444
		if eval "test x$CURSES_LIB_NAME = x"; then
			# Reset libs if the above slang tests failed.
			if test "x$enable_utf8" != xno; then
				LIBS=$_libs
			fi

			AC_CHECK_HEADER(slcurses.h,
				AC_MSG_CHECKING([for SLtt_initialize in -lslang])
				_libs=$LIBS
				LIBS="$LIBS -lslang"
				AC_TRY_RUN([
445
446
447
#include <slcurses.h>
int main(void)
{
448
449
	SLtt_initialize(NULL);
	return 0;
450
}],
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
					[AC_MSG_RESULT(yes)
					AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
					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)

					# We might need the term library.
					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([
470
471
472
#include <slcurses.h>
int main(void)
{
473
474
	SLtt_initialize(NULL);
	return 0;
475
}],
476
477
478
479
480
481
482
483
484
485
486
487
488
489
						[AC_MSG_RESULT(yes)
						AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
						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)

						# We might need the math library.
						AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
						LIBS="$LIBS -lm"
						AC_TRY_RUN([
490
491
492
#include <slcurses.h>
int main(void)
{
493
494
	SLtt_initialize(NULL);
	return 0;
495
}],
496
497
498
499
500
501
502
503
504
505
506
507
508
							[AC_MSG_RESULT(yes)
							AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
							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([
509
510
511
512
  *** The header file slcurses.h was not found.  This header file
  *** is required if you wish to use Slang support.  Please either
  *** install a version of Slang that includes the slcurses.h file
  *** or do not call the configure script with --with-slang.]))
513
		fi
514

515
516
517
		if test "${_libs+set}" = "set"; then
			LIBS=$_libs
		fi
518

519
520
521
522
523
		if test x$with_slang != xyes; then
			LDFLAGS=${_ldflags}
		fi
		;;
	esac], [AC_MSG_RESULT(no)])
524

525

526
527
dnl Checks for functions.

528
if test "x$enable_utf8" != xno; then
529
	AC_CHECK_FUNCS(iswalnum iswpunct mblen mbstowcs mbtowc wctomb)
530
fi
Chris Allegretta's avatar
Chris Allegretta committed
531
532
dnl Checks for typedefs, structures, and compiler characteristics.

533
dnl Checks for available flags.
534

535
536
AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"], [], [])

Chris Allegretta's avatar
Chris Allegretta committed
537
dnl Checks for library functions.
538

Chris Allegretta's avatar
Chris Allegretta committed
539
AC_TYPE_SIGNAL
540

Chris Allegretta's avatar
Chris Allegretta committed
541
dnl Checks for libraries.
542

543
if eval "test x$CURSES_LIB_NAME = x"; then
544
545
546
547
548
549
550
551
552
553
554
555
556
557
	if test "x$enable_utf8" != xno; then
		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
558
559
fi

560
if eval "test x$CURSES_LIB_NAME = x"; then
561
562
563
564
565
566
567
568
569
570
571
572
573
574
	AC_CHECK_HEADERS(ncurses.h)

	if test "x$enable_utf8" != xno; then
		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"
575
	fi
576

577
578
579
	if eval "test x$CURSES_LIB_NAME = x"; then
		AC_CHECK_LIB(ncurses, initscr, [CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses])
	fi
Chris Allegretta's avatar
Chris Allegretta committed
580
581
fi

582
if eval "test x$CURSES_LIB_NAME = x"; then
583
	AC_CHECK_HEADERS(curses.h)
584

585
586
587
	if test "x$enable_utf8" != xno; then
		AC_CHECK_LIB(curses, get_wch, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses CURSES_LIB_WIDE=yes])
	fi
588

589
590
591
	if eval "test x$CURSES_LIB_NAME = x"; then
		AC_CHECK_LIB(curses, initscr, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses])
	fi
Chris Allegretta's avatar
Chris Allegretta committed
592
593
fi

594
if eval "test x$CURSES_LIB_NAME = x"; then
595
	AC_MSG_ERROR([
596
597
598
  *** No curses lib was found.  Please install the curses header files
  *** from libncursesw5-dev (Debian), ncurses-devel (Fedora), or similar.
  *** (Or install ncurses from https://ftp.gnu.org/gnu/ncurses/.)])
Chris Allegretta's avatar
Chris Allegretta committed
599
else
600
	AC_MSG_RESULT([Using $CURSES_LIB_NAME as the curses library])
Chris Allegretta's avatar
Chris Allegretta committed
601
602
fi

603
AC_CHECK_LIB([$CURSES_LIB_NAME], [use_default_colors],
604
605
			 [AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() function.])],
			 [], [$CURSES_LIB])
606
AC_CHECK_LIB([$CURSES_LIB_NAME], [set_escdelay],
607
608
			 [AC_DEFINE(HAVE_SET_ESCDELAY, 1, [Define this if your curses library has the set_escdelay() function.])],
			 [], [$CURSES_LIB])
609
AC_CHECK_LIB([$CURSES_LIB_NAME], [key_defined],
610
611
			 [AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() function.])],
			 [], [$CURSES_LIB])
612

613
dnl Parse any configure options.
Chris Allegretta's avatar
Chris Allegretta committed
614
615

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

Chris Allegretta's avatar
Chris Allegretta committed
617
618
AC_SUBST(CURSES_LIB)

619
if test "x$enable_utf8" != xno && \
620
621
622
623
624
625
626
627
	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_mblen = xyes && \
	test x$ac_cv_func_mbstowcs = xyes && \
	test x$ac_cv_func_mbtowc = xyes && \
	test x$ac_cv_func_wctomb = xyes; then
		AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support.])
628
else
629
630
	if test "x$enable_utf8" = xyes; then
		AC_MSG_ERROR([
631
632
633
634
635
  *** UTF-8 support was requested, but insufficient UTF-8 support was
  *** detected in your curses and/or C libraries.  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.])
636
637
	elif test "x$enable_utf8" != xno; then
		AC_MSG_WARN([
638
639
640
641
642
  *** Insufficient UTF-8 support was detected in your curses and/or C
  *** 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.])
643
	fi
644
645
fi

646
AC_CACHE_CHECK([for enhanced regular expression flag], nano_cv_flag_reg_enhanced,
647
648
649
650
651
652
653
654
			   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <regex.h>]],
												   [[
													 #ifndef REG_ENHANCED
													 error: No REG_ENHANCED support!
													 #endif
												   ]])],
								  [nano_cv_flag_reg_enhanced=yes],
								  [nano_cv_flag_reg_enhanced=no])])
655
656
dnl The bundled gnulib regex module doesn't support REG_ENHANCED.
if test "$ac_use_included_regex" = "yes"; then
657
	nano_cv_flag_reg_enhanced="no"
658
659
fi
if test "$nano_cv_flag_reg_enhanced" = "yes"; then
660
	nano_reg_extended="REG_EXTENDED | REG_ENHANCED"
661
else
662
	nano_reg_extended="REG_EXTENDED"
663
fi
664

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

668
if test x$color_support = xyes; then
669
#    if test x$CURSES_LIB_NAME = xcurses; then
670
671
		AC_MSG_CHECKING([whether _XOPEN_SOURCE_EXTENDED is needed])
		AC_TRY_RUN([
672
673
674
#include <curses.h>
int main(void)
{
675
676
	int testcolor = COLOR_WHITE;
	return 0;
677
}], AC_MSG_RESULT(no),
678
	    AC_TRY_RUN([
679
680
681
682
683
684
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED 1
#endif
#include <curses.h>
int main(void)
{
685
686
	int testcolor = COLOR_WHITE;
	return 0;
687
}],
688
689
690
691
692
693
		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]))
694
695
#    fi
fi
696

697
698
699
700
701
AC_MSG_CHECKING([whether LINES and COLS can be redefined])
AC_TRY_RUN([
#include <curses.h>
int main(void)
{
702
703
704
	LINES = 80;
	COLS = 25;
	return 0;
705
}],
706
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.])
707
708
709
710
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no),
AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))

711
AS_IF([test "x$enable_libmagic" != "xno"], [
712
  AC_CHECK_HEADERS([magic.h])
713
  AC_CHECK_LIB(magic, magic_open)
714
  AC_CHECK_HEADERS([zlib.h])
715
  AC_CHECK_LIB(z, inflate)
716
])
717

718
# Check for groff html support.
719
720
AC_MSG_CHECKING([for HTML support in groff])
groff -t -mandoc -Thtml </dev/null >/dev/null
721
if test $? -ne 0 ; then
722
	AC_MSG_RESULT([no])
723
724
725
	AC_MSG_WARN([
  *** Will not generate HTML version of man pages. ***
  *** Consider installing a newer version of groff with HTML support. ***])
726
	groff_html_support=no
727
else
728
729
	AC_MSG_RESULT([yes])
	groff_html_support=yes
730
731
732
fi
AM_CONDITIONAL(GROFF_HTML, test x$groff_html_support = xyes)

Jordi Mallach's avatar
Jordi Mallach committed
733
734
735
AC_CONFIG_FILES([
Makefile
doc/Makefile
736
doc/sample.nanorc
Mike Frysinger's avatar
Mike Frysinger committed
737
lib/Makefile
Jordi Mallach's avatar
Jordi Mallach committed
738
739
740
m4/Makefile
po/Makefile.in
src/Makefile
741
syntax/Makefile
Jordi Mallach's avatar
Jordi Mallach committed
742
743
744
nano.spec
])

Jordi Mallach's avatar
Jordi Mallach committed
745
AC_OUTPUT