Handle template expressions that may use the << or >> operators
[arduino-ctags.git] / configure.ac
blob7fc81d409a42ad83e135e57c7ccc0fe558f18ed3
1 # $Id$
3 #       Copyright (c) 2009, Darren Hiebert
5 #       This source code is released for free distribution under the terms
6 #       of the GNU General Public License.
8 #       Process this file with autoconf to produce a configure script.
10 AC_PREREQ([2.61])
11 AC_INIT([ctags.h])
12 AC_CONFIG_HEADERS([config.h])
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
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.
58 #ifndef INTERNAL_SORT
59 # undef EXTERNAL_SORT
60 #endif
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.])
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
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 ]) ])
140 # Checks for configuration options
141 # --------------------------------
143 AC_ARG_WITH(posix-regex,
144 [  --with-posix-regex      use Posix regex interface, if available])
146 AC_ARG_WITH(readlib,
147 [  --with-readlib          include readtags library object during install])
149 # AC_ARG_WITH(perl-regex,
150 # [  --with-perl-regex       use Perl pcre interface, if available])
152 AC_ARG_ENABLE(etags,
153 [  --enable-etags          enable the installation of links for etags])
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))
161 AC_ARG_ENABLE(external-sort,
162 [  --disable-external-sort use internal sort algorithm instead of sort program])
164 AC_ARG_ENABLE(custom-config,
165 [  --enable-custom-config=FILE
166                           enable custom config file for site-wide defaults])
168 AC_ARG_ENABLE(macro-patterns,
169 [  --enable-macro-patterns use patterns as default method to locate macros
170                           instead of line numbers])
172 AC_ARG_ENABLE(maintainer-mode,
173 [  --enable-maintainer-mode
174                           use maintainer makefile])
176 AC_ARG_ENABLE(shell-globbing,
177 [  --enable-shell-globbing=DIR
178                           does shell expand wildcards (yes|no)? [yes]])
180 AC_ARG_ENABLE(tmpdir,
181 [  --enable-tmpdir=DIR     default directory for temporary files [ARG=/tmp]],
182         tmpdir_specified=yes)
185 # Process configuration options
186 # -----------------------------
188 if test "$enable_maintainer_mode" = yes ; then
189         AC_MSG_RESULT(enabling maintainer mode)
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)
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)
207 AC_SUBST(install_targets)
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)
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)
221 # Checks for programs
222 # -------------------
224 AC_PROG_CC
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
249 AC_PROG_LN_S
250 AC_CHECK_PROG(STRIP, strip, strip, :)
253 # Checks for operating environment
254 # --------------------------------
256 # Check for temporary directory
257 AC_MSG_CHECKING(directory to use for temporary files)
258 if test -n "$enable_tmpdir"; then
259         tmpdir="$enable_tmpdir"
260 elif test -n "$TMPDIR"; then
261         tmpdir="$TMPDIR"
262 elif test -n "$TMPDIR"; then
263         tmpdir="$TMPDIR"
264 elif test -n "$TMP"; then
265         tmpdir="$TMP"
266 elif test -n "$TEMP"; then
267         tmpdir="$TEMP"
268 elif test -d "c:/"; then
269         tmpdir="c:/"
270 else
271         tmpdir="/tmp"
273 if test -d $tmpdir ; then
274         AC_MSG_RESULT($tmpdir)
275         AC_DEFINE_UNQUOTED(TMPDIR, "$tmpdir")
276 else
277         AC_MSG_ERROR($tmpdir does not exist)
280 # Check whether system supports #! scripts
281 AC_SYS_INTERPRETER
282 if test yes = "$interpval"; then
283         AC_DEFINE(SYS_INTERPRETER)
286 # Test for case-insensitive filenames
287 AC_MSG_CHECKING(for case-insensitive filenames)
288 touch conftest.cif
289 if test -f CONFTEST.CIF; then
290         AC_MSG_RESULT(yes)
291         AC_DEFINE(CASE_INSENSITIVE_FILENAMES)
292 else
293         AC_MSG_RESULT(no)
295 rm -f conftest.cif
297 AC_MSG_CHECKING(selected sort method)
298 if test no = "$enable_external_sort"; then
299         AC_MSG_RESULT(simple internal algorithm)
300 else
301         AC_MSG_RESULT(external sort utility)
302         enable_external_sort=no
303     AC_CHECK_PROG(sort_found, sort, yes, no)
304         if test "$sort_found" = yes ; then
305                 AC_MSG_CHECKING(if sort accepts our command line)
306                 touch ${tmpdir}/sort.test
307                 sort -u -f -o ${tmpdir}/sort.test ${tmpdir}/sort.test 1>/dev/null 2>&1
308                 if test $? -ne 0 ; then
309                         AC_MSG_RESULT(no)
310                 else
311                         AC_MSG_RESULT(yes)
312                         AC_DEFINE(EXTERNAL_SORT)
313                         enable_external_sort=yes
314                 fi
315                 rm -f ${tmpdir}/sort.test
316     fi
318 if test "$enable_external_sort" != yes ; then
319         AC_MSG_RESULT(using internal sort algorithm as fallback)
323 # Checks for header files
324 # -----------------------
326 AC_CHECK_HEADERS_ONCE([dirent.h fcntl.h fnmatch.h stat.h stdlib.h string.h])
327 AC_CHECK_HEADERS_ONCE([time.h types.h unistd.h])
328 AC_CHECK_HEADERS_ONCE([sys/dir.h sys/stat.h sys/times.h sys/types.h])
331 # Checks for header file macros
332 # -----------------------------
334 CHECK_HEADER_DEFINE(L_tmpnam, [stdio.h],, AC_DEFINE(L_tmpnam, 20))
336 CHECK_HEADER_DEFINE(INT_MAX, [limits.h],,
337         CHECK_HEADER_DEFINE(MAXINT, [limits.h],
338                 AC_DEFINE(INT_MAX, MAXINT), AC_DEFINE(INT_MAX, 32767)))
341 # Checks for typedefs
342 # -------------------
344 AC_TYPE_SIZE_T
345 AC_TYPE_OFF_T
347 AC_MSG_CHECKING(for fpos_t)
348 AC_EGREP_HEADER(fpos_t, stdio.h, AC_MSG_RESULT(yes),
350         AC_MSG_RESULT(no)
351         AC_DEFINE(fpos_t, long)
354 AC_MSG_CHECKING(for clock_t)
355 AC_EGREP_HEADER(clock_t, time.h, AC_MSG_RESULT(yes),
357         AC_MSG_RESULT(no)
358         AC_DEFINE(clock_t, long)
362 # Checks for compiler characteristics
363 # -----------------------------------
365 # AC_CYGWIN
366 # AC_MINGW32
367 AC_C_CONST
368 AC_OBJEXT
369 AC_EXEEXT
371 AC_MSG_CHECKING(if struct stat contains st_ino)
372 AC_TRY_COMPILE([#include <sys/stat.h>], [
373         struct stat st;
374         stat(".", &st);
375         if (st.st_ino > 0)
376                 exit(0);
377 ], have_st_ino=yes, have_st_ino=no)
378 AC_MSG_RESULT($have_st_ino)
379 if test yes = "$have_st_ino"; then
380         AC_DEFINE(HAVE_STAT_ST_INO)
384 # Checks for library functions
385 # ----------------------------
387 AC_CHECK_FUNCS(fnmatch)
388 AC_CHECK_FUNCS(strstr)
389 AC_CHECK_FUNCS(strcasecmp stricmp, break)
390 AC_CHECK_FUNCS(strncasecmp strnicmp, break)
391 AC_CHECK_FUNCS(fgetpos, have_fgetpos=yes)
393 # SEEK_SET should be in stdio.h, but may be in unistd.h on SunOS 4.1.x
394 if test "$have_fgetpos" != yes ; then
395         CHECK_HEADER_DEFINE(SEEK_SET, stdio.h,,
396                 CHECK_HEADER_DEFINE(SEEK_SET, unistd.h,,
397                         AC_DEFINE(SEEK_SET, 0)))
400 AC_CHECK_FUNCS(mkstemp, have_mkstemp=yes)
401 if test "$have_mkstemp" != yes ; then
402         AC_CHECK_FUNCS(tempnam, have_tempnam=yes)
404 if test "$have_mkstemp" != yes -a "$have_tempnam" != yes; then
405         AC_CHECK_FUNCS(chmod)
406         if test "$tmpdir_specified" = yes ; then
407                 AC_MSG_RESULT(use of tmpnam overrides temporary directory selection)
408         fi
411 AC_CHECK_FUNCS(opendir findfirst _findfirst, break)
412 AC_CHECK_FUNCS(strerror)
413 AC_CHECK_FUNCS(clock times, break)
414 AC_CHECK_FUNCS(remove, have_remove=yes,
415         CHECK_HEADER_DEFINE(remove, unistd.h,, AC_DEFINE(remove, unlink)))
417 AC_CHECK_FUNCS(truncate, have_truncate=yes)
418 # === Cannot nest AC_CHECK_FUNCS() calls
419 if test "$have_truncate" != yes  ; then
420         AC_CHECK_FUNCS(ftruncate, have_ftruncate=yes)
421         if test "$have_ftruncate" != yes ; then
422                 AC_CHECK_FUNCS(chsize)
423         fi
426 AC_CHECK_FUNCS(setenv, have_setenv=yes)
427 # === Cannot nest AC_CHECK_FUNCS() calls
428 if test "$have_setenv" != yes ; then
429         AC_CHECK_FUNCS(putenv, have_putenv=yes)
430         if test "$have_putenv" = yes ; then
431                 AC_EGREP_HEADER(putenv, stdlib.h, have_putenv_prototype=yes)
432                 if test "$have_putenv_prototype" = yes ; then
433                         AC_MSG_CHECKING(putenv prototype)
434                         AC_EGREP_HEADER([[^A-Za-zo-9_]putenv[   ]*\(.*const.*\)[        ]*;],
435                                 stdlib.h, AC_MSG_RESULT(correct),
436                                 [
437                                         AC_MSG_RESULT(no const)
438                                         AC_DEFINE(NON_CONST_PUTENV_PROTOTYPE)
439                                 ])
440                 fi
441         fi
445 # if test yes = "$CYGWIN"; then with_posix_regex=no; fi
446 if test no != "$with_posix_regex"; then
447         AC_CHECK_FUNCS(regcomp)
448         AC_MSG_CHECKING(if regcomp works)
449         AC_TRY_RUN([
450 #include <sys/types.h>
451 #include <regex.h>
452 main() {
453         regex_t patbuf;
454         exit (regcomp (&patbuf, "/hello/", 0) != 0);
455 }],regcomp_works=yes,regcomp_works=no,AC_DEFINE(CHECK_REGCOMP))
456         AC_MSG_RESULT($regcomp_works)
457         if test yes != "$regcomp_works"; then
458                 AC_DEFINE(REGCOMP_BROKEN)
459         fi
462 # if test yes = "$with_perl_regex"; then
463 #       AC_MSG_CHECKING(for Perl regex library)
464 #       pcre_candidates="$with_perl_regex $HOME/local/lib* /usr*/local/lib* /usr/lib*"
465 #       for lib in $pcre_candidates; do
466 #               if test -f $lib/libpcreposix.so; then
467 #                       pcre_lib="-L$lib -lpcreposix"
468 #                       break
469 #               elif test -f $lib/libpcreposix.a; then
470 #                       pcre_lib="$lib/libpcreposix.a"
471 #                       break
472 #               fi
473 #       done
474 #       if test -z "$pcre_lib"; then
475 #               AC_MSG_RESULT(not found)
476 #       else
477 #               AC_MSG_RESULT($lib)
478 #               AC_DEFINE(HAVE_REGCOMP)
479 #               LDFLAGS="$LDFLAGS $pcre_lib"
480 #               have_regex=yes
481 #       fi
482 # fi
485 # Checks for missing prototypes
486 # -----------------------------
487 AC_CHECKING(for new missing prototypes)
489 AC_DEFUN(CHECK_PROTO, [
490         AC_EGREP_HEADER([[^A-Za-z0-9_]$1([      ]+[A-Za-z0-9_]*)?[       ]*\(],
491         $2,
492         ,
493         [
494                 AC_MSG_RESULT([adding prototype for $1])
495                 AC_DEFINE(patsubst([NEED_PROTO_NAME], [NAME], translit([$1], [[a-z]], [[A-Z]])))
496         ])])
498 if test "$have_remove" = yes ; then
499         CHECK_PROTO(remove, stdio.h)
500 else
501         CHECK_PROTO(unlink,     unistd.h)
503 CHECK_PROTO(malloc,     stdlib.h)
504 CHECK_PROTO(getenv,     stdlib.h)
505 CHECK_PROTO(stat,       sys/stat.h)
506 CHECK_PROTO(lstat,      sys/stat.h)
507 if test "$have_fgetpos" = yes ; then
508         CHECK_PROTO(fgetpos, stdio.h)
510 if test "$have_truncate" = yes ; then
511         CHECK_PROTO(truncate, unistd.h)
513 if test "$have_ftruncate" = yes ; then
514         CHECK_PROTO(ftruncate, unistd.h)
518 # Output files
519 # ------------
522 rm -f Makefile
523 if test "$enable_maintainer_mode" = yes ; then
524         AC_MSG_RESULT(creating maintainer Makefile)
525         ln -s maintainer.mak Makefile
526         makefile_out=
527 else
528         makefile_out=Makefile
530 AC_OUTPUT($makefile_out)
532 # vim:ts=4:sw=4: