capt_get_packet(): check for key press only every 20ms
[iptraf-ng.git] / configure.ac
blobaccfc44f576db9e6ac51334f25f36031d3104b45
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 AC_PREREQ(2.59)
5 AC_INIT([iptraf-ng], [@@IPTRAF_VERSION@@], [iptraf-ng@fedorahosted.org])
7 AC_CONFIG_SRCDIR([src/iptraf.c])
9 config_file=config.mak.autogen
10 config_append=config.mak.append
11 config_in=config.mak.in
13 echo "# ${config_append}.  Generated by configure." > "${config_append}"
16 ## Definitions of macros
17 # CONF_APPEND_LINE(LINE)
18 # --------------------------
19 # Append LINE to file ${config_append}
20 AC_DEFUN([CONF_APPEND_LINE],
21 [echo "$1" >> "${config_append}"])# CONF_APPEND_LINE
23 # ARG_SET_PATH(PROGRAM)
24 # -------------------------
25 # Provide --with-PROGRAM=PATH option to set PATH to PROGRAM
26 # Optional second argument allows setting NO_PROGRAM=YesPlease if
27 # --without-PROGRAM version used.
28 AC_DEFUN([ARG_SET_PATH],
29 [AC_ARG_WITH([$1],
30  [AS_HELP_STRING([--with-$1=PATH],
31                  [provide PATH to $1])],
32  [CONF_APPEND_PATH($1,$2)],[])
33 ])# ARG_SET_PATH
35 # CONF_APPEND_PATH(PROGRAM)
36 # ------------------------------
37 # Parse --with-PROGRAM=PATH option to set PROGRAM_PATH=PATH
38 # Used by ARG_SET_PATH(PROGRAM)
39 # Optional second argument allows setting NO_PROGRAM=YesPlease if
40 # --without-PROGRAM is used.
41 AC_DEFUN([CONF_APPEND_PATH],
42 [PROGRAM=m4_toupper($1); \
43 if test "$withval" = "no"; then \
44         if test -n "$2"; then \
45                 m4_toupper($1)_PATH=$withval; \
46                 AC_MSG_NOTICE([Disabling use of ${PROGRAM}]); \
47                 CONF_APPEND_LINE(NO_${PROGRAM}=YesPlease); \
48                 CONF_APPEND_LINE(${PROGRAM}_PATH=); \
49         else \
50                 AC_MSG_ERROR([You cannot use git without $1]); \
51         fi; \
52 else \
53         if test "$withval" = "yes"; then \
54                 AC_MSG_WARN([You should provide path for --with-$1=PATH]); \
55         else \
56                 m4_toupper($1)_PATH=$withval; \
57                 AC_MSG_NOTICE([Setting m4_toupper($1)_PATH to $withval]); \
58                 CONF_APPEND_LINE(${PROGRAM}_PATH=$withval); \
59         fi; \
60 fi; \
61 ]) # CONF_APPEND_PATH
63 # PARSE_WITH(PACKAGE)
64 # -----------------------
65 # For use in AC_ARG_WITH action-if-found, for packages default ON.
66 # * Set NO_PACKAGE=YesPlease for --without-PACKAGE
67 # * Set PACKAGEDIR=PATH for --with-PACKAGE=PATH
68 # * Unset NO_PACKAGE for --with-PACKAGE without ARG
69 AC_DEFUN([PARSE_WITH],
70 [PACKAGE=m4_toupper($1); \
71 if test "$withval" = "no"; then \
72         m4_toupper(NO_$1)=YesPlease; \
73 elif test "$withval" = "yes"; then \
74         m4_toupper(NO_$1)=; \
75 else \
76         m4_toupper(NO_$1)=; \
77         m4_toupper($1)DIR=$withval; \
78         AC_MSG_NOTICE([Setting m4_toupper($1)DIR to $withval]); \
79         CONF_APPEND_LINE(${PACKAGE}DIR=$withval); \
80 fi \
81 ])# PARSE_WITH
83 # PARSE_WITH_SET_MAKE_VAR(WITHNAME, VAR, HELP_TEXT)
84 # ---------------------
85 # Set VAR to the value specied by --with-WITHNAME.
86 # No verification of arguments is performed, but warnings are issued
87 # if either 'yes' or 'no' is specified.
88 # HELP_TEXT is presented when --help is called.
89 # This is a direct way to allow setting variables in the Makefile.
90 AC_DEFUN([PARSE_WITH_SET_MAKE_VAR],
91 [AC_ARG_WITH([$1],
92  [AS_HELP_STRING([--with-$1=VALUE], $3)],
93  if test -n "$withval"; then \
94   if test "$withval" = "yes" -o "$withval" = "no"; then \
95     AC_MSG_WARN([You likely do not want either 'yes' or 'no' as]
96                      [a value for $1 ($2).  Maybe you do...?]); \
97   fi; \
98   \
99   AC_MSG_NOTICE([Setting $2 to $withval]); \
100   CONF_APPEND_LINE($2=$withval); \
101  fi)])# PARSE_WITH_SET_MAKE_VAR
104 dnl CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
105 dnl -----------------------------------------
106 dnl Similar to AC_CHECK_FUNC, but on systems that do not generate
107 dnl warnings for missing prototypes (e.g. FreeBSD when compiling without
108 dnl -Wall), it does not work.  By looking for function definition in
109 dnl libraries, this problem can be worked around.
110 AC_DEFUN([CHECK_FUNC],[AC_CHECK_FUNC([$1],[
111   AC_SEARCH_LIBS([$1],,
112   [$2],[$3])
113 ],[$3])])
116 dnl STASH_FLAGS(BASEPATH_VAR)
117 dnl -----------------------------
118 dnl Allow for easy stashing of LDFLAGS and CPPFLAGS before running
119 dnl tests that may want to take user settings into account.
120 AC_DEFUN([STASH_FLAGS],[
121 if test -n "$1"; then
122    old_CPPFLAGS="$CPPFLAGS"
123    old_LDFLAGS="$LDFLAGS"
124    CPPFLAGS="-I$1/include $CPPFLAGS"
125    LDFLAGS="-L$1/$lib $LDFLAGS"
130 dnl UNSTASH_FLAGS(BASEPATH_VAR)
131 dnl -----------------------------
132 dnl Restore the stashed *FLAGS values.
133 AC_DEFUN([UNSTASH_FLAGS],[
134 if test -n "$1"; then
135    CPPFLAGS="$old_CPPFLAGS"
136    LDFLAGS="$old_LDFLAGS"
140 ## Site configuration related to programs (before tests)
141 ## --with-PACKAGE[=ARG] and --without-PACKAGE
143 # Set lib to alternative name of lib directory (e.g. lib64)
144 AC_ARG_WITH([lib],
145  [AS_HELP_STRING([--with-lib=ARG],
146                  [ARG specifies alternative name for lib directory])],
147  [if test "$withval" = "no" || test "$withval" = "yes"; then \
148         AC_MSG_WARN([You should provide name for --with-lib=ARG]); \
149 else \
150         lib=$withval; \
151         AC_MSG_NOTICE([Setting lib to '$lib']); \
152         CONF_APPEND_LINE(lib=$withval); \
153 fi; \
154 ],[])
156 if test -z "$lib"; then
157    AC_MSG_NOTICE([Setting lib to 'lib' (the default)])
158    lib=lib
162 # Define NO_CURL if you do not have curl installed.  git-http-pull and
163 # git-http-push are not built, and you cannot use http:// and https://
164 # transports.
166 # Define CURLDIR=/foo/bar if your curl header and library files are in
167 # /foo/bar/include and /foo/bar/lib directories.
168 AC_ARG_WITH(ncurses,
169 AS_HELP_STRING([--with-ncurses],[support http(s):// transports (default is YES)])
170 AS_HELP_STRING([],              [ARG can be also prefix for curl library and headers]),
171 PARSE_WITH(ncurses))
174 ## Checks for programs.
175 AC_MSG_NOTICE([CHECKS for programs])
177 AC_PROG_CC([cc gcc])
178 AC_C_INLINE
179 case $ac_cv_c_inline in
180   inline | yes | no)    ;;
181   *)                    AC_SUBST([INLINE], [$ac_cv_c_inline]) ;;
182 esac
183 #AC_PROG_INSTALL                # needs install-sh or install.sh in sources
184 AC_CHECK_TOOLS(AR, [gar ar], :)
185 AC_CHECK_PROGS(TAR, [gtar tar])
187 AC_CHECK_PROGS(ASCIIDOC, [asciidoc])
188 if test -n "$ASCIIDOC"; then
189         AC_MSG_CHECKING([for asciidoc version])
190         asciidoc_version=`$ASCIIDOC --version 2>/dev/null`
191         case "${asciidoc_version}" in
192         asciidoc' '7*)
193                 ASCIIDOC7=YesPlease
194                 AC_MSG_RESULT([${asciidoc_version} > 7])
195                 ;;
196         asciidoc' '8*)
197                 ASCIIDOC7=
198                 AC_MSG_RESULT([${asciidoc_version}])
199                 ;;
200         *)
201                 ASCIIDOC7=
202                 AC_MSG_RESULT([${asciidoc_version} (unknown)])
203                 ;;
204         esac
206 AC_SUBST(ASCIIDOC7)
208 ## Checks for libraries.
209 AC_MSG_NOTICE([CHECKS for libraries])
211 if test -z "$NO_NCURSES"; then
212 STASH_FLAGS($NCURSESSDIR)
213 AC_CHECK_LIB([ncurses], [initscr],
214 [NO_NCURSES=],
215 [NO_NCURSES=YesPlease])
216 UNSTASH_FLAGS($NCURSESDIR)
217 AC_SUBST(NO_NCURSES)
220 CFLAGS="$CFLAGS -W -Wall -std=gnu99 -pedantic"
222 ## Output files
223 AC_CONFIG_FILES(["${config_file}":"${config_in}":"${config_append}"])
224 AC_OUTPUT