File: configure.ac

package info (click to toggle)
wmnd 0.4.18-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,112 kB
  • sloc: sh: 4,163; ansic: 3,674; makefile: 58
file content (236 lines) | stat: -rw-r--r-- 6,211 bytes parent folder | download | duplicates (2)
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
225
226
227
228
229
230
231
232
233
234
235
236
# process this file with autoconf >= 2.5 to produce a configure script.
# report bugs and comments to wavexx@thregr.org

# initialization
AC_INIT(wmnd, 0.4.18, wavexx@thregr.org)
AC_CONFIG_SRCDIR(src/wmnd.c)
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([foreign])
AM_CONFIG_HEADER(config.h)

# C compiler rules
AC_LANG([C])
AC_PROG_CC
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(net/ppp_defs.h)

# extend the namespace when building with strict c99 but do so conditionally,
# since it breaks FreeBSD's 8.1 which hasn't proper namespace separation.
AC_CHECK_TYPE([u_int],, [
  AC_DEFINE(_BSD_SOURCE,, [BSD function declarations])
])
AC_CHECK_DECLS([strdup, getopt],, [
  AC_DEFINE(_XOPEN_SOURCE, 600, [XOPEN function declarations])
])

# math library
AC_SEARCH_LIBS(sin, m,, [AC_MSG_ERROR(math library is required)])

# X libraries
AC_PATH_XTRA
CFLAGS="$CFLAGS $X_CFLAGS"
LDFLAGS="$LDFLAGS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS"

# check for XPM headers, libraries
AC_HAVE_LIBRARY(X11,, [AC_MSG_ERROR(X11 library is required)])
AC_HAVE_LIBRARY(Xext,, [AC_MSG_ERROR(Xext library is required)])
AC_HAVE_LIBRARY(Xpm,, [AC_MSG_ERROR(Xpm library is required)])

# check for standard typedefs
AC_TYPE_PID_T
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T


# like AC_ARG_ENABLE, but with COMMON SENSE(tm) added
AC_DEFUN([ARG_ENABLE],
[
	AC_ARG_ENABLE([$1], [$2],, [enableval="no"])
	AS_IF([test "$enableval" = "no"], [$4], [$3])
])

AC_DEFUN([ARG_DISABLE],
[
	AC_ARG_ENABLE([$1], [$2],, [enableval="yes"])
	AS_IF([test "$enableval" = "no"], [$3], [$4])
])


# drivers selection
ARG_ENABLE(drivers,
	[AS_HELP_STRING(
		[--enable-drivers="..."],
		[manually selects drivers. defaults to auto])],
[
	ac_drivers="$enable_drivers"
	AC_MSG_NOTICE([overriding driver autodetection: $ac_drivers])
], [
	# let the user specify an empty set
	ac_drivers="auto"
])

# driver detection block: skip this block if the user manually specify
# drivers on the command line
AS_IF([test "$ac_drivers" = "auto"],
[
	# reset the state variable
	ac_drivers=""
	
	# linux_proc
	AC_CHECK_FILE(/proc/net/dev,
		[ac_drivers="$ac_drivers linux_proc"]
	)
	
	# freebsd_sysctl
	AC_MSG_CHECKING(for FreeBSD sysctl availability)
	AC_PREPROC_IFELSE([AC_LANG_SOURCE(
	[
		#include <net/if_mib.h>
		#include <sys/sysctl.h>
	])], [
		ac_drivers="$ac_drivers freebsd_sysctl"
		AC_MSG_RESULT(yes)
	], [
		AC_MSG_RESULT(no)
	])
	
	# solaris_fpppd
	AC_CHECK_HEADER(sys/stropts.h,
		[AC_CHECK_FILE(/dev/ppp,
			[ac_drivers="$ac_drivers solaris_fpppd"]
		)]
	)
	
	# solaris_kstat
	AC_CHECK_HEADER(kstat.h,
		[AC_SEARCH_LIBS(kstat_open, kstat,
			[ac_drivers="$ac_drivers solaris_kstat"]
		)]
	)

	# netbsd_ioctl
	AC_MSG_CHECKING(for NetBSD ioctl availability)
	AC_COMPILE_IFELSE([AC_LANG_SOURCE(
	[
		#include <sys/types.h>
		#include <sys/sockio.h>
		#include <sys/ioctl.h>
		#include <net/if.h>
		#include <ifaddrs.h>

		void aFunc() { ioctl(0, SIOCGIFDATA, NULL); }
	])], [
		ac_drivers="$ac_drivers netbsd_ioctl"
		AC_MSG_RESULT(yes)
	], [
		AC_MSG_RESULT(no)
	])

	# irix_pcp
	AC_CHECK_HEADER(pcp/pmapi.h,
		[AC_SEARCH_LIBS(pmLookupName, pcp,
			[ac_drivers="$ac_drivers irix_pcp"]
		)]
	)

	# generic_snmp
	AC_CHECK_HEADER(net-snmp/net-snmp-config.h,
		[AC_SEARCH_LIBS(snmp_sess_init, [snmp netsnmp],
			[ac_drivers="$ac_drivers generic_snmp"]
		)]
	)
])
for driver in $ac_drivers;
do
	# we must repeat the define constants many times
	# to make autoheader automatically recognize them all
	case "$driver" in
	linux_proc)	AC_DEFINE(USE_LINUX_PROC, "linux_proc", [enable linux proc driver]);;
	freebsd_sysctl)	AC_DEFINE(USE_FREEBSD_SYSCTL, "freebsd_sysctl", [enable freebsd sysctl driver]);;
	netbsd_ioctl)	AC_DEFINE(USE_NETBSD_IOCTL, "netbsd_ioctl", [enable nebsd ioctl driver]);;
	solaris_fpppd)	AC_DEFINE(USE_SOLARIS_FPPPD, "solaris_fpppd", [solaris streams pppd]);;
	solaris_kstat)	AC_DEFINE(USE_SOLARIS_KSTAT, "solaris_kstat", [enable solaris kstat driver]);;
	irix_pcp)	AC_DEFINE(USE_IRIX_PCP, "irix_pcp", [IRIX Performance Co-Pilot]);;
	generic_snmp)	AC_DEFINE(USE_GENERIC_SNMP, "generic_snmp", [Generic SNMP module]);;
	*)		AC_MSG_ERROR([unknown driver name $driver]);;
	esac
	
	drivers="$drivers $driver"
done


# Dummy driver
ARG_DISABLE(dummy-driver,
	[AS_HELP_STRING([--disable-dummy-driver],
		[disable the dummy driver])],,
[
	drivers="$drivers testing_dummy"
	AC_DEFINE(USE_TESTING_DUMMY, "testing_dummy", [fallback driver])
])

# trend support
ARG_DISABLE(trend,
	[AS_HELP_STRING([--disable-trend], [disable trend support])],,
	[AC_DEFINE(USE_TREND,, [trend support])]
)

# debugging
ARG_ENABLE(debug,
	[AS_HELP_STRING(
		[--enable-debug],
		[find the meaning of life, and everything])],,
	[AC_DEFINE(NDEBUG, 42, [shameless(tm)])]
)

# display modes selection
ARG_ENABLE(modes,
	[AS_HELP_STRING(
		[--enable-modes="..."],
		[manually select visual modes. defaults to all])],,
	[enable_modes="traditional mgraph waveform wmwave wmnet sepgraphs twisted charts needle lines"]
)
for mode in $enable_modes;
do
	# we must repeat the define constants many times
	# to make autoheader automatically recognize them all
	case "$mode" in
	traditional)	AC_DEFINE(USE_DRW_TRADITIONAL,, [traditional drawing mode]);;
	mgraph)		AC_DEFINE(USE_DRW_MGRAPH,, [mgraph drawing mode]);;
	waveform)	AC_DEFINE(USE_DRW_WAVEFORM,, [waveform drawing mode]);;
	wmwave)		AC_DEFINE(USE_DRW_WMWAVE,, [wmwave drawing mode]);;
	wmnet)		AC_DEFINE(USE_DRW_WMNET,, [wmnet drawing mode]);;
	sepgraphs)	AC_DEFINE(USE_DRW_SEPGRAPHS,, [sepgraphs drawing mode]);;
	twisted)	AC_DEFINE(USE_DRW_TWISTED,, [twisted drawing mode]);;
	charts)		AC_DEFINE(USE_DRW_CHARTS,, [charts drawing mode]);;
	needle)		AC_DEFINE(USE_DRW_NEEDLE,, [needle drawing mode]);;
	lines)		AC_DEFINE(USE_DRW_LINES,, [lines drawing mode]);;
	*)		AC_MSG_ERROR([unknown display mode $mode]);;
	esac
	
	dspmodes="$dspmodes $mode"
done


# check for inline statement useability
AC_C_INLINE

# check for basic type sizes
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long)

# output files
AC_CONFIG_FILES([
	Makefile
	src/Makefile
])

AC_OUTPUT

AC_MSG_NOTICE([configuration:

disable trend support: ${disable_trend:-no}
enabled drivers:      ${drivers:- none}
enabled display modes:${dspmodes:- none}
])