File: configure.ac

package info (click to toggle)
iptraf-ng 1:1.1.4-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,856 kB
  • ctags: 1,289
  • sloc: ansic: 11,913; makefile: 367; sh: 31; awk: 1
file content (224 lines) | stat: -rw-r--r-- 6,621 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT([iptraf-ng], [@@IPTRAF_VERSION@@], [iptraf-ng@fedorahosted.org])

AC_CONFIG_SRCDIR([src/iptraf.c])

config_file=config.mak.autogen
config_append=config.mak.append
config_in=config.mak.in

echo "# ${config_append}.  Generated by configure." > "${config_append}"


## Definitions of macros
# CONF_APPEND_LINE(LINE)
# --------------------------
# Append LINE to file ${config_append}
AC_DEFUN([CONF_APPEND_LINE],
[echo "$1" >> "${config_append}"])# CONF_APPEND_LINE
#
# ARG_SET_PATH(PROGRAM)
# -------------------------
# Provide --with-PROGRAM=PATH option to set PATH to PROGRAM
# Optional second argument allows setting NO_PROGRAM=YesPlease if
# --without-PROGRAM version used.
AC_DEFUN([ARG_SET_PATH],
[AC_ARG_WITH([$1],
 [AS_HELP_STRING([--with-$1=PATH],
                 [provide PATH to $1])],
 [CONF_APPEND_PATH($1,$2)],[])
])# ARG_SET_PATH
#
# CONF_APPEND_PATH(PROGRAM)
# ------------------------------
# Parse --with-PROGRAM=PATH option to set PROGRAM_PATH=PATH
# Used by ARG_SET_PATH(PROGRAM)
# Optional second argument allows setting NO_PROGRAM=YesPlease if
# --without-PROGRAM is used.
AC_DEFUN([CONF_APPEND_PATH],
[PROGRAM=m4_toupper($1); \
if test "$withval" = "no"; then \
	if test -n "$2"; then \
		m4_toupper($1)_PATH=$withval; \
		AC_MSG_NOTICE([Disabling use of ${PROGRAM}]); \
		CONF_APPEND_LINE(NO_${PROGRAM}=YesPlease); \
		CONF_APPEND_LINE(${PROGRAM}_PATH=); \
	else \
		AC_MSG_ERROR([You cannot use git without $1]); \
	fi; \
else \
	if test "$withval" = "yes"; then \
		AC_MSG_WARN([You should provide path for --with-$1=PATH]); \
	else \
		m4_toupper($1)_PATH=$withval; \
		AC_MSG_NOTICE([Setting m4_toupper($1)_PATH to $withval]); \
		CONF_APPEND_LINE(${PROGRAM}_PATH=$withval); \
	fi; \
fi; \
]) # CONF_APPEND_PATH
#
# PARSE_WITH(PACKAGE)
# -----------------------
# For use in AC_ARG_WITH action-if-found, for packages default ON.
# * Set NO_PACKAGE=YesPlease for --without-PACKAGE
# * Set PACKAGEDIR=PATH for --with-PACKAGE=PATH
# * Unset NO_PACKAGE for --with-PACKAGE without ARG
AC_DEFUN([PARSE_WITH],
[PACKAGE=m4_toupper($1); \
if test "$withval" = "no"; then \
	m4_toupper(NO_$1)=YesPlease; \
elif test "$withval" = "yes"; then \
	m4_toupper(NO_$1)=; \
else \
	m4_toupper(NO_$1)=; \
	m4_toupper($1)DIR=$withval; \
	AC_MSG_NOTICE([Setting m4_toupper($1)DIR to $withval]); \
	CONF_APPEND_LINE(${PACKAGE}DIR=$withval); \
fi \
])# PARSE_WITH
#
# PARSE_WITH_SET_MAKE_VAR(WITHNAME, VAR, HELP_TEXT)
# ---------------------
# Set VAR to the value specied by --with-WITHNAME.
# No verification of arguments is performed, but warnings are issued
# if either 'yes' or 'no' is specified.
# HELP_TEXT is presented when --help is called.
# This is a direct way to allow setting variables in the Makefile.
AC_DEFUN([PARSE_WITH_SET_MAKE_VAR],
[AC_ARG_WITH([$1],
 [AS_HELP_STRING([--with-$1=VALUE], $3)],
 if test -n "$withval"; then \
  if test "$withval" = "yes" -o "$withval" = "no"; then \
    AC_MSG_WARN([You likely do not want either 'yes' or 'no' as]
		     [a value for $1 ($2).  Maybe you do...?]); \
  fi; \
  \
  AC_MSG_NOTICE([Setting $2 to $withval]); \
  CONF_APPEND_LINE($2=$withval); \
 fi)])# PARSE_WITH_SET_MAKE_VAR

dnl
dnl CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
dnl -----------------------------------------
dnl Similar to AC_CHECK_FUNC, but on systems that do not generate
dnl warnings for missing prototypes (e.g. FreeBSD when compiling without
dnl -Wall), it does not work.  By looking for function definition in
dnl libraries, this problem can be worked around.
AC_DEFUN([CHECK_FUNC],[AC_CHECK_FUNC([$1],[
  AC_SEARCH_LIBS([$1],,
  [$2],[$3])
],[$3])])

dnl
dnl STASH_FLAGS(BASEPATH_VAR)
dnl -----------------------------
dnl Allow for easy stashing of LDFLAGS and CPPFLAGS before running
dnl tests that may want to take user settings into account.
AC_DEFUN([STASH_FLAGS],[
if test -n "$1"; then
   old_CPPFLAGS="$CPPFLAGS"
   old_LDFLAGS="$LDFLAGS"
   CPPFLAGS="-I$1/include $CPPFLAGS"
   LDFLAGS="-L$1/$lib $LDFLAGS"
fi
])

dnl
dnl UNSTASH_FLAGS(BASEPATH_VAR)
dnl -----------------------------
dnl Restore the stashed *FLAGS values.
AC_DEFUN([UNSTASH_FLAGS],[
if test -n "$1"; then
   CPPFLAGS="$old_CPPFLAGS"
   LDFLAGS="$old_LDFLAGS"
fi
])

## Site configuration related to programs (before tests)
## --with-PACKAGE[=ARG] and --without-PACKAGE
#
# Set lib to alternative name of lib directory (e.g. lib64)
AC_ARG_WITH([lib],
 [AS_HELP_STRING([--with-lib=ARG],
                 [ARG specifies alternative name for lib directory])],
 [if test "$withval" = "no" || test "$withval" = "yes"; then \
	AC_MSG_WARN([You should provide name for --with-lib=ARG]); \
else \
	lib=$withval; \
	AC_MSG_NOTICE([Setting lib to '$lib']); \
	CONF_APPEND_LINE(lib=$withval); \
fi; \
],[])

if test -z "$lib"; then
   AC_MSG_NOTICE([Setting lib to 'lib' (the default)])
   lib=lib
fi

#
# Define NO_CURL if you do not have curl installed.  git-http-pull and
# git-http-push are not built, and you cannot use http:// and https://
# transports.
#
# Define CURLDIR=/foo/bar if your curl header and library files are in
# /foo/bar/include and /foo/bar/lib directories.
AC_ARG_WITH(ncurses,
AS_HELP_STRING([--with-ncurses],[support http(s):// transports (default is YES)])
AS_HELP_STRING([],              [ARG can be also prefix for curl library and headers]),
PARSE_WITH(ncurses))


## Checks for programs.
AC_MSG_NOTICE([CHECKS for programs])
#
AC_PROG_CC([cc gcc])
AC_C_INLINE
case $ac_cv_c_inline in
  inline | yes | no)	;;
  *)			AC_SUBST([INLINE], [$ac_cv_c_inline]) ;;
esac
#AC_PROG_INSTALL		# needs install-sh or install.sh in sources
AC_CHECK_TOOLS(AR, [gar ar], :)
AC_CHECK_PROGS(TAR, [gtar tar])

AC_CHECK_PROGS(ASCIIDOC, [asciidoc])
if test -n "$ASCIIDOC"; then
	AC_MSG_CHECKING([for asciidoc version])
	asciidoc_version=`$ASCIIDOC --version 2>/dev/null`
	case "${asciidoc_version}" in
	asciidoc' '7*)
		ASCIIDOC7=YesPlease
		AC_MSG_RESULT([${asciidoc_version} > 7])
		;;
	asciidoc' '8*)
		ASCIIDOC7=
		AC_MSG_RESULT([${asciidoc_version}])
		;;
	*)
		ASCIIDOC7=
		AC_MSG_RESULT([${asciidoc_version} (unknown)])
		;;
	esac
fi
AC_SUBST(ASCIIDOC7)

## Checks for libraries.
AC_MSG_NOTICE([CHECKS for libraries])

if test -z "$NO_NCURSES"; then
STASH_FLAGS($NCURSESSDIR)
AC_CHECK_LIB([ncurses], [initscr],
[NO_NCURSES=],
[NO_NCURSES=YesPlease])
UNSTASH_FLAGS($NCURSESDIR)
AC_SUBST(NO_NCURSES)
fi

CFLAGS="$CFLAGS -W -Wall -std=gnu99 -pedantic"

## Output files
AC_CONFIG_FILES(["${config_file}":"${config_in}":"${config_append}"])
AC_OUTPUT