1dnl
2dnl autoconf for ipmitool
3dnl
4AC_INIT([ipmitool], [1.8.18])
5AC_CONFIG_SRCDIR([src/ipmitool.c])
6AC_CANONICAL_SYSTEM
7AM_INIT_AUTOMAKE
8AM_CONFIG_HEADER(config.h)
9AC_PREREQ(2.50)
10AC_SUBST(ac_configure_args)
11
12dnl check for requirements
13AC_PROG_CC
14AC_PROG_INSTALL
15AC_PROG_LN_S
16AC_PROG_MAKE_SET
17AC_CHECK_PROG([RPMBUILD], [rpmbuild], [rpmbuild], [rpm])
18AC_CHECK_PROG([SED], [sed], [sed])
19
20AC_HEADER_STDC
21AC_CHECK_HEADERS([stdlib.h string.h sys/ioctl.h sys/stat.h unistd.h paths.h])
22AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/socket.h])
23AC_CHECK_HEADERS([sys/byteorder.h byteswap.h])
24
25AC_C_CONST
26AC_C_INLINE
27AC_C_BIGENDIAN
28
29AC_FUNC_SELECT_ARGTYPES
30AC_FUNC_STRTOD
31AC_CHECK_FUNCS([alarm gethostbyname getaddrinfo getifaddrs socket select])
32AC_CHECK_FUNCS([memmove memset strchr strdup strerror])
33AC_CHECK_FUNCS([getpassphrase])
34
35CFLAGS="$CFLAGS -Wall -Wextra -std=gnu99 -pedantic -Wformat -Wformat-nonliteral"
36
37AM_PROG_LIBTOOL
38LIBTOOL="$LIBTOOL --silent"
39
40AC_SEARCH_LIBS([gethostbyname], [nsl])
41AC_SEARCH_LIBS([getaddrinfo], [nsl])
42AC_SEARCH_LIBS([getifaddrs], [nsl])
43AC_SEARCH_LIBS([socket], [socket], [],
44	[AC_CHECK_LIB([nsl], [socket],
45		[LIBS="$LIBS -lsocket -lnsl"], [], [-lsocket])])
46
47if test "x$prefix" = "xNONE"; then
48	prefix="$ac_default_prefix"
49fi
50
51if test "x$exec_prefix" = "xNONE"; then
52	exec_prefix="$prefix"
53fi
54
55dnl
56dnl set default option values
57dnl
58
59xenable_all_options=yes
60xenable_intf_bmc=no
61xenable_intf_dummy=no
62xenable_intf_imb=yes
63xenable_intf_lipmi=yes
64xenable_intf_open=yes
65#xenable_intf_serial=yes
66xenable_intf_usb=no
67xenable_ipmishell=yes
68
69dnl set some things so we build with GNU tools on Solaris
70case "$host_os" in
71solaris*)
72	MAKE=gmake
73	STRIP=gstrip
74	LD=gld
75	AR=gar
76	# openssl libs are in /usr/sfw/lib on solaris 10
77	LIBS="$LIBS -R/usr/sfw/lib"
78	# disable the linux-specific interfaces
79	xenable_intf_bmc=yes
80	xenable_intf_imb=no
81	xenable_intf_open=no
82	xenable_intf_lipmi=no
83	xenable_ipmishell=no
84	xenable_all_options=no
85	;;
86*cygwin*)
87	# disable the linux and solaris-specific interfaces
88	xenable_intf_imb=no
89	xenable_intf_open=no
90	xenable_intf_lipmi=no
91	;;
92*darwin*|aix*)
93	# disable the linux and solaris-specific interfaces
94	xenable_intf_imb=no
95	xenable_intf_open=no
96	xenable_intf_lipmi=no
97	xenable_ipmishell=no
98	;;
99*freebsd*)
100	xenable_intf_imb=no
101	xenable_intf_lipmi=no
102	CFLAGS="$CFLAGS -D__BSD_VISIBLE"
103	;;
104*netbsd*)
105	xenable_intf_imb=no
106	xenable_intf_lipmi=no
107	xenable_intf_open=no
108	;;
109gnu*)
110	# disable the linux and solaris-specific interfaces on Hurd
111	xenable_intf_imb=no
112	xenable_intf_open=no
113	xenable_intf_usb=yes
114	;;
115esac
116
117AC_SUBST(ARCH, $host_cpu)
118AC_SUBST(OS, $host_os)
119AC_SUBST(PSTAMP, $host)
120AC_SUBST(BASEDIR, $prefix)
121
122dnl allow solaris builds to include all options
123AC_ARG_ENABLE([solaris-opt],
124	[AC_HELP_STRING([--enable-solaris-opt],
125			[enable all options for Solaris [default=no]])],
126	[xenable_solaris_opt=$enableval],
127	[xenable_solaris_opt=no])
128if test "x$xenable_all_options" = "xyes" || test "x$xenable_solaris_opt" = "xyes"; then
129	AC_DEFINE(ENABLE_ALL_OPTIONS, [1], [Define to 1 to enable all command line options.])
130fi
131
132dnl Determine anonymous union/structure support in GCC
133AC_TRY_COMPILE([
134#include <stdio.h>
135	], [
136	struct test {
137		union {
138			int a;
139			unsigned int b;
140		};
141	} test;
142
143	printf("a is %d", test.a);
144        ], ac_need_fms_extension=no, ac_need_fms_extension=yes)
145if test "x$ac_need_fms_extension" = "xyes"; then
146       CFLAGS="$CFLAGS -fms-extensions"
147       AC_SUBST(CFLAGS)
148fi
149
150dnl check for OpenSSL functionality
151AC_ARG_ENABLE([internal-md5],
152	[AC_HELP_STRING([--enable-internal-md5],
153			[enable internal MD5 library [default=no]])],
154	[xenable_internal_md5=$enableval],
155	[xenable_internal_md5=no])
156
157AC_CHECK_LIB([crypto], [EVP_aes_128_cbc],
158	[if test "x$xenable_internal_md5" != "xyes"; then
159	    have_crypto=yes; LIBS="$LIBS -lcrypto"
160	fi],
161	[have_crypto=no], [-lcrypto])
162
163AC_CHECK_LIB([crypto], [EVP_sha256],
164	[if test "x$xenable_internal_sha256" != "xyes"; then
165		if test "x$have_crypto" != "xyes"; then
166			LIBS="$LIBS -lcrypto"
167		have_sha256=yes
168		fi
169		AC_DEFINE(HAVE_CRYPTO_SHA256, [1], [Define to 1 if libcrypto supports SHA256.])
170	fi],
171	[], [-lcrypto])
172
173AC_CHECK_LIB([crypto], [MD5_Init],
174	[if test "x$xenable_internal_md5" != "xyes"; then
175	    if test "x$have_crypto" != "xyes"; then
176	        LIBS="$LIBS -lcrypto"
177	        have_md5=yes
178	    fi
179	    AC_DEFINE(HAVE_CRYPTO_MD5, [1], [Define to 1 if libcrypto supports MD5.])
180	fi],
181	[], [-lcrypto])
182
183AC_CHECK_LIB([crypto], [MD2_Init],
184	[if test "x$xenable_internal_md5" != "xyes"; then
185	    if test "x$have_crypto" != "xyes" && test "x$have_md5" != "xyes"; then
186	        LIBS="$LIBS -lcrypto"
187	        have_md2=yes
188	    fi
189	    AC_DEFINE(HAVE_CRYPTO_MD2, [1], [Define to 1 if libcrypto supports MD2.])
190	fi],
191	[], [-lcrypto])
192
193dnl enable IPMIv1.5 LAN interface
194AC_ARG_ENABLE([intf-lan],
195	[AC_HELP_STRING([--enable-intf-lan],
196			[enable IPMIv1.5 LAN interface [default=yes]])],
197	[xenable_intf_lan=$enableval],
198	[xenable_intf_lan=yes])
199if test "x$xenable_intf_lan" = "xstatic" || test "x$xenable_intf_lan" = "xplugin"; then
200	xenable_intf_lan=yes
201fi
202if test "x$xenable_intf_lan" = "xyes"; then
203	AC_DEFINE(IPMI_INTF_LAN, [1], [Define to 1 to enable LAN IPMIv1.5 interface.])
204	AC_SUBST(INTF_LAN, [lan])
205	AC_SUBST(INTF_LAN_LIB, [libintf_lan.la])
206	IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB lan/libintf_lan.la"
207fi
208
209dnl enable IPMI USB interface
210AC_ARG_ENABLE([intf-usb],
211	[AC_HELP_STRING([--enable-intf-usb],
212			[enable IPMI USB interface [default=auto]])],
213		[xenable_intf_usb=$enableval],
214		[xenable_intf_usb=$xenable_intf_usb])
215if test "x$xenable_intf_usb" = "xstatic" || test "x$xenable_intf_usb" = "xplugin"; then
216   xenable_intf_usb=yes
217fi
218if test "x$xenable_intf_usb" = "xyes"; then
219	AC_DEFINE(IPMI_INTF_USB, [1], [Define to 1 to enable USB interface.])
220	AC_SUBST(INTF_USB, [usb])
221	AC_SUBST(INTF_USB_LIB, [libintf_usb.la])
222	IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB usb/libintf_usb.la"
223fi
224
225dnl enable IPMIv2.0 RMCP+ LAN interface
226AC_ARG_ENABLE([intf-lanplus],
227	[AC_HELP_STRING([--enable-intf-lanplus],
228			[enable IPMIv2.0 RMCP+ LAN interface [default=auto]])],
229	[xenable_intf_lanplus=$enableval],
230	[xenable_intf_lanplus=$have_crypto])
231if test "x$xenable_intf_lanplus" = "xstatic" || test "x$xenable_intf_lanplus" = "xplugin"; then
232	xenable_intf_lanplus=yes
233fi
234if test "x$xenable_intf_lanplus" != "xno" && test "x$have_crypto" != "xyes"; then
235	echo "** The lanplus interface requires an SSL library with EVP_aes_128_cbc defined."
236	xenable_intf_lanplus=no
237fi
238if test "x$xenable_intf_lanplus" = "xyes"; then
239	AC_DEFINE(IPMI_INTF_LANPLUS, [1], [Define to 1 to enable LAN+ IPMIv2 interface.])
240	AC_SUBST(INTF_LANPLUS, [lanplus])
241	AC_SUBST(INTF_LANPLUS_LIB, [libintf_lanplus.la])
242	IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB lanplus/libintf_lanplus.la"
243else
244	xenable_intf_lanplus=no
245fi
246
247ORIG_CPPFLAGS=$CPPFLAGS
248
249dnl enable serial interface
250AC_ARG_ENABLE([intf-serial],
251	[AC_HELP_STRING([--enable-intf-serial],
252			[enable direct Serial Basic/Terminal mode interface [default=yes]])],
253	[xenable_intf_serial=$enableval], [xenable_intf_serial=yes])
254if test "x$enable_intf_serial" = "xstatic" || test "x$enable_intf_serial" = "xplugin"; then
255   xenable_intf_serial=yes
256fi
257if test "x$xenable_intf_serial" = "xyes"; then
258    AC_DEFINE(IPMI_INTF_SERIAL, [1], [Define to 1 to enable serial interface.])
259    AC_SUBST(INTF_SERIAL, [serial])
260    AC_SUBST(INTF_SERIAL_LIB, [libintf_serial.la])
261    IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB serial/libintf_serial.la"
262else
263	xenable_intf_serial=no
264fi
265
266dnl look for OpenIPMI header files
267AC_ARG_WITH([kerneldir],
268	[AC_HELP_STRING([--with-kerneldir=DIR],
269			[set kernel include path to DIR])],
270	[if test "x$with_kerneldir" = "xyes"; then
271	    with_kerneldir="/lib/modules/`uname -r`/build"
272	fi
273	CFLAGS="$CFLAGS -I ${with_kerneldir}/include"
274	AC_SUBST(CFLAGS)
275	CPPFLAGS="$CPPFLAGS -I ${with_kerneldir}/include"
276	AC_SUBST(CPPFLAGS)
277	if test -s ${with_kerneldir}/include/linux/version.h ; then
278	    kernelver=`grep UTS_RELEASE ${with_kerneldir}/include/linux/version.h | \
279	        sed 's/^\#define UTS_RELEASE \"\(2\.[0-9]\)\..*/\1/'`
280	    if test "x$kernelver" = "x2.6"; then
281	        CPPFLAGS="$CPPFLAGS -D__user="
282	        AC_SUBST(CPPFLAGS)
283	    fi
284	fi])
285
286AH_TEMPLATE([HAVE_LINUX_COMPILER_H], [])
287AC_MSG_CHECKING([for linux/compiler.h])
288
289m4_version_prereq([2.68],
290	[AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <linux/compiler.h>]])],
291		[AC_DEFINE(HAVE_LINUX_COMPILER_H, [1],
292			[Define to 1 if you have the <linux/compiler.h> header file.])
293		AC_MSG_RESULT([yes])],
294		[AC_MSG_RESULT([no])])],
295	[AC_PREPROC_IFELSE([#include <linux/compiler.h>],
296		[AC_DEFINE(HAVE_LINUX_COMPILER_H, [1],
297		[Define to 1 if you have the <linux/compiler.h> header file.])
298		AC_MSG_RESULT([yes])],
299		[AC_MSG_RESULT([no])])])
300
301CPPFLAGS=$ORIG_CPPFLAGS
302AC_SUBST(CPPFLAGS)
303
304AC_CHECK_HEADER([sys/ioccom.h],
305	[AC_DEFINE(HAVE_SYS_IOCCOM_H, [1],
306	[Define to 1 if you have the <sys/ioccom.h> header file.])])
307
308AC_CHECK_HEADER([linux/ipmi.h],
309	[AC_DEFINE(HAVE_OPENIPMI_H, [1],
310	[Define to 1 if you have the <linux/ipmi.h> header file.])],
311	[AC_CHECK_HEADER([sys/ipmi.h],
312		[AC_DEFINE(HAVE_FREEBSD_IPMI_H, [1],
313		[Define to 1 if you have the <sys/ipmi.h> header file.])],
314		[echo "** Unable to find OpenIPMI header files.  Using internal version."])])
315
316dnl look for FreeIPMI files
317AC_CHECK_LIB(freeipmi, ipmi_open_inband, [have_free=yes], [have_free=no])
318if test "x$have_free" != "xyes"; then
319	AC_CHECK_LIB(freeipmi, ipmi_ctx_open_inband, [have_free=yes], [have_free=no])
320fi
321AC_ARG_ENABLE([intf-free],
322	[AC_HELP_STRING([--enable-intf-free],
323		[enable FreeIPMI IPMI interface [default=auto]])],
324	[xenable_intf_free=$enableval],
325	[xenable_intf_free=$have_free])
326if test "x$xenable_intf_free" = "xstatic" || test "x$xenable_intf_free" = "xplugin"; then
327	xenable_intf_free=yes
328fi
329if test "x$xenable_intf_free" != "xno" && test "x$have_free" != "xyes"; then
330	echo "** Unable to build FreeIPMI interface support!"
331	xenable_intf_free=no
332fi
333if test "x$xenable_intf_free" = "xyes"; then
334dnl Determine if you got the right FreeIPMI version
335    AC_MSG_CHECKING([for libfreeipmi version 0.3.0])
336    AC_TRY_COMPILE([
337#include <sys/types.h>	/* For size_t */
338#include <stdio.h>	/* For NULL */
339#include <freeipmi/freeipmi.h>
340#include <freeipmi/udm/ipmi-udm.h>
341    ], [
342    ipmi_device_t dev;
343    dev = ipmi_open_inband(IPMI_DEVICE_KCS,
344                           0,
345                           0,
346                           0,
347                           NULL,
348                           0);
349    ], ac_free_version_0_3_0=yes, ac_free_version_0_3_0=no)
350    AC_MSG_RESULT($ac_free_version_0_3_0)
351    AC_MSG_CHECKING([for libfreeipmi version 0.4.0])
352    AC_TRY_COMPILE([
353#include <sys/types.h>	/* For size_t */
354#include <stdio.h>	/* For NULL */
355#include <freeipmi/freeipmi.h>
356#include <freeipmi/udm/ipmi-udm.h>
357    ], [
358    ipmi_device_t dev = NULL;
359    int rv;
360    dev = ipmi_device_create();
361    rv = ipmi_open_inband(dev,
362                          IPMI_DEVICE_KCS,
363                          0,
364                          0,
365                          0,
366                          NULL,
367                          0);
368    ], ac_free_version_0_4_0=yes, ac_free_version_0_4_0=no)
369    AC_MSG_RESULT($ac_free_version_0_4_0)
370    AC_MSG_CHECKING([for libfreeipmi version 0.5.0])
371    AC_TRY_COMPILE([
372#include <sys/types.h>	/* For size_t */
373#include <stdio.h>	/* For NULL */
374#include <freeipmi/freeipmi.h>
375#include <freeipmi/udm/ipmi-udm.h>
376    ], [
377    ipmi_device_t dev = NULL;
378    int rv;
379    dev = ipmi_device_create();
380    rv = ipmi_open_inband(dev,
381                          IPMI_DEVICE_KCS,
382                          0,
383                          0,
384                          0,
385                          NULL,
386                          0,
387                          0);
388    ], ac_free_version_0_5_0=yes, ac_free_version_0_5_0=no)
389    AC_MSG_RESULT($ac_free_version_0_5_0)
390
391    AC_MSG_CHECKING([for libfreeipmi version 0.6.0])
392    AC_TRY_COMPILE([
393#include <stdio.h>	/* For NULL */
394#include <freeipmi/freeipmi.h>
395    ], [
396    ipmi_ctx_t ctx = NULL;
397    int rv;
398    ctx = ipmi_ctx_create();
399    rv = ipmi_ctx_open_inband(ctx,
400                              IPMI_DEVICE_KCS,
401                              0,
402                              0,
403                              0,
404                              NULL,
405                              0,
406                              0);
407    ], ac_free_version_0_6_0=yes, ac_free_version_0_6_0=no)
408    AC_MSG_RESULT($ac_free_version_0_6_0)
409
410    if test "x$ac_free_version_0_3_0" = "xyes" \
411       || test "x$ac_free_version_0_4_0" = "xyes" \
412       || test "x$ac_free_version_0_5_0" = "xyes" \
413       || test "x$ac_free_version_0_6_0" = "xyes"; then
414       AC_DEFINE(IPMI_INTF_FREE, [1], [Define to 1 to enable FreeIPMI interface.])
415       AC_SUBST(INTF_FREE, [free])
416       AC_SUBST(INTF_FREE_LIB, [libintf_free.la])
417       IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB free/libintf_free.la"
418       if test "x$ac_free_version_0_3_0" = "xyes"; then
419          AC_DEFINE(IPMI_INTF_FREE_0_3_0, [1], [Define to 1 for FreeIPMI 0.3.0.])
420       fi
421       if test "x$ac_free_version_0_4_0" = "xyes"; then
422          AC_DEFINE(IPMI_INTF_FREE_0_4_0, [1], [Define to 1 for FreeIPMI 0.4.0.])
423       fi
424       if test "x$ac_free_version_0_5_0" = "xyes"; then
425          AC_DEFINE(IPMI_INTF_FREE_0_5_0, [1], [Define to 1 for FreeIPMI 0.5.0.])
426       fi
427       if test "x$ac_free_version_0_6_0" = "xyes"; then
428          AC_DEFINE(IPMI_INTF_FREE_0_6_0, [1], [Define to 1 for FreeIPMI 0.6.0.])
429       fi
430    else
431       xenable_intf_free=no
432    fi
433
434    AC_CHECK_LIB(freeipmi,
435      ipmi_cmd_raw_ipmb,
436      AC_DEFINE(IPMI_INTF_FREE_BRIDGING, [1],
437        [Define to 1 to enable FreeIPMI Bridging Support.]))
438fi
439
440dnl look for termios header file
441AC_CHECK_HEADER([termios.h],
442	[AC_DEFINE(HAVE_TERMIOS_H, [1], [Define to 1 if you have <termios.h>.])],
443	[AC_CHECK_HEADER([sys/termios.h],
444		[AC_DEFINE(HAVE_SYS_TERMIOS_H, [1], [Define to 1 if you have <sys/termios.h>.])],
445		[echo "** Unable to find termios header file."])])
446
447dnl set RPM distro tag for use in RPM name
448AC_ARG_WITH([rpm-distro],
449	[AC_HELP_STRING([--with-rpm-distro=DISTRO],
450			[set Linux distribution tag for use in RPM version string])],
451	[AC_SUBST(DISTRO, $with_rpm_distro)])
452
453dnl set RPM release tag
454AC_ARG_WITH([rpm-release],
455	[AC_HELP_STRING([--with-rpm-release=RELEASE],
456			[set release number for RPM release field])],
457	[], [with_rpm_release=1])
458AC_SUBST(RPM_RELEASE, $with_rpm_release)
459
460dnl enable Linux OpenIPMI interface
461AC_ARG_ENABLE([intf-open],
462	[AC_HELP_STRING([--enable-intf-open],
463			[enable Linux OpenIPMI interface [default=auto]])],
464	[xenable_intf_open=$enableval],
465	[])
466if test "x$xenable_intf_open" = "xstatic" || test "x$xenable_intf_open" = "xplugin"; then
467	xenable_intf_open=yes
468fi
469if test "x$xenable_intf_open" = "xyes"; then
470	AC_DEFINE(IPMI_INTF_OPEN, [1], [Define to 1 to enable Linux OpenIPMI interface.])
471	AC_SUBST(INTF_OPEN, [open])
472	AC_SUBST(INTF_OPEN_LIB, [libintf_open.la])
473	IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB open/libintf_open.la"
474
475	dnl Check for dual bridge support in OpenIPMI
476	AC_MSG_CHECKING([for OpenIPMI dual bridge support])
477	have_openipmi_dual_bridge=no
478	ORIG_CPPFLAGS="$CPPFLAGS"
479	CPPFLAGS="$CPPFLAGS -Isrc/plugins/open -DENABLE_INTF_OPEN_DUAL_BRIDGE"
480	AC_TRY_COMPILE([
481			#if defined(HAVE_OPENIPMI_H)
482			# if defined(HAVE_LINUX_COMPILER_H)
483			#  include <linux/compiler.h>
484			# endif
485			# include <linux/ipmi.h>
486			#elif defined(HAVE_FREEBSD_IPMI_H)
487			# include <sys/ipmi.h>
488			#else
489			# include "open.h"
490			#endif
491		], [
492			struct ipmi_ipmb_addr a;
493			a.transit_slave_addr = 0;
494		], [have_openipmi_dual_bridge=yes])
495	if test x"$have_openipmi_dual_bridge" = x"yes"; then
496		AC_DEFINE(ENABLE_INTF_OPEN_DUAL_BRIDGE, [1],
497			[Define to 1 to enable OpenIPMI interface dual bridge support])
498	fi
499	CPPFLAGS="$ORIG_CPPFLAGS"
500	AC_MSG_RESULT([$have_openipmi_dual_bridge])
501fi
502
503dnl enable Intel IMB interface
504AC_ARG_ENABLE([intf-imb],
505	[AC_HELP_STRING([--enable-intf-imb],
506			[enable Intel IMB driver interface [default=auto]])],
507	[xenable_intf_imb=$enableval],
508	[])
509if test "x$xenable_intf_imb" = "xstatic" || test "x$xenable_intf_imb" = "xplugin"; then
510	xenable_intf_imb=yes
511fi
512if test "x$xenable_intf_imb" = "xyes"; then
513	AC_DEFINE(IPMI_INTF_IMB, [1], [Define to 1 to enable Intel IMB interface.])
514	AC_SUBST(INTF_IMB, [imb])
515	AC_SUBST(INTF_IMB_LIB, [libintf_imb.la])
516	IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB imb/libintf_imb.la"
517fi
518
519dnl enable Solaris LIPMI interface
520AC_CHECK_HEADER([sys/lipmi/lipmi_intf.h], [have_lipmi=yes], [have_lipmi=no])
521AC_ARG_ENABLE([intf-lipmi],
522	[AC_HELP_STRING([--enable-intf-lipmi],
523			[enable Solaris 9 x86 IPMI interface [default=no]])],
524	[xenable_intf_lipmi=$enableval],
525	[])
526if test "x$xenable_intf_lipmi" = "xstatic" || test "x$xenable_intf_lipmi" = "xplugin"; then
527	xenable_intf_lipmi=yes
528fi
529if test "x$xenable_intf_lipmi" != "xno" && test "x$have_lipmi" != "xyes"; then
530	echo "** Unable to build Solaris 9 x86 IPMI interface support!"
531	xenable_intf_lipmi=no
532fi
533if test "x$xenable_intf_lipmi" = "xyes"; then
534	AC_DEFINE(IPMI_INTF_LIPMI, [1], [Define to 1 to enable Solaris 9 LIPMI interface.])
535	AC_SUBST(INTF_LIPMI, [lipmi])
536	AC_SUBST(INTF_LIPMI_LIB, [libintf_lipmi.la])
537	IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB lipmi/libintf_lipmi.la"
538fi
539
540dnl enable Solaris BMC interface
541AC_ARG_ENABLE([intf-bmc],
542	[AC_HELP_STRING([--enable-intf-bmc],
543			[enable Solaris 10 x86 IPMI interface [default=auto]])],
544	[xenable_intf_bmc=$enableval],
545	[xenable_intf_bmc=no])
546if test "x$xenable_intf_bmc" = "xstatic" || test "x$xenable_intf_bmc" = "xplugin"; then
547	xenable_intf_bmc=yes
548fi
549if test "x$xenable_intf_bmc" = "xyes"; then
550	AC_DEFINE(IPMI_INTF_BMC, [1], [Define to 1 to enable Solaris 10 BMC interface.])
551	AC_SUBST(INTF_BMC, [bmc])
552	AC_SUBST(INTF_BMC_LIB, [libintf_bmc.la])
553	IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB bmc/libintf_bmc.la"
554fi
555
556dnl enable Dummy interface for testing
557AC_ARG_ENABLE([intf-dummy],
558	[AC_HELP_STRING([--enable-intf-dummy],
559			[enable Dummy(test) interface [default=no]])],
560	[xenable_intf_dummy=$enableval], [xenable_intf_dummy=no])
561if test "x$xenable_intf_dummy" = "xyes"; then
562	AC_DEFINE(IPMI_INTF_DUMMY, [1], [Define to 1 to enable Dummy interface.])
563	AC_SUBST(INTF_DUMMY, [dummy])
564	AC_SUBST(INTF_DUMMY_LIB, [libintf_dummy.la])
565	IPMITOOL_INTF_LIB="$IPMITOOL_INTF_LIB dummy/libintf_dummy.la"
566fi
567
568AC_SUBST(IPMITOOL_INTF_LIB)
569
570if test "x$xenable_ipmishell" = "xyes"; then
571	AC_SEARCH_LIBS([tgetent], [tinfo ncurses curses readline termcap])
572	AC_SEARCH_LIBS([initscr], [ncurses curses], [have_curses=yes])
573	AC_SEARCH_LIBS([readline], [readline edit], [have_readline=yes])
574	if test "x$have_curses" != "xyes" || test "x$have_readline" != "xyes"; then
575		xenable_ipmishell=no
576	fi
577fi
578
579dnl check for readline library to enable ipmi shell
580AC_ARG_ENABLE([ipmishell],
581	[AC_HELP_STRING([--enable-ipmishell],
582			[enable IPMI shell interface [default=auto]])],
583	[xenable_ipmishell=$enableval],
584	[])
585if test "x$xenable_ipmishell" = "xyes"; then
586	AC_SEARCH_LIBS([tgetent], [tinfo ncurses curses readline termcap])
587	AC_SEARCH_LIBS([initscr], [ncurses curses], [have_curses=yes])
588	AC_SEARCH_LIBS([readline], [readline edit], [have_readline=yes])
589	if test "x$have_curses" != "xyes"; then
590		AC_MSG_ERROR([** Unable to find curses required by ipmishell.])
591	fi
592	if test "x$have_readline" != "xyes"; then
593		AC_MSG_ERROR([** Unable to find readline required by ipmishell.])
594	fi
595	AC_DEFINE(HAVE_READLINE, [1], [Define to 1 if readline present.])
596fi
597
598dnl Enable -Wall -Werror
599AC_ARG_ENABLE([buildcheck],
600	[AC_HELP_STRING([--enable-buildcheck],
601			[enable -Wall -Werror for build testing [default=no]])],
602	[xenable_buildcheck=$enableval],
603	[xenable_buildcheck=no])
604if test "x$xenable_buildcheck" != "xno"; then
605	CFLAGS="$CFLAGS -Wall -Werror -Wpointer-arith -Wstrict-prototypes"
606fi
607AC_SUBST(CFLAGS)
608
609dnl Enable extra file security paranoia
610AC_ARG_ENABLE([file-security],
611	[AC_HELP_STRING([--enable-file-security],
612			[enable extra security checks on files opened for read [default=no]])],
613	[xenable_file_security=$enableval],
614	[xenable_file_security=no])
615if test "x$xenable_file_security" != "xno"; then
616	AC_DEFINE(ENABLE_FILE_SECURITY, [1], [Define to 1 for extra file security.])
617fi
618
619
620AC_TRY_COMPILE([],[
621	#include <stdio.h>
622
623	struct packstruct {
624		unsigned char t0       :5;
625		unsigned char t1       :5;
626		unsigned char t2       :5;
627		unsigned char t3       :5;
628		unsigned char t4       :4;
629	} __attribute__ ((packed));
630
631	int
632	main(int argc, char ** argv)
633	{
634	if(sizeof(struct packstruct) != 3)
635	return(1);
636	else
637	return(0);
638	}
639	],
640	[],
641	[AC_DEFINE(HAVE_PRAGMA_PACK,[1],
642		[Define to 1 if you need to use #pragma pack instead of __attribute__ ((packed))])]
643)
644
645
646dnl Generate files for build
647AC_CONFIG_FILES([Makefile
648		doc/Makefile
649		contrib/Makefile
650		control/Makefile
651		control/pkginfo
652		control/prototype
653		control/rpmmacros
654		control/ipmitool.spec
655		lib/Makefile
656		include/Makefile
657		include/ipmitool/Makefile
658		src/Makefile
659		src/plugins/Makefile
660		src/plugins/lan/Makefile
661		src/plugins/lanplus/Makefile
662		src/plugins/open/Makefile
663		src/plugins/free/Makefile
664		src/plugins/imb/Makefile
665		src/plugins/bmc/Makefile
666		src/plugins/usb/Makefile
667		src/plugins/lipmi/Makefile
668		src/plugins/serial/Makefile
669		src/plugins/dummy/Makefile])
670
671AC_OUTPUT
672
673AC_MSG_RESULT([])
674AC_MSG_RESULT([ipmitool $VERSION])
675AC_MSG_RESULT([])
676AC_MSG_RESULT([Interfaces])
677AC_MSG_RESULT([  lan     : $xenable_intf_lan])
678AC_MSG_RESULT([  lanplus : $xenable_intf_lanplus])
679AC_MSG_RESULT([  open    : $xenable_intf_open])
680AC_MSG_RESULT([  free    : $xenable_intf_free])
681AC_MSG_RESULT([  imb     : $xenable_intf_imb])
682AC_MSG_RESULT([  bmc     : $xenable_intf_bmc])
683AC_MSG_RESULT([  usb     : $xenable_intf_usb])
684AC_MSG_RESULT([  lipmi   : $xenable_intf_lipmi])
685AC_MSG_RESULT([  serial  : $xenable_intf_serial])
686AC_MSG_RESULT([  dummy   : $xenable_intf_dummy])
687AC_MSG_RESULT([])
688AC_MSG_RESULT([Extra tools])
689AC_MSG_RESULT([  ipmievd   : yes])
690AC_MSG_RESULT([  ipmishell : $xenable_ipmishell])
691AC_MSG_RESULT([])
692
693