~ubuntu-branches/ubuntu/vivid/openipmi/vivid

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
AC_INIT(README.Force)
AC_CONFIG_HEADER([config.h])
AC_CANONICAL_TARGET
OPENIPMI_PKG_NAME=OpenIPMI
OPENIPMI_VERSION_MAJOR=2
OPENIPMI_VERSION_MINOR=0
OPENIPMI_VERSION_RELEASE=13
OPENIPMI_VERSION_EXTRA=
AM_INIT_AUTOMAKE(OpenIPMI, ${OPENIPMI_VERSION_MAJOR}.${OPENIPMI_VERSION_MINOR}.${OPENIPMI_VERSION_RELEASE}${OPENIPMI_VERSION_EXTRA})

OPENIPMI_SMI=

case $target_os in
	linux*)
		AC_DEFINE([HAVE_OPENIPMI_SMI], [], [We have a local IPMI interface])
		;;

	cygwin*)
		AC_DEFINE([HAVE_CYGWIN_TARGET], [], [Running on CYGWIN])
		;;
esac

AC_SUBST(OPENIPMI_SMI)

# Check for execinfo.h
AC_CHECK_HEADERS(execinfo.h)

SNMPLIBS=

# Where do we find the UCD SNMP includes and libs
tryucdsnmp=yes
AC_ARG_WITH(ucdsnmp,
[  --with-ucdsnmp=PATH             Look for ucdsnmp in PATH.],
    if test "x$withval" = "xyes"; then
      tryucdsnmp=yes
    elif test "x$withval" = "xno"; then
      tryucdsnmp=no
    elif test -d "$withval"; then
      CPPFLAGS="-I$withval/include $CPPFLAGS"
      SNMPLIBS="-L$withval/lib $SNMPLIBS"
      tryucdsnmp=yes
    fi,
)

AC_ARG_WITH(snmpflags,
[  --with-snmpflags=flags          Set the flags to compile with SNMP.],
    CPPFLAGS="$withval $CPPFLAGS"
)

AC_ARG_WITH(snmplibs,
[  --with-snmplibs=libs            Set the libraries to link with SNMP.],
    SNMPLIBS="$withval"
)

POPTCFLAGS=
AC_ARG_WITH(poptflags,
[  --with-poptflags=flags          Set the flags to compile with popt.],
    CPPFLAGS="$withval $CPPFLAGS"
)

POPTCFLAGS=
AC_ARG_WITH(poptlibs,
[  --with-poptlibs=libs            Set the libraries to link with popt.],
    POPTLIBS="$withval"
)

# If UCD SNMP requires OpenSSL, this tells where to find the crypto lib
tryopenssl=yes
AC_ARG_WITH(openssl,
[  --with-openssl[[=yes|no|PATH]]    Look for openssl, with the optional path.],
    if test "x$withval" = "xyes"; then
      tryopenssl=yes
    elif test "x$withval" = "xno"; then
      tryopenssl=no
    elif test -d "$withval"; then
      SNMPLIBS="-L$withval/lib $SNMPLIBS"
      OPENSSLLIBS="-L$withval/lib"
      OPENSSLINCS="-I$withval/include"
      tryopenssl=yes
    fi,
)

AC_ARG_WITH(opensslflags,
[  --with-opensslflags=flags       Set the flags to compile with OpenSSL.],
    OPENSSLINCS="$withval"
)

AC_ARG_WITH(openssllibs,
[  --with-openssllibs=libs         Set the libraries to link with OpenSSL.],
    OPENSSLLIBS="$withval",
)

tryglib=yes
AC_ARG_WITH(glib,
[  --with-glib=yes|no              Look for glib.],
    if test "x$withval" = "xyes"; then
      tryglib=yes
    elif test "x$withval" = "xno"; then
      tryglib=no
    fi,
)

glibver=
AC_ARG_WITH(glibver,
[  --with-glibver=ver              Set the glib version, either 1.2 or 2.0.],
    glibver="$withval",
)

glibcflags=
AC_ARG_WITH(glibcflags,
[  --with-glibcflags=flags         Set the flags to compile with glib.],
    glibcflags="$withval",
)

gliblibs=
AC_ARG_WITH(gliblibs,
[  --with-gliblibs=libs            Set the libraries to link with glib.],
    gliblibs="$withval",
)

tryglib12=yes
AC_ARG_WITH(glib12,
[  --with-glib12=yes|no            Look for glib version 1.2.],
    if test "x$withval" = "xyes"; then
      tryglib12=yes
    elif test "x$withval" = "xno"; then
      tryglib12=no
    fi,
)

glib12cflags=
AC_ARG_WITH(glib12cflags,
[  --with-glib12cflags=flags       Set the flags to compile with glib 1.2.],
    glibcflags="$withval",
)

gliblibs=
AC_ARG_WITH(glib12libs,
[  --with-glib12libs=libs          Set the libraries to link with glib 1.2.],
    gliblibs="$withval",
)

trytcl=yes
AC_ARG_WITH(tcl,
[  --with-tcl=yes|no               Look for tcl.],
    if test "x$withval" = "xyes"; then
      trytcl=yes
    elif test "x$withval" = "xno"; then
      trytcl=no
    fi,
)

tclcflags=
AC_ARG_WITH(tclcflags,
[  --with-tclcflags=flags          Set the flags to compile with tcl.],
    tclcflags="$withval",
)

tcllibs=
AC_ARG_WITH(tcllibs,
[  --with-tcllibs=libs             Set the libraries to link with tcl.],
    tcllibs="$withval",
)

tryperl=yes
perldir=
AC_ARG_WITH(perl,
[  --with-perl[[=yes|no|PATH]]       Look for perl, with the optional path.],
    if test "x$withval" = "xyes"; then
      tryperl=yes
    elif test "x$withval" = "xno"; then
      tryperl=no
    elif test -d "$withval"; then
      perldir="$withval"
      tryperl=yes
    fi,
)

perlinstalldir=
AC_ARG_WITH(perlinstall,
[  --with-perlinstall=PATH         Install perl modules in the given location.],
    perlinstalldir="$withval",
)

perlcflags=
AC_ARG_WITH(perlcflags,
[  --with-perlcflags=PATH          Use the given flags when compiling perl parts.],
    perlcflags="$withval",
)

perlusepthreads=
AC_ARG_WITH(perlusepthreads,
[  --with-perlusepthreads[[=yes|no]] Use threads with perl.],
   if test "x$withval" = "xyes"; then
      perlusepthreads="yes"
   elif test "x$withval" = "xno"; then
      perlusepthreads="no"
   elif test "x$withval" = "x"; then
      perlusepthreads="yes"
   fi,
)

trypython=yes
AC_ARG_WITH(python,
[  --with-python[[=yes|no|PATH]]     Look for python, with the optional path.],
    if test "x$withval" = "xyes"; then
      trypython=yes
    elif test "x$withval" = "xno"; then
      trypython=no
    elif test -d "$withval"; then
      trypython=yes
    fi,
)

pythoninstalldir=
AC_ARG_WITH(pythoninstall,
[  --with-pythoninstall=PATH       Install python modules in the given location.],
    pythoninstalldir="$withval",
)

pythoninstalllibdir=
AC_ARG_WITH(pythoninstalllib,
[  --with-pythoninstalllib=PATH       Install python libraries in the given location.],
    pythoninstalllibdir="$withval",
)

pythoncflags=
AC_ARG_WITH(pythoncflags,
[  --with-pythoncflags=PATH        Use the given flags when compiling python parts.],
    pythoncflags="$withval",
)

pythonusepthreads=
AC_ARG_WITH(pythonusepthreads,
[  --with-pythonusepthreads[[=yes|no]] Use threads with python.],
   if test "x$withval" = "xyes"; then
      pythonusepthreads="yes"
   elif test "x$withval" = "xno"; then
      pythonusepthreads="no"
   elif test "x$withval" = "x"; then
      pythonusepthreads="yes"
   fi,
)

tkinter=
AC_ARG_WITH(tkinter,
[  --with-tkinter[[=yes|no]]       GUI package for python.],
   if test "x$withval" = "xyes"; then
      tkinter="yes"
   elif test "x$withval" = "xno"; then
      tkinter="no"
   elif test "x$withval" = "x"; then
      tkinter="yes"
   fi,
)

tryswig=yes
swigprog=
AC_ARG_WITH(swig,
[  --with-swig[[=yes|no|PATH]]       Look for swig, with the optional path.],
    if test "x$withval" = "x"; then
      tryswig=yes
    elif test "x$withval" = "xyes"; then
      tryswig=yes
    elif test "x$withval" = "xno"; then
      tryswig=no
    else
      swigprog=$withval
    fi,
)

AC_PROG_CC
AC_PROG_LIBTOOL
AC_STDC_HEADERS
AC_CHECK_FUNCS(getaddrinfo)

AC_SUBST(OPENIPMI_VERSION_MAJOR)
AC_SUBST(OPENIPMI_VERSION_MINOR)
AC_SUBST(OPENIPMI_VERSION_RELEASE)
AC_SUBST(OPENIPMI_VERSION_EXTRA)

AC_SUBST(POPTLIBS)

FOUND_POPT_HEADER=no
AC_CHECK_HEADER(popt.h, FOUND_POPT_HEADER=yes; )
if test "x$FOUND_POPT_HEADER" != "xyes"; then
   echo "Could not find headers for the popt library"
   exit 1
fi

if test "x$POPTLIBS" = "x"; then
   AC_CHECK_LIB(popt, poptHelpOptions, POPTLIBS=-lpopt)
   if test "x$POPTLIBS" = ""; then
      echo "Could not find the popt library"
      exit 1
   fi
fi

# Check for GDBM
have_gdbm_h="no"
GDBM_LIB=
AC_CHECK_HEADER(gdbm.h, have_gdbm_h="yes"; )
if test "x$have_gdbm_h" = "xyes"; then
   AC_CHECK_LIB(gdbm, gdbm_open,
		AC_DEFINE([HAVE_GDBM], [], [Have GDBM libraries])
		GDBM_LIB=-lgdbm; )
fi
AC_SUBST(GDBM_LIB)

# Find pkg-config
pkgprog=
AC_PATH_PROG(pkgprog, pkg-config)

# Handle GLIB support
haveglib=no
if test "x$glibver" = "x" -o "x$glibcflags" = "x" -o "x$gliblibs" = "x"; then
   glibprog=
   if test "x$tryglib" != "xno"; then
      if test "x$pkgprog" != "x"; then
         glibprog=$pkgprog
      else
         AC_PATH_PROG(glibprog, glib-config)
      fi
   fi
   GLIB_CFLAGS=
   GLIB_LIBS=
   if test "x$glibprog" != "x"; then
      # Try 2.0 first
      GLIB_CFLAGS=`$glibprog --cflags gthread-2.0 2>/dev/null`
      if test $? = 0; then
         haveglib=yes
         GLIB_VERSION='2.0'
         GLIB_LIBS=`$glibprog --libs gthread-2.0 2>/dev/null`
      else
         # Now try 1.2
         GLIB_CFLAGS=`$glibprog --cflags gthread`
         if test $? = 0; then
            haveglib=yes
	    GLIB_VERSION='1.2'
	    GLIB_LIBS=`$glibprog --libs gthread`
         fi
      fi
   fi
else
   haveglib=yes
   GLIB_CFLAGS="$glibcflags"
   GLIB_VERSION="$glibver"
   GLIB_LIBS="$gliblibs"
fi
echo "checking for glib... $haveglib"
   
if test "x$haveglib" = "xyes"; then
   AC_DEFINE([HAVE_GLIB], [], [Have GLIB libraries])
   GLIB_LIB='$(top_builddir)/glib/libOpenIPMIglib.la'
   GLIB_SO='$(top_builddir)/glib/.libs/libOpenIPMIglib.so'
   GLIB_PKGCONF=OpenIPMIglib.pc
   GLIB_TARGET=libOpenIPMIglib.la
else
   GLIB_LIB=
   GLIB_SO=
   GLIB_PKGCONF=
   GLIB_TARGET=
fi
AC_SUBST(GLIB_VERSION)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)

AC_SUBST(GLIB_LIB)
AC_SUBST(GLIB_SO)
AC_SUBST(GLIB_PKGCONF)
AC_SUBST(GLIB_TARGET)


# We allow a glib 1.2 specific library, too.
haveglib12=no
if test "x$glib12cflags" = "x" -o "x$glib12libs" = "x"; then
   glibprog=
   if test "x$tryglib12" != "xno"; then
      AC_PATH_PROG(glibprog, glib-config)
   fi
   GLIB12_CFLAGS=
   GLIB12_LIBS=
   if test "x$glibprog" != "x"; then
      GLIB12_CFLAGS=`$glibprog --cflags gthread`
      if test $? = 0; then
         haveglib12=yes
   	 GLIB12_LIBS=`$glibprog --libs gthread`
      fi
   fi
else
   haveglib12=yes
   GLIB12_CFLAGS="$glib12cflags"
   GLIB12_LIBS="$glib12libs"
fi

echo "checking for glib 1.2... $haveglib12"

if test "x$haveglib12" = "xyes"; then
   AC_DEFINE([HAVE_GLIB12], [], [Have the GLIB 1.2 libraries])
   GLIB12_LIB='$(top_builddir)/glib/libOpenIPMIglib12.la'
   GLIB12_SO='$(top_builddir)/glib/.libs/libOpenIPMIglib12.so'
   GLIB12_PKGCONF=OpenIPMIglib12.pc
   GLIB12_TARGET=libOpenIPMIglib12.la
else
   GLIB12_LIB=
   GLIB12_SO=
   GLIB12_PKGCONF=
   GLIB12_TARGET=
fi
AC_SUBST(GLIB12_CFLAGS)
AC_SUBST(GLIB12_LIBS)

AC_SUBST(GLIB12_LIB)
AC_SUBST(GLIB12_SO)
AC_SUBST(GLIB12_PKGCONF)
AC_SUBST(GLIB12_TARGET)


if test "x$haveglib12" = "xyes" -o "x$haveglib" = "xyes"; then
   GLIB_DIR=glib
   # If we only have one glib library, just directly link with it in swig.
   # If we have two libraries, the swig code dynamically loads it and we
   # don't directly link with it.
   if test "x$haveglib12" = "xyes" -a "x$haveglib" = "xyes"; then
      GLIB_SINGLE_LIB=
      GLIB_SINGLE_SO=
   else
      if test "x$haveglib12" = "xyes"; then
         GLIB_SINGLE_LIB=$GLIB12_LIB
         GLIB_SINGLE_SO=$GLIB12_SO
      else
         GLIB_SINGLE_LIB=$GLIB_LIB
         GLIB_SINGLE_SO=$GLIB_SO
      fi
   fi
else
   GLIB_DIR=
   GLIB_SINGLE_LIB=
   GLIB_SINGLE_SO=
fi
AC_SUBST(GLIB_DIR)
AC_SUBST(GLIB_SINGLE_LIB)
AC_SUBST(GLIB_SINGLE_SO)

# Handle TCL support
TCL_LIBS=
TCL_CFLAGS=
havetcl=no
if test "x$trytcl" != "xno"; then
   FOUND_TCL_HEADER=no
   ver=`echo 'puts \$tcl_version' | tclsh`
   if test "x$tclcflags" = "x"; then
      AC_CHECK_HEADER(tcl.h, FOUND_TCL_HEADER=yes; )
      if test "x$FOUND_TCL_HEADER" != "xyes"; then
         echo -n "checking for /usr/include/tcl$ver... "
	 if test 'x$ver' != 'x' -a -d "/usr/include/tcl$ver"; then
	    echo "yes"
	    tclcflags="-I /usr/include/tcl$ver"
            TCL_CFLAGS="$tclcflags"
            FOUND_TCL_HEADER=yes
         else
	    echo "no"
	 fi
      fi
   else
      TCL_CFLAGS="$tclcflags"
      FOUND_TCL_HEADER=yes
   fi
   if test "x$tcllibs" = "x"; then
      if test "x$FOUND_TCL_HEADER" = "xyes"; then
         AC_CHECK_LIB(tcl, Tcl_DoOneEvent, TCL_LIBS=-ltcl)
         if test "x$TCL_LIBS" = "x"; then
            AC_CHECK_LIB(tcl$ver, Tcl_DoOneEvent, TCL_LIBS=-ltcl$ver)
	 fi
      fi
   else
      TCL_LIBS="$tcllibs"
   fi
   if test "x$FOUND_TCL_HEADER" = "xyes" -a "x$TCL_LIBS" != "x"; then
      havetcl=yes
   fi
fi

echo "checking for tcl... $havetcl"
   
if test "x$havetcl" == "xyes"; then
   OLDLIBS="$LIBS"
   LIBS="$LIBS $TCL_LIBS"
   AC_LINK_IFELSE([AC_LANG_CALL(, Tcl_GetTime)], [echo "Have Tcl_GetTime"],
		  [echo "Redefine Tcl_GetTime as TclpGetTime";
		   AC_DEFINE([Tcl_GetTime], [TclpGetTime],
                            [If no Tcl_GetTime, redefine as TclpGetTime])])
   LIBS="$OLDLIBS"
fi

if test "x$havetcl" = "xyes"; then
   AC_DEFINE([HAVE_TCL], [], [Have TCL libraries])
   TCL_LIB='$(top_builddir)/tcl/libOpenIPMItcl.la'
   TCL_SO='$(top_builddir)/tcl/.libs/libOpenIPMItcl.so'
   TCL_PKGCONF=OpenIPMItcl.pc
   TCL_TARGET=libOpenIPMItcl.la
   TCL_DIR=tcl
else
   TCL_LIB=
   TCL_SO=
   TCL_PKGCONF=
   TCL_TARGET=
   TCL_DIR=
fi
AC_SUBST(TCL_CFLAGS)
AC_SUBST(TCL_LIBS)

AC_SUBST(TCL_LIB)
AC_SUBST(TCL_SO)
AC_SUBST(TCL_PKGCONF)
AC_SUBST(TCL_TARGET)
AC_SUBST(TCL_DIR)

# Handle PERL support
if test "x$perlcflags" = "x" -o "x$perlinstalldir" = "x"; then
   perlprog=
   if test "x$tryperl" != "xno"; then
      AC_PATH_PROG(perlprog, perl)
   fi
   if test "x$perlprog" != "x"; then
      # Find the place where perl lives.
      if test "x$perldir" = "x"; then
	 perldir=`$perlprog -e 'for $i (@INC) { if (-r "$i/CORE/perl.h") { print "$i"; last; } }'`
      fi

      # Now find a proper installation location.
      if test "x$perlinstalldir" = "x"; then
	 perlinstalldir=`(eval \`perl -V:installvendorarch\`; echo $installvendorarch)`
	 if test "x$perlinstalldir" = "x" -o ! -d "$perlinstalldir"; then
	    perlinstalldir=`$perlprog -e 'for $i (@INC) { if ($i =~ /site_perl\/.+\/.+/) { print "$i"; last; } }'`
	 fi
	 if test "x$perlinstalldir" = "x" -o ! -d "$perlinstalldir"; then
	    perlinstalldir=`$perlprog -e 'for $i (@INC) { if ($i =~ /vendor_perl\/.+\/.+/) { print "$i"; last; } }'`
	 fi
	 if test "x$perlinstalldir" = "x" -o ! -d "$perlinstalldir"; then
	    perlinstalldir=$perldir
	 fi
      fi
   fi

   if test "x$perldir" != "x"; then
      tpprog=`$perlprog -e "\\$p = \"$perlinstalldir\"; \\$u = \"$prefix\"; \\$p =~ s/\\$u//; print \\$p"`
      AC_DEFINE([HAVE_PERL], [], [Have perl installed])
      PERL_DIR=perl
      if test "x$perlcflags" = "x"; then
         PERL_CFLAGS="-I $perldir/CORE `$perlprog -V:ccflags | grep ccflags | sed 's/^.*ccflags=.\(.*\).;$/\1/'`"
      else
	  PERL_CFLAGS="$perlcflags"
      fi
      if test "$tpprog" = "$perlinstalldir"; then
	 PERL_INSTALL_DIR="$perlinstalldir"
      else
	 PERL_INSTALL_DIR="\${prefix}$tpprog"
      fi

   else
      PERL_DIR=
      PERL_CFLAGS=
      PERL_INSTALL_DIR=
      PERL_HAS_POSIX_THREADS=
      PERL_POSIX_LIB=
      PERL_POSIX_SO=
   fi
else
   AC_DEFINE([HAVE_PERL], [], [Have perl installed])
   PERL_DIR=perl
   PERL_CFLAGS="$perlcflags"
   PERL_INSTALL_DIR="$perlinstalldir"
fi
if test "x$perlprog" != "x"; then
   if test "x$perlusepthreads" = "x"; then
      if $perlprog -V:usethreads | grep -q 'define'; then
         perlusepthreads="yes"
      fi
   fi
   echo "checking for perl threads... $perlusepthreads"
fi
if test "x$perlusepthreads" = "xyes"; then
   PERL_HAS_POSIX_THREADS=1
   PERL_POSIX_LIB='$(top_builddir)/unix/libOpenIPMIpthread.la'
   PERL_POSIX_SO='$(top_builddir)/unix/.libs/libOpenIPMIpthread.so'
else
   PERL_HAS_POSIX_THREADS=0
   PERL_POSIX_LIB='$(top_builddir)/unix/libOpenIPMIposix.la'
   PERL_POSIX_SO='$(top_builddir)/unix/.libs/libOpenIPMIposix.so'
fi
AC_SUBST(PERL_DIR)
AC_SUBST(PERL_CFLAGS)
AC_SUBST(PERL_INSTALL_DIR)
AC_SUBST(PERL_HAS_POSIX_THREADS)
AC_SUBST(PERL_POSIX_LIB)
AC_SUBST(PERL_POSIX_SO)

# Handle PYTHON support
if test "x$pythoncflags" = "x" -o "x$pythoninstalldir" = "x"; then
   pythonprog=
   if test "x$trypython" != "xno"; then
      AC_PATH_PROG(pythonprog, python)
   fi
   if test "x$pythonprog" != "x"; then
      # Now find a proper installation location.
      if test "x$pythoninstalldir" = "x"; then
	 pythoninstalldir=`$pythonprog -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib();'`
	 if test "x$pythoninstalldir" = "x" -o ! -d "$pythoninstalldir"; then
	    pythoninstalldir=
	 fi
      fi
   fi

   if test "x$pythoncflags" = "x"; then
      pythoninc=`$pythonprog -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_inc();'`
      if test "x$pythoninc" != "x"; then
         pythoncflags="-I$pythoninc"
      else
         pythoncflags=""
      fi
   else
      PYTHON_CFLAGS="$pythoncflags"
   fi

   if test "x$pythoninstalldir" != "x"; then
      if test "x$pythoninstalllibdir" = "x"; then
	 pythoninstalllibdir=$pythoninstalldir
      fi
      AC_DEFINE([HAVE_PYTHON], [], [Have Python installed])
      PYTHON_DIR=python
      PYTHON_CFLAGS="$pythoncflags"
      PYTHON_INSTALL_DIR="$pythoninstalldir"
      PYTHON_INSTALL_LIB_DIR="$pythoninstalllibdir"
   else
      PYTHON_DIR=
      PYTHON_CFLAGS=
      PYTHON_INSTALL_DIR=
      PYTHON_INSTALL_LIB_DIR=
   fi
else
   if test "x$pythoninstalllibdir" = "x"; then
      pythoninstalllibdir=$pythoninstalldir
   fi
   AC_DEFINE([HAVE_PYTHON], [], [Have Python installed])
   PYTHON_DIR=python
   PYTHON_CFLAGS="$pythoncflags"
   PYTHON_INSTALL_DIR="$pythoninstalldir"
   PYTHON_INSTALL_LIB_DIR="$pythoninstalllibdir"
fi
if test "x$pythonprog" != "x"; then
   if test "x$pythonusepthreads" = "x"; then
      pythonusepthreads=`echo -e "try:\n  import thread\n  print 'yes'\nexcept:\n  print 'no'\n" | python`
   fi
   echo "checking for python threads... $pythonusepthreads"
fi
if test "x$pythonusepthreads" = "xyes"; then
   PYTHON_HAS_POSIX_THREADS=1
   PYTHON_POSIX_LIB='$(top_builddir)/unix/libOpenIPMIpthread.la'
   PYTHON_POSIX_SO='$(top_builddir)/unix/.libs/libOpenIPMIpthread.so'
else
   PYTHON_HAS_POSIX_THREADS=0
   PYTHON_POSIX_LIB='$(top_builddir)/unix/libOpenIPMIposix.la'
   PYTHON_POSIX_SO='$(top_builddir)/unix/.libs/libOpenIPMIposix.so'
fi
AC_SUBST(PYTHON_DIR)
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_INSTALL_DIR)
AC_SUBST(PYTHON_INSTALL_LIB_DIR)
AC_SUBST(PYTHON_HAS_POSIX_THREADS)
AC_SUBST(PYTHON_POSIX_LIB)
AC_SUBST(PYTHON_POSIX_SO)

# Check for Tkinter/Tix
if test "x$tkinter" = "x"; then
   if test "x$pythonprog" != "x"; then
      tkinter=`echo -e "try:\n  import Tix\n  print 'yes'\nexcept:\n  print 'no'\n" | python`
   fi
fi
echo "checking for tkinter... $tkinter"
if test "x$tkinter" = "xyes"; then
   PYTHON_GUI_DIR=openipmigui
else
   PYTHON_GUI_DIR=
fi
AC_SUBST(PYTHON_GUI_DIR)

# Now check for swig
if test "x$swigprog" = "x" -a "x$tryswig" = "xyes"; then
   AC_PATH_PROG(swigprog, swig)
fi
if test "x$swigprog" != "x"; then
   swigver=`$swigprog -version 2>&1 | grep 'SWIG Version' | sed 's/SWIG Version //'`
   swigmajor=`echo $swigver | sed 's/\.[[0-9]]*\.[[0-9]]*$//'`
   swigminor=`echo $swigver | sed 's/^[[0-9]]*\.\([[0-9]]*\)\.[[0-9]]*$/\1/'`
   swigrel=`echo $swigver | sed 's/^[[0-9]]*\.[[0-9]]*\.//'`
   if test '(' "$swigmajor" -lt 1 ')' -o '(' '(' "$swigmajor" -eq 1 ')' -a '(' "$swigminor" -lt 3 ')' ')' -o '(' '(' "$swigmajor" -eq 1 ')' -a '(' "$swigminor" -eq 3 ')' -a '(' "$swigrel" -lt 21 ')' ')'; then
      echo "***swig must be version 1.3.21 or greater, disabling swig and perl/python"
   else
      echo "swig version $swigver"
      AC_DEFINE([HAVE_SWIG], [], [Have swig installed])
      SWIG_DIR=swig
      SWIG=$swigprog
   fi
else
   SWIG_DIR=
   SWIG=
fi
AC_SUBST(SWIG_DIR)
AC_SUBST(SWIG)

# Handle SNMP support
if test "x$tryucdsnmp" != "xno"; then

   HAVE_UCDSNMP=no
   HAVE_NETSNMP=no
   FOUND_SNMPINCL=no
   # Try net snmp first
   AC_CHECK_HEADER(net-snmp/net-snmp-config.h,
                   FOUND_SNMPINCL=yes; HAVE_NETSNMP=yes; )
   if test "x$FOUND_SNMPINCL" = "xno"; then
      # Try old UCD snmp
      AC_CHECK_HEADER(snmp_api.h, FOUND_SNMPINCL=yes; )
      if test "x$FOUND_SNMPINCL" = "xno"; then
          AC_CHECK_HEADER(ucd-snmp/snmp_api.h,
                   FOUND_SNMPINCL=yes;
		   AC_DEFINE([HAVE_ALT_UCDSNMP_DIR], [], [Alternate UCD SMP directory]))
      fi
   fi

   if test "x$FOUND_SNMPINCL" = "xyes"; then
      if test "x$HAVE_NETSNMP" = "xyes"; then
         AC_CHECK_LIB(netsnmp, snmp_add, 
		      SNMPLIBS="-lnetsnmp $SNMPLIBS"
		      AC_DEFINE([HAVE_UCDSNMP], [], [Have UCD SNMP])
		      AC_DEFINE([HAVE_NETSNMP], [], [Have Net SNMP])
		      HAVE_UCDSNMP=yes
		      HAVE_NETSNMP=yes,
		      ,
		      $SNMPLIBS)
         if test "x$HAVE_UCDSNMP" = "xno"; then
	     # Try net snmp with crypto
	     AC_CHECK_LIB(netsnmp, snmp_add_full, 
	                  SNMPLIBS="-lnetsnmp -lcrypto $SNMPLIBS"
		          AC_DEFINE([HAVE_UCDSNMP], [], [Have UCD SNMP])
		          AC_DEFINE([HAVE_NETSNMP], [], [Have Net SNMP])
			  HAVE_UCDSNMP=yes
			  HAVE_NETSNMP=yes,
			  ,
			  -lcrypto $SNMPLIBS)
         fi
         if test "x$HAVE_UCDSNMP" = "xno"; then
	     AC_MSG_WARN([Found NET SNMP include files, but could not find libraries])
	 fi
      else
         AC_CHECK_LIB(snmp, snmp_open_ex, 
		      SNMPLIBS="-lsnmp $SNMPLIBS"
		      AC_DEFINE([HAVE_UCDSNMP], [], [Have UCD SNMP])
		      HAVE_UCDSNMP=yes,
		      ,
		      $SNMPLIBS)
         if test "x$HAVE_UCDSNMP" = "xno"; then
            # Try with the crypto lib
            AC_CHECK_LIB(snmp, snmp_sess_perror, 
		         SNMPLIBS="-lsnmp -lcrypto $SNMPLIBS"
		         AC_DEFINE([HAVE_UCDSNMP], [], [Have UCD SNMP])
			 HAVE_UCDSNMP=yes,
			 ,
			 -lcrypto $SNMPLIBS)
         fi
         if test "x$HAVE_UCDSNMP" = "xno"; then
	     AC_MSG_WARN([Found UCD SNMP include files, but could not find libraries])
	 fi
      fi
   fi
fi

AC_SUBST(SNMPLIBS)

# Handle SNMP support
if test "x$tryopenssl" != "xno"; then

   HAVE_OPENSSL=no
   # Try net snmp first
   AC_CHECK_HEADER(openssl/crypto.h, FOUND_OPENSSL=yes; )

   if test "x$FOUND_OPENSSL" = "xyes"; then
      AC_CHECK_LIB(crypto, CRYPTO_malloc, 
		   OPENSSLLIBS="-lcrypto $OPENSSLLIBS"
		   AC_DEFINE([HAVE_OPENSSL], [], [Have the openssl libraries])
		   HAVE_OPENSSL=yes,
		   ,
		   $OPENSSLLIBS)
   fi
fi

AC_SUBST(OPENSSLLIBS)
AC_SUBST(OPENSSLINCS)

AC_HAVE_FUNCS(syslog)

# Now check for dia and the dia version.  They changed the output format
# specifier without leaving backwards-compatible handling, so lots of ugly
# checks here.
DIA=
AC_PATH_PROG(diaprog, dia)
if test "x$diaprog" != "x"; then
   diaver=`$diaprog --version | sed 's/Dia version \([[0-9]]\+\.[[0-9]]\+\), .*$/\1/'`
   tmp=`echo $diaver | sed 's/^[[0-9]]\+\.[[0-9]]\+$//'`
   if test "x$diaver" == "x" -o "x$tmp" != 'x'; then
      # Couldn't get the dia version, give up.
      echo "Couldn't determine the dia version from '$diaver'"
   else
      DIA="$diaprog"
      diaver_major=`echo $diaver | sed 's/\.[[0-9]]\+$//'`
      diaver_minor=`echo $diaver | sed 's/^[[0-9]]\+\.//'`
      echo "dia version is $diaver_major.$diaver_minor"
      if test $diaver_major -lt 1 -a $diaver_minor -lt 95; then
         # 0.94 and below use --export-to-format
	 DIA_FILTER_NAME=--export-to-format
      else
	 DIA_FILTER_NAME=--filter
      fi
   fi
fi

LATEX=
BIBTEX=
DVIPDF=
AC_PATH_PROG(LATEX, latex)
AC_PATH_PROG(BIBTEX, bibtex)
AC_PATH_PROG(DVIPDF, dvipdf)
if test "x$DIA" == "x" -o "x$LATEX" == "x" -o "x$BIBTEX" == "x" -o "x$DVIPDF" == "x"; then
   echo "dia, latex, bibtex, and/or dvipdf is not present or not valid, you cannot regenerate documentation"
   echo "The documentation comes already generated, so this is generally not a problem"
fi
AC_SUBST(DIA)
AC_SUBST(DIA_FILTER_NAME)
AC_SUBST(LATEX)
AC_SUBST(BIBTEX)
AC_SUBST(DVIPDF)

OPENIPMI_SWIG_LIBS="${PYTHON_POSIX_LIB} \$(top_builddir)/lib/libOpenIPMI.la \$(top_builddir)/utils/libOpenIPMIutils.la \$(top_builddir)/cmdlang/libOpenIPMIcmdlang.la ${GLIB_SINGLE_LIB} ${TCL_LIB}"
OPENIPMI_SWIG_SO="${PYTHON_POSIX_SO}:\$(top_builddir)/lib/.libs/libOpenIPMI.so:\$(top_builddir)/utils/.libs/libOpenIPMIutils.so:\$(top_builddir)/cmdlang/.libs/libOpenIPMIcmdlang.so:${GLIB_SINGLE_SO}:${TCL_SO}"
AC_SUBST(OPENIPMI_SWIG_LIBS)
AC_SUBST(OPENIPMI_SWIG_SO)

# Everything from here to AC_OUTPUT is for libedit

# AC_PROG_LIBTOOL runs AC_CANONICAL_HOST
case $host in 
   *-sun-*) AC_DEFINE([_SUNOS], [], [Solaris's term.h does horrid things.]);;
esac

AC_CHECK_LIB(curses, tgetent,,
   [AC_CHECK_LIB(ncurses, tgetent,,
      [AC_MSG_ERROR([libtermcap, libcurses or libncurses are required!])] )] )

# Checks for header files.
AC_FUNC_ALLOCA
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([fcntl.h limits.h malloc.h stdlib.h string.h sys/ioctl.h sys/param.h termios.h unistd.h curses.h ncurses.h sys/cdefs.h])

## include curses.h to prevent "Present But Cannot Be Compiled"
AC_CHECK_HEADERS([term.h],,,
[[#if HAVE_CURSES_H
# include <curses.h>
#elif HAVE_NCURSES_H
# include <ncurses.h>
#endif
]])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_CHECK_TYPES([u_int32_t])

# Checks for library functions.
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_FORK
AC_CHECK_FUNCS(strlcpy strlcat fgetln)
AC_PROG_GCC_TRADITIONAL
## _AIX is offended by rpl_malloc and rpl_realloc
#AC_FUNC_MALLOC
#AC_FUNC_REALLOC
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_CHECK_FUNCS([endpwent isascii memchr memset re_comp regcomp strcasecmp strchr strcspn strdup strerror strrchr strstr strtol issetugid])
EL_GETPW_R_POSIX
EL_GETPW_R_DRAFT

# End of libedit inclusions

AC_OUTPUT(Makefile
	  utils/Makefile
	  lib/Makefile
	  unix/Makefile
	  glib/Makefile
	  tcl/Makefile
	  ui/Makefile
	  lanserv/Makefile
	  sample/Makefile
	  doc/Makefile
	  man/Makefile
	  swig/Makefile
	  swig/perl/Makefile
	  swig/python/Makefile
	  swig/python/openipmigui/Makefile
	  libedit/Makefile
	  cmdlang/Makefile
	  include/Makefile
	  include/OpenIPMI/Makefile
	  include/OpenIPMI/ipmiif.h
	  include/OpenIPMI/internal/Makefile
	  include/linux/Makefile
	  OpenIPMI.spec
	  OpenIPMIutils.pc
	  OpenIPMI.pc
	  OpenIPMIpthread.pc
	  OpenIPMIposix.pc
	  OpenIPMIglib.pc
	  OpenIPMIglib12.pc
	  OpenIPMItcl.pc
	  OpenIPMIcmdlang.pc
	  OpenIPMIui.pc)