1OPENIPMI_PKG_NAME=OpenIPMI
2AC_INIT([OpenIPMI], [2.0.29], [minyard@acm.org], [OpenIPMI])
3AC_CANONICAL_TARGET
4AM_INIT_AUTOMAKE([-Wall])
5AC_CONFIG_HEADER([config.h])
6AM_PROG_AR
7
8AC_CONFIG_MACRO_DIR([m4])
9
10AC_SUBST(OPENIPMI_VERSION_MAJOR, 2)
11AC_SUBST(OPENIPMI_VERSION_MINOR, 0)
12AC_SUBST(OPENIPMI_VERSION_RELEASE, 29)
13AC_SUBST(OPENIPMI_VERSION_EXTRA, )
14
15
16OPENIPMI_SMI=false
17
18case $target_os in
19	linux*)
20		OPENIPMI_SMI=true
21		AC_DEFINE([HAVE_OPENIPMI_SMI], 1,
22			[Have Linux local interface])
23		;;
24
25	cygwin*)
26		AC_DEFINE([HAVE_CYGWIN_TARGET], 1, [Running on CYGWIN])
27		;;
28
29	solaris*)
30		# Some solaris systems have epoll, but it's too broken to use.
31		ax_cv_have_epoll_pwait=false
32		;;
33esac
34
35AM_CONDITIONAL([HAVE_OPENIPMI_SMI], [${OPENIPMI_SMI}])
36
37SNMPLIBS=
38
39# Where do we find the UCD SNMP includes and libs
40tryucdsnmp=yes
41AC_ARG_WITH(ucdsnmp,
42[  --with-ucdsnmp=PATH             Look for ucdsnmp in PATH.],
43    if test "x$withval" = "xyes"; then
44      tryucdsnmp=yes
45    elif test "x$withval" = "xno"; then
46      tryucdsnmp=no
47    elif test -d "$withval"; then
48      CPPFLAGS="-I$withval/include $CPPFLAGS"
49      SNMPLIBS="-L$withval/lib $SNMPLIBS"
50      tryucdsnmp=yes
51    fi,
52)
53
54AC_ARG_WITH(snmpflags,
55[  --with-snmpflags=flags          Set the flags to compile with SNMP.],
56    CPPFLAGS="$withval $CPPFLAGS"
57)
58
59AC_ARG_WITH(snmplibs,
60[  --with-snmplibs=libs            Set the libraries to link with SNMP.],
61    SNMPLIBS="$withval"
62)
63
64POPTCFLAGS=
65AC_ARG_WITH(poptflags,
66[  --with-poptflags=flags          Set the flags to compile with popt.],
67    CPPFLAGS="$withval $CPPFLAGS"
68)
69
70POPTCFLAGS=
71AC_ARG_WITH(poptlibs,
72[  --with-poptlibs=libs            Set the libraries to link with popt.],
73    POPTLIBS="$withval"
74)
75
76# If UCD SNMP requires OpenSSL, this tells where to find the crypto lib
77tryopenssl=yes
78AC_ARG_WITH(openssl,
79[  --with-openssl[[=yes|no|PATH]]    Look for openssl, with the optional path.],
80    if test "x$withval" = "xyes"; then
81      tryopenssl=yes
82    elif test "x$withval" = "xno"; then
83      tryopenssl=no
84    elif test -d "$withval"; then
85      SNMPLIBS="-L$withval/lib $SNMPLIBS"
86      OPENSSLLIBS="-L$withval/lib"
87      OPENSSLINCS="-I$withval/include"
88      tryopenssl=yes
89    fi,
90)
91
92AC_ARG_WITH(opensslflags,
93[  --with-opensslflags=flags       Set the flags to compile with OpenSSL.],
94    OPENSSLINCS="$withval"
95)
96
97AC_ARG_WITH(openssllibs,
98[  --with-openssllibs=libs         Set the libraries to link with OpenSSL.],
99    OPENSSLLIBS="$withval",
100)
101
102tryglib=yes
103AC_ARG_WITH(glib,
104[  --with-glib=yes|no              Look for glib.],
105    if test "x$withval" = "xyes"; then
106      tryglib=yes
107    elif test "x$withval" = "xno"; then
108      tryglib=no
109    fi,
110)
111
112glibver=
113AC_ARG_WITH(glibver,
114[  --with-glibver=ver              Set the glib version, either 1.2 or 2.0.],
115    glibver="$withval",
116)
117
118glibcflags=
119AC_ARG_WITH(glibcflags,
120[  --with-glibcflags=flags         Set the flags to compile with glib.],
121    glibcflags="$withval",
122)
123
124gliblibs=
125AC_ARG_WITH(gliblibs,
126[  --with-gliblibs=libs            Set the libraries to link with glib.],
127    gliblibs="$withval",
128)
129
130trytcl=yes
131AC_ARG_WITH(tcl,
132[  --with-tcl=yes|no               Look for tcl.],
133    if test "x$withval" = "xyes"; then
134      trytcl=yes
135    elif test "x$withval" = "xno"; then
136      trytcl=no
137    fi,
138)
139
140tclcflags=
141AC_ARG_WITH(tclcflags,
142[  --with-tclcflags=flags          Set the flags to compile with tcl.],
143    tclcflags="$withval",
144)
145
146tcllibs=
147AC_ARG_WITH(tcllibs,
148[  --with-tcllibs=libs             Set the libraries to link with tcl.],
149    tcllibs="$withval",
150)
151
152tryperl=yes
153perldir=
154AC_ARG_WITH(perl,
155[  --with-perl[[=yes|no|PATH]]       Look for perl, with the optional path.],
156    if test "x$withval" = "xyes"; then
157      tryperl=yes
158    elif test "x$withval" = "xno"; then
159      tryperl=no
160    elif test -d "$withval"; then
161      perldir="$withval"
162      tryperl=yes
163    fi,
164)
165
166perlinstalldir=
167AC_ARG_WITH(perlinstall,
168[  --with-perlinstall=PATH         Install perl modules in the given location.],
169    perlinstalldir="$withval",
170)
171
172perlcflags=
173AC_ARG_WITH(perlcflags,
174[  --with-perlcflags=PATH          Use the given flags when compiling perl parts.],
175    perlcflags="$withval",
176)
177
178perlusepthreads=
179AC_ARG_WITH(perlusepthreads,
180[  --with-perlusepthreads[[=yes|no]] Use threads with perl.],
181   if test "x$withval" = "xyes"; then
182      perlusepthreads="yes"
183   elif test "x$withval" = "xno"; then
184      perlusepthreads="no"
185   elif test "x$withval" = "x"; then
186      perlusepthreads="yes"
187   fi,
188)
189
190pythonprog=
191trypython=yes
192AC_ARG_WITH(python,
193[  --with-python[[=yes|no|PATH]]     Look for python, with the optional path.],
194    if test "x$withval" = "x"; then
195      trypython=yes
196    elif test "x$withval" = "xyes"; then
197      trypython=yes
198    elif test "x$withval" = "xno"; then
199      trypython=no
200    else
201      pythonprog="$withval"
202      trypython=yes
203    fi,
204)
205
206pythoninstalldir=
207AC_ARG_WITH(pythoninstall,
208[  --with-pythoninstall=PATH       Install python modules in the given location.],
209    pythoninstalldir="$withval",
210)
211
212pythoninstalllibdir=
213AC_ARG_WITH(pythoninstalllib,
214[  --with-pythoninstalllib=PATH       Install python libraries in the given location.],
215    pythoninstalllibdir="$withval",
216)
217
218pythoncflags=
219AC_ARG_WITH(pythoncflags,
220[  --with-pythoncflags=PATH        Use the given flags when compiling python parts.],
221    pythoncflags="$withval",
222)
223
224pythonusepthreads=
225AC_ARG_WITH(pythonusepthreads,
226[  --with-pythonusepthreads[[=yes|no]] Use threads with python.],
227   if test "x$withval" = "xyes"; then
228      pythonusepthreads="yes"
229   elif test "x$withval" = "xno"; then
230      pythonusepthreads="no"
231   elif test "x$withval" = "x"; then
232      pythonusepthreads="yes"
233   fi,
234)
235
236tkinter=
237AC_ARG_WITH(tkinter,
238[  --with-tkinter[[=yes|no]]       GUI package for python.],
239   if test "x$withval" = "xyes"; then
240      tkinter="yes"
241   elif test "x$withval" = "xno"; then
242      tkinter="no"
243   elif test "x$withval" = "x"; then
244      tkinter="yes"
245   fi,
246)
247
248tryswig=yes
249swigprog=
250AC_ARG_WITH(swig,
251[  --with-swig[[=yes|no|PATH]]       Look for swig, with the optional path.],
252    if test "x$withval" = "x"; then
253      tryswig=yes
254    elif test "x$withval" = "xyes"; then
255      tryswig=yes
256    elif test "x$withval" = "xno"; then
257      tryswig=no
258    else
259      swigprog=$withval
260    fi,
261)
262
263MARVELL_BMC_DIR=
264AC_ARG_WITH(marvell-bmc,
265[  --with-marvell-bmc            Enable the Marvell BMC.],
266    MARVELL_BMC_DIR=marvell-bmc
267)
268AC_SUBST([MARVELL_BMC_DIR])
269
270AM_PROG_CC_C_O
271AC_PROG_LIBTOOL
272AC_STDC_HEADERS
273
274AC_CHECK_HEADERS(execinfo.h)
275AC_CHECK_HEADERS([netinet/ether.h])
276AC_CHECK_HEADERS([sys/ethernet.h])
277
278# Check whether we need -lrt added.
279AC_CHECK_LIB(c, clock_gettime, RT_LIB=, RT_LIB=-lrt)
280AC_SUBST(RT_LIB)
281
282AC_SUBST(POPTLIBS)
283
284FOUND_POPT_HEADER=no
285AC_CHECK_HEADER(popt.h, FOUND_POPT_HEADER=yes; )
286if test "x$FOUND_POPT_HEADER" != "xyes"; then
287   echo "Could not find headers for the popt library"
288   exit 1
289fi
290
291if test "x$POPTLIBS" = "x"; then
292   AC_CHECK_LIB(popt, poptGetContext, POPTLIBS=-lpopt)
293   if test "x$POPTLIBS" = ""; then
294      echo "Could not find the popt library"
295      exit 1
296   fi
297fi
298
299# Check for GDBM
300have_gdbm_h="no"
301GDBM_LIB=
302AC_CHECK_HEADER(gdbm.h, have_gdbm_h="yes"; )
303if test "x$have_gdbm_h" = "xyes"; then
304   AC_CHECK_LIB(gdbm, gdbm_open,
305		AC_DEFINE([HAVE_GDBM], [], [Have GDBM libraries])
306		GDBM_LIB=-lgdbm; )
307fi
308AC_SUBST(GDBM_LIB)
309
310# Find pkg-config
311pkgprog=
312AC_PATH_PROG(pkgprog, pkg-config)
313
314# Handle GLIB support
315haveglib=no
316if test "x$glibver" = "x" -o "x$glibcflags" = "x" -o "x$gliblibs" = "x"; then
317   glibprog=
318   if test "x$tryglib" != "xno"; then
319      if test "x$pkgprog" != "x"; then
320         glibprog=$pkgprog
321      fi
322   fi
323   GLIB_CFLAGS=
324   GLIB_LIBS=
325   if test "x$glibprog" != "x"; then
326      GLIB_CFLAGS=`$glibprog --cflags gthread-2.0 2>/dev/null`
327      if test $? = 0; then
328         haveglib=yes
329         GLIB_VERSION='2.0'
330         GLIB_LIBS=`$glibprog --libs gthread-2.0 2>/dev/null`
331      fi
332   fi
333else
334   haveglib=yes
335   GLIB_CFLAGS="$glibcflags"
336   GLIB_VERSION="$glibver"
337   GLIB_LIBS="$gliblibs"
338fi
339echo "checking for glib... $haveglib"
340
341if test "x$haveglib" = "xyes"; then
342   AC_DEFINE([HAVE_GLIB], [], [Have GLIB libraries])
343   GLIB_LIB='$(top_builddir)/glib/libOpenIPMIglib.la'
344   GLIB_SO='$(top_builddir)/glib/.libs/libOpenIPMIglib.so'
345   GLIB_PKGCONF=OpenIPMIglib.pc
346   GLIB_TARGET=libOpenIPMIglib.la
347   GLIB_DIR=glib
348else
349   GLIB_LIB=
350   GLIB_SO=
351   GLIB_PKGCONF=
352   GLIB_TARGET=
353   GLIB_DIR=
354fi
355AC_SUBST(GLIB_VERSION)
356AC_SUBST(GLIB_CFLAGS)
357AC_SUBST(GLIB_LIBS)
358AC_SUBST(GLIB_LIB)
359AC_SUBST(GLIB_SO)
360AC_SUBST(GLIB_PKGCONF)
361AC_SUBST(GLIB_TARGET)
362AC_SUBST(GLIB_DIR)
363
364# Handle TCL support
365TCL_LIBS=
366TCL_CFLAGS=
367havetcl=no
368if test "x$trytcl" != "xno"; then
369   FOUND_TCL_HEADER=no
370   ver=`echo 'puts \$tcl_version' | tclsh`
371   if test "x$tclcflags" = "x"; then
372      AC_CHECK_HEADER(tcl/tcl.h, FOUND_TCL_HEADER=yes; )
373      if test "x$FOUND_TCL_HEADER" != "xyes"; then
374         AC_CHECK_HEADER(tcl/tcl.h, FOUND_TCL_HEADER=yes; )
375	 if test "x$FOUND_TCL_HEADER" == "xyes"; then
376	    tclcflags="-I /usr/include/tcl$ver"
377            TCL_CFLAGS="$tclcflags"
378	 fi
379      else
380	tclcflags="-I /usr/include/tcl"
381        TCL_CFLAGS="$tclcflags"
382      fi
383   else
384      TCL_CFLAGS="$tclcflags"
385      FOUND_TCL_HEADER=yes
386   fi
387   if test "x$tcllibs" = "x"; then
388      if test "x$FOUND_TCL_HEADER" = "xyes"; then
389         AC_CHECK_LIB(tcl, Tcl_DoOneEvent, TCL_LIBS=-ltcl)
390         if test "x$TCL_LIBS" = "x"; then
391            AC_CHECK_LIB(tcl$ver, Tcl_DoOneEvent, TCL_LIBS=-ltcl$ver)
392	 fi
393      fi
394   else
395      TCL_LIBS="$tcllibs"
396   fi
397   if test "x$FOUND_TCL_HEADER" = "xyes" -a "x$TCL_LIBS" != "x"; then
398      havetcl=yes
399   fi
400fi
401
402echo "checking for tcl... $havetcl"
403
404if test "x$havetcl" = "xyes"; then
405   OLDLIBS="$LIBS"
406   LIBS="$LIBS $TCL_LIBS"
407   AC_LINK_IFELSE([AC_LANG_CALL(, Tcl_GetTime)], [echo "Have Tcl_GetTime"],
408		  [echo "Redefine Tcl_GetTime as TclpGetTime";
409		   AC_DEFINE([Tcl_GetTime], [TclpGetTime],
410                            [If no Tcl_GetTime, redefine as TclpGetTime])])
411   LIBS="$OLDLIBS"
412fi
413
414if test "x$havetcl" = "xyes"; then
415   AC_DEFINE([HAVE_TCL], [], [Have TCL libraries])
416   TCL_LIB='$(top_builddir)/tcl/libOpenIPMItcl.la'
417   TCL_SO='$(top_builddir)/tcl/.libs/libOpenIPMItcl.so'
418   TCL_PKGCONF=OpenIPMItcl.pc
419   TCL_TARGET=libOpenIPMItcl.la
420   TCL_DIR=tcl
421else
422   TCL_LIB=
423   TCL_SO=
424   TCL_PKGCONF=
425   TCL_TARGET=
426   TCL_DIR=
427fi
428AC_SUBST(TCL_CFLAGS)
429AC_SUBST(TCL_LIBS)
430
431AC_SUBST(TCL_LIB)
432AC_SUBST(TCL_SO)
433AC_SUBST(TCL_PKGCONF)
434AC_SUBST(TCL_TARGET)
435AC_SUBST(TCL_DIR)
436
437# Handle PERL support
438if test "x$perlcflags" = "x" -o "x$perlinstalldir" = "x"; then
439   perlprog=
440   if test "x$tryperl" != "xno"; then
441      AC_PATH_PROG(perlprog, perl)
442   fi
443   if test "x$perlprog" != "x"; then
444      # Find the place where perl lives.
445      if test "x$perldir" = "x"; then
446	 perldir=`$perlprog -e 'for $i (@INC) { if (-r "$i/CORE/perl.h") { print "$i"; last; } }'`
447      fi
448
449      # Now find a proper installation location.
450      if test "x$perlinstalldir" = "x"; then
451	 perlinstalldir=`(eval \`perl -V:installvendorarch\`; echo $installvendorarch)`
452	 if test "x$perlinstalldir" = "x" -o ! -d "$perlinstalldir"; then
453	    perlinstalldir=`$perlprog -e 'for $i (@INC) { if ($i =~ /site_perl\/.+\/.+/) { print "$i"; last; } }'`
454	 fi
455	 if test "x$perlinstalldir" = "x" -o ! -d "$perlinstalldir"; then
456	    perlinstalldir=`$perlprog -e 'for $i (@INC) { if ($i =~ /vendor_perl\/.+\/.+/) { print "$i"; last; } }'`
457	 fi
458	 if test "x$perlinstalldir" = "x" -o ! -d "$perlinstalldir"; then
459	    perlinstalldir=$perldir
460	 fi
461      fi
462   fi
463
464   if test "x$perldir" != "x"; then
465      tpprog=`$perlprog -e "\\$p = \"$perlinstalldir\"; \\$u = \"$prefix\"; \\$p =~ s/\\$u//; print \\$p"`
466      AC_DEFINE([HAVE_PERL], [], [Have perl installed])
467      PERL_DIR=perl
468      if test "x$perlcflags" = "x"; then
469         PERL_CFLAGS="-I $perldir/CORE `$perlprog -V:ccflags | grep ccflags | sed 's/^.*ccflags=.\(.*\).;$/\1/'`"
470      else
471	  PERL_CFLAGS="$perlcflags"
472      fi
473      if test "$tpprog" = "$perlinstalldir"; then
474	 PERL_INSTALL_DIR="$perlinstalldir"
475      else
476	 PERL_INSTALL_DIR="\${prefix}$tpprog"
477      fi
478
479   else
480      PERL_DIR=
481      PERL_CFLAGS=
482      PERL_INSTALL_DIR=
483      PERL_HAS_POSIX_THREADS=
484      PERL_POSIX_LIB=
485      PERL_POSIX_SO=
486   fi
487else
488   AC_DEFINE([HAVE_PERL], [], [Have perl installed])
489   PERL_DIR=perl
490   PERL_CFLAGS="$perlcflags"
491   PERL_INSTALL_DIR="$perlinstalldir"
492fi
493if test "x$perlprog" != "x"; then
494   if test "x$perlusepthreads" = "x"; then
495      if $perlprog -V:usethreads | grep -q 'define'; then
496         perlusepthreads="yes"
497      fi
498   fi
499   echo "checking for perl threads... $perlusepthreads"
500fi
501if test "x$perlusepthreads" = "xyes"; then
502   PERL_HAS_POSIX_THREADS=1
503   PERL_POSIX_LIB='$(top_builddir)/unix/libOpenIPMIpthread.la'
504   PERL_POSIX_SO='$(top_builddir)/unix/.libs/libOpenIPMIpthread.so'
505else
506   PERL_HAS_POSIX_THREADS=0
507   PERL_POSIX_LIB='$(top_builddir)/unix/libOpenIPMIposix.la'
508   PERL_POSIX_SO='$(top_builddir)/unix/.libs/libOpenIPMIposix.so'
509fi
510AC_SUBST(PERL_DIR)
511AC_SUBST(PERL_CFLAGS)
512AC_SUBST(PERL_INSTALL_DIR)
513AC_SUBST(PERL_HAS_POSIX_THREADS)
514AC_SUBST(PERL_POSIX_LIB)
515AC_SUBST(PERL_POSIX_SO)
516
517# Handle PYTHON support
518PYTHON_DIR=
519PYTHON_INSTALL_DIR=
520PYTHON_INSTALL_LIB_DIR=
521PYTHON_SWIG_FLAGS=
522if test "x$trypython" = "xyes"; then
523   if test "x$pythonprog" != "x"; then
524      PYTHON="$pythonprog"
525   fi
526   if test "x$pythoncflags" != "x"; then
527      PYTHON_CPPFLAGS="$pythoncflags"
528   fi
529   AX_PYTHON_DEVEL
530fi
531if test "x$PYTHON" != "x"; then
532   AX_PROG_PYTHON_VERSION([3.0.0], [PYTHON_SWIG_FLAGS=-py3], [])
533   AC_DEFINE([HAVE_PYTHON], [], [Have Python installed])
534   PYTHON_DIR=python
535   if test "x$pythoninstalldir" = "x"; then
536      PYTHON_INSTALL_DIR="$PYTHON_SITE_PKG"
537   else
538      PYTHON_INSTALL_DIR="$pythoninstalldir"
539   fi
540   if test "x$pythoninstalllibdir" = "x"; then
541      PYTHON_INSTALL_LIB_DIR="$PYTHON_INSTALL_DIR"
542   else
543      PYTHON_INSTALL_LIB_DIR="$pythoninstalllibdir"
544   fi
545
546   if test "x$pythonusepthreads" = "x"; then
547      cat - <<_ACEOF >conftest.py
548try:
549  import threading
550  print('yes')
551except:
552  print('no')
553_ACEOF
554      pythonusepthreads=`$PYTHON conftest.py`
555      rm -f conftest.py
556   fi
557   echo "checking for python threads... $pythonusepthreads"
558
559   if test "x$pythonusepthreads" = "xyes"; then
560      PYTHON_HAS_POSIX_THREADS=1
561      PYTHON_POSIX_LIB='$(top_builddir)/unix/libOpenIPMIpthread.la'
562      PYTHON_POSIX_SO='$(top_builddir)/unix/.libs/libOpenIPMIpthread.so'
563   else
564      PYTHON_HAS_POSIX_THREADS=0
565      PYTHON_POSIX_LIB='$(top_builddir)/unix/libOpenIPMIposix.la'
566      PYTHON_POSIX_SO='$(top_builddir)/unix/.libs/libOpenIPMIposix.so'
567   fi
568fi
569
570AC_SUBST(PYTHON_DIR)
571AC_SUBST(PYTHON_INSTALL_DIR)
572AC_SUBST(PYTHON_INSTALL_LIB_DIR)
573AC_SUBST(PYTHON_HAS_POSIX_THREADS)
574AC_SUBST(PYTHON_POSIX_LIB)
575AC_SUBST(PYTHON_POSIX_SO)
576AC_SUBST(PYTHON_SWIG_FLAGS)
577
578# Check for Tkinter/Tix
579if test "x$tkinter" = "x"; then
580   if test "x$pythonprog" != "x"; then
581      cat - <<_ACEOF >conftest.py
582try:
583  import Tix
584  print('yes')
585except:
586  print('no')
587_ACEOF
588      tkinter=`python conftest.py`
589      rm -f conftest.py
590   fi
591fi
592echo "checking for tkinter... $tkinter"
593if test "x$tkinter" = "xyes"; then
594   PYTHON_GUI_DIR=openipmigui
595else
596   PYTHON_GUI_DIR=
597fi
598AC_SUBST(PYTHON_GUI_DIR)
599
600# Now check for swig
601SWIG_DIR=
602SWIG=
603if test "x$tryswig" = "xyes"; then
604   if test "x$swigprog" != "x"; then
605      SWIG="$swigprog"
606   fi
607   AX_PKG_SWIG([1.3.21])
608   if test "x$SWIG" != "x"; then
609      AC_DEFINE([HAVE_SWIG], [], [Have swig installed])
610      SWIG_DIR=swig
611   fi
612fi
613AC_SUBST(SWIG_DIR)
614AC_SUBST(SWIG)
615
616# Handle SNMP support
617if test "x$tryucdsnmp" != "xno"; then
618
619   HAVE_UCDSNMP=no
620   HAVE_NETSNMP=no
621   FOUND_SNMPINCL=no
622   # Try net snmp first
623   AC_CHECK_HEADER(net-snmp/net-snmp-config.h,
624                   FOUND_SNMPINCL=yes; HAVE_NETSNMP=yes; )
625   if test "x$FOUND_SNMPINCL" = "xno"; then
626      # Try old UCD snmp
627      AC_CHECK_HEADER(snmp_api.h, FOUND_SNMPINCL=yes; )
628      if test "x$FOUND_SNMPINCL" = "xno"; then
629          AC_CHECK_HEADER(ucd-snmp/snmp_api.h,
630                   FOUND_SNMPINCL=yes;
631		   AC_DEFINE([HAVE_ALT_UCDSNMP_DIR], [], [Alternate UCD SMP directory]))
632      fi
633   fi
634
635   if test "x$FOUND_SNMPINCL" = "xyes"; then
636      if test "x$HAVE_NETSNMP" = "xyes"; then
637         AC_CHECK_LIB(netsnmp, snmp_add,
638		      SNMPLIBS="-lnetsnmp $SNMPLIBS"
639		      AC_DEFINE([HAVE_UCDSNMP], [], [Have UCD SNMP])
640		      AC_DEFINE([HAVE_NETSNMP], [], [Have Net SNMP])
641		      HAVE_UCDSNMP=yes
642		      HAVE_NETSNMP=yes,
643		      ,
644		      $SNMPLIBS)
645         if test "x$HAVE_UCDSNMP" = "xno"; then
646	     # Try net snmp with crypto
647	     AC_CHECK_LIB(netsnmp, snmp_add_full,
648	                  SNMPLIBS="-lnetsnmp -lcrypto $SNMPLIBS"
649		          AC_DEFINE([HAVE_UCDSNMP], [], [Have UCD SNMP])
650		          AC_DEFINE([HAVE_NETSNMP], [], [Have Net SNMP])
651			  HAVE_UCDSNMP=yes
652			  HAVE_NETSNMP=yes,
653			  ,
654			  -lcrypto $SNMPLIBS)
655         fi
656         if test "x$HAVE_UCDSNMP" = "xno"; then
657	     AC_MSG_WARN([Found NET SNMP include files, but could not find libraries])
658	 fi
659      else
660         AC_CHECK_LIB(snmp, snmp_open_ex,
661		      SNMPLIBS="-lsnmp $SNMPLIBS"
662		      AC_DEFINE([HAVE_UCDSNMP], [], [Have UCD SNMP])
663		      HAVE_UCDSNMP=yes,
664		      ,
665		      $SNMPLIBS)
666         if test "x$HAVE_UCDSNMP" = "xno"; then
667            # Try with the crypto lib
668            AC_CHECK_LIB(snmp, snmp_sess_perror,
669		         SNMPLIBS="-lsnmp -lcrypto $SNMPLIBS"
670		         AC_DEFINE([HAVE_UCDSNMP], [], [Have UCD SNMP])
671			 HAVE_UCDSNMP=yes,
672			 ,
673			 -lcrypto $SNMPLIBS)
674         fi
675         if test "x$HAVE_UCDSNMP" = "xno"; then
676	     AC_MSG_WARN([Found UCD SNMP include files, but could not find libraries])
677	 fi
678      fi
679   fi
680fi
681
682AC_SUBST(SNMPLIBS)
683
684# Handle SNMP support
685if test "x$tryopenssl" != "xno"; then
686
687   HAVE_OPENSSL=no
688   # Try net snmp first
689   AC_CHECK_HEADER(openssl/crypto.h, FOUND_OPENSSL=yes; )
690
691   if test "x$FOUND_OPENSSL" = "xyes"; then
692      AC_CHECK_LIB(crypto, CRYPTO_malloc,
693		   OPENSSLLIBS="-lcrypto $OPENSSLLIBS"
694		   AC_DEFINE([HAVE_OPENSSL], [], [Have the openssl libraries])
695		   HAVE_OPENSSL=yes,
696		   ,
697		   $OPENSSLLIBS)
698   fi
699fi
700
701AC_SUBST(OPENSSLLIBS)
702AC_SUBST(OPENSSLINCS)
703
704AC_CHECK_LIB(socket, bind, [SOCKETLIB=-lsocket], [SOCKETLIB=])
705AC_SUBST(SOCKETLIB)
706
707AC_CHECK_LIB(socket, getaddrinfo, [AC_DEFINE([HAVE_GETADDRINFO], 1)],
708             [AC_CHECK_FUNCS(getaddrinfo)])
709
710AC_HAVE_FUNCS(syslog)
711
712# Now check for dia and the dia version.  They changed the output format
713# specifier without leaving backwards-compatible handling, so lots of ugly
714# checks here.
715DIA=
716AC_PATH_PROG(diaprog, dia)
717if test "x$diaprog" != "x"; then
718   diaver=`$diaprog --version 2>&1 | grep 'Dia version' | sed 's/Dia version \([[^,]]*\), .*$/\1/' | sed 's/^\([[0-9.]]\+\)+.*$/\1/'`
719   tmp=`echo $diaver | sed 's/^[[0-9.]]\+$//'`
720   if test "x$diaver" = "x" -o "x$tmp" != 'x'; then
721      # Couldn't get the dia version, give up.
722      echo "Couldn't determine the dia version from '$diaver'"
723      exit 1
724   else
725      DIA="$diaprog"
726      diaver_major=`echo $diaver | sed 's/\.[[0-9.]]\+$//'`
727      diaver_minor=`echo $diaver | sed 's/^[[0-9]]\+\.//' | sed 's/\.[[0-9.]]\+$//'`
728      echo "dia version is $diaver_major.$diaver_minor"
729      if test $diaver_major -lt 1 -a $diaver_minor -lt 95; then
730         # 0.94 and below use --export-to-format
731	 DIA_FILTER_NAME=--export-to-format
732      else
733	 DIA_FILTER_NAME=--filter
734      fi
735   fi
736fi
737
738LATEX=
739BIBTEX=
740DVIPDF=
741AC_PATH_PROG(LATEX, latex)
742AC_PATH_PROG(BIBTEX, bibtex)
743AC_PATH_PROG(DVIPDF, dvipdf)
744if test "x$DIA" = "x" -o "x$LATEX" = "x" -o "x$BIBTEX" = "x" -o "x$DVIPDF" = "x"; then
745   echo "dia, latex, bibtex, and/or dvipdf is not present or not valid, you cannot regenerate documentation"
746   echo "The documentation comes already generated, so this is generally not a problem"
747fi
748AC_SUBST(DIA)
749AC_SUBST(DIA_FILTER_NAME)
750AC_SUBST(LATEX)
751AC_SUBST(BIBTEX)
752AC_SUBST(DVIPDF)
753
754OPENIPMI_SWIG_LIBS="${PYTHON_POSIX_LIB} \$(top_builddir)/lib/libOpenIPMI.la \$(top_builddir)/utils/libOpenIPMIutils.la \$(top_builddir)/cmdlang/libOpenIPMIcmdlang.la ${GLIB_LIB} ${TCL_LIB}"
755OPENIPMI_SWIG_SO="${PYTHON_POSIX_SO}:\$(top_builddir)/lib/.libs/libOpenIPMI.so:\$(top_builddir)/utils/.libs/libOpenIPMIutils.so:\$(top_builddir)/cmdlang/.libs/libOpenIPMIcmdlang.so:${GLIB_SO}:${TCL_SO}"
756AC_SUBST(OPENIPMI_SWIG_LIBS)
757AC_SUBST(OPENIPMI_SWIG_SO)
758
759AX_HAVE_EPOLL_PWAIT(
760   [AX_CONFIG_FEATURE_ENABLE(epoll_pwait)],
761   [AX_CONFIG_FEATURE_DISABLE(epoll_pwait)])
762AX_CONFIG_FEATURE(
763   [epoll_pwait], [This platform supports epoll(7) with epoll_pwait(2)],
764   [HAVE_EPOLL_PWAIT], [This platform supports epoll(7) with epoll_pwait(2).])
765
766AC_CHECK_LIB(curses, tgetent, TERM_LIBS=-lcurses,
767   [AC_CHECK_LIB(ncursesw, tgetent, TERM_LIBS=-lncursesw,
768    [AC_CHECK_LIB(ncurses, tgetent, TERM_LIBS=-lncurses,
769      [AC_MSG_ERROR([libtermcap, libcurses or libncurses are required!])])] )] )
770AC_SUBST(TERM_LIBS)
771
772AC_CHECK_FUNCS(cfmakeraw)
773
774if test "${build}" != "${host}" ; then
775	AC_CHECK_PROGS(BUILD_CC, [${build_alias}-gcc ${build}-gcc gcc])
776else
777	BUILD_CC="$CC"
778fi
779AC_SUBST([BUILD_CC])
780
781AC_OUTPUT(Makefile
782	  utils/Makefile
783	  lib/Makefile
784	  unix/Makefile
785	  glib/Makefile
786	  tcl/Makefile
787	  ui/Makefile
788	  lanserv/Makefile
789	  lanserv/OpenIPMI/Makefile
790	  lanserv/sdrcomp/Makefile
791	  lanserv/marvell-bmc/Makefile
792	  sample/Makefile
793	  doc/Makefile
794	  man/Makefile
795	  swig/Makefile
796	  swig/perl/Makefile
797	  swig/python/Makefile
798	  swig/python/openipmigui/Makefile
799	  cmdlang/Makefile
800	  include/Makefile
801	  include/OpenIPMI/Makefile
802	  include/OpenIPMI/ipmiif.h
803	  include/OpenIPMI/internal/Makefile
804	  OpenIPMI.spec
805	  OpenIPMIutils.pc
806	  OpenIPMI.pc
807	  OpenIPMIpthread.pc
808	  OpenIPMIposix.pc
809	  OpenIPMIglib.pc
810	  OpenIPMItcl.pc
811	  OpenIPMIcmdlang.pc
812	  OpenIPMIui.pc)
813