configure.ac 12.1 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

27
AC_PREREQ(2.54)
Chris Allegretta's avatar
Chris Allegretta committed
28
29

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

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

Chris Allegretta's avatar
Chris Allegretta committed
39
40
dnl Checks for header files.
AC_HEADER_STDC
41
AC_CHECK_HEADERS(fcntl.h getopt.h libintl.h limits.h regex.h termio.h termios.h unistd.h)
42
43
44
45
46
AC_CHECK_HEADER(regex.h,
    AC_MSG_CHECKING([for broken regexec])
    AC_TRY_RUN([
#include <sys/types.h>
#include <regex.h>
47
48
49
50
51
52
53
54
55
56
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;
}],
57
	AC_MSG_RESULT(no),
David Lawrence Ramsey's avatar
   
David Lawrence Ramsey committed
58
	AC_MSG_RESULT(yes); AC_DEFINE(BROKEN_REGEXEC, 1, [Define this if your regexec() function segfaults when passed an empty string under certain conditions.])
59
60
    )
)
Chris Allegretta's avatar
Chris Allegretta committed
61
62

dnl options
Chris Allegretta's avatar
Chris Allegretta committed
63
64
65
AC_ARG_ENABLE(debug, 
[  --enable-debug          Enable debugging (disabled by default)],
 [if test x$enableval = xyes; then
66
    AC_DEFINE(DEBUG, 1, [Define this to enable nano debug messages and assert warnings.])
Chris Allegretta's avatar
Chris Allegretta committed
67
68
69
70
    debug_support=yes
 fi])

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

74
75
76
77
78
79
80
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
81
AC_ARG_ENABLE(tiny,
82
[  --enable-tiny           Disable features for the sake of size],
Chris Allegretta's avatar
Chris Allegretta committed
83
[if test x$enableval = xyes; then
84
    AC_DEFINE(NANO_SMALL, 1, [Define this to make the nano executable as small as possible.]) tiny_support=yes
85
    AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in (crappy) file browser.]) 
86
87
    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
88
89
    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).]) 
90
91
    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
92
93
 fi])

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

100
101
102
103
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.])
104
105
 fi])

106
107
108
109
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.]) 
110
111
 fi])

112
113
AC_ARG_ENABLE(mouse,
[  --disable-mouse         Disable mouse support (and -m flag)],
114
 [if test x$enableval != xyes; then
115
    AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse functions.])
116
117
 fi])

118
119
AC_ARG_ENABLE(operatingdir,
[  --disable-operatingdir  Disable setting of operating directory (chroot of sorts)],
120
 [if test x$enableval != xyes; then
121
    AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable setting of the operating directory (chroot of sorts).])
122
123
 fi])

124
AC_ARG_ENABLE(speller,
125
[  --disable-speller       Disable spell checker function],
126
 [if test x$enableval != xyes; then
127
    AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the use(full|less) spelling functions.])
128
129
 fi])

130
131
AC_ARG_ENABLE(tabcomp,
[  --disable-tabcomp       Disable tab completion code for a smaller binary],
132
 [if test x$enableval != xyes; then
133
    AC_DEFINE(DISABLE_TABCOMP, 1, [Define to disable the tab completion code Chris worked so hard on!]) 
Chris Allegretta's avatar
Chris Allegretta committed
134
135
 fi])

136
AC_ARG_ENABLE(wrapping,
137
[  --disable-wrapping      Disable all wrapping of text (and -w flag)],
138
 [if test x$enableval != xyes; then
139
    AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable any and all text wrapping.])
140
141
 fi])

142
143
144
145
146
147
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])

148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
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
166
167
 fi])

168
169
170
171
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
172
173
 fi])

174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
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])

190
AC_MSG_CHECKING([whether to use slang])
Chris Allegretta's avatar
Chris Allegretta committed
191
192
193
194
195
196
197
198
199
200
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)

201
202
203
204
205
	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
206
207

	AC_CHECK_HEADER(slcurses.h,
208
	    AC_MSG_CHECKING([for SLtt_initialize in -lslang])
209
210
	    _libs=$LIBS
	    LIBS="$LIBS -lslang"
211
212
	    AC_TRY_RUN([
#include <slcurses.h>
213
214
215
216
217
int main(void)
{
    SLtt_initialize(NULL);
    return 0;
}],
218
		[AC_MSG_RESULT(yes)
219
		AC_DEFINE(USE_SLANG, 1, [Define to use the slang wrappers for curses instead of native curses.])
220
221
222
223
224
225
226
		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], [
227
228
229
		AC_MSG_RESULT(no)
		# We might need the term library
		for termlib in ncurses curses termcap terminfo termlib; do
230
		    AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
231
232
233
		    test -n "$tcap" && break
		done

234
		AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
235
		LIBS="$LIBS $tcap"
236
237
		AC_TRY_RUN([
#include <slcurses.h>
238
239
240
241
242
int main(void)
{
    SLtt_initialize(NULL);
    return 0;
}],
243
		    [AC_MSG_RESULT(yes)
244
		    AC_DEFINE(USE_SLANG, 1, [Define to use the slang wrappers for curses instead of native curses.])
245
246
247
248
249
250
251
252
253
		    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
254
		    AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
255
		    LIBS="$LIBS -lm"
256
257
		    AC_TRY_RUN([
#include <slcurses.h>
258
259
260
261
262
int main(void)
{
    SLtt_initialize(NULL);
    return 0;
}],
263
			[AC_MSG_RESULT(yes)
264
			AC_DEFINE(USE_SLANG, 1, [Define to use the slang wrappers for curses instead of native curses.])
265
266
267
268
269
270
271
			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],
272
273
274
275
			[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
276
277
278
279
280
281
282
	    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
]))

283
284
	test "${_libs+set}" = "set" && LIBS=$_libs

285
286
287
	if test "$with_slang" != "yes"; then
	    LDFLAGS=${_ldflags}
	fi
Chris Allegretta's avatar
Chris Allegretta committed
288
	;;
289
    esac], [AC_MSG_RESULT(no)])
Chris Allegretta's avatar
Chris Allegretta committed
290
291

dnl Checks for functions
292
AC_CHECK_FUNCS(snprintf vsnprintf isblank strcasecmp strncasecmp strcasestr strnlen)
Chris Allegretta's avatar
Chris Allegretta committed
293
294
if test "x$ac_cv_func_snprintf" = "xno" -o "xac_cv_func_vsnprintf" = "xno"
then
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
295
296
297
	AM_PATH_GLIB_2_0(2.0.0,,
	    [AM_PATH_GLIB(1.2.4,,
		[AC_MSG_ERROR([
Chris Allegretta's avatar
Chris Allegretta committed
298
299
*** snprintf() and/or vsnprintf() not found.  GLIB not found either.
*** You need both snprintf() and vsnprintf().  Alternatively you can
300
*** install the GLIB library which can be found at ftp://ftp.gtk.org/.])],
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
301
		glib)])
Chris Allegretta's avatar
Chris Allegretta committed
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
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)
317
    AC_CHECK_LIB(ncurses, tgetent, [CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses])
Chris Allegretta's avatar
Chris Allegretta committed
318
319
320
321
fi

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

Chris Allegretta's avatar
Chris Allegretta committed
325
326
327
# Fallback for PDCurses and less useful curses libs...
if eval "test x$CURSES_LIB_NAME = x"
then
328
    AC_CHECK_LIB(curses, initscr, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses])
Chris Allegretta's avatar
Chris Allegretta committed
329
330
fi

Chris Allegretta's avatar
Chris Allegretta committed
331
332
if eval "test x$CURSES_LIB_NAME = x"
then
333
    AC_CHECK_LIB(termcap, tgetent, [CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap])
Chris Allegretta's avatar
Chris Allegretta committed
334
335
336
337
338
339
340
341
342
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
343
    AC_MSG_RESULT([Using $CURSES_LIB_NAME as the termcap library])
Chris Allegretta's avatar
Chris Allegretta committed
344
345
346
fi


347
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.]))
348

Chris Allegretta's avatar
Chris Allegretta committed
349
350
351
dnl Parse any configure options

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

Chris Allegretta's avatar
Chris Allegretta committed
353
354
AC_SUBST(CURSES_LIB)

David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
355
if test "x$GLIB_CFLAGS" != "x"
Chris Allegretta's avatar
Chris Allegretta committed
356
then
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
357
	CFLAGS="$CFLAGS $GLIB_CFLAGS"
Chris Allegretta's avatar
Chris Allegretta committed
358
fi
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
359
if test "x$GLIB_LIBS" != "x"
Chris Allegretta's avatar
Chris Allegretta committed
360
then
David Lawrence Ramsey's avatar
David Lawrence Ramsey committed
361
	LDFLAGS="$LDFLAGS $GLIB_LIBS"
Chris Allegretta's avatar
Chris Allegretta committed
362
363
fi

Jordi Mallach's avatar
Jordi Mallach committed
364
365
366
367
368
369
370
371
372
373
374
375
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
376
AC_OUTPUT