and added files
[bcm963xx.git] / userapps / opensource / net-snmp / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 AC_INIT(agent/mibgroup/ucd-snmp/extensible.c)
4 AC_CONFIG_HEADER(include/net-snmp/net-snmp-config.h)
5 AC_MSG_CACHE_INIT()
6
7 dnl
8 dnl save the configure arguments
9 dnl
10 AC_DEFINE_UNQUOTED(CONFIGURE_OPTIONS,"\"$ac_configure_args\"")
11 CONFIGURE_OPTIONS="\"$ac_configure_args\""
12 AC_SUBST(CONFIGURE_OPTIONS)
13
14 dnl
15 dnl Compilation setup
16 dnl
17 AC_ARG_WITH(cc, [
18 Compiler Options:
19   --with-cc=CC                    use CC to compile (default=gcc).],
20     [CC=$with_cc;export CC])
21
22 AC_ARG_WITH(ar,
23 [  --with-ar=AR                    use AR as the archiver.],
24     [AR=$with_ar; export AR])
25
26 AC_ARG_WITH(endianness,
27 [  --with-endianness=big|little    define endianness of target platform when
28                                   cross-compiling.],
29     [if test $with_endianness != "big" -a $with_endianness != "little" ; then
30        AC_MSG_ERROR([Endianness must be big or little, not \"$with_endianness\".]);
31      fi
32 ])
33
34 AC_ARG_WITH(cflags,
35 [  --with-cflags=CFLAGS            use CFLAGS as compile time arguments.],
36     [CFLAGS=$with_cflags; export CFLAGS])
37
38 AC_ARG_WITH(ldflags,
39 [  --with-ldflags=LDFLAGS          use LDFLAGS as link time arguments to ld.],
40     [LDFLAGS=$with_ldflags; export LDFLAGS])
41
42 AC_ARG_WITH(libs,
43 [  --with-libs=LIBS                use LIBS as link time arguments to ld.],
44     [LIBS=$with_libs; export LIBS])
45
46 AC_ARG_ENABLE(silent-libtool,
47 [  --enable-silent-libtool         Pass --silent to libtool.],
48         LIBTOOLFLAGS=--silent)
49 AC_SUBST(LIBTOOLFLAGS)
50
51 AC_ARG_ENABLE(mini_agent,
52 [  --enable-mini-agent             Build a minimal agent.],
53     mini_agent="yes",mini_agent="no")
54
55 AC_ARG_ENABLE(ipv6,
56 [  --enable-ipv6                   Generate IPv6 ready version.],
57     [if test "x$enable_ipv6" = "xyes"; then
58       AC_DEFINE(INET6)
59     fi])
60
61 AC_ARG_ENABLE(debugging,
62 [  --enable-debugging              Outputs extra debugging information at all
63                                   times.  Normally, you should not enable this,
64                                   but instead use the -D flag of the commands,
65                                   which toggles debbuging output at runtime.
66   --disable-debugging             Disallows debugging code to be built in.
67                                   This might provide some speed benefits.],
68     AC_DEFINE(SNMP_ALWAYS_DEBUG))
69
70 AC_ARG_ENABLE(developer,
71 [  --enable-developer              Turns on super-duper-extra-compile-warnings
72                                   when using gcc.],
73     developer=yes)
74
75 if test "x$enable_debugging" = "xno"; then
76     AC_DEFINE(SNMP_NO_DEBUGGING)
77 fi
78
79 AC_ARG_WITH(dmalloc,
80 [  --with-dmalloc=PATH             Use dmalloc library (www.dmalloc.com)],
81     if test "x$withval" = "xyes"; then
82       LIBS="$LIBS -ldmalloc"
83       AC_DEFINE(HAVE_DMALLOC_H)
84     elif test -d "$withval"; then
85       AC_ADD_SEARCH_PATH($withval)
86       LIBS="$LIBS -ldmalloc"
87       AC_DEFINE(HAVE_DMALLOC_H)
88     fi
89 )
90 AC_SUBST(HAVE_DMALLOC_H)
91
92 AC_ARG_WITH(efence,
93 [  --with-efence                   Look for and use libefence (malloc).],
94       use_efence="$withval")
95
96 tryrsaref=no
97 AC_ARG_WITH(rsaref,
98 [  --with-rsaref=PATH              Look for librsaref in PATH/lib.],
99     if test "x$withval" = "xyes"; then
100       tryrsaref=yes
101     elif test "x$withval" = "xno"; then
102       tryrsaref=no
103     elif test -d "$withval"; then
104       AC_ADD_SEARCH_PATH($withval)
105       tryrsaref=yes
106     fi,
107 )
108
109 tryopenssl=defaultyes
110 askedopenssl=no
111 AC_ARG_WITH(openssl,
112 [  --with-openssl=PATH             Look for openssl in PATH/lib.],
113     if test "x$withval" = "xyes"; then
114       tryopenssl=yes
115       askedopenssl=yes
116     elif test "x$withval" = "xno"; then
117       tryopenssl=no
118     elif test -d "$withval"; then
119       AC_ADD_SEARCH_PATH($withval)
120       tryopenssl=yes
121       askedopenssl=yes
122     fi,
123 )
124 if test "x$tryopenssl" = "xdefaultyes"; then
125       AC_ADD_SEARCH_PATH(/usr/local/ssl)
126       tryopenssl=yes
127 fi
128
129
130 AC_ARG_ENABLE(privacy,
131 [  --disable-privacy               Don't compile in support for privacy.])
132 if test "x$enable_privacy" != "xno"; then
133   AC_DEFINE(SCAPI_AUTHPRIV)
134 fi
135
136 AC_ARG_ENABLE(internal-md5,
137 [  --enable-internal-md5           Use the internal MD5 support.],
138 AC_DEFINE(USE_INTERNAL_MD5))
139
140
141 AC_ARG_WITH(opaque-special-types,
142 [  --without-opaque-special-types  Don't use special opaque encodings.
143                                   SNMP normally cannot handle
144                                   floating numbers, nor large 64 bit
145                                   integers well.  By default, the
146                                   net-snmp package compiles in
147                                   support for these extra datatypes
148                                   (in a legal way)])
149
150 AC_ARG_WITH(mibdirs,
151 [  --with-mibdirs=\"dir1:dir2:\"     Default directories to look for mibs.
152                                     (Default: \$HOME/.snmp/mibs:DATADIR/snmp/mibs)],
153     [DEFAULT_MIBDIRS="$with_mibdirs"
154     AC_DEFINE_UNQUOTED(DEFAULT_MIBDIRS,"$with_mibdirs")])
155
156 AC_ARG_WITH(mibs,
157 [  --with-mibs=\"item1:item2:\"      Default mib IDs to read.
158                                     (The default list is \"IP-MIB:IF-MIB:
159                                     TCP-MIB:UDP-MIB:SNMPv2-MIB:RFC1213-MIB\"
160                                     with the addition of any mibs used
161                                     by the mib modules the agent is
162                                     configured with)],
163     DEFAULT_MIBS="$with_mibs")
164
165 AC_ARG_WITH(mibfiles,
166 [  --with-mibfiles=\"file1:file2\"   Default mib files to load.
167                                     (Default:  none.  uses IDs above instead.)],
168     AC_DEFINE_UNQUOTED(DEFAULT_MIBFILES,"$with_mibfiles"))
169
170
171 AC_ARG_ENABLE(testing-code,
172 [  --enable-testing-code           Enables some code sections that should 
173                                   only be used for testing of certain
174                                   SNMP functionalities.  This should *not* 
175                                   be turned on for production use.  Ever.],
176     AC_DEFINE(SNMP_TESTING_CODE))
177
178 AC_ARG_ENABLE(reentrant,
179 [  --enable-reentrant              Enables locking functions that protect
180                                   library resources in some multi-threading
181                                   environments.  This does not guarantee
182                                   thread-safe operation.
183                                   Currently an experimental setting.],
184     with_res_locks="yes",with_res_locks="no")
185
186 AC_ARG_WITH(root-access,
187 [
188 Configuring the agent:
189   --without-root-access           The snmpd agent won't require root access to
190                                   run it.  The information it returns in the
191                                   mib-II tree may not be correct, however.])
192
193 AC_ARG_WITH(kmem-usage,
194 [
195 Configuring the agent:
196   --without-kmem-usage            Do not include any code related to the use
197                                   of kmem. This option can only be used with
198                                   the option --enable-mini-agent.])
199
200 AC_ARG_WITH(dummy-values,
201 [  --with-dummy-values             Provide 'placeholder' dummy values where
202                                   the necessary information is not available.
203                                   This is technically not compliant with the
204                                   SNMP specifications, but was how the agent
205                                   operated for versions < 4.0.])
206
207 AC_ARG_WITH(persistent-directory,
208 [  --with-persistent-directory=\"directory\"
209                                   Default directory for persistent data storage.],ac_cv_user_prompt_PERSISTENT_DIRECTORY="$with_persistent_directory")
210
211 AC_ARG_WITH(copy_persistent_files,
212 [  --with-copy-persistent-files=\"no\" Don't copy persistent files
213                                        (or use \"yes\" to copy them).
214                                        (Default: yes)],
215     ac_cv_user_prompt_COPY_PERSISTENT_FILES="$with_copy_persistent_files")
216
217 AC_ARG_WITH(default-snmp-version,
218 [  --with-default-snmp-version=\"3\" Default version of SNMP to use.
219                                   (Default: 3)
220                                   Legal values: 1, 2 (for SNMPv2c) or 3.],
221     ac_cv_user_prompt_DEFAULT_SNMP_VERSION="$with_default_snmp_version")
222
223 dnl we test this now and later as well.  we test it now so configure can die
224 dnl early on with an error rather than waiting till the end of the script.
225 if test "x$ac_cv_user_prompt_DEFAULT_SNMP_VERSION" != "x"; then
226   if test "$ac_cv_user_prompt_DEFAULT_SNMP_VERSION" != "1" -a "$ac_cv_user_prompt_DEFAULT_SNMP_VERSION" != "2" -a "$ac_cv_user_prompt_DEFAULT_SNMP_VERSION" != "3"; then
227     AC_MSG_ERROR(Illegal version number passed to --with-default-snmp-version)
228   fi
229 fi
230
231 AC_ARG_WITH(sys_contact,
232 [  --with-sys-contact=\"who@where\"  Default system contact.
233                                     (Default: LOGIN@DOMAINNAME)],
234     ac_cv_user_prompt_SYS_CONTACT="$with_sys_contact")
235
236 AC_ARG_WITH(sys_location,
237 [  --with-sys-location=\"location\"  Default system location.
238                                     (Default: Unknown)],
239     ac_cv_user_prompt_SYS_LOC="$with_sys_location")
240
241 AC_ARG_WITH(logfile,
242 [  --with-logfile=\"location\"       Default log file location for snmpd.],
243     ac_cv_user_prompt_LOGFILE="$with_logfile")
244
245 dnl This can't be within AC_ARG_WITH.  I don't want to read autoconf m4
246 dnl to find out why.
247 AC_SUBST(WRAPLIBS)
248
249 AC_ARG_WITH(transports,
250 [  --with-transports=\"t1 t2 ...\"   Compile in the given SNMP transport
251                                     modules (space separated list).])
252 AC_ARG_WITH(out_transports,
253 [  --with-out-transports=\"t1 ...\"  Exclude listed SNMP transports
254                                     (space separated list).
255
256   Available SNMP transport modules are:
257
258     UDP         support for SNMP over UDP/IP.
259                 This transport is always compiled in.
260     UDPIPv6     support for SNMP over UDP/IPv6.
261                 This transport is available for Linux, Solaris and
262                 FreeBSD.
263                 It is never compiled in by default.
264     TCPIPv6     support for SNMP over UDP/IPv6.
265                 This transport is available for Linux, Solaris and
266                 FreeBSD.
267                 It is never compiled in by default.
268     TCP         support for SNMP over TCP/IP.
269                 This transport is compiled in by default, but may be ommitted.
270     Unix        support for SNMP over Unix domain protocols.
271                 This transport is compiled in by default except on Win32
272                 platforms, and may be omitted.
273     Callback    support for SNMP over an internal locally connected pair
274                 of snmp_sessions.
275     AAL5PVC     support for SNMP over AAL5 PVCs.
276                 This transport is presently only available for Linux,
277                 is never compiled in by default and may be omitted.
278     IPX         support for SNMP over IPX per RFC 1420.
279                 This transport is presently only available for Linux,
280                 is never compiled in by default and may be omitted.
281 ])
282
283 dnl
284 dnl Catch common mistakes in transport options
285 dnl
286 AC_ARG_WITH(transport,,    AC_MSG_ERROR([ Invalid option. Use --with-transports instead ])     )
287 AC_ARG_WITH(out_transport,,AC_MSG_ERROR([ Invalid option. Use --with-out-transports instead ]) )
288
289 dnl
290 dnl security modules
291 dnl
292
293 AC_ARG_WITH(security-modules,
294 [  --with-security-modules=\"s1 s2 ...\"   Compile in the given SNMP security
295                                     module services (space separated list).
296
297   Available SNMP security services:
298
299         usm                support for user based SNMP security
300                            (required and always compiled in)
301         ksm                support for kerberos based SNMP security
302 ])
303
304 dnl
305 dnl mib modules
306 dnl
307
308 AC_ARG_WITH(mib_modules,
309 [  --with-mib-modules=\"item1 ...\"  Compile with additional mib modules
310                                     (Space separated list).])
311
312 AC_ARG_WITH(out_mib_modules,
313 [  --with-out-mib-modules=\"list\"   Compile without these mib modules.
314
315   Default mib modules compiled into the agent (which can be removed):
316   
317     mibII                  support for the mib-II tree.
318     snmpv3mibs             support for the snmpv3 mib modules.
319     ucd_snmp               UCD-SNMP-MIB specific extensions.
320     agent_mibs             NET-SNMP-AGENT-MIB extensions
321     agentx                 (see below)
322     notification           mibs supporting specification of trap destinations.
323     target                 Support for the SNMP WGs TARGET-MIB.
324     utilities              general agent configuration utilities.
325
326   Optional mib modules that can be built into the agent include:
327     host                   host resources mib support.
328                              (beta level code for linux, hpux, solaris, bsdi)
329     disman/event-mib       support for the DISMAN-EVENT-MIB (beta)
330                              (supports self monitoring and notification 
331                               delivery when error conditions are found)
332     smux                   smux support to allow subagents to attach to snmpd.
333     mibII/mta_sendmail     Sendmail statistics monitoring (MTA-MIB)
334     misc/ipfwacc           accounting rules IP firewall information (linux).
335     ipfwchains/ipfwchains  firewall chains under ipfw for linux.
336                            (Download separately from the ucd-snmp ftp site.)
337     ucd-snmp/diskio        Table of io-devices and how much data they have
338                            read/written.  (only tested on Solaris)
339     tunnel                 Linux TUNNEL-MIB support (ifTable extension)
340
341   AgentX support:  (warning: beta code)
342     agentx/subagent        allows the agent to run as either a snmp agent
343                            or as an agentX sub-agent.
344     agentx/master          makes the agent run as an agentX master agent
345                            as well as a normal snmp agent.
346     agentx                 includes both agentx/master and agentx/client.
347
348   Optional modules for C coders to look at and/or include as extension examples:
349   
350     examples/ucdDemoPublic  SNMPv3 interoperability testing mib.
351     examples/example        example C code extension.])
352
353
354 dnl
355 AC_ARG_WITH(enterprise-oid,
356 [Enterprise OIDs:  (warning: this should be used with caution.)
357
358   --with-enterprise-oid              The enterprise number assigned to the
359                                      vendor by IANA.  See
360                                      http://www.iana.org/cgi-bin/enterprise.pl
361                                      to get one, though using the default is
362                                      probably the right choice is most cases.
363                                      (default 8072 = "enterprise.net-snmp")],[
364   if test "$withval" = yes; then
365     AC_MSG_ERROR([ Please provide a value for the enterprise number ]);
366   fi
367   AC_DEFINE_UNQUOTED(ENTERPRISE_OID, $withval)
368   ent_oid="1,3,6,1,4,1,$withval"
369   AC_DEFINE_UNQUOTED(ENTERPRISE_MIB, $ent_oid)
370   ent_dot_oid="1.3.6.1.4.1.$withval"
371   AC_DEFINE_UNQUOTED(ENTERPRISE_DOT_MIB, $ent_dot_oid)
372   AC_MSG_RESULT(using enterprise number $withval)
373 ],[
374   AC_MSG_RESULT(using default "enterprise.net-snmp")
375 ])
376
377 AC_ARG_WITH(enterprise-sysoid,
378 [
379   --with-enterprise-sysoid           The base OID for the sysObjectID
380                                      of the system group
381                                      (default .1.3.6.1.4.1.8072.3.2... = 
382                                       "netSnmpAgentOIDs...")],[
383   if test "$withval" = yes; then
384     AC_MSG_ERROR([ Please provide a base OID value ]);
385   fi
386   sys_oid=`echo "$withval" | sed 's/^\.//' | sed 's/\./\,/g'`
387   AC_DEFINE_UNQUOTED(SYSTEM_MIB, $sys_oid)
388   sys_dot_oid=`echo "$withval" | sed 's/^\.//'`
389   AC_DEFINE_UNQUOTED(SYSTEM_DOT_MIB, $sys_dot_oid)
390   sysoid_len=`echo "$withval" | sed 's/[^\.]//g' | awk -F\. '{ print NF }'`
391   AC_DEFINE_UNQUOTED(SYSTEM_DOT_MIB_LENGTH, $sysoid_len)
392   AC_MSG_RESULT(using enterprise sysOID $withval ....)
393 ],[
394   AC_MSG_RESULT(using default enterprise sysOID "NET-SNMP-MIB::netSnmpAgentOIDs...")
395 ])
396
397 AC_ARG_WITH(enterprise-notification-oid,
398 [
399   --with-enterprise-notification-oid The OID used for the root of
400                                      enterprise specific notifications.
401                                      (default .1.3.6.1.4.1.2021 = "enterprise.ucdavis")],[
402   if test "$withval" = yes; then
403     AC_MSG_ERROR([ Please provide a base OID value ]);
404   fi
405   notification_oid=`echo "$withval" | sed 's/^\.//' | sed 's/\./\,/g'`
406   AC_DEFINE_UNQUOTED(NOTIFICATION_MIB, $notification_oid)
407   notification_dot_oid=`echo "$withval" | sed 's/^\.//'`
408   AC_DEFINE_UNQUOTED(NOTIFICATION_DOT_MIB, $notification_dot_oid)
409   notificationoid_len=`echo "$withval" | sed 's/[^\.]//g' | awk -F\. '{ print NF }'`
410   AC_DEFINE_UNQUOTED(NOTIFICATION_DOT_MIB_LENGTH, $notificationoid_len)
411   AC_MSG_RESULT(using enterprise notifications $withval)
412 ],[
413   AC_MSG_RESULT(using default notifications "NET-SNMP-MIB::netSnmpNotifications")
414 ])
415 dnl
416 dnl Catch common mistakes in configure options
417 dnl
418 AC_ARG_WITH(mib_module,,    AC_MSG_ERROR([ Invalid option. Use --with-mib-modules instead ])     )
419 AC_ARG_WITH(out_mib_module,,AC_MSG_ERROR([ Invalid option. Use --with-out-mib-modules instead ]) )
420
421 dnl
422 dnl Perl specific
423 dnl
424 AC_ARG_WITH(perl-modules,
425 [
426 Perl:
427   --with-perl-modules             Install the perl modules along with the rest
428                                   of the net-snmp toolkit.],
429     install_perl=yes)
430
431 AC_ARG_ENABLE(embedded-perl,
432 [
433   --enable-embedded-perl          Embed perl in the SNMP agent.
434                                   [forces --with-perl-modules as well.]],
435     embed_perl="yes", embed_perl="no")
436
437 dnl
438 dnl otherwise prompted information
439 dnl
440 AC_ARG_WITH(defaults,
441 [
442 Miscellaneous:
443   --with-defaults          Use defaults for prompted values.],
444     defaults="yes",defaults="no")
445
446 AC_ARG_ENABLE(ucd-snmp-compatibility,
447 [--enable-ucd-snmp-compatibility  Install ucd-snmp look-alike headers and libs.], ucd_compat=yes, ucd_compat=no)
448 dnl
449 dnl setup install targets
450 dnl
451 if test "x$ucd_compat" != "xno" ; then  
452   installucdheaders=installucdheaders
453   installucdlibs=installucdlibs
454   AC_MSG_CACHE_ADD(UCD-SNMP compatability:     enabled)
455 fi
456 AC_SUBST(installucdheaders)
457 AC_SUBST(installucdlibs)
458
459 dnl Only define if specifically chosen as --without (i.e., default to true). 
460 if test "x$with_root_access" = "xno"; then
461   AC_DEFINE(NO_ROOT_ACCESS)
462 fi
463
464 dnl Only define if specifically chosen as --without (i.e., default to true).
465 if test "x$with_kmem_usage" = "xno"; then
466   AC_DEFINE(NO_KMEM_USAGE)
467 fi
468
469 dnl Define unless specifically suppressed (i.e., option defaults to false). 
470 if test "x$with_dummy_values" != "xyes"; then
471   AC_DEFINE(NO_DUMMY_VALUES)
472 fi
473
474 dnl Only define if specifically chosen as --without (i.e., default to true). 
475 if test "x$with_opaque_special_types" != "xno"; then
476   AC_DEFINE(OPAQUE_SPECIAL_TYPES)
477 fi
478
479
480 dnl overflow problems with hpux's sh
481 dnl taken from Perl's Configure script 
482
483 AC_MSG_CHECKING(if I need to feed myself to ksh)
484 if test -f /hp-ux -a -f /bin/ksh; then
485   if (PATH=.; alias -x) >/dev/null 2>&1; then
486     AC_MSG_RESULT(no)
487   else
488     AC_MSG_RESULT(yes)
489     if test "x$1" = "x"; then
490       exec /bin/ksh $0
491     else
492       exec /bin/ksh $0 "$@"
493     fi
494   fi
495 else
496   AC_MSG_RESULT(no)
497 fi
498
499 if test "x$developer" != "xno" -a -f $srcdir/remove-files; then
500   dnl turn on the developer flag when taken from a CVS checkout (not a release)
501   developer="yes"
502 fi
503
504 dnl disable --enable-shared by default in cvs/developer cases.
505 if test "x$developer" = "xyes"; then
506   dnl don't do anything if option set via cmdline
507   if test "${enable_shared+set}" != set; then
508     enable_shared=no
509   fi
510 fi
511
512 dnl perl requires shared libs
513 if test "x$embed_perl" = "xyes"; then
514     if test "x$enable_shared" != "xyes"; then
515       AC_MSG_ERROR(--enable-embedded-perl requires --enable-shared)
516     fi
517 fi
518
519 AC_PROG_CC
520 AC_PROG_CPP
521 AC_AIX
522 AC_EXEEXT
523
524 dnl libtool stuff for shared/static libraries.
525 AC_LIBTOOL_DLOPEN
526 AC_LIBTOOL_WIN32_DLL
527 AC_PROG_LIBTOOL
528
529 dnl Checks for programs.
530 AC_PROG_INSTALL
531 AC_PROG_LN_S
532 AC_PROG_MAKE_SET
533 AC_PATH_PROG(PSPROG,ps)
534 AC_PATH_PROG(PERLPROG,perl)
535 AC_CHECK_PROGS(WHOAMI, whoami logname, whoami)
536 AC_CHECK_PROGS(SED,sed gsed)
537 AC_CHECK_PROG(AUTOCONF, autoconf)
538 AC_CHECK_PROG(AUTOHEADER, autoheader)
539 if test "x$ac_cv_prog_AUTOCONF" = "x"; then
540         AUTOCONF=":"
541         AC_SUBST(AUTOCONF)
542 fi
543 if test "x$ac_cv_prog_AUTOHEADER" = "x"; then
544         AUTOHEADER=":"
545         AC_SUBST(AUTOHEADER)
546 fi
547
548 AC_PATH_PROG(UNAMEPROG,uname)
549 AC_DEFINE_UNQUOTED(UNAMEPROG,"$UNAMEPROG")
550
551 AC_C_CONST
552 AC_C_INLINE
553
554 dnl get version number.
555 AC_MSG_CHECKING(for net-snmp version number)
556 VERSION=`grep NetSnmpVersionInfo.*= $srcdir/snmplib/snmp_version.c | sed 's/";.*//;s/.*"//;s/pre/0./;'`
557 changequote(, )
558 RELEASEVERSION=`echo $VERSION | sed 's/^\([0-9]\)\.\([0-9]\)/\1:\2:0/'`
559 changequote([, ])
560 AC_SUBST(VERSION)
561 AC_SUBST(RELEASEVERSION)
562 AC_MSG_RESULT($VERSION)
563 AC_MSG_CACHE_ADD(Net-SNMP Version:           $VERSION)
564
565 dnl super type checking
566 AC_MSG_CHECKING(for developer gcc flags)
567 if test "x$developer" = "xyes" -a "x$ac_cv_prog_gcc" = "xyes"; then
568   DEVFLAGS="-Wall -Wstrict-prototypes -Wwrite-strings -Wcast-qual -Wno-char-subscripts"
569 else
570   DEVFLAGS=""
571 fi
572 AC_MSG_RESULT($DEVFLAGS)
573 AC_SUBST(DEVFLAGS)
574
575 dnl system check
576 AC_CANONICAL_SYSTEM
577 changequote(, )
578 PARTIALTARGETOS=`echo $target_os | sed 's/[-._].*//'`
579 CFLAGS="$CFLAGS -D$PARTIALTARGETOS"
580 changequote([, ])
581 AC_MSG_CACHE_ADD(Building for:               $PARTIALTARGETOS)
582
583 dnl
584 dnl check for special includes and pick one
585 dnl
586
587 AC_MSG_CHECKING(for system include file)
588 changequote(, )
589 filebase=$target_os
590 dnl ignore binary format indication
591 filebase=`echo $filebase | sed 's/elf//'`
592 filebase=`echo $filebase | sed 's/aout//'`
593 filebase=`echo $filebase | sed 's/ecoff//'`
594 filebase=`echo $filebase | sed 's/coff//'`
595 while test "x$filebase" != "x$last" -a ! -f $srcdir/include/net-snmp/system/$filebase.h
596 do
597     last=$filebase
598     filebase=`echo $filebase | sed 's/[-._][^-._]*$//'`
599     if test "x$filebase" = "x$last"; then
600         filebase=`echo $filebase | sed 's/[0-9]*$//'`
601     fi
602 done
603
604 if test "x$filebase" = "x$last"; then
605     filebase="generic"
606 fi
607 ac_cv_SYSTEM_INCLUDE_FILE="net-snmp/system/$filebase.h"
608
609 changequote([, ])
610 AC_MSG_RESULT($ac_cv_SYSTEM_INCLUDE_FILE)
611 AC_DEFINE_UNQUOTED(SYSTEM_INCLUDE_FILE, "$ac_cv_SYSTEM_INCLUDE_FILE")
612
613 dnl second part, the CPU type.
614
615 AC_MSG_CHECKING(for machine-type include file)
616 changequote(, )
617 filebase=$target_cpu
618 while test "x$filebase" != "x$last" -a ! -f $srcdir/include/net-snmp/machine/$filebase.h
619 do
620     last=$filebase
621     filebase=`echo $filebase | sed 's/[-._][^-._]*$//'`
622 done
623
624 if test "x$filebase" = "x$last"; then
625     filebase="generic"
626 fi
627 ac_cv_MACHINE_INCLUDE_FILE="net-snmp/machine/$filebase.h"
628
629 changequote([, ])
630 AC_MSG_RESULT($ac_cv_MACHINE_INCLUDE_FILE)
631 AC_DEFINE_UNQUOTED(MACHINE_INCLUDE_FILE, "$ac_cv_MACHINE_INCLUDE_FILE")
632
633 AC_PATH_PROG(CCPATH,$CC)
634 dnl watch out for /usr/ucb/cc on solaris, it doesn't work with this package.
635 case $target_os in
636     bsdi*)
637         if test "x$CCPATH" = "x/usr/ucb/cc" -o "x$CCPATH" = "x/usr/bin/cc"; then
638             AC_MSG_ERROR([
639
640 *** The BSDI /usr/ucb/cc compiler does not work with this package.  
641 *** Please run configure with --with-cc=gcc
642 ])
643         fi
644     ;;
645     solaris*)
646         if test "x$CCPATH" = "x/usr/ucb/cc"; then
647             AC_MSG_ERROR([
648
649 *** The solaris /usr/ucb/cc compiler does not work with this package.  
650 *** Please put a different compiler in your path first or run
651 *** configure with --with-cc=XX, where XX is the compiler you want to use.
652 ])
653         fi
654     ;;
655 esac
656     
657 AC_MSG_CHECKING(for additional cpp flags)
658 dnl gcc extra CPPFLAGS
659 if test "x$GCC" = "xyes" -a "x$CPP" = "x$CC -E"; then
660   dnl extra cpp flags for gnu c compiler to allow .in file extensions.
661   EXTRACPPFLAGS="-x c"
662 else
663   EXTRACPPFLAGS=""
664 fi
665
666 dnl Solaris extra cpp flags.
667 if test "x$GCC" != "xyes"; then
668   case $target_os in
669     solaris*) EXTRACPPFLAGS="$EXTRACPPFLAGS -Xs" ;;
670   esac
671 fi
672
673 AC_SUBST(EXTRACPPFLAGS)
674 AC_MSG_RESULT($EXTRACPPFLAGS)
675
676 dnl Prefixes must begin with "/"
677
678 if test "x$prefix" = "xNONE"; then
679   prefix=/usr/local
680 fi
681
682 fch=`echo $prefix | sed 's/\(.\).*/\1/'`
683 if test $fch != "/" ; then
684    prefix=`pwd`/$prefix
685    echo "adjusting prefix to $prefix"
686 fi
687
688 if test "x$exec_prefix" = "xNONE"; then
689   exec_prefix=$prefix
690 fi
691
692 fch=`echo $exec_prefix | sed 's/\(.\).*/\1/'`
693 if test $fch != "/" ; then
694    exec_prefix=`pwd`/$exec_prefix
695    echo "adjusting exec_prefix to $exec_prefix"
696 fi
697
698 dnl Set SNMPLIBPATH & SNMPSHAREPATH
699
700 SNMPLIBPATH=""
701 tmpset="$libdir/snmp"
702 while test "x$tmpset" != "x$SNMPLIBPATH"; do
703   SNMPLIBPATH="$tmpset"
704   eval tmpset="$tmpset"
705 done
706 AC_DEFINE_UNQUOTED(SNMPLIBPATH,"$SNMPLIBPATH")
707 AC_DEFINE_UNQUOTED(SNMPDLMODPATH,"$SNMPLIBPATH/dlmod")
708
709 SNMPSHAREPATH=""
710 tmpset="$datadir/snmp"
711 while test "x$tmpset" != "x$SNMPSHAREPATH"; do
712   SNMPSHAREPATH="$tmpset"
713   eval tmpset="$tmpset"
714 done
715 AC_DEFINE_UNQUOTED(SNMPSHAREPATH,"$SNMPSHAREPATH")
716
717 if test "x$DEFAULT_MIBDIRS" = "x"; then
718   AC_DEFINE_UNQUOTED(DEFAULT_MIBDIRS,"\$HOME/.snmp/mibs:$SNMPSHAREPATH/mibs")
719 fi
720
721 SNMPCONFPATH=""
722 tmpset="$sysconfdir/snmp"
723 while test "x$tmpset" != "x$SNMPCONFPATH"; do
724   SNMPCONFPATH="$tmpset"
725   eval tmpset="$tmpset"
726 done
727 AC_DEFINE_UNQUOTED(SNMPCONFPATH,"$SNMPCONFPATH")
728 AC_SUBST(SNMPCONFPATH)
729
730 dnl guess IPv6 stack type.
731 if test "x$enable_ipv6" = "xyes"; then
732         v6type=unknown
733         v6lib=none
734         v6trylibc=no
735
736         AC_MSG_CHECKING([ipv6 stack type])
737         for i in v6d toshiba kame inria zeta linux-glibc linux-inet6; do
738                 case $i in
739                 v6d)
740                         AC_EGREP_CPP(yes, [dnl
741 #include </usr/local/v6/include/sys/types.h>
742 #ifdef __V6D__
743 yes
744 #endif],
745                                 [v6type=$i; v6lib=v6;
746                                 v6libdir=/usr/local/v6/lib;
747                                 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
748                         ;;
749                 toshiba)
750                         AC_EGREP_CPP(yes, [dnl
751 #include <sys/param.h>
752 #ifdef _TOSHIBA_INET6
753 yes
754 #endif],
755                                 [v6type=$i; v6lib=inet6;
756                                 v6libdir=/usr/local/v6/lib;
757                                 CFLAGS="-DINET6 $CFLAGS"])
758                         ;;
759                 kame)
760                         AC_EGREP_CPP(yes, [dnl
761 #include <netinet/in.h>
762 #ifdef __KAME__
763 yes
764 #endif],
765                                 [v6type=$i; v6lib=inet6;
766                                 v6libdir=/usr/local/v6/lib;
767                                 v6trylibc=yes;
768                                 CFLAGS="-DINET6 $CFLAGS"])
769                         ;;
770                 inria)
771                         AC_EGREP_CPP(yes, [dnl
772 #include <netinet/in.h>
773 #ifdef IPV6_INRIA_VERSION
774 yes
775 #endif],
776                                 [v6type=$i;
777                                 v6lib=dummy;
778                                 v6libdir=none;
779                                 v6trylibc=yes;
780                                 CFLAGS="-DINET6 $CFLAGS"])
781                         ;;
782                 zeta)
783                         AC_EGREP_CPP(yes, [dnl
784 #include <sys/param.h>
785 #ifdef _ZETA_MINAMI_INET6
786 A
787 yes
788 #endif],
789                                 [v6type=$i; v6lib=inet6;
790                                 v6libdir=/usr/local/v6/lib;
791                                 CFLAGS="-DINET6 $CFLAGS"])
792                         ;;
793                 linux-glibc)
794                         AC_EGREP_CPP(yes, [dnl
795 #include <features.h>
796 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC_ > 2))
797 yes
798 #endif],
799                                 [v6type=$i;
800                                 v6lib=dummy;
801                                 v6libdir=none;
802                                 v6trylibc=yes;
803                                 CFLAGS="-DINET6 $CFLAGS"])
804                         ;;
805                 linux-inet6)
806                         if test -d /usr/inet6; then
807                                 v6type=$i
808                                 v6lib=inet6
809                                 v6libdir=/usr/inet6/lib
810                                 CFLAGS="-DINET6 $CFLAGS"
811                         fi
812                         ;;
813                 esac
814                 if test "$v6type" != "unknown"; then
815                         break
816                 fi
817         done
818
819         if test "$v6lib" != "none"; then
820                 if test -d $v6libdir -a -f $v6libdir/lib$v6lib.a; then
821                         LIBS="-L$v6libdir -l$v6lib $LIBS"
822                         enable_ipv6="yes"
823                         AC_MSG_RESULT(["$v6type, $enable_ipv6, using lib$v6lib"])
824                 elif test "$v6trylibc" = "yes"; then
825                         enable_ipv6="yes"
826                         AC_MSG_RESULT(["$v6type, $enable_ipv6, using libc"])
827                 else
828                         AC_MSG_ERROR(no IPv6 library lib$v6lib.a found.)
829                         exit 1
830                 fi
831         else
832                 enable_ipv6="no"
833                 AC_MSG_RESULT(["$v6type, $enable_ipv6"])
834         fi
835 fi
836
837 dnl
838 dnl Maybe add library extensions for thread mutex locking.
839 dnl
840
841 if test "x$with_res_locks" = "xyes"; then
842   AC_DEFINE(NS_REENTRANT)
843 EOF
844
845     case $target_os in
846
847     aix*)
848         CC_RUNTIME_ARG="$CC_RUNTIME_ARG -lpthreads"
849         ;;
850
851     *)
852         ;;
853
854     esac
855 fi
856
857 AC_MSG_CHECKING(whether we have to build PIC code)
858 echo "$with_mib_modules" | grep "ucd-snmp/dlmod" >/dev/null
859 if test $? -eq 0 ; then
860         DLLIBS="-ldl"
861         LIB_CFLAGS="$LIB_CFLAGS $SHLIB_CFLAGS"
862         AC_MSG_RESULT(yes)
863 else
864         DLLIBS=""
865         AC_MSG_RESULT(no)
866 fi
867
868 dnl
869 dnl Do transport module processing.
870 dnl
871 AC_MSG_CHECKING(for and configuring transport modules to use)
872 transport_src_list=""
873 transport_hdr_list=""
874 transport_def_list=""
875 transport_result_list=""
876 transport_add_list=""
877 new_with_transport_list=`echo $with_transports | sed 's/,/ /g;'`
878 new_with_out_transport_list=`echo $with_out_transports | sed 's/,/ /g;'`
879
880 dnl
881 dnl Add the default transports to the list
882 dnl
883 if test "x$PARTIALTARGETOS" = "xcygwin"; then
884   transport_default_list="UDP TCP Callback"
885 else
886   transport_default_list="UDP TCP Unix Callback"
887 fi
888 if test "x$enable_ipv6" = "xyes"; then
889   transport_default_list="UDPIPv6 TCPIPv6 $transport_default_list"
890 fi
891 for i in $transport_default_list; do
892   if echo " $new_with_transport_list " | grep " $i " >/dev/null; then
893     :
894   else
895     transport_add_list="$i $transport_add_list"
896   fi
897 done
898 new_transport_list="$transport_add_list $new_with_transport_list"
899
900 for i in $new_transport_list; do
901   if echo " $new_with_out_transport_list " | grep " $i " >/dev/null; then
902     if test "x$i" = "xUDP"; then
903       echo
904       AC_MSG_ERROR(It is not possible to compile without UDP/IP support.)
905     fi
906   else
907     if test "x$i" = "xAAL5PVC"; then
908       if test "x$PARTIALTARGETOS" != "xlinux"; then
909         echo
910         AC_MSG_ERROR(AAL5 PVC support unavailable for this platform (Linux only))
911       fi
912     fi
913     if test "x$i" = "xIPX"; then
914       if test "x$PARTIALTARGETOS" != "xlinux"; then
915         echo
916         AC_MSG_ERROR(IPX support unavailable for this platform (Linux only))
917       fi
918     fi
919     if test "x$i" = "xUnix"; then
920       if test "x$PARTIALTARGETOS" = "xcygwin"; then
921         echo
922         AC_MSG_ERROR(Unix domain protocol support unavailable for this platform)
923       fi
924     fi
925     transport_src="snmp"$i"Domain.c"
926     transport_hdr="snmp"$i"Domain.h"
927     rel_transport_src="snmplib/"$transport_src
928     rel_transport_hdr="include/net-snmp/library/"$transport_hdr
929     if test -f "$srcdir/$rel_transport_src"; then
930       transport_result_list="$transport_result_list $i"
931       transport_src_list="$transport_src $transport_src_list"
932       if test -f "$srcdir/$rel_transport_hdr"; then
933         transport_hdr_list="$transport_hdr $transport_hdr_list"
934       fi
935       transport_def=`echo $i | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
936       transport_def_list="SNMP_TRANSPORT_"$transport_def"_DOMAIN $transport_def_list"
937     else
938       echo
939       AC_MSG_ERROR(Cannot find file $transport_src to support SNMP transport domain $i.)
940     fi
941   fi
942 done
943 transport_obj_list=`echo " $transport_src_list " | sed 's/\.c/\.o/g'`
944 transport_lobj_list=`echo " $transport_src_list " | sed 's/\.c/\.lo/g'`
945 AC_SUBST(transport_hdr_list)
946 AC_SUBST(transport_src_list)
947 AC_SUBST(transport_obj_list)
948 AC_SUBST(transport_lobj_list)
949 for i in $transport_def_list; do
950   AC_DEFINE_UNQUOTED($i)
951 done
952 AC_MSG_RESULT($transport_result_list.)
953 AC_MSG_CACHE_ADD(Network transport support: $transport_result_list)
954
955 dnl
956 dnl Security modules to use
957 dnl 
958
959 AC_MSG_CHECKING(for security modules to use)
960 security_def_list="usm"
961 security_src_list=""
962 security_obj_list=""
963 security_lobj_list=""
964 security_init_file="snmplib/snmpsm_init.h"
965 security_incl_file="include/net-snmp/library/snmpv3-security-includes.h"
966 new_with_security=`echo $with_security_modules | sed 's/,/ /g;'`
967 new_with_out_security=`echo $with_out_security_modules | sed 's/,/ /g;'`
968
969 if test ! -d include; then
970   mkdir include
971 fi
972 if test ! -d include/net-snmp; then
973   mkdir include/net-snmp
974 fi
975 if test ! -d include/net-snmp/agent; then
976   mkdir include/net-snmp/agent
977 fi
978 if test ! -d include/net-snmp/library; then
979   mkdir include/net-snmp/library
980 fi
981 if test ! -d include/ucd-snmp; then
982   mkdir include/ucd-snmp
983 fi
984
985 if test ! -d snmplib; then
986   mkdir snmplib
987 fi
988 echo "/* This file is automatically generated by configure.  Do not modify by hand. */" > $security_init_file
989 echo "/* This file is automatically generated by configure.  Do not modify by hand. */" > $security_incl_file
990
991 for i in $security_def_list; do
992   if echo " $new_with_out_security " | grep " $i " > /dev/null; then
993     if test "x$i" = "xusm"; then
994         echo
995         AC_MSG_ERROR(The USM security module is mandatory)
996     fi
997   else
998     new_with_security="$new_with_security $i"
999   fi
1000 done
1001
1002 for i in $new_with_security; do
1003   cfile="snmp"$i".c"
1004   hfile="snmp"$i".h"
1005
1006   # make sure support exists for it
1007   if test -f $srcdir"/snmplib/"$cfile -a -f $srcdir"/include/net-snmp/library/"$hfile; then
1008     :
1009   else
1010     echo
1011     AC_MSG_ERROR(No such security module: $i / $cfile / $hfile)
1012   fi
1013
1014   # define a bunch of stuff to enable it
1015   security_src_list="$security_src_list $cfile"
1016   security_hdr_list="$security_hdr_list $hfile"
1017   security_obj_list="$security_obj_list snmp"$i".o"
1018   security_lobj_list="$security_lobj_list snmp"$i".lo"
1019   def_name="SNMP_SECMOD_"`echo $i | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
1020   echo "init_"$i"();" >> $security_init_file
1021   echo "#include <net-snmp/library/$hfile>" >> $security_incl_file
1022   AC_DEFINE_UNQUOTED($def_name)
1023 done
1024
1025 AC_SUBST(security_src_list)
1026 AC_SUBST(security_obj_list)
1027 AC_SUBST(security_lobj_list)
1028 AC_SUBST(security_hdr_list)
1029 AC_MSG_RESULT($new_with_security)
1030 AC_MSG_CACHE_ADD(SNMPv3 Security Modules:   $new_with_security)
1031
1032 dnl
1033 dnl Handle the special case of KSM to see which crypto API we support
1034 dnl
1035
1036 for sec in $new_with_security
1037 do
1038   if test x$sec = xksm; then
1039     AC_MSG_CHECKING(to see which crypto API we need to use)
1040
1041     AC_CHECK_FUNC(krb5_c_encrypt,[
1042       AC_MSG_RESULT(new MIT crypto API)
1043       AC_DEFINE(MIT_NEW_CRYPTO)],[
1044       AC_MSG_RESULT(old MIT crypto API)])
1045   fi
1046 done
1047
1048 dnl
1049 dnl Do hairy agent module processing.
1050 dnl
1051 AC_MSG_CHECKING(for and configuring mib modules to use)
1052 changequote(, )
1053
1054 mibdir="agent/mibgroup"
1055 module_list=""
1056 module_list_code=""
1057 new_with_mib_modules=`echo $with_mib_modules | sed 's/,/ /g;'`
1058 new_with_out_mib_modules=`echo $with_out_mib_modules | sed 's/,/ /g;'`
1059 new_module_list="mibII ucd_snmp snmpv3mibs notification target agent_mibs agentx agent_mibs utilities $new_with_mib_modules"
1060 default_mibs=IP-MIB:IF-MIB:TCP-MIB:UDP-MIB:SNMPv2-MIB:RFC1213-MIB:NOTIFICATION-LOG-MIB
1061
1062 if test "x$mini_agent" = "xyes"; then
1063 new_with_out_mib_modules="mibII $new_with_out_mib_modules"
1064 new_module_list="snmpv3mibs mibII/snmp_mib mibII/system_mib mibII/sysORTable mibII/vacm_vars $new_with_mib_modules"
1065 default_mibs=SNMPv2-MIB:RFC1213-MIB
1066 default_mibs_install=" "
1067 fi
1068
1069
1070 if test "x$enable_ipv6" = "xyes"; then
1071         new_module_list="$new_module_list mibII/ipv6"
1072 fi
1073
1074 dnl Create include file list for snmp_vars.h to use.
1075 if test ! -d agent; then
1076   mkdir agent
1077 fi
1078 if test ! -d agent/mibgroup; then
1079   mkdir agent/mibgroup
1080 fi
1081 for i in $mibdir/mib_module_includes.h $mibdir/mib_module_inits.h $mibdir/mib_module_shutdown.h include/net-snmp/agent/mib_module_config.h $mibdir/mib_module_dot_conf.h; do
1082   rm -f $i
1083   echo "/* This file is automatically generated by configure.  Do not modify by hand. */" > $i
1084 done
1085
1086 test_modules="$new_module_list"
1087 new_module_list=""
1088 module_list_h=""
1089
1090 for i in $test_modules
1091  do
1092   if echo " $new_with_out_mib_modules " | grep " $i " > /dev/null; then
1093     :
1094   else
1095     new_module_list="$new_module_list $i"
1096   fi
1097 done
1098
1099 changequote([, ])
1100 AC_MSG_RESULT($new_module_list.)
1101 AC_MSG_CACHE_ADD(Agent MIB code:            $new_module_list)
1102
1103 AC_MSG_CHECKING(for and configuring mib modules pieces to use)
1104 FD=AC_FD_MSG
1105 changequote(, )
1106
1107 while test "x$new_module_list" != "x"; do
1108   for i in $new_module_list
1109     do
1110     if echo " $new_with_out_mib_modules " | grep " $i " > /dev/null; then
1111       :
1112     else
1113       if test -f $srcdir/$mibdir/$i.h; then
1114         new_list=""
1115         new_list_arch=`grep config_arch_require $srcdir/$mibdir/$i.h | sed 's/.*config_arch_require(\(.*\), *\(.*\)).*/\1-xarchx-\2/'`
1116         if test "x$new_list_arch" != "x"; then
1117           for j in $new_list_arch
1118             do
1119             archtest=`echo $j | sed 's/-xarchx-.*//'`
1120             if test "x$target_os" = "x$archtest" -o "x$PARTIALTARGETOS" = "x$archtest"; then
1121               new_list="$new_list `echo $j | sed 's/.*-xarchx-//'`"
1122             fi
1123           done
1124         fi
1125         new_list="$new_list `grep config_require $srcdir/$mibdir/$i.h | sed 's/.*config_require(\(.*\)).*/\1/'`"
1126         if test "x$new_list" != "x"; then
1127           for j in $new_list
1128             do
1129             if test ! -f $srcdir/$mibdir/$j.h; then
1130               changequote([, ])
1131               AC_MSG_ERROR(mib module "$i" requires module "$j" but $j.h or $j.c could not be found in $srcdir/$mibdir)
1132               changequote(, )
1133             elif echo " $new_with_out_mib_modules " | grep " $j " > /dev/null; then
1134               changequote([, ])
1135               AC_MSG_WARN(mib module "$i" requires module "$j" but you told me to compile without it)
1136               changequote(, )
1137             elif echo " $module_list $new_list_two $new_module_list " | grep " $j " > /dev/null; then
1138               :
1139             else
1140               new_list_two="$new_list_two $j"
1141             fi
1142           done
1143         fi
1144         new_mibs=`grep config_add_mib $srcdir/$mibdir/$i.h | sed 's/.*config_add_mib(\(.*\)).*/\1/'`
1145         if test "x$new_mibs" != "x"; then
1146             for j in $new_mibs
1147                 do
1148                 if test "x`echo :$default_mibs: | grep :$j:`" = "x"; then
1149                     default_mibs="$default_mibs:$j"
1150                 fi
1151                 if test -f $srcdir/mibs/$j.txt; then
1152                     if echo $default_mibs_install | grep " $j " > /dev/null; then
1153                             :
1154                     else
1155                             default_mibs_install="$default_mibs_install $j.txt"
1156                     fi
1157                 fi
1158             done
1159         fi
1160       else
1161         changequote([, ])
1162         AC_MSG_ERROR(module files $i.h or $i.c could not be found in $srcdir/$mibdir)
1163         changequote(, )
1164       fi
1165       module_list="$module_list $i"
1166       echo '#include "'"mibgroup/$i.h"'"' >> $mibdir/mib_module_includes.h
1167       module_list_h="$module_list_h mibgroup/$i.h"
1168       if test -f $srcdir/$mibdir/$i.c; then
1169         module_list_code="$module_list_code $i"
1170         mnm=`echo $i | sed 's/.*\///;s/\.c$//;'`
1171         temp_init=`grep init_$mnm $srcdir/$mibdir/$i.c | grep -v _init_$mnm`
1172         if test "x$temp_init" != "x"; then
1173             echo "  if (should_init(\"$mnm\")) init_$mnm();" >> $mibdir/mib_module_inits.h
1174         fi
1175         if grep shutdown_`basename $i` $srcdir/$mibdir/$i.c > /dev/null; then
1176             echo "  if (should_init(\"`basename $i`\")) shutdown_`basename $i`();" >> $mibdir/mib_module_shutdown.h
1177         fi
1178       fi
1179       if test "x`echo $i | sed 's/\///g;'`" != "x$i"; then
1180         mnd=`echo $i | sed 's/\/[^/]*$//;'`
1181         if test ! -d ./$mibdir/$mnd; then
1182             module_directories="$module_directories ./$mibdir/$mnd"
1183         fi
1184       fi
1185       if grep config_load_mib $srcdir/$mibdir/$i.h > /dev/null 2>&1; then
1186         changequote([, ])
1187         AC_MSG_WARN(mib module "$i" uses the "config_load_mib" directive, which is no longer supported.  It probably won't work.)
1188         changequote(, )
1189       fi
1190       grep config_parse_dot_conf $srcdir/$mibdir/$i.h | sed 's@.*config_parse_dot_conf(\([^)]*\), *\([^),]*\), *\([^),]*\), *\([^),]*\)).*@register_config_handler("snmpd",\1, \2, \3, \4);@' >> $mibdir/mib_module_dot_conf.h
1191       sym="`echo ${i} | sed 's/[^a-zA-Z0-9_]/_/g' | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`"
1192       echo "/* Define if compiling with the ${i} module files.  */" >> include/net-snmp/agent/mib_module_config.h
1193       echo "#define USING_${sym}_MODULE 1" >> include/net-snmp/agent/mib_module_config.h
1194       echo " " >> include/net-snmp/agent/mib_module_config.h
1195       echo $ac_n " $i$ac_c" >&$FD
1196     fi
1197   done
1198   new_module_list="$new_list_two"
1199   new_list_two=""
1200 done
1201 module_list_o=`echo "$module_list_code " | sed 's/\([^ ]\) /\1.o /g'`
1202 module_list_lo=`echo "$module_list_code " | sed 's/\([^ ]\) /\1.lo /g'`
1203 module_list_c=`echo "$module_list_code " | sed 's/\([^ ]\) /\1.c /g'`
1204 mibgroup_list_o=`echo " $module_list_o " | sed 's@ \([^ ]*\)\.o@ mibgroup/\1.o @g'`
1205 mibgroup_list_lo=`echo " $module_list_lo " | sed 's@ \([^ ]*\)\.lo@ mibgroup/\1.lo @g'`
1206 changequote([, ])
1207 MODULE_LIST=$module_list_code
1208 AC_SUBST(MODULE_LIST)
1209 AC_SUBST(module_list_c)
1210 AC_SUBST(module_list_h)
1211 AC_SUBST(module_list_o)
1212 AC_SUBST(module_list_lo)
1213 AC_SUBST(mibgroup_list_o)
1214 AC_SUBST(mibgroup_list_lo)
1215 AC_SUBST(module_list)
1216 AC_SUBST(default_mibs_install)
1217
1218 AC_MSG_RESULT(.)
1219
1220 AC_MSG_CHECKING(if directories need to be created)
1221 for i in $module_directories; do
1222   $srcdir/mkinstalldirs $i
1223 done
1224 AC_MSG_RESULT(.)
1225
1226 AC_MSG_CHECKING(default mib files to read)
1227 if test "x$DEFAULT_MIBS" = "x"; then
1228   DEFAULT_MIBS="$default_mibs"
1229 fi
1230 AC_DEFINE_UNQUOTED(DEFAULT_MIBS,"$DEFAULT_MIBS")
1231 AC_MSG_RESULT($DEFAULT_MIBS)
1232
1233 dnl
1234 dnl Check for kernel location
1235 dnl
1236
1237 AC_CACHE_CHECK(for location of system kernel,ac_cv_KERNEL_LOC,
1238 [ac_cv_KERNEL_LOC="unknown"
1239 dnl First determine if test expects a -f or a -c (character device (SYSV))
1240
1241 if test -c /dev/null; then
1242   CFLAG="-c"
1243 elif test -f /dev/null; then
1244   CFLAG="-f"
1245 else
1246   dnl fall back
1247   CFLAG="-f"
1248 fi
1249 for i in /vmunix /hp-ux /stand/vmunix /dev/ksyms /kernel/unix /kernel/genunix /netbsd /unix /kernel /bsd /mach_kernel
1250   do
1251   if test -f $i -o $CFLAG $i; then
1252     ac_cv_KERNEL_LOC="$i"
1253     break;
1254   fi
1255 done
1256 if test $i = "unknown"; then
1257   AC_MSG_WARN(Can't find system kernel...  Setting to /vmunix)
1258   ac_cv_KERNEL_LOC="/vmunix"
1259 fi
1260 ])
1261
1262 AC_DEFINE_UNQUOTED(KERNEL_LOC,"$ac_cv_KERNEL_LOC")
1263
1264 dnl
1265 dnl Check for mount table location
1266 dnl
1267
1268 AC_CACHE_CHECK(for mount table location,ac_cv_ETC_MNTTAB,
1269 [ac_cv_ETC_MNTTAB="unknown"
1270 for i in /etc/mnttab /etc/mtab /etc/filesystems
1271   do
1272   if test -f $i; then
1273     ac_cv_ETC_MNTTAB="$i"
1274     break;
1275   fi
1276 done
1277 ])
1278
1279 AC_DEFINE_UNQUOTED(ETC_MNTTAB,"$ac_cv_ETC_MNTTAB")
1280
1281 dnl Check for /dev/dmem or /dev/drum location
1282 AC_CACHE_CHECK(for location of swap device,ac_cv_DMEM_LOC,
1283 [
1284 dnl First determine if test expects a -f or a -c (character device (SYSV))
1285
1286 if test -f /dev/kmem; then
1287   CTEST="test -f"
1288 elif test -c /dev/kmem; then
1289   CTEST="test -c"
1290 else
1291   dnl fall back
1292   CTEST="test -f"
1293 fi
1294
1295 if $CTEST /dev/dmem; then
1296   ac_cv_DMEM_LOC="/dev/dmem"
1297 elif $CTEST /dev/drum; then
1298   ac_cv_DMEM_LOC="/dev/drum"
1299 else
1300   ac_cv_DMEM_LOC="none"
1301 fi
1302 ])
1303
1304 if test "x$ac_cv_DMEM_LOC" != "xnone"; then
1305   AC_DEFINE_UNQUOTED(DMEM_LOC,"$ac_cv_DMEM_LOC")
1306 fi
1307
1308 dnl forced efence turned off.
1309 dnl if test "x$developer" = "xyes" -a "x$use_efence" != "xno"; then
1310 dnl    use_efence="yes"
1311 dnl fi
1312
1313 if test "x$use_efence" = "xyes"; then
1314     AC_CHECK_LIB(efence, EF_Exit)
1315 fi
1316
1317 dnl Checks for libraries.
1318 dnl AC_CHECK_LIB(des, main)
1319 AC_CHECK_LIB(m, asin)
1320 dnl nlist is needed for uptime on some sytems in the generic library
1321 AC_CHECK_LIB(elf, nlist)
1322
1323 dnl On some platforms (Irix) libnsl and libsocket should not be used.
1324 AC_CHECK_FUNC(gethostbyname, AC_DEFINE(HAVE_GETHOSTBYNAME),
1325         AC_CHECK_LIB(nsl, gethostbyname, AC_DEFINE(HAVE_GETHOSTBYNAME)
1326         LIBS="${LIBS} -lnsl"))
1327 AC_CHECK_FUNC(getservbyname, AC_DEFINE(HAVE_GETSERVBYNAME),
1328         AC_CHECK_LIB(socket, getservbyname, AC_DEFINE(HAVE_GETSERVBYNAME)
1329         LIBS="${LIBS} -lsocket"))
1330
1331 dnl Replace `main' with a function in -lkstat:
1332 AC_CHECK_LIB(kstat, kstat_lookup)
1333 dnl Check for nlist in mld (irix)
1334 AC_CHECK_LIB(mld, nlist)
1335
1336 dnl Check for security related functions
1337 if test "x$tryopenssl" != "xno"; then
1338     if test "x$tryrsaref" != "xno"; then
1339          AC_CHECK_LIB(rsaref, RSAPrivateDecrypt)
1340          AC_CHECK_LIB(RSAglue, RSA_PKCS1_RSAref)
1341     fi
1342
1343     AC_CHECK_LIB(crypto, EVP_md5)
1344     AC_CHECK_FUNCS(AES_cfb128_encrypt)
1345 fi
1346
1347 dnl Check for libraries that the agent needs
1348 dnl saving old libraries
1349 NONAGENTLIBS=$LIBS
1350
1351 dnl check for tcp wrapper support
1352 _cppflags="${CPPFLAGS}"
1353 _ldflags="${LDFLAGS}"
1354
1355 AC_ARG_WITH(libwrap,
1356 [  --with-libwrap[=LIBPATH] Compile in libwrap (tcp_wrappers) support.],[
1357   if test "$with_libwrap" != "no"; then
1358     if test "$with_libwrap" != "yes"; then
1359       CPPFLAGS="${CPPFLAGS} -I$with_libwrap/include"
1360       LDFLAGS="${LDFLAGS} -L$with_libwrap/lib"
1361     fi
1362
1363     _libs=${LIBS}
1364     AC_CHECK_HEADER(tcpd.h, ,
1365             AC_MSG_ERROR(Asked to use libwrap but I couldn't find tcpd.h.))
1366
1367     LIBS="$LIBS -lwrap"
1368         AC_MSG_CHECKING(for TCP wrappers library -lwrap)
1369         AC_TRY_LINK([#include <tcpd.h>
1370                      int allow_severity = 0;
1371                      int deny_severity  = 0;
1372                     ],[hosts_access((void *)0)],
1373         [
1374             AC_MSG_RESULT(yes)
1375             AC_DEFINE(USE_LIBWRAP)
1376             test "$with_libwrap" != no -a "$with_libwrap" != yes && WRAPLIBS="-L$with_libwrap/lib"
1377             WRAPLIBS="$WRAPLIBS -lwrap"],
1378         [
1379             AC_MSG_RESULT(no)
1380             dnl Linux RedHat 6.1 won't link libwrap without libnsl
1381             AC_CHECK_FUNC(yp_get_default_domain, ,
1382                 AC_CHECK_LIB(nsl, yp_get_default_domain))
1383             AC_MSG_CHECKING(for TCP wrappers library -lwrap linked with -lnsl)
1384             AC_TRY_LINK([#include <tcpd.h>
1385                          int allow_severity = 0;
1386                          int deny_severity  = 0;
1387                         ],[hosts_access((void *)0)],
1388
1389                         AC_MSG_RESULT(yes)
1390                         AC_DEFINE(USE_LIBWRAP)
1391                         test "$with_libwrap" != no -a "$with_libwrap" != yes && WRAPLIBS="-L$with_libwrap/lib"
1392                         WRAPLIBS="$WRAPLIBS -lwrap -lnsl",
1393
1394                         AC_MSG_RESULT(no)
1395                         AC_MSG_ERROR(Asked to use libwrap but I couldn't find it.))
1396         ])
1397     CPPFLAGS=${_cppflags}
1398     LDFLAGS=${_ldflags}
1399     LIBS=${_libs}
1400   fi
1401 ])
1402
1403 dnl
1404 dnl rpm libraries only needed for the host resources mib software
1405 dnl installed tables (on linux in particular)
1406 dnl
1407 if echo " $module_list " | grep " host/hr_swinst " > /dev/null; then
1408   dnl ARG.  RPM is a real pain.
1409   dnl FWIW librpm.la, librpmio.la, and libpopt.la have correct dependencies.
1410   _rpmlibs=""
1411
1412   dnl zlib is required for newer versions of rpm
1413   _cppflags="${CPPFLAGS}"
1414   _ldflags="${LDFLAGS}"
1415
1416   AC_ARG_WITH(zlib,
1417   [  --with-zlib[=DIR]        use libz in DIR],[
1418     if test -d "$withval"; then
1419       CPPFLAGS="${CPPFLAGS} -I$withval/include"
1420       LDFLAGS="${LDFLAGS} -L$withval/lib"
1421     fi
1422   ])
1423
1424   dnl dunno if this is needed for rpm-4.0.x, earlier probably needs.
1425   AC_CHECK_HEADER(zlib.h,
1426       AC_CHECK_LIB(z, gzread, , CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}),
1427       CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags})
1428
1429   dnl two variants of bzip2 need checking.
1430   AC_CHECK_LIB(bz2, bzread, [_rpmlibs="$_rpmlibs -lbz2"],
1431      AC_CHECK_LIB(bz2, BZ2_bzread, [_rpmlibs="$_rpmlibs -lbz2"],))
1432
1433   dnl two variants of db1 need checking.
1434   AC_CHECK_LIB(db1, dbopen, [_rpmlibs="-ldb1 $_rpmlibs"],
1435      AC_CHECK_LIB(db, dbopen, [_rpmlibs="-ldb $_rpmlibs"]))
1436
1437   dnl two variants of db3 need checking.
1438   AC_CHECK_LIB(db-3.1, db_create, [_rpmlibs="-ldb-3.1 $_rpmlibs"],
1439     AC_CHECK_LIB(db-3.0, db_create, [_rpmlibs="-ldb-3.0 $_rpmlibs"]))
1440   
1441   dnl rpm-3.0.5 and later needs popt.
1442   AC_CHECK_LIB(popt, poptParseArgvString, [_rpmlibs="-lpopt $_rpmlibs"])
1443   
1444   dnl rpm-4.0.x needs rpmio.
1445   AC_CHECK_LIB(rpmio, Fopen, [_rpmlibs="-lrpmio $_rpmlibs"],,$_rpmlibs)
1446   
1447   dnl now check for rpm using the appropriate libraries.
1448   AC_CHECK_LIB(rpm, rpmGetFilesystemList,[
1449     AC_DEFINE(HAVE_LIBRPM)
1450     LIBS="-lrpm $_rpmlibs $LIBS"
1451     CFLAGS="$CFLAGS -I/usr/include/rpm"
1452   ],[
1453     dnl rpm-4.0.3 librpmdb actually contains what we need.
1454     AC_CHECK_LIB(rpmdb, rpmdbOpen,[
1455       AC_DEFINE(HAVE_LIBRPM)
1456       LIBS="-lrpmdb -lrpm $_rpmlibs $LIBS"
1457       CFLAGS="$CFLAGS -I/usr/include/rpm"
1458     ],,-lrpm $_rpmlibs)
1459   ])
1460 fi
1461   
1462 dnl Replace `main' with a function in -lkvm:
1463 AC_CHECK_LIB(kvm, kvm_read)
1464 dnl DYNAMIC MODULE SUPPORT
1465 AC_CHECK_LIB(dl, dlopen)
1466 AC_CHECK_FUNCS(dlopen)
1467
1468 AC_CHECK_FUNCS(kvm_openfiles nlist knlist kvm_getprocs)
1469 echo "$with_mib_modules" | grep "ucd-snmp/diskio" >/dev/null
1470 dnl whether we need -ldevstat for diskio MIB
1471 if test $? -eq 0 ; then
1472         AC_CHECK_FUNC(getdevs, AC_DEFINE(HAVE_GETDEVS),
1473                 AC_CHECK_LIB(devstat, getdevs, AC_DEFINE(HAVE_GETDEVS)
1474                 LIBS="${LIBS} -ldevstat"))
1475 fi
1476
1477
1478 dnl
1479 dnl Install the various perl modules
1480 dnl
1481
1482 if test "x$install_perl" = "xyes" -o "x$embed_perl" = "xyes"; then
1483     PERLTARGS="perlmodules"
1484     PERLINSTALLTARGS="perlinstall"
1485     AC_SUBST(PERLTARGS)
1486     AC_SUBST(PERLINSTALLTARGS)
1487     AC_MSG_CACHE_ADD(SNMP Perl modules:          enabled)
1488 fi
1489
1490 dnl
1491 dnl Embedded Perl specific stuff
1492 dnl
1493 if test "x$embed_perl" = "xyes"; then
1494     myperl=$ac_cv_path_PERLPROG
1495     if test $myperl = "no"; then
1496       AC_MSG_ERROR(--enable-embedded-perl requested but no perl executable found)
1497     fi
1498
1499     AC_MSG_CHECKING(for perl CFLAGS)
1500     perlcflags=`$myperl -MExtUtils::Embed -e ccopts`
1501     AC_MSG_RESULT($perlcflags)
1502     CPPFLAGS="$CPPFLAGS $perlcflags"
1503
1504     AC_MSG_CHECKING(for perl LDFLAGS)
1505     perlldopts=`$myperl -MExtUtils::Embed -e ldopts`
1506     AC_MSG_RESULT($perlldopts)
1507     LIBS="$LIBS $perlldopts"
1508
1509     dnl newer perl vs older perl call functions
1510     AC_CHECK_FUNCS(eval_pv perl_eval_pv)
1511
1512     AC_DEFINE(NETSNMP_EMBEDDED_PERL)
1513     OTHERAGENTLIBOBJS="snmp_perl.o"
1514     OTHERAGENTLIBLOBJS="snmp_perl.lo"
1515
1516     EMBEDPERLINSTALL="embedperlinstall"
1517     AC_SUBST(EMBEDPERLINSTALL)
1518     AC_MSG_CACHE_ADD(Embedded perl support:      enabled)
1519 fi
1520
1521 dnl reset libs
1522 AGENTLIBS=$LIBS
1523 LIBS=$NONAGENTLIBS
1524
1525 dnl Checks for header files.
1526 AC_HEADER_STDC
1527 AC_HEADER_DIRENT
1528 AC_HEADER_SYS_WAIT
1529 AC_CHECK_HEADERS(stdarg.h string.h fcntl.h limits.h sys/file.h sys/ioctl.h syslog.h unistd.h netinet/tcpip.h netinet/in.h netinet/ip.h netinet/ip_icmp.h net/if.h netdb.h sys/dmap.h machine/pte.h xti.h sys/sockio.h sys/socket.h sys/un.h fstab.h sys/fs.h mtab.h ufs/fs.h ufs/ffs/fs.h sys/fixpoint.h machine/param.h sys/vm.h vm/vm.h sys/vmmeter.h sys/vmparam.h sys/vmmac.h sys/vmsystm.h sys/mbuf.h sys/time.h sys/swap.h inet/mib2.h sys/statvfs.h sys/vfs.h sys/mnttab.h sys/user.h sys/proc.h sys/select.h mntent.h sys/mntent.h kstat.h utsname.h sys/utsname.h sys/cdefs.h getopt.h locale.h pthread.h sys/loadavg.h regex.h linux/tasks.h pwd.h grp.h utmpx.h)
1530 dnl FreeBSD required headers
1531 AC_CHECK_HEADERS(malloc.h sys/param.h net/if_dl.h sys/sysctl.h stdlib.h net/if_mib.h net/if_types.h net/if_var.h sys/queue.h osreldate.h machine/types.h sys/socketvar.h)
1532 dnl Linux
1533 AC_CHECK_HEADERS(sys/conf.h netinet/in_systm.h netinet/tcp.h netinet/udp.h netinet/in_var.h netinet/if_ether.h netinet/ip_var.h netinet/tcp_timer.h netinet/tcp_var.h netinet/tcp_fsm.h netinet/udp_var.h netinet/icmp_var.h sys/protosw.h nlist.h ioctls.h asm/page.h netipx/ipx.h)
1534 dnl NetBSD required headers
1535 AC_CHECK_HEADERS(arpa/inet.h kvm.h sys/pool.h uvm/uvm_param.h uvm/uvm_extern.h vm/vm_param.h vm/vm_extern.h)
1536 dnl BSDi2 headers
1537 AC_CHECK_HEADERS(sys/mount.h vm/swap_pager.h ufs/ufs/dinode.h)
1538 dnl BSDi3 headers
1539 AC_CHECK_HEADERS(sys/stat.h sys/vnode.h ufs/ufs/quota.h ufs/ufs/inode.h)
1540 dnl irix headers
1541 AC_CHECK_HEADERS(sys/hashing.h sys/tcpipstats.h sys/sysmp.h)
1542 dnl from smux stuff
1543 AC_CHECK_HEADERS(err.h sys/filio.h sgtty.h)
1544 dnl AIX needs this for statfs func
1545 AC_CHECK_HEADERS(sys/statfs.h)
1546 dnl Dynix
1547 AC_CHECK_HEADERS(net/route.h)
1548 dnl for HostRes (HP-UX at least)
1549 AC_CHECK_HEADERS(sys/dkio.h sys/diskio.h sys/pstat.h linux/hdreg.h pkglocs.h)
1550 dnl for HostRes (Solaris 2.x at least)
1551 AC_CHECK_HEADERS(pkginfo.h,
1552     AC_CHECK_LIB(adm, pkginfo, AC_DEFINE(HAVE_PKGINFO)
1553     LIBS="${LIBS} -ladm"
1554     AGENTLIBS="${AGENTLIBS} -ladm"))
1555 dnl WIN32
1556 AC_CHECK_HEADERS(winsock.h, AGENTLIBS="${AGENTLIBS} -liphlpapi")
1557 AC_CHECK_HEADERS(io.h)
1558 dnl SCO
1559 AC_CHECK_HEADERS(sys/stream.h)
1560 dnl KAME
1561 AC_CHECK_HEADERS(netinet/ip6.h netinet6/in6_var.h netinet6/in6_pcb.h netinet6/ip6_var.h netinet6/tcp6.h netinet6/tcp6_fsm.h netinet6/nd6.h netinet6/tcp6_timer.h netinet6/tcp6_var.h)
1562 dnl DYNAMIC MODULE SUPPORT
1563 AC_CHECK_HEADERS(dlfcn.h)
1564 dnl table_array helper support
1565 AC_CHECK_HEADERS(search.h)
1566
1567 dnl RPM subdirectory path (sigh)
1568 if echo " $module_list " | grep " host/hr_swinst " > /dev/null; then
1569   AC_CHECK_HEADERS(rpmio.h,, [
1570      AC_CHECK_HEADERS(rpm/rpmio.h, CFLAGS="-I/usr/include/rpm $CFLAGS")
1571   ])
1572 fi
1573
1574 dnl OpenBSD 2.6 needs netinet/in.h before netinet/in_pcb.h
1575 AC_MSG_CHECKING([for netinet/in_pcb.h])
1576 AC_CACHE_VAL(cv_have_netinet_in_pcb_h,
1577 [ AC_TRY_CPP( [
1578 #include <netinet/in.h>
1579 #include <netinet/in_pcb.h>
1580 ], cv_have_netinet_in_pcb_h=yes, cv_have_netinet_in_pcb_h=no)])
1581 AC_MSG_RESULT($cv_have_netinet_in_pcb_h)
1582 if test $cv_have_netinet_in_pcb_h = yes; then
1583   AC_DEFINE(HAVE_NETINET_IN_PCB_H)
1584 fi
1585
1586 dnl NetBSD needs machine/types.h before sys/disklabel.h
1587 AC_MSG_CHECKING([for sys/disklabel.h])
1588 AC_CACHE_VAL(cv_have_sys_disklabel_h,
1589 [ AC_TRY_CPP( [
1590 #include <machine/types.h>
1591 #include <sys/disklabel.h>
1592 ], cv_have_sys_disklabel_h=yes, cv_have_sys_disklabel_h=no)])
1593 AC_MSG_RESULT($cv_have_sys_disklabel_h)
1594 if test $cv_have_sys_disklabel_h = yes; then
1595   AC_DEFINE(HAVE_SYS_DISKLABEL_H)
1596 fi
1597
1598 dnl OpenSSL
1599 AC_CHECK_HEADERS(openssl/hmac.h openssl/evp.h openssl/aes.h openssl/des.h)
1600
1601 dnl Printing
1602 AC_PATH_PROG(LPSTAT_PATH,lpstat)
1603 if test x$LPSTAT_PATH != x; then
1604     AC_DEFINE_UNQUOTED(LPSTAT_PATH,"$LPSTAT_PATH")
1605     AC_DEFINE(HAVE_LPSTAT)
1606 fi
1607 AC_CHECK_FUNCS(cgetnext)
1608 if test -r /etc/printcap; then
1609     AC_DEFINE(HAVE_PRINTCAP)
1610 fi
1611
1612 AC_MSG_CHECKING(for authentication support)
1613 if test "x$ac_cv_lib_crypto_EVP_md5" != "xyes" -o "x$ac_cv_header_openssl_hmac_h" != "xyes" -o "x$ac_cv_header_openssl_hmac_h" != "xyes"; then
1614 dnl if OpenSSL is not found, default to using internal md5 support.
1615     AC_DEFINE(USE_INTERNAL_MD5)
1616     authmodes="MD5"
1617     encrmodes=""
1618     AC_MSG_RESULT(Internal MD5 Support)
1619     if test "x$askedopenssl" = "xyes"; then
1620         AC_MSG_ERROR(Asked to use OpenSSL but I couldn't find it.)
1621     fi
1622 else
1623     if test "x$tryopenssl" = "xno"; then
1624         authmodes="MD5"
1625         encrmodes=""
1626         AC_DEFINE(USE_INTERNAL_MD5)
1627         AC_MSG_RESULT(Internal MD5 Support)
1628     else
1629         authmodes="MD5 SHA1"
1630         if test $ac_cv_header_openssl_aes_h = "yes" ; then
1631             encrmodes="DES AES128 AES192 AES256"
1632         else
1633             encrmodes="DES"
1634         fi
1635         AC_DEFINE(USE_OPENSSL)
1636         AC_MSG_RESULT(OpenSSL Support)
1637     fi
1638 fi
1639
1640 AC_MSG_CACHE_ADD(Authentication support:     $authmodes)
1641 AC_MSG_CACHE_ADD(Encryption support:         $encrmodes)
1642
1643 dnl Checks for typedefs, structures, and compiler characteristics.
1644 AC_TYPE_OFF_T
1645 AC_TYPE_PID_T
1646 AC_HEADER_TIME
1647
1648 dnl this should use AC_CHECK_TYPE, but it's broken at least in 2.13-14
1649 dnl so we do it by hand.
1650 AC_MSG_CHECKING(for socklen_t)
1651 AC_CACHE_VAL(ac_cv_type_$1,
1652 [AC_EGREP_CPP(dnl
1653 changequote(<<,>>)dnl
1654 <<socklen_t[^a-zA-Z_0-9]>>dnl
1655 changequote([,]), [#include <sys/types.h>
1656 #if STDC_HEADERS
1657 #include <stdlib.h>
1658 #include <stddef.h>
1659 #endif
1660 #ifdef HAVE_SYS_SOCKET_H
1661 #include <sys/socket.h>
1662 #endif], ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no)])dnl
1663
1664 AC_MSG_RESULT($ac_cv_type_socklen_t)
1665 if test $ac_cv_type_socklen_t = yes; then
1666   AC_DEFINE(HAVE_SOCKLEN_T)
1667 fi
1668
1669 dnl AIX keeps in_addr_t in /usr/include/netinet/in.h
1670 AC_MSG_CHECKING(for in_addr_t)
1671 AC_CACHE_VAL(ac_cv_type_$1,
1672 [AC_EGREP_CPP(dnl
1673 changequote(<<,>>)dnl
1674 <<in_addr_t[^a-zA-Z_0-9]>>dnl
1675 changequote([,]), [#include <sys/types.h>
1676 #if STDC_HEADERS
1677 #include <stdlib.h>
1678 #include <stddef.h>
1679 #endif
1680 #ifdef HAVE_NETINET_IN_H
1681 #include <netinet/in.h>
1682 #endif], ac_cv_type_in_addr_t=yes, ac_cv_type_in_addr_t=no)])dnl
1683
1684 AC_MSG_RESULT($ac_cv_type_in_addr_t)
1685 if test $ac_cv_type_in_addr_t = yes; then
1686   AC_DEFINE(HAVE_IN_ADDR_T)
1687 fi
1688
1689 dnl Check ps args
1690 AC_CACHE_CHECK(for correct flags to ps, ac_cv_ps_flags,
1691 [if test "`($PSPROG -e 2>&1) | egrep ' (ps) *$' | awk '{print $NF}'`" = "ps" ; then
1692   ac_cv_ps_flags="-e"
1693 elif test "`($PSPROG -el 2>&1) | egrep ' (ps) *$' | awk '{print $NF}'`" = "ps" ; then
1694   ac_cv_ps_flags="-el"
1695 elif test "`($PSPROG acx 2>&1) | egrep ' (ps) *$' | awk '{print $NF}'`" = "ps" ; then
1696   ac_cv_ps_flags="acx"
1697 elif test "`($PSPROG -acx 2>&1) | egrep ' (ps) *$' | awk '{print $NF}'`" = "ps" ; then
1698   ac_cv_ps_flags="-acx"
1699 elif test "`($PSPROG -o pid,tt,state,time,ucomm 2>&1) | egrep ' ps *$' | awk '{print $NF}'`" = "ps" ; then
1700   ac_cv_ps_flags="-o pid,tt,state,time,ucomm"
1701 elif test "`($PSPROG ax 2>&1) | egrep ' (ps) *$' | awk '{print $NF}'`" = "ps" ; then
1702   ac_cv_ps_flags="ax"
1703 else
1704   AC_MSG_WARN(Unable to determine valid ps flags...  defaulting...)
1705   ac_cv_ps_flags="-acx"
1706 fi
1707 ])
1708
1709 PSCMD="$PSPROG $ac_cv_ps_flags"
1710 AC_SUBST(PSCMD)
1711 AC_DEFINE_UNQUOTED(PSCMD, "$PSPROG $ac_cv_ps_flags")
1712
1713 dnl Checks for byte order
1714 if test $cross_compiling = yes; then
1715   if test $with_endianness = "big"; then
1716     AC_DEFINE(WORDS_BIGENDIAN)
1717   elif test -z $with_endianness; then
1718     AC_MSG_ERROR([You are cross-compiling, but you have not specified the target's endianness])
1719   fi
1720 else
1721   if test $with_endianness; then
1722     AC_MSG_ERROR([Endianness has been specified, but you are not cross-compiling.])
1723   fi
1724   AC_C_BIGENDIAN
1725 fi
1726
1727 dnl Checks for library functions.
1728 AC_FUNC_ALLOCA
1729 AC_PROG_GCC_TRADITIONAL
1730 AC_FUNC_MEMCMP
1731 AC_TYPE_SIGNAL
1732 AC_FUNC_GETMNTENT
1733 AC_CHECK_FUNCS(setmntent gethostname uname gettimeofday select socket strtol strtoul)
1734 AC_CHECK_FUNCS(strchr strdup memcpy memmove index bcopy strcasestr regcomp)
1735 AC_CHECK_FUNCS(signal setsid sigset sigblock sighold strerror setenv vsnprintf snprintf)
1736 AC_CHECK_FUNCS(sigaction)
1737 AC_CHECK_FUNCS(snprintf strtoul)
1738 AC_CHECK_FUNCS(random lrand48 rand)
1739 AC_CHECK_FUNCS(execv system fork getpid strncasecmp sigalrm)
1740 if echo " $module_list " | grep " host/hr_swinst " > /dev/null; then
1741   OLDLIBS=$LIBS
1742   LIBS=$AGENTLIBS
1743   AC_CHECK_FUNCS(rpmGetPath)
1744   LIBS=$OLDLIBS
1745 fi
1746
1747 AC_CHECK_FUNCS(getloadavg)
1748 AC_CHECK_FUNCS(getaddrinfo getipnodebyname)
1749 dnl BSDi2 functions differ
1750 AC_CHECK_FUNCS(statvfs statfs)
1751 AC_CHECK_FUNCS(getdtablesize)
1752 dnl freebsd2 checks
1753 AC_CHECK_FUNCS(getfsstat)
1754 AC_CHECK_FUNCS(usleep)
1755 AC_CHECK_FUNCS(setlocale)
1756 AC_CHECK_FUNCS(tcgetattr)
1757 AC_CHECK_FUNCS(if_nameindex if_freenameindex)
1758 dnl solaris checks
1759 AC_CHECK_FUNCS(getpagesize)
1760 AC_CHECK_FUNCS(mkstemp)
1761 AC_CHECK_FUNCS(getpwnam getgrnam setgid setuid setgroups)
1762 dnl High resolution alarm support
1763 AC_CHECK_FUNCS(setitimer)
1764
1765 AC_MSG_CHECKING([for SIOCGIFADDR in sys/ioctl.h])
1766 AC_CACHE_VAL(cv_sys_ioctl_h_has_SIOCGIFADDR,
1767 [ AC_EGREP_CPP(xxxyesxxx,
1768 [
1769 #ifdef HAVE_SYS_IOCTL_H
1770 #include <sys/ioctl.h>
1771 #endif
1772 #ifdef SIOCGIFADDR
1773 xxxyesxxx
1774 #endif
1775 ], cv_sys_ioctl_h_has_SIOCGIFADDR=yes, cv_sys_ioctl_h_has_SIOCGIFADDR=no)])
1776 AC_MSG_RESULT($cv_sys_ioctl_h_has_SIOCGIFADDR)
1777 if test $cv_sys_ioctl_h_has_SIOCGIFADDR = yes; then
1778   AC_DEFINE(SYS_IOCTL_H_HAS_SIOCGIFADDR)
1779 fi
1780
1781 # ultrix
1782 AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
1783 AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
1784 [AC_TRY_RUN([
1785 #ifdef HAVE_SYS_PARAM_H
1786 #include <sys/param.h>
1787 #endif
1788 #include <sys/types.h>
1789 #ifdef HAVE_SYS_MOUNT_H
1790 #include <sys/mount.h>
1791 #endif
1792 #ifdef HAVE_SYS_FS_TYPES_H
1793 #include <sys/fs_types.h>
1794 #endif
1795 main ()
1796 {
1797 struct fs_data fsd;
1798 /* Ultrix's statfs returns 1 for success,
1799    0 for not mounted, -1 for failure.  */
1800 exit (statfs (".", &fsd) != 1);
1801 }],
1802 fu_cv_sys_stat_fs_data=yes,
1803 fu_cv_sys_stat_fs_data=no,
1804 fu_cv_sys_stat_fs_data=no)])
1805 AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
1806 if test $fu_cv_sys_stat_fs_data = yes; then
1807   AC_DEFINE(STAT_STATFS_FS_DATA)
1808 fi
1809
1810 dnl check if compiler pre-processor defines __FUNCTION__
1811 AC_CACHE_CHECK(if __FUNCTION__ is defined,ac_cv_HAVE_CPP_UNDERBAR_FUNCTION_DEFINED,
1812 [
1813 AC_TRY_COMPILE(,[
1814     char *cp = __FUNCTION__;
1815 ], ac_cv_HAVE_CPP_UNDERBAR_FUNCTION_DEFINED=yes, ac_cv_HAVE_CPP_UNDERBAR_FUNCTION_DEFINED=no)])
1816
1817 if test "x$ac_cv_HAVE_CPP_UNDERBAR_FUNCTION_DEFINED" = "xyes"; then
1818   AC_DEFINE(HAVE_CPP_UNDERBAR_FUNCTION_DEFINED)
1819 fi
1820
1821 AC_CHECK_STRUCT_FOR([
1822 #ifdef HAVE_SYS_PARAM_H
1823 #include <sys/param.h>
1824 #endif
1825 #include <sys/types.h>
1826 #include <sys/signal.h>
1827 ], sigaction, sa_sigaction, no)
1828
1829 AC_CHECK_STRUCT_FOR([
1830 #ifdef HAVE_SYS_PARAM_H
1831 #include <sys/param.h>
1832 #endif
1833 #include <sys/types.h>
1834 #define KERNEL
1835 #define _KERNEL
1836 #include <sys/socket.h>
1837 #undef KERNEL
1838 #undef _KERNEL
1839 ], sockaddr, sa_len, no)
1840
1841 AC_CHECK_STRUCT_FOR([
1842 #ifdef HAVE_SYS_PARAM_H
1843 #include <sys/param.h>
1844 #endif
1845 #include <sys/types.h>
1846 #define KERNEL
1847 #define _KERNEL
1848 #include <sys/socket.h>
1849 #undef KERNEL
1850 #undef _KERNEL
1851 ], sockaddr, sa_union.sa_generic.sa_family2, no)
1852
1853 AC_CHECK_STRUCT_FOR([
1854 #ifdef HAVE_SYS_PARAM_H
1855 #include <sys/param.h>
1856 #endif
1857 #include <sys/types.h>
1858 #define KERNEL
1859 #define _KERNEL
1860 #include <sys/socket.h>
1861 #undef KERNEL
1862 #undef _KERNEL
1863 #include <net/route.h>
1864 ], rtentry, rt_dst, no)
1865
1866 dnl checking for 4.3 vs 4.4 rtentry.
1867 AC_CACHE_CHECK(type of rtentry structure,ac_cv_RTENTRY_TYPE,
1868 [
1869
1870 dnl 4.4 compat
1871 AC_TRY_COMPILE([
1872 #ifdef HAVE_SYS_PARAM_H
1873 #include <sys/param.h>
1874 #endif
1875 #include <sys/types.h>
1876 #define KERNEL
1877 #define _KERNEL
1878 #include <sys/socket.h>
1879 #undef KERNEL
1880 #undef _KERNEL
1881 #include <net/route.h>
1882 ],[
1883
1884 #ifndef STRUCT_RTENTRY_HAS_RT_DST
1885 #define rt_dst rt_nodes->rn_key
1886 #endif
1887
1888   struct rtentry rt; 
1889   rt.rt_nodes[0].rn_flags = 1;
1890   rt.rt_dst;
1891   ], ac_cv_RTENTRY_TYPE="BSD-4.4")
1892
1893 dnl 4.3 compat
1894 if test "x$ac_cv_RTENTRY_TYPE" = "x"; then
1895 AC_TRY_COMPILE([
1896 #ifdef HAVE_SYS_PARAM_H
1897 #include <sys/param.h>
1898 #endif
1899 #include <sys/types.h>
1900 #define KERNEL
1901 #define _KERNEL
1902 #include <sys/socket.h>
1903 #undef KERNEL
1904 #undef _KERNEL
1905 #include <net/route.h>
1906 ],[
1907 struct rtentry rt; 
1908 rt.rt_hash;
1909 ], ac_cv_RTENTRY_TYPE="BSD-4.3")
1910 fi
1911
1912 dnl else ack.
1913 if test "x$ac_cv_RTENTRY_TYPE" = "x"; then
1914   AC_MSG_RESULT(Unknown)
1915   ac_cv_RTENTRY_TYPE="unknown"
1916 fi
1917
1918 ])
1919
1920 if test "x$ac_cv_RTENTRY_TYPE" = "xBSD-4.4"; then
1921   AC_DEFINE(RTENTRY_4_4)
1922 fi
1923
1924 dnl checking for alpha's ortentry vs rtentry
1925 if test "x$ac_cv_RTENTRY_TYPE" = "xunknown"; then
1926 AC_CACHE_CHECK(for struct rtentry, ac_cv_struct_rtentry,
1927 [AC_EGREP_CPP(ortentry, [#define KERNEL
1928 #include <net/route.h>
1929 ],  ac_cv_struct_rtentry=ortentry,  ac_cv_struct_rtentry=rtentry )
1930 if test "x$ac_cv_struct_rtentry" = "xrtentry" ; then
1931   ac_cv_struct_rtentry="rtentry"
1932 else
1933   ac_cv_struct_rtentry="ortentry"
1934 fi
1935 ])
1936 else
1937   RTENTRY_TYPE="rtentry"
1938   ac_cv_struct_rtentry="rtentry"
1939 fi
1940
1941 if test "x$ac_cv_struct_rtentry" != "x"; then
1942   AC_DEFINE_UNQUOTED(RTENTRY,struct ${ac_cv_struct_rtentry})
1943 else
1944   AC_DEFINE(RTENTRY,struct rtentry)
1945 fi
1946
1947 dnl check for 4.3's rtentry->rt_next
1948 if test "x$ac_cv_RTENTRY_TYPE" = "xBSD-4.3"; then
1949 AC_CACHE_CHECK(for struct rtentry has a rt_next node, 
1950         ac_cv_struct_rtentry_rt_next,
1951 [
1952 AC_TRY_COMPILE([
1953 #ifdef HAVE_SYS_PARAM_H
1954 #include <sys/param.h>
1955 #endif
1956 #include <sys/types.h>
1957 #define KERNEL
1958 #define _KERNEL
1959 #include <sys/socket.h>
1960 #undef KERNEL
1961 #undef _KERNEL
1962 #include <net/route.h>
1963 ],[
1964 struct rtentry rt; 
1965 rt.rt_next;
1966 ], ac_cv_struct_rtentry_rt_next=yes,  ac_cv_struct_rtentry_rt_next=no )
1967 ])
1968
1969 if test "x$ac_cv_struct_rtentry_rt_next" = "xyes"; then
1970   AC_DEFINE(RTENTRY_RT_NEXT)
1971 fi
1972
1973 fi
1974
1975 dnl Check struct rtentry for various things.
1976 AC_CHECK_STRUCT_FOR([
1977 #ifdef HAVE_SYS_PARAM_H
1978 #include <sys/param.h>
1979 #endif
1980 #include <sys/types.h>
1981 #define KERNEL
1982 #define _KERNEL
1983 #include <sys/socket.h>
1984 #undef KERNEL
1985 #undef _KERNEL
1986 #include <net/route.h>
1987 ], rtentry, rt_unit)
1988
1989 AC_CHECK_STRUCT_FOR([
1990 #ifdef HAVE_SYS_PARAM_H
1991 #include <sys/param.h>
1992 #endif
1993 #include <sys/types.h>
1994 #define KERNEL
1995 #define _KERNEL
1996 #include <sys/socket.h>
1997 #undef KERNEL
1998 #undef _KERNEL
1999 #include <net/route.h>
2000 ], rtentry, rt_refcnt)
2001
2002 AC_CHECK_STRUCT_FOR([
2003 #ifdef HAVE_SYS_PARAM_H
2004 #include <sys/param.h>
2005 #endif
2006 #include <sys/types.h>
2007 #define KERNEL
2008 #define _KERNEL
2009 #include <sys/socket.h>
2010 #undef KERNEL
2011 #undef _KERNEL
2012 #include <net/route.h>
2013 ], rtentry, rt_hash)
2014
2015 AC_CHECK_STRUCT_FOR([
2016 #ifdef HAVE_SYS_PARAM_H
2017 #include <sys/param.h>
2018 #endif
2019 #include <sys/types.h>
2020 #define KERNEL
2021 #define _KERNEL
2022 #include <sys/socket.h>
2023 #undef KERNEL
2024 #undef _KERNEL
2025 #include <net/route.h>
2026 ], rtentry, rt_use)
2027
2028 dnl Check tcpstat for tcpstat.tcp_rcvmemdrop
2029 AC_CHECK_STRUCT_FOR([
2030 #ifdef HAVE_SYS_PARAM_H
2031 #include <sys/param.h>
2032 #endif
2033 #include <sys/types.h>
2034 #include <netinet/tcp.h>
2035 #ifdef HAVE_NETINET_TCP_TIMER_H
2036 #include <netinet/tcp_timer.h>
2037 #endif
2038
2039 #ifdef HAVE_NETINET_TCP_VAR_H
2040 #include <netinet/tcp_var.h>
2041 #endif
2042 ], tcpstat, tcp_rcvmemdrop)
2043
2044 dnl irix checks
2045
2046 AC_CHECK_STRUCT_FOR([
2047 #ifdef HAVE_SYS_PARAM_H
2048 #include <sys/param.h>
2049 #endif
2050 #include <sys/types.h>
2051 #include <sys/socket.h>
2052 #include <net/if.h>
2053 #ifdef HAVE_NET_IF_VAR_H
2054 #include <net/if_var.h>
2055 #endif
2056 ], ifnet, if_mtu)
2057
2058 if test "x$ac_cv_struct_ifnet_has_if_mtu" = "xno"; then
2059 AC_CACHE_CHECK(if _KERNEL needs to be defined for if_mtu, ac_cv_IFNET_NEEDS_KERNEL,
2060 [
2061 if test "x$ac_cv_struct_ifnet_has_if_mtu" = "xyes"; then
2062   ac_cv_IFNET_NEEDS_KERNEL=no
2063 else
2064 AC_TRY_COMPILE([
2065 #define _KERNEL 1
2066 #ifdef HAVE_SYS_PARAM_H
2067 #include <sys/param.h>
2068 #endif
2069 #include <sys/types.h>
2070 #include <sys/socket.h>
2071 #ifdef HAVE_SYS_TIME_H
2072 #include <sys/time.h>
2073 #endif
2074 #include <net/if.h>
2075 #ifdef HAVE_NET_IF_VAR_H
2076 #include <net/if_var.h>
2077 #endif
2078 ],[
2079 struct ifnet testit;
2080 testit.if_mtu = 0;
2081 ], ac_cv_IFNET_NEEDS_KERNEL=yes, ac_cv_IFNET_NEEDS_KERNEL=no)
2082 fi
2083 ])
2084
2085 if test "x$ac_cv_IFNET_NEEDS_KERNEL" = "xyes"; then
2086   AC_DEFINE(IFNET_NEEDS_KERNEL)
2087 fi
2088 fi
2089
2090 AC_CHECK_STRUCT_FOR([
2091 #ifdef IFNET_NEEDS_KERNEL
2092 #define _KERNEL 1
2093 #endif
2094 #ifdef HAVE_SYS_PARAM_H
2095 #include <sys/param.h>
2096 #endif
2097 #include <sys/types.h>
2098 #include <sys/socket.h>
2099 #ifdef HAVE_SYS_TIME_H
2100 #include <sys/time.h>
2101 #endif
2102 #include <net/if.h>
2103 #ifdef HAVE_NET_IF_VAR_H
2104 #include <net/if_var.h>
2105 #endif
2106 ], ifaddr, ifa_next)
2107
2108 dnl Check ifnet entries using macro defined in aclocal.m4.
2109 dnl
2110 dnl XXX  Broken on FreeBSD where these are #define'd in <net/if.h>
2111 dnl
2112 AC_CHECK_IFNET_FOR(if_baudrate)
2113 AC_CHECK_IFNET_FOR(if_baudrate.ifs_value)
2114 AC_CHECK_IFNET_FOR(if_speed)
2115 AC_CHECK_IFNET_FOR(if_type)
2116 AC_CHECK_IFNET_FOR(if_imcasts)
2117 AC_CHECK_IFNET_FOR(if_iqdrops)
2118 AC_CHECK_IFNET_FOR(if_noproto)
2119 AC_CHECK_IFNET_FOR(if_omcasts)
2120 AC_CHECK_IFNET_FOR(if_xname,no)
2121 AC_CHECK_IFNET_FOR(if_lastchange.tv_sec)
2122 AC_CHECK_IFNET_FOR(if_obytes)
2123 AC_CHECK_IFNET_FOR(if_ibytes)
2124 AC_CHECK_IFNET_FOR(if_addrlist)
2125 AC_CHECK_IFNET_FOR(if_addrhead.tqh_first)
2126
2127 AC_CHECK_STRUCT_FOR([
2128 #include <sys/types.h>
2129 #if HAVE_NETINET_IN_H
2130 #include <netinet/in.h>
2131 #endif
2132 #if HAVE_NETINET_IP_VAR_H
2133 #include <netinet/ip_var.h>
2134 #endif
2135 #if HAVE_NETINET_UDP_H
2136 #include <netinet/udp.h>
2137 #endif
2138 #if HAVE_NETINET_UDP_VAR_H
2139 #include <netinet/udp_var.h>
2140 #endif
2141 ],udpstat,udps_discard)
2142
2143 AC_CHECK_STRUCT_FOR([
2144 #include <sys/types.h>
2145 #if HAVE_NETINET_IN_H
2146 #include <netinet/in.h>
2147 #endif
2148 #if HAVE_NETINET_IP_VAR_H
2149 #include <netinet/ip_var.h>
2150 #endif
2151 #if HAVE_NETINET_UDP_H
2152 #include <netinet/udp.h>
2153 #endif
2154 #if HAVE_NETINET_UDP_VAR_H
2155 #include <netinet/udp_var.h>
2156 #endif
2157 ],udpstat,udps_noport)
2158
2159 AC_CHECK_STRUCT_FOR([
2160 #include <sys/types.h>
2161 #if HAVE_NETINET_IN_H
2162 #include <netinet/in.h>
2163 #endif
2164 #if HAVE_NETINET_IP_VAR_H
2165 #include <netinet/ip_var.h>
2166 #endif
2167 #if HAVE_NETINET_UDP_H
2168 #include <netinet/udp.h>
2169 #endif
2170 #if HAVE_NETINET_UDP_VAR_H
2171 #include <netinet/udp_var.h>
2172 #endif
2173 ],udpstat,udps_noportbcast)
2174
2175 AC_CHECK_STRUCT_FOR([
2176 #include <sys/types.h>
2177 #if HAVE_NETINET_IN_H
2178 #include <netinet/in.h>
2179 #endif
2180 #if HAVE_NETINET_IP_VAR_H
2181 #include <netinet/ip_var.h>
2182 #endif
2183 #if HAVE_NETINET_UDP_H
2184 #include <netinet/udp.h>
2185 #endif
2186 #if HAVE_NETINET_UDP_VAR_H
2187 #include <netinet/udp_var.h>
2188 #endif
2189 ],udpstat,udps_fullsock)
2190
2191 AC_CHECK_STRUCT_FOR([
2192 #ifdef HAVE_SYS_PARAM_H
2193 #include <sys/param.h>
2194 #endif
2195 #include <sys/types.h>
2196 #include <sys/socket.h>
2197 #ifdef HAVE_SYS_TIME_H
2198 #include <sys/time.h>
2199 #endif
2200 #include <net/if.h>
2201 #if HAVE_NETINET_IN_H
2202 #include <netinet/in.h>
2203 #endif
2204 #if HAVE_NETINET_IF_ETHER_H
2205 #include <netinet/if_ether.h>
2206 #endif
2207 ],arphd,at_next)
2208
2209 AC_CHECK_STRUCT_FOR([
2210 #if HAVE_SYS_CONF_H
2211 #include <sys/conf.h>
2212 #endif
2213 ],swdevt,sw_nblksenabled)
2214
2215 AC_CHECK_STRUCT_FOR([
2216 #ifdef HAVE_SYS_STAT_H
2217 #include <sys/stat.h>
2218 #endif
2219 #if HAVE_SYS_STATFS_H
2220 #include <sys/statfs.h>
2221 #endif
2222 #if HAVE_SYS_STATVFS_H
2223 #include <sys/statvfs.h>
2224 #endif
2225 ],statvfs,f_frsize)
2226
2227 AC_CHECK_STRUCT_FOR([
2228 #ifdef HAVE_SYS_STAT_H
2229 #include <sys/stat.h>
2230 #endif
2231 #if HAVE_SYS_STATFS_H
2232 #include <sys/statfs.h>
2233 #endif
2234 #if HAVE_SYS_STATVFS_H
2235 #include <sys/statvfs.h>
2236 #endif
2237 ],statvfs,f_files)
2238
2239 AC_CHECK_STRUCT_FOR([
2240 #ifdef HAVE_SYS_STAT_H
2241 #include <sys/stat.h>
2242 #endif
2243 #if HAVE_SYS_STATFS_H
2244 #include <sys/statfs.h>
2245 #endif
2246 #ifdef HAVE_SYS_PARAM_H
2247 #include <sys/param.h>
2248 #include <sys/types.h>
2249 #endif
2250 #ifdef HAVE_SYS_MOUNT_H
2251 #include <sys/mount.h>
2252 #endif
2253 ],statfs,f_files)
2254
2255 AC_CHECK_STRUCT_FOR([
2256 #ifdef HAVE_SYS_STAT_H
2257 #include <sys/stat.h>
2258 #endif
2259 #if HAVE_SYS_STATFS_H
2260 #include <sys/statfs.h>
2261 #endif
2262 #ifdef HAVE_SYS_PARAM_H
2263 #include <sys/param.h>
2264 #include <sys/types.h>
2265 #endif
2266 #ifdef HAVE_SYS_MOUNT_H
2267 #include <sys/mount.h>
2268 #endif
2269 ],statfs,f_ffree)
2270
2271 AC_CHECK_STRUCT_FOR([
2272 #ifdef HAVE_SYS_STAT_H
2273 #include <sys/stat.h>
2274 #endif
2275 #if HAVE_SYS_STATFS_H
2276 #include <sys/statfs.h>
2277 #endif
2278 #ifdef HAVE_SYS_PARAM_H
2279 #include <sys/param.h>
2280 #include <sys/types.h>
2281 #endif
2282 #ifdef HAVE_SYS_MOUNT_H
2283 #include <sys/mount.h>
2284 #endif
2285 ],statfs,f_favail)
2286
2287 AC_CHECK_STRUCT_FOR([
2288 #if HAVE_NLIST_H
2289 #include <nlist.h>
2290 #endif
2291 ],nlist,n_value)
2292
2293 dnl check struct ipstat for various things
2294 AC_CHECK_STRUCT_FOR([
2295 #include <sys/types.h>
2296 #if HAVE_NETINET_IN_H
2297 #include <netinet/in.h>
2298 #endif
2299 #if HAVE_NETINET_IP_VAR_H
2300 #include <netinet/ip_var.h>
2301 #endif
2302 ], ipstat, ips_cantforward)
2303
2304 AC_CHECK_STRUCT_FOR([
2305 #include <sys/types.h>
2306 #if HAVE_NETINET_IN_H
2307 #include <netinet/in.h>
2308 #endif
2309 #if HAVE_NETINET_IP_VAR_H
2310 #include <netinet/ip_var.h>
2311 #endif
2312 ], ipstat, ips_cantfrag)
2313
2314 AC_CHECK_STRUCT_FOR([
2315 #include <sys/types.h>
2316 #if HAVE_NETINET_IN_H
2317 #include <netinet/in.h>
2318 #endif
2319 #if HAVE_NETINET_IP_VAR_H
2320 #include <netinet/ip_var.h>
2321 #endif
2322 ], ipstat, ips_delivered)
2323
2324 AC_CHECK_STRUCT_FOR([
2325 #include <sys/types.h>
2326 #if HAVE_NETINET_IN_H
2327 #include <netinet/in.h>
2328 #endif
2329 #if HAVE_NETINET_IP_VAR_H
2330 #include <netinet/ip_var.h>
2331 #endif
2332 ], ipstat, ips_fragdropped)
2333
2334 AC_CHECK_STRUCT_FOR([
2335 #include <sys/types.h>
2336 #if HAVE_NETINET_IN_H
2337 #include <netinet/in.h>
2338 #endif
2339 #if HAVE_NETINET_IP_VAR_H
2340 #include <netinet/ip_var.h>
2341 #endif
2342 ], ipstat, ips_fragtimeout)
2343
2344 AC_CHECK_STRUCT_FOR([
2345 #include <sys/types.h>
2346 #if HAVE_NETINET_IN_H
2347 #include <netinet/in.h>
2348 #endif
2349 #if HAVE_NETINET_IP_VAR_H
2350 #include <netinet/ip_var.h>
2351 #endif
2352 ], ipstat, ips_localout)
2353
2354 AC_CHECK_STRUCT_FOR([
2355 #include <sys/types.h>
2356 #if HAVE_NETINET_IN_H
2357 #include <netinet/in.h>
2358 #endif
2359 #if HAVE_NETINET_IP_VAR_H
2360 #include <netinet/ip_var.h>
2361 #endif
2362 ], ipstat, ips_noproto)
2363
2364 AC_CHECK_STRUCT_FOR([
2365 #include <sys/types.h>
2366 #if HAVE_NETINET_IN_H
2367 #include <netinet/in.h>
2368 #endif
2369 #if HAVE_NETINET_IP_VAR_H
2370 #include <netinet/ip_var.h>
2371 #endif
2372 ], ipstat, ips_noroute)
2373
2374 AC_CHECK_STRUCT_FOR([
2375 #include <sys/types.h>
2376 #if HAVE_NETINET_IN_H
2377 #include <netinet/in.h>
2378 #endif
2379 #if HAVE_NETINET_IP_VAR_H
2380 #include <netinet/ip_var.h>
2381 #endif
2382 ], ipstat, ips_odropped)
2383
2384 AC_CHECK_STRUCT_FOR([
2385 #include <sys/types.h>
2386 #if HAVE_NETINET_IN_H
2387 #include <netinet/in.h>
2388 #endif
2389 #if HAVE_NETINET_IP_VAR_H
2390 #include <netinet/ip_var.h>
2391 #endif
2392 ], ipstat, ips_ofragments)
2393
2394 AC_CHECK_STRUCT_FOR([
2395 #include <sys/types.h>
2396 #if HAVE_NETINET_IN_H
2397 #include <netinet/in.h>
2398 #endif
2399 #if HAVE_NETINET_IP_VAR_H
2400 #include <netinet/ip_var.h>
2401 #endif
2402 ], ipstat, ips_reassembled)
2403
2404 dnl check for the des_ks_struct.weak_key attribute, which indicates the 
2405 dnl older opensll version is being used.
2406 if test "x$ac_cv_header_openssl_des_h" = "xyes" ; then
2407 AC_CHECK_STRUCT_FOR([
2408 #include <openssl/des.h>
2409 ], des_ks_struct, weak_key)
2410 fi
2411
2412 dnl attempt to figure out if sysctl is usable
2413
2414 if test $cross_compiling = yes; then
2415   AC_MSG_WARN([Can't check sysctl, manually define CAN_USE_SYSCTL if platform support available])
2416 else
2417   AC_CACHE_CHECK(if sysctl can read kernel information,ac_cv_CAN_USE_SYSCTL,
2418   [AC_TRY_RUN([
2419 #if TIME_WITH_SYS_TIME
2420 # include <sys/time.h>
2421 # include <time.h>
2422 #else
2423 # if HAVE_SYS_TIME_H
2424 #  include <sys/time.h>
2425 # else
2426 #  include <time.h>
2427 # endif
2428 #endif
2429 #if HAVE_SYS_PARAM_H
2430 # include <sys/param.h>
2431 #endif
2432 #include <sys/types.h>
2433 #if HAVE_SYS_SYSCTL_H
2434 # include <sys/sysctl.h>
2435 #endif
2436
2437 main() {
2438   int                 mib[2];
2439   size_t              len;
2440   struct timeval boottime;
2441   
2442   mib[0] = CTL_KERN;
2443   mib[1] = KERN_BOOTTIME;
2444   
2445   len = sizeof(boottime);
2446   sysctl(mib, 2, &boottime, &len, NULL, NULL);
2447   if (boottime.tv_sec != 0)
2448     exit(0);
2449   else
2450     exit(1);
2451 }
2452   ], ac_cv_CAN_USE_SYSCTL=yes, ac_cv_CAN_USE_SYSCTL=no, ac_cv_CAN_USE_SYSCTL=no)])
2453 fi
2454
2455 if test "x$ac_cv_CAN_USE_SYSCTL" = "xyes"; then
2456   AC_DEFINE(CAN_USE_SYSCTL)
2457 fi
2458
2459 dnl
2460 dnl In FreeBSD 4.x, the TCP timer constants aren't.  They are defined
2461 dnl in terms of `hz', the kernel clock tick.  In this case,
2462 dnl we need to have a local variable `hz' in scope and set to a useful
2463 dnl value whenever we use one of these constants.
2464 dnl
2465 AC_CACHE_CHECK(whether TCP timers depend on \`hz',ac_cv_TCPTV_NEEDS_HZ,
2466 [AC_EGREP_CPP(hz,
2467 [#include <netinet/tcp_timer.h>
2468 TCPTV_SRTTDFLT
2469 ], ac_cv_TCPTV_NEEDS_HZ=yes, ac_cv_TCPTV_NEEDS_HZ=no)])
2470
2471 if test "x$ac_cv_TCPTV_NEEDS_HZ" = "xyes"; then
2472   AC_DEFINE(TCPTV_NEEDS_HZ)
2473 fi
2474
2475 dnl
2476 dnl define the agent libraries variable
2477 dnl
2478 AC_SUBST(AGENTLIBS)
2479 AC_SUBST(OTHERAGENTLIBOBJS)
2480 AC_SUBST(OTHERAGENTLIBLOBJS)
2481
2482 dnl
2483 dnl Prompt for various bits of user information
2484 dnl
2485
2486 if test "x$ac_cv_user_prompt_LOGFILE" = "x" -o "x$ac_cv_user_prompt_SYS_LOC" = "x" -o "x$ac_cv_user_prompt_SYS_CONTACT" = "x" -o "x$ac_cv_user_prompt_DEFAULT_SNMP_VERSION" = "x"; then
2487 AC_CACHE_CHECK(if you have run configure before, ac_cv_have_warned,
2488 [
2489 if test "x$defaults" = "xno"; then
2490 cat << EOF
2491
2492          ************** Configuration Section **************
2493
2494         You are about to be prompted with a series of questions.  Answer
2495 them carefully, as they determine how the SNMP agent and related
2496 applications are to function.
2497
2498         After the configure script finishes, you can browse the newly
2499 created config.h file for further - less important - parameters to
2500 modify.  Be careful if you re-run configure though, since config.h will
2501 be overwritten.
2502
2503 -Press return to continue-
2504 EOF
2505
2506 read tmpinput
2507 ac_cv_have_warned="yes"
2508 echo $ac_n "disabling above prompt for future runs...  $ac_c"
2509 else
2510   ac_cv_have_warned="no"
2511 fi
2512 ])
2513 else
2514   ac_cv_have_warned="yes"
2515 fi
2516
2517 ME=`$WHOAMI`
2518 if test -f /etc/resolv.conf; then
2519   LOC=`cat /etc/resolv.conf | grep '^domain' | tail -1 | awk '{print $NF}'`
2520 else
2521   LOC="@no.where"
2522 fi
2523
2524 AC_PROMPT_USER(DEFAULT_SNMP_VERSION,[
2525
2526 *** Default SNMP Version:
2527
2528         Starting with Net-SNMP 5.0, you can choose the default version of
2529 the SNMP protocol to use when no version is given explicitly on the
2530 command line, or via an 'snmp.conf' file.  In the past this was set to
2531 SNMPv1, but you can use this to switch to SNMPv3 if desired.  SNMPv3
2532 will provide a more secure management environment (and thus you're
2533 encouraged to switch to SNMPv3), but may break existing scripts that
2534 rely on the old behaviour.  (Though such scripts will probably need to
2535 be changed to use the '-c' community flag anyway, as the SNMPv1
2536 command line usage has changed as well.).
2537    At this prompt you can select \"1\", \"2\" (for SNMPv2c), or \"3\" as
2538 the default version for the command tools (snmpget, ...) to use.  This
2539 can always be overridden at runtime using the -v flag to the tools, or
2540 by using the \"defVersion\" token in your snmp.conf file.
2541
2542 Default version of SNMP to use],3,unquoted)
2543
2544 dnl we tested this above before the prompt, but the prompt may give a new value.
2545 if test "$ac_cv_user_prompt_DEFAULT_SNMP_VERSION" != "1" -a "$ac_cv_user_prompt_DEFAULT_SNMP_VERSION" != "2" -a "$ac_cv_user_prompt_DEFAULT_SNMP_VERSION" != "3"; then
2546   AC_MSG_ERROR([Illegal version number.  Only 1, 2 (for SNMPv2c) and 3 are supported.])
2547 fi
2548
2549 AC_PROMPT_USER(SYS_CONTACT,[
2550
2551 *** System Contact Information:
2552
2553         Describes who should be contacted about the host the agent is
2554 running on.  This information is available in the MIB-II tree.  This
2555 can also be over-ridden using the \"syscontact\" syntax in the agent's
2556 configuration files.
2557
2558 System Contact Information],$ME@$LOC,quoted)
2559
2560 AC_PROMPT_USER(SYS_LOC,[
2561
2562 *** System Location:
2563
2564         Describes the location of the system.  This information is
2565 available in the MIB-II tree.  this can also be over-ridden using the
2566 \"syslocation\" syntax in the agent's configuration files.
2567
2568 System Location],Unknown,quoted)
2569
2570 if test -d /var/log; then
2571   defaultlog="/var/log/snmpd.log"
2572 else
2573   defaultlog="/usr/adm/snmpd.log"
2574 fi
2575   
2576 AC_PROMPT_USER(LOGFILE,[
2577
2578 *** Logfile location:
2579
2580         Enter the default location for the snmpd agent to dump
2581 information & errors to.  If not defined (enter the keyword \"none\"
2582 at the prompt below) the agent will use stdout and stderr instead.
2583 (Note: This value can be over-ridden using command line options.)
2584
2585 Location to write logfile],$defaultlog,quoted)
2586
2587 if test -d /var; then
2588   defaultstore="/var/net-snmp"
2589   ucddefaultstore="/var/ucd-snmp"
2590 else
2591   defaultstore="/etc/net-snmp"
2592   ucddefaultstore="/etc/ucd-snmp"
2593 fi
2594   
2595 AC_PROMPT_USER(PERSISTENT_DIRECTORY,[
2596
2597 *** snmpd persistent storage location:
2598
2599         Enter a directory for the SNMP library to store persistent
2600 data in the form of a configuration file.  This default location is
2601 different than the old default location (which was for ucd-snmp).  If
2602 you stay with the new path, I'll ask you in a second if you wish to
2603 copy your files over to the new location (once only).  If you pick
2604 some other path than the default, you'll have to copy them yourself.
2605 There is nothing wrong with picking the old path ($ucddefaultstore) if
2606 you'd rather.
2607
2608 Location to write persistent information],$defaultstore,quoted)
2609
2610 PERSISTENT_DIRECTORY=$ac_cv_user_prompt_PERSISTENT_DIRECTORY
2611 AC_SUBST(PERSISTENT_DIRECTORY)
2612 UCDPERSISTENT_DIRECTORY=$ucddefaultstore
2613 AC_SUBST(UCDPERSISTENT_DIRECTORY)
2614
2615 if test $PERSISTENT_DIRECTORY = "$defaultstore" -a -d "$ucddefaultstore" -a ! -d "$defaultstore" ; then
2616 AC_CACHE_CHECK(If we should copy the old persistent directory, ac_cv_user_prompt_COPY_PERSISTENT_FILES,
2617 [
2618 AC_PROMPT_USER_NO_DEFINE(ac_cv_user_prompt_COPY_PERSISTENT_FILES,[
2619
2620 *** Copying old ucd-snmp persistent files to net-snmp persistent directory:
2621
2622         Would you like to copy the older ucd-snmp persistent files
2623 into your new net-snmp persistent file path?  This will functionally
2624 save all your ucd-snmp data and let it be used within the net-snmp
2625 tools.  This will only be done once when you run make install.  If you
2626 wish to do this, enter "yes" at the prompt.
2627
2628 Copy ucd-snmp data into the net-snmp data directory],"yes")
2629 ])
2630 else
2631 ac_cv_user_prompt_COPY_PERSISTENT_FILES="no"
2632 fi
2633 COPY_PERSISTENT_FILES="$ac_cv_user_prompt_COPY_PERSISTENT_FILES"
2634 AC_SUBST(COPY_PERSISTENT_FILES)
2635
2636 AC_SUBST(DLLIBS)
2637
2638 AC_OUTPUT([
2639  Makefile:Makefile.top:Makefile.in:Makefile.rules
2640  snmplib/Makefile:Makefile.top:snmplib/Makefile.in:Makefile.rules:snmplib/Makefile.depend
2641  apps/Makefile:Makefile.top:apps/Makefile.in:Makefile.rules:apps/Makefile.depend
2642  apps/snmpnetstat/Makefile:Makefile.top:apps/snmpnetstat/Makefile.in:Makefile.rules:apps/snmpnetstat/Makefile.depend
2643  agent/Makefile:Makefile.top:agent/Makefile.in:Makefile.rules:agent/Makefile.depend
2644  agent/helpers/Makefile:Makefile.top:agent/helpers/Makefile.in:Makefile.rules:agent/helpers/Makefile.depend
2645  agent/mibgroup/Makefile:Makefile.top:agent/mibgroup/Makefile.in:Makefile.rules:agent/mibgroup/Makefile.depend
2646  local/Makefile:Makefile.top:local/Makefile.in:Makefile.rules
2647  testing/Makefile:Makefile.top:testing/Makefile.in
2648  man/Makefile:Makefile.top:man/Makefile.in:Makefile.rules
2649  mibs/Makefile:Makefile.top:mibs/Makefile.in:Makefile.rules
2650  net-snmp-config:net-snmp-config.in
2651 ], echo timestamp > stamp-h)
2652
2653 AC_MSG_CACHE_DISPLAY()
2654
2655 dnl Local Variables:
2656 dnl mode: Autoconf
2657 dnl comment-start: "dnl"
2658 dnl End: