Debian Codegraph @

configure.ac

raw
1 # $Id$
2
3 # Copyright (c) 2009, Darren Hiebert
4 #
5 # This source code is released for free distribution under the terms
6 # of the GNU General Public License.
7
8 # Process this file with autoconf to produce a configure script.
9
10 AC_PREREQ([2.61])
11 AC_INIT([ctags.h])
12 AC_CONFIG_HEADERS([config.h])
13
14 AH_TEMPLATE([PACKAGE], [Package name.])
15 AH_TEMPLATE([VERSION], [Package version.])
16 AH_TEMPLATE([clock_t],
17 [Define to the appropriate type if <time.h> does not define this.])
18 AH_TEMPLATE([fpos_t],
19 [Define to long if <stdio.h> does not define this.])
20 AH_TEMPLATE([L_tmpnam],
21 [Define to the appropriate size for tmpnam() if <stdio.h> does not define
22 this.])
23 AH_TEMPLATE([HAVE_STAT_ST_INO],
24 [Define this macro if the field "st_ino" exists in struct stat in
25 <sys/stat.h>.])
26 AH_TEMPLATE([remove],
27 [Define remove to unlink if you have unlink(), but not remove().])
28 AH_TEMPLATE([SEEK_SET],
29 [Define this value used by fseek() appropriately if <stdio.h>
30 (or <unistd.h> on SunOS 4.1.x) does not define them.])
31 AH_TEMPLATE([INT_MAX],
32 [Define as the maximum integer on your system if not defined <limits.h>.])
33 AH_TEMPLATE([CUSTOM_CONFIGURATION_FILE],
34 [You can define this label to be a string containing the name of a
35 site-specific configuration file containing site-wide default options. The
36 files /etc/ctags.conf and /usr/local/etc/ctags.conf are already checked,
37 so only define one here if you need a file somewhere else.])
38 AH_TEMPLATE([MACROS_USE_PATTERNS],
39 [Define this label if you want macro tags (defined lables) to use patterns
40 in the EX command by default (original ctags behavior is to use line
41 numbers).])
42 AH_VERBATIM([DEFAULT_FILE_FORMAT], [
43 /* Define this as desired.
44 * 1: Original ctags format
45 * 2: Extended ctags format with extension flags in EX-style comment.
46 */
47 #define DEFAULT_FILE_FORMAT 2
48 ])
49 AH_TEMPLATE([SYS_INTERPRETER],
50 [Define this label if your system supports starting scripts with a line of
51 the form "#! /bin/sh" to select the interpreter to use for the script.])
52 AH_TEMPLATE([CASE_INSENSITIVE_FILENAMES],
53 [Define this label if your system uses case-insensitive file names])
54 AH_VERBATIM([EXTERNAL_SORT], [
55 /* Define this label to use the system sort utility (which is probably more
56 * efficient) over the internal sorting algorithm.
57 */
58 #ifndef INTERNAL_SORT
59 # undef EXTERNAL_SORT
60 #endif
61 ])
62 AH_TEMPLATE([TMPDIR],
63 [If you wish to change the directory in which temporary files are stored,
64 define this label to the directory desired.])
65 AH_TEMPLATE([REGCOMP_BROKEN],
66 [Define this label if regcomp() is broken.])
67 AH_TEMPLATE([CHECK_REGCOMP],
68 [Define this label if you wish to check the regcomp() function at run time
69 for correct behavior. This function is currently broken on Cygwin.])
70 AH_TEMPLATE([__USE_FIXED_PROTOTYPES__],
71 [This corrects the problem of missing prototypes for certain functions
72 in some GNU installations (e.g. SunOS 4.1.x).])
73 AH_TEMPLATE([NON_CONST_PUTENV_PROTOTYPE],
74 [Define this is you have a prototype for putenv() in <stdlib.h>, but
75 doesn't declare its argument as "const char *".])
76 AH_TEMPLATE([NEED_PROTO_REMOVE],
77 [If you receive error or warning messages indicating that you are missing
78 a prototype for, or a type mismatch using, the following function, define
79 this label and remake.])
80 AH_TEMPLATE([NEED_PROTO_UNLINK],
81 [If you receive error or warning messages indicating that you are missing
82 a prototype for, or a type mismatch using, the following function, define
83 this label and remake.])
84 AH_TEMPLATE([NEED_PROTO_MALLOC],
85 [If you receive error or warning messages indicating that you are missing
86 a prototype for, or a type mismatch using, the following function, define
87 this label and remake.])
88 AH_TEMPLATE([NEED_PROTO_GETENV],
89 [If you receive error or warning messages indicating that you are missing
90 a prototype for, or a type mismatch using, the following function, define
91 this label and remake.])
92 AH_TEMPLATE([NEED_PROTO_FGETPOS],
93 [If you receive error or warning messages indicating that you are missing
94 a prototype for, or a type mismatch using, the following function, define
95 this label and remake.])
96 AH_TEMPLATE([NEED_PROTO_STAT],
97 [If you receive error or warning messages indicating that you are missing
98 a prototype for, or a type mismatch using, the following function, define
99 this label and remake.])
100 AH_TEMPLATE([NEED_PROTO_LSTAT],
101 [If you receive error or warning messages indicating that you are missing
102 a prototype for, or a type mismatch using, the following function, define
103 this label and remake.])
104 AH_TEMPLATE([NEED_PROTO_TRUNCATE],
105 [If you receive error or warning messages indicating that you are missing
106 a prototype for, or a type mismatch using, the following function, define
107 this label and remake.])
108 AH_TEMPLATE([NEED_PROTO_FTRUNCATE],
109 [If you receive error or warning messages indicating that you are missing
110 a prototype for, or a type mismatch using, the following function, define
111 this label and remake.])
112
113
114
115 # Report system info
116 # ------------------
117 program_name=[`grep 'PROGRAM_NAME *"' ctags.h | sed -e 's/.*"\([^"]*\)".*/\1/'`]
118 program_version=[`grep 'PROGRAM_VERSION *"' ctags.h | sed -e 's/.*"\([^"]*\)".*/\1/'`]
119 echo "$program_name, version $program_version"
120 uname -mrsv 2>/dev/null
121
122 # Define convenience macros
123 # -------------------------
124 # CHECK_HEADER_DEFINE(LABEL, HEADER [,ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ] ])
125 AC_DEFUN([CHECK_HEADER_DEFINE], [
126 AC_MSG_CHECKING([if $1 is defined in $2])
127 AC_EGREP_CPP(yes,
128 [#include <$2>
129 #ifdef $1
130 yes
131 #endif
132 ], [
133 AC_MSG_RESULT(yes)
134 [$3]
135 ], [
136 AC_MSG_RESULT(no)
137 [$4]
138 ]) ])
139
140 # Checks for configuration options
141 # --------------------------------
142
143 AC_ARG_WITH(posix-regex,
144 [ --with-posix-regex use Posix regex interface, if available])
145
146 AC_ARG_WITH(readlib,
147 [ --with-readlib include readtags library object during install])
148
149 # AC_ARG_WITH(perl-regex,
150 # [ --with-perl-regex use Perl pcre interface, if available])
151
152 AC_ARG_ENABLE(etags,
153 [ --enable-etags enable the installation of links for etags])
154
155 AC_ARG_ENABLE(extended-format,
156 [ --disable-extended-format
157 disable extension flags; use original ctags file
158 format only],
159 AC_DEFINE(DEFAULT_FILE_FORMAT, 1), AC_DEFINE(DEFAULT_FILE_FORMAT, 2))
160
161 AC_ARG_ENABLE(external-sort,
162 [ --disable-external-sort use internal sort algorithm instead of sort program])
163
164 AC_ARG_ENABLE(custom-config,
165 [ --enable-custom-config=FILE
166 enable custom config file for site-wide defaults])
167
168 AC_ARG_ENABLE(macro-patterns,
169 [ --enable-macro-patterns use patterns as default method to locate macros
170 instead of line numbers])
171
172 AC_ARG_ENABLE(maintainer-mode,
173 [ --enable-maintainer-mode
174 use maintainer makefile])
175
176 AC_ARG_ENABLE(shell-globbing,
177 [ --enable-shell-globbing=DIR
178 does shell expand wildcards (yes|no)? [yes]])
179
180 AC_ARG_ENABLE(tmpdir,
181 [ --enable-tmpdir=DIR default directory for temporary files [ARG=/tmp]],
182 tmpdir_specified=yes)
183
184
185 # Process configuration options
186 # -----------------------------
187
188 if test "$enable_maintainer_mode" = yes ; then
189 AC_MSG_RESULT(enabling maintainer mode)
190 fi
191
192 install_targets="install-ctags"
193 AC_MSG_CHECKING(whether to install link to etags)
194 if test yes = "$enable_etags"; then
195 AC_MSG_RESULT(yes)
196 install_targets="$install_targets install-etags"
197 else
198 AC_MSG_RESULT(no)
199 fi
200 AC_MSG_CHECKING(whether to install readtags object file)
201 if test yes = "$with_readlib"; then
202 AC_MSG_RESULT(yes)
203 install_targets="$install_targets install-lib"
204 else
205 AC_MSG_RESULT(no)
206 fi
207 AC_SUBST(install_targets)
208
209 if test "$enable_custom_config" = no -o "$enable_custom_config" = yes ; then
210 AC_MSG_RESULT(no name supplied for custom configuration file)
211 elif test -n "$enable_custom_config" ; then
212 AC_DEFINE_UNQUOTED(CUSTOM_CONFIGURATION_FILE, "$enable_custom_config")
213 AC_MSG_RESULT($enable_custom_config will be used as custom configuration file)
214 fi
215
216 if test "$enable_macro_patterns" = yes ; then
217 AC_DEFINE(MACROS_USE_PATTERNS)
218 AC_MSG_RESULT(tag file will use patterns for macros by default)
219 fi
220
221 # Checks for programs
222 # -------------------
223
224 AC_PROG_CC
225
226 case `uname` in
227 HP-UX)
228 AC_MSG_CHECKING(HP-UX native compiler)
229 if test "$CC" = "cc"; then
230 AC_MSG_RESULT(yes; adding compiler options for ANSI support)
231 CFLAGS="$CFLAGS -Aa -D_HPUX_SOURCE"
232 else
233 AC_MSG_RESULT(no)
234 fi
235 ;;
236 SunOS)
237 if uname -r | grep '5\.' >/dev/null 2>&1; then
238 AC_MSG_CHECKING(Solaris native compiler)
239 if test "$CC" = "cc" -a "`which cc`" = "/usr/ucb/cc"; then
240 AC_MSG_RESULT(yes; adding compiler option for ANSI support)
241 CC="$CC -Xa"
242 else
243 AC_MSG_RESULT(no)
244 fi
245 fi
246 ;;
247 esac
248
249 AC_PROG_LN_S
250 AC_CHECK_PROG(STRIP, strip, strip, :)
251 AC_SYS_LARGEFILE
252
253
254 # Checks for operating environment
255 # --------------------------------
256
257 # Check for temporary directory
258 AC_MSG_CHECKING(directory to use for temporary files)
259 if test -n "$enable_tmpdir"; then
260 tmpdir="$enable_tmpdir"
261 elif test -n "$TMPDIR"; then
262 tmpdir="$TMPDIR"
263 elif test -n "$TMPDIR"; then
264 tmpdir="$TMPDIR"
265 elif test -n "$TMP"; then
266 tmpdir="$TMP"
267 elif test -n "$TEMP"; then
268 tmpdir="$TEMP"
269 elif test -d "c:/"; then
270 tmpdir="c:/"
271 else
272 tmpdir="/tmp"
273 fi
274 if test -d $tmpdir ; then
275 AC_MSG_RESULT($tmpdir)
276 AC_DEFINE_UNQUOTED(TMPDIR, "$tmpdir")
277 else
278 AC_MSG_ERROR($tmpdir does not exist)
279 fi
280
281 # Check whether system supports #! scripts
282 AC_SYS_INTERPRETER
283 if test yes = "$interpval"; then
284 AC_DEFINE(SYS_INTERPRETER)
285 fi
286
287 # Test for case-insensitive filenames
288 AC_MSG_CHECKING(for case-insensitive filenames)
289 touch conftest.cif
290 if test -f CONFTEST.CIF; then
291 AC_MSG_RESULT(yes)
292 AC_DEFINE(CASE_INSENSITIVE_FILENAMES)
293 else
294 AC_MSG_RESULT(no)
295 fi
296 rm -f conftest.cif
297
298 AC_MSG_CHECKING(selected sort method)
299 if test no = "$enable_external_sort"; then
300 AC_MSG_RESULT(simple internal algorithm)
301 else
302 AC_MSG_RESULT(external sort utility)
303 enable_external_sort=no
304 AC_CHECK_PROG(sort_found, sort, yes, no)
305 if test "$sort_found" = yes ; then
306 AC_MSG_CHECKING(if sort accepts our command line)
307 touch ${tmpdir}/sort.test
308 sort -u -f -o ${tmpdir}/sort.test ${tmpdir}/sort.test 1>/dev/null 2>&1
309 if test $? -ne 0 ; then
310 AC_MSG_RESULT(no)
311 else
312 AC_MSG_RESULT(yes)
313 AC_DEFINE(EXTERNAL_SORT)
314 enable_external_sort=yes
315 fi
316 rm -f ${tmpdir}/sort.test
317 fi
318 fi
319 if test "$enable_external_sort" != yes ; then
320 AC_MSG_RESULT(using internal sort algorithm as fallback)
321 fi
322
323
324 # Checks for header files
325 # -----------------------
326
327 AC_CHECK_HEADERS_ONCE([dirent.h fcntl.h fnmatch.h stat.h stdlib.h string.h])
328 AC_CHECK_HEADERS_ONCE([time.h types.h unistd.h])
329 AC_CHECK_HEADERS_ONCE([sys/dir.h sys/stat.h sys/times.h sys/types.h])
330
331
332 # Checks for header file macros
333 # -----------------------------
334
335 CHECK_HEADER_DEFINE(L_tmpnam, [stdio.h],, AC_DEFINE(L_tmpnam, 20))
336
337 CHECK_HEADER_DEFINE(INT_MAX, [limits.h],,
338 CHECK_HEADER_DEFINE(MAXINT, [limits.h],
339 AC_DEFINE(INT_MAX, MAXINT), AC_DEFINE(INT_MAX, 32767)))
340
341
342 # Checks for typedefs
343 # -------------------
344
345 AC_TYPE_SIZE_T
346 AC_TYPE_OFF_T
347
348 AC_MSG_CHECKING(for fpos_t)
349 AC_EGREP_HEADER(fpos_t, stdio.h, AC_MSG_RESULT(yes),
350 [
351 AC_MSG_RESULT(no)
352 AC_DEFINE(fpos_t, long)
353 ])
354
355 AC_MSG_CHECKING(for clock_t)
356 AC_EGREP_HEADER(clock_t, time.h, AC_MSG_RESULT(yes),
357 [
358 AC_MSG_RESULT(no)
359 AC_DEFINE(clock_t, long)
360 ])
361
362
363 # Checks for compiler characteristics
364 # -----------------------------------
365
366 # AC_CYGWIN
367 # AC_MINGW32
368 AC_C_CONST
369 AC_OBJEXT
370 AC_EXEEXT
371
372 AC_MSG_CHECKING(if struct stat contains st_ino)
373 AC_TRY_COMPILE([#include <sys/stat.h>], [
374 struct stat st;
375 stat(".", &st);
376 if (st.st_ino > 0)
377 exit(0);
378 ], have_st_ino=yes, have_st_ino=no)
379 AC_MSG_RESULT($have_st_ino)
380 if test yes = "$have_st_ino"; then
381 AC_DEFINE(HAVE_STAT_ST_INO)
382 fi
383
384
385 # Checks for library functions
386 # ----------------------------
387
388 AC_CHECK_FUNCS(fnmatch)
389 AC_CHECK_FUNCS(strstr)
390 AC_CHECK_FUNCS(strcasecmp stricmp, break)
391 AC_CHECK_FUNCS(strncasecmp strnicmp, break)
392 AC_CHECK_FUNCS(fgetpos, have_fgetpos=yes)
393
394 # SEEK_SET should be in stdio.h, but may be in unistd.h on SunOS 4.1.x
395 if test "$have_fgetpos" != yes ; then
396 CHECK_HEADER_DEFINE(SEEK_SET, stdio.h,,
397 CHECK_HEADER_DEFINE(SEEK_SET, unistd.h,,
398 AC_DEFINE(SEEK_SET, 0)))
399 fi
400
401 AC_CHECK_FUNCS(mkstemp, have_mkstemp=yes)
402 if test "$have_mkstemp" != yes ; then
403 AC_CHECK_FUNCS(tempnam, have_tempnam=yes)
404 fi
405 if test "$have_mkstemp" != yes -a "$have_tempnam" != yes; then
406 AC_CHECK_FUNCS(chmod)
407 if test "$tmpdir_specified" = yes ; then
408 AC_MSG_RESULT(use of tmpnam overrides temporary directory selection)
409 fi
410 fi
411
412 AC_CHECK_FUNCS(opendir findfirst _findfirst, break)
413 AC_CHECK_FUNCS(strerror)
414 AC_CHECK_FUNCS(clock times, break)
415 AC_CHECK_FUNCS(remove, have_remove=yes,
416 CHECK_HEADER_DEFINE(remove, unistd.h,, AC_DEFINE(remove, unlink)))
417
418 AC_CHECK_FUNCS(truncate, have_truncate=yes)
419 # === Cannot nest AC_CHECK_FUNCS() calls
420 if test "$have_truncate" != yes ; then
421 AC_CHECK_FUNCS(ftruncate, have_ftruncate=yes)
422 if test "$have_ftruncate" != yes ; then
423 AC_CHECK_FUNCS(chsize)
424 fi
425 fi
426
427 AC_CHECK_FUNCS(setenv, have_setenv=yes)
428 # === Cannot nest AC_CHECK_FUNCS() calls
429 if test "$have_setenv" != yes ; then
430 AC_CHECK_FUNCS(putenv, have_putenv=yes)
431 if test "$have_putenv" = yes ; then
432 AC_EGREP_HEADER(putenv, stdlib.h, have_putenv_prototype=yes)
433 if test "$have_putenv_prototype" = yes ; then
434 AC_MSG_CHECKING(putenv prototype)
435 AC_EGREP_HEADER([[^A-Za-zo-9_]putenv[ ]*\(.*const.*\)[ ]*;],
436 stdlib.h, AC_MSG_RESULT(correct),
437 [
438 AC_MSG_RESULT(no const)
439 AC_DEFINE(NON_CONST_PUTENV_PROTOTYPE)
440 ])
441 fi
442 fi
443 fi
444
445 #
446 # if test yes = "$CYGWIN"; then with_posix_regex=no; fi
447 if test no != "$with_posix_regex"; then
448 AC_CHECK_FUNCS(regcomp)
449 AC_MSG_CHECKING(if regcomp works)
450 AC_TRY_RUN([
451 #include <sys/types.h>
452 #include <regex.h>
453 main() {
454 regex_t patbuf;
455 exit (regcomp (&patbuf, "/hello/", 0) != 0);
456 }],regcomp_works=yes,regcomp_works=no,AC_DEFINE(CHECK_REGCOMP))
457 AC_MSG_RESULT($regcomp_works)
458 if test yes != "$regcomp_works"; then
459 AC_DEFINE(REGCOMP_BROKEN)
460 fi
461 fi
462
463 # if test yes = "$with_perl_regex"; then
464 # AC_MSG_CHECKING(for Perl regex library)
465 # pcre_candidates="$with_perl_regex $HOME/local/lib* /usr*/local/lib* /usr/lib*"
466 # for lib in $pcre_candidates; do
467 # if test -f $lib/libpcreposix.so; then
468 # pcre_lib="-L$lib -lpcreposix"
469 # break
470 # elif test -f $lib/libpcreposix.a; then
471 # pcre_lib="$lib/libpcreposix.a"
472 # break
473 # fi
474 # done
475 # if test -z "$pcre_lib"; then
476 # AC_MSG_RESULT(not found)
477 # else
478 # AC_MSG_RESULT($lib)
479 # AC_DEFINE(HAVE_REGCOMP)
480 # LDFLAGS="$LDFLAGS $pcre_lib"
481 # have_regex=yes
482 # fi
483 # fi
484
485
486 # Checks for missing prototypes
487 # -----------------------------
488 AC_CHECKING(for new missing prototypes)
489
490 AC_DEFUN(CHECK_PROTO, [
491 AC_EGREP_HEADER([[^A-Za-z0-9_]$1([ ]+[A-Za-z0-9_]*)?[ ]*\(],
492 $2,
493 ,
494 [
495 AC_MSG_RESULT([adding prototype for $1])
496 AC_DEFINE(patsubst([NEED_PROTO_NAME], [NAME], translit([$1], [[a-z]], [[A-Z]])))
497 ])])
498
499 if test "$have_remove" = yes ; then
500 CHECK_PROTO(remove, stdio.h)
501 else
502 CHECK_PROTO(unlink, unistd.h)
503 fi
504 CHECK_PROTO(malloc, stdlib.h)
505 CHECK_PROTO(getenv, stdlib.h)
506 CHECK_PROTO(stat, sys/stat.h)
507 CHECK_PROTO(lstat, sys/stat.h)
508 if test "$have_fgetpos" = yes ; then
509 CHECK_PROTO(fgetpos, stdio.h)
510 fi
511 if test "$have_truncate" = yes ; then
512 CHECK_PROTO(truncate, unistd.h)
513 fi
514 if test "$have_ftruncate" = yes ; then
515 CHECK_PROTO(ftruncate, unistd.h)
516 fi
517
518
519 # Output files
520 # ------------
521
522
523 rm -f Makefile
524 if test "$enable_maintainer_mode" = yes ; then
525 AC_MSG_RESULT(creating maintainer Makefile)
526 ln -s maintainer.mak Makefile
527 makefile_out=
528 else
529 makefile_out=Makefile
530 fi
531 AC_OUTPUT($makefile_out)
532
533 # vim:ts=4:sw=4: