1 | dnl This file is intended for use both internally in libgtop and in every program |
---|
2 | dnl that wants to use it. |
---|
3 | dnl |
---|
4 | dnl It defines the following variables: |
---|
5 | dnl |
---|
6 | dnl * 'libgtop_sysdeps_dir' - sysdeps dir for libgtop. |
---|
7 | dnl * 'libgtop_use_machine_h' - some of system dependend parts of libgtop provide |
---|
8 | dnl their own header file. In this case we need to |
---|
9 | dnl define 'HAVE_GLIBTOP_MACHINE_H'. |
---|
10 | dnl * 'libgtop_need_server' - is the server really needed? Defines 'NEED_LIBGTOP' |
---|
11 | dnl if true; defines conditional 'NEED_LIBGTOP'. |
---|
12 | |
---|
13 | AC_DEFUN([LIBGTOP_HACKER_TESTS],[ |
---|
14 | AC_REQUIRE([AC_CANONICAL_HOST]) |
---|
15 | |
---|
16 | case "$host_os" in |
---|
17 | linux*) |
---|
18 | AC_ARG_WITH(linux-table, |
---|
19 | [ --with-linux-table Use the table () function from Martin Baulig],[ |
---|
20 | linux_table="$withval"],[linux_table=auto]) |
---|
21 | if test $linux_table = yes ; then |
---|
22 | AC_CHECK_HEADER(linux/table.h, linux_table=yes, linux_table=no) |
---|
23 | elif test $linux_table = auto ; then |
---|
24 | AC_MSG_CHECKING(for table function in Linux Kernel) |
---|
25 | AC_TRY_RUN([ |
---|
26 | #include <stdio.h> |
---|
27 | #include <stdlib.h> |
---|
28 | |
---|
29 | #include <unistd.h> |
---|
30 | #include <linux/unistd.h> |
---|
31 | #include <linux/table.h> |
---|
32 | |
---|
33 | #include <syscall.h> |
---|
34 | |
---|
35 | static inline _syscall3 (int, table, int, type, union table *, tbl, const void *, param); |
---|
36 | |
---|
37 | int |
---|
38 | main (void) |
---|
39 | { |
---|
40 | union table tbl; |
---|
41 | int ret; |
---|
42 | |
---|
43 | ret = table (TABLE_VERSION, NULL, NULL); |
---|
44 | |
---|
45 | if (ret == -1) |
---|
46 | exit (-errno); |
---|
47 | |
---|
48 | exit (ret < 1 ? ret : 0); |
---|
49 | } |
---|
50 | ], linux_table=yes, linux_table=no, linux_table=no) |
---|
51 | AC_MSG_RESULT($linux_table) |
---|
52 | fi |
---|
53 | if test $linux_table = yes ; then |
---|
54 | AC_DEFINE(HAVE_LINUX_TABLE) |
---|
55 | fi |
---|
56 | AM_CONDITIONAL(LINUX_TABLE, test $linux_table = yes) |
---|
57 | ;; |
---|
58 | esac |
---|
59 | ]) |
---|
60 | |
---|
61 | AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[ |
---|
62 | AC_REQUIRE([AC_CANONICAL_HOST]) |
---|
63 | |
---|
64 | AC_SUBST(libgtop_sysdeps_dir) |
---|
65 | AC_SUBST(libgtop_use_machine_h) |
---|
66 | AC_SUBST(libgtop_need_server) |
---|
67 | |
---|
68 | AC_ARG_WITH(libgtop-examples, |
---|
69 | [ --with-libgtop-examples Build the libgtop examples (default=no)],[ |
---|
70 | build_examples="$withval"], [build_examples=no]) |
---|
71 | |
---|
72 | AM_CONDITIONAL(EXAMPLES, test x"$build_examples" = xyes) |
---|
73 | |
---|
74 | AC_ARG_ENABLE(hacker-mode, |
---|
75 | [ --enable-hacker-mode Enable building of unstable sysdeps], |
---|
76 | [hacker_mode="$enableval"], [hacker_mode=no]) |
---|
77 | |
---|
78 | AM_CONDITIONAL(HACKER_MODE, test x"$hacker_mode" = xyes) |
---|
79 | |
---|
80 | if test x$hacker_mode = xyes ; then |
---|
81 | LIBGTOP_HACKER_TESTS |
---|
82 | fi |
---|
83 | |
---|
84 | AC_ARG_WITH(libgtop-smp, |
---|
85 | [ --with-libgtop-smp Enable SMP support (default-auto)],[ |
---|
86 | libgtop_smp="$withval"],[libgtop_smp=auto]) |
---|
87 | |
---|
88 | if test $libgtop_smp = auto ; then |
---|
89 | AC_MSG_CHECKING(whether to enable SMP support) |
---|
90 | case "$host_os" in |
---|
91 | linux*) |
---|
92 | libgtop_smp=yes |
---|
93 | ;; |
---|
94 | *) |
---|
95 | libgtop_smp=no |
---|
96 | ;; |
---|
97 | esac |
---|
98 | AC_MSG_RESULT($libgtop_smp) |
---|
99 | fi |
---|
100 | |
---|
101 | if test $libgtop_smp = yes ; then |
---|
102 | AC_DEFINE(HAVE_LIBGTOP_SMP) |
---|
103 | fi |
---|
104 | |
---|
105 | AM_CONDITIONAL(LIBGTOP_SMP, test $libgtop_smp = yes) |
---|
106 | |
---|
107 | AC_MSG_CHECKING(for libgtop sysdeps directory) |
---|
108 | |
---|
109 | case "$host_os" in |
---|
110 | linux*) |
---|
111 | if test x$linux_table = xyes ; then |
---|
112 | libgtop_sysdeps_dir=kernel |
---|
113 | libgtop_use_machine_h=no |
---|
114 | else |
---|
115 | libgtop_sysdeps_dir=linux |
---|
116 | libgtop_use_machine_h=no |
---|
117 | libgtop_have_sysinfo=yes |
---|
118 | fi |
---|
119 | libgtop_need_server=no |
---|
120 | ;; |
---|
121 | freebsd*|netbsd*|openbsd*|bsdi*) |
---|
122 | libgtop_sysdeps_dir=freebsd |
---|
123 | libgtop_use_machine_h=yes |
---|
124 | libgtop_need_server=yes |
---|
125 | libgtop_postinstall='chgrp kmem $(bindir)/libgtop_server && chmod 2755 $(bindir)/libgtop_server' |
---|
126 | ;; |
---|
127 | solaris*) |
---|
128 | libgtop_sysdeps_dir=solaris |
---|
129 | libgtop_use_machine_h=yes |
---|
130 | libgtop_need_server=yes |
---|
131 | libgtop_postinstall='chgrp sys $(bindir)/libgtop_server && chmod 2755 $(bindir)/libgtop_server' |
---|
132 | ;; |
---|
133 | *) |
---|
134 | if test x$hacker_mode = xyes ; then |
---|
135 | case "$host_os" in |
---|
136 | sunos4*) |
---|
137 | #Please note that this port is obsolete and not working at |
---|
138 | #all. It is only useful for people who want to fix it ... :-) |
---|
139 | libgtop_sysdeps_dir=sun4 |
---|
140 | libgtop_use_machine_h=yes |
---|
141 | libgtop_need_server=yes |
---|
142 | ;; |
---|
143 | osf*) |
---|
144 | libgtop_sysdeps_dir=osf1 |
---|
145 | libgtop_use_machine_h=yes |
---|
146 | libgtop_need_server=yes |
---|
147 | ;; |
---|
148 | *) |
---|
149 | libgtop_sysdeps_dir=stub |
---|
150 | libgtop_use_machine_h=no |
---|
151 | libgtop_need_server=no |
---|
152 | ;; |
---|
153 | esac |
---|
154 | else |
---|
155 | libgtop_sysdeps_dir=stub |
---|
156 | libgtop_use_machine_h=no |
---|
157 | libgtop_need_server=no |
---|
158 | fi |
---|
159 | ;; |
---|
160 | esac |
---|
161 | |
---|
162 | test -z "$libgtop_postinstall" && libgtop_postinstall=: |
---|
163 | |
---|
164 | AC_MSG_RESULT($libgtop_sysdeps_dir) |
---|
165 | |
---|
166 | AC_SUBST(libgtop_sysdeps_dir) |
---|
167 | AC_SUBST(libgtop_postinstall) |
---|
168 | AC_SUBST(libgtop_have_sysinfo) |
---|
169 | |
---|
170 | case "$host_os" in |
---|
171 | *bsd*) |
---|
172 | AC_CHECK_HEADERS(net/if_var.h) |
---|
173 | AC_MSG_CHECKING([for I4B]) |
---|
174 | AC_TRY_COMPILE([ |
---|
175 | #include <sys/types.h> |
---|
176 | #include <sys/socket.h> |
---|
177 | |
---|
178 | #include <net/if.h> |
---|
179 | #include <net/if_types.h> |
---|
180 | |
---|
181 | #ifdef HAVE_NET_IF_VAR_H |
---|
182 | #include <net/if_var.h> |
---|
183 | #endif |
---|
184 | |
---|
185 | #include <net/netisr.h> |
---|
186 | #include <net/route.h> |
---|
187 | |
---|
188 | #if defined(__FreeBSD__) || defined(__NetBSD__) |
---|
189 | #include <net/if_sppp.h> |
---|
190 | #else |
---|
191 | #include <i4b/sppp/if_sppp.h> |
---|
192 | #endif |
---|
193 | ],[ |
---|
194 | size_t size = sizeof (struct sppp); |
---|
195 | ], have_i4b=yes, have_i4b=no) |
---|
196 | AC_MSG_RESULT($have_i4b) |
---|
197 | if test x$have_i4b = xyes; then |
---|
198 | AC_DEFINE(HAVE_I4B) |
---|
199 | AC_MSG_CHECKING([for I4B accounting]) |
---|
200 | AC_TRY_COMPILE([ |
---|
201 | #include <sys/types.h> |
---|
202 | #include <sys/socket.h> |
---|
203 | |
---|
204 | #include <net/if.h> |
---|
205 | #include <net/if_types.h> |
---|
206 | |
---|
207 | #ifdef HAVE_NET_IF_VAR_H |
---|
208 | #include <net/if_var.h> |
---|
209 | #endif |
---|
210 | |
---|
211 | #include <net/netisr.h> |
---|
212 | #include <net/route.h> |
---|
213 | |
---|
214 | #if defined(__FreeBSD__) || defined(__NetBSD__) |
---|
215 | #include <net/if_sppp.h> |
---|
216 | #else |
---|
217 | #include <i4b/sppp/if_sppp.h> |
---|
218 | #endif |
---|
219 | |
---|
220 | #include <machine/i4b_acct.h> |
---|
221 | ],[ |
---|
222 | size_t size = sizeof (struct i4bisppp_softc); |
---|
223 | ], have_i4b_acct=yes, have_i4b_acct=no) |
---|
224 | AC_MSG_RESULT($have_i4b_acct) |
---|
225 | if test x$have_i4b_acct = xyes ; then |
---|
226 | AC_DEFINE(HAVE_I4B_ACCT) |
---|
227 | else |
---|
228 | AC_WARN([ |
---|
229 | *** I4B accounting disabled - you won't get any PPP statistics. |
---|
230 | *** Read "misc/i4b_acct.txt" in the LibGTop source directory |
---|
231 | *** to see how to enable it.]) |
---|
232 | fi |
---|
233 | fi |
---|
234 | ;; |
---|
235 | linux*) |
---|
236 | os_major_version=`uname -r | sed 's/-pre[[0-9]]*//' | \ |
---|
237 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
---|
238 | os_minor_version=`uname -r | sed 's/-pre[[0-9]]*//' | \ |
---|
239 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
---|
240 | os_micro_version=`uname -r | sed 's/-pre[[0-9]]*//' | \ |
---|
241 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
---|
242 | os_version_expr="$os_major_version 65536 * $os_minor_version 256 * + $os_micro_version + p q" |
---|
243 | |
---|
244 | AC_CHECK_HEADERS(linux/version.h, have_linux_version_h=yes, |
---|
245 | have_linux_version_h=no) |
---|
246 | |
---|
247 | if test x$have_linux_version_h = xyes ; then |
---|
248 | version_code=`cat /usr/include/linux/version.h | \ |
---|
249 | grep \#define | grep LINUX_VERSION_CODE` |
---|
250 | os_version_code=`echo $version_code | \ |
---|
251 | sed 's/^.*LINUX_VERSION_CODE[[ \t]]*\([[0-9]]*\).*$/\1/'` |
---|
252 | else |
---|
253 | os_version_code=`echo "$os_version_expr" | dc` |
---|
254 | fi |
---|
255 | |
---|
256 | AC_MSG_CHECKING(for Linux kernel version code) |
---|
257 | AC_DEFINE_UNQUOTED(GLIBTOP_LINUX_VERSION_CODE, $os_version_code) |
---|
258 | AC_MSG_RESULT($os_version_code) |
---|
259 | ;; |
---|
260 | solaris*) |
---|
261 | os_major_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]\)\.*\([[0-9]]*\)/\1/'` |
---|
262 | os_minor_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]\)\.*\([[0-9]]*\)/\2/'` |
---|
263 | os_micro_version=`uname -r | sed 's/\([[0-9]]*\).\([[0-9]]\)\.*\([[0-9]]*\)/\3/'` |
---|
264 | test -z "$os_micro_version" && os_micro_version=0 |
---|
265 | os_version_expr="$os_major_version 100 * $os_minor_version 10 * + $os_micro_version + p q" |
---|
266 | os_version_code=`echo "$os_version_expr" | dc` |
---|
267 | |
---|
268 | AC_MSG_CHECKING(for Solaris release code) |
---|
269 | AC_DEFINE_UNQUOTED(GLIBTOP_SOLARIS_RELEASE, $os_version_code) |
---|
270 | AC_MSG_RESULT($os_version_code) |
---|
271 | ;; |
---|
272 | esac |
---|
273 | |
---|
274 | AC_MSG_CHECKING(for machine.h in libgtop sysdeps dir) |
---|
275 | AC_MSG_RESULT($libgtop_use_machine_h) |
---|
276 | |
---|
277 | AC_MSG_CHECKING(whether we need libgtop) |
---|
278 | AC_MSG_RESULT($libgtop_need_server) |
---|
279 | |
---|
280 | if test x$libgtop_need_server = xyes ; then |
---|
281 | AC_DEFINE(NEED_LIBGTOP) |
---|
282 | fi |
---|
283 | |
---|
284 | if test x$libgtop_use_machine_h = xyes ; then |
---|
285 | AC_DEFINE(HAVE_GLIBTOP_MACHINE_H) |
---|
286 | fi |
---|
287 | |
---|
288 | AM_CONDITIONAL(NEED_LIBGTOP, test x$libgtop_need_server = xyes) |
---|
289 | ]) |
---|
290 | |
---|