1 dnl Autoconfigure input file for apcupsd (derived from fetchmail-4.7.4).
3 dnl Copyright (C) 1999-2000 Riccardo Facchetti <riccardo@master.oasi.gpa.it>
5 dnl Process this file with autoconf to produce a configure script.
6 dnl Process this file with autoheader to produce a config.h.in
9 dnl A distinctive file to look for in srcdir.
12 dnl Config header file.
13 AC_CONFIG_HEADER(include/config.h:autoconf/config.h.in)
16 AC_CONFIG_AUX_DIR(${topdir}/autoconf)
24 dnl go up one more level
30 VERSION=`sed -n -e 's/^.*VERSION.*"\(.*\)"$/\1/p' ${srcdir}/include/version.h`
33 DATE=`sed -n -e 's/^.*[ \t]*ADATE.*"\(.*\)"$/\1/p' ${srcdir}/include/version.h`
37 dnl These need to be searched before.
39 AC_PATH_PROGS(TRUEPRG, true, :)
40 AC_PATH_PROGS(FALSEPRG, false, :)
43 dnl Create a new path statement starting with what the user has and
44 dnl adding directories we might need.
46 #PATH=$PATH:/bin:/sbin:/etc:/usr/bin:/usr/bin/X11:/usr/sbin:/usr/local/bin:/usr/local/sbin
50 dnl Interesting things are often in /usr/local
51 CPPFLAGS="${CPPFLAGS}"
54 if test $HAVE_UNAME=yes -a x`uname -s` = xSunOS
56 dnl ----------------------------------------
58 dnl ----------------------------------------
59 AC_PREFIX_DEFAULT(/opt/apcupsd)
60 dnl --exec-prefix == eprefix == prefix
61 dnl --bindir == eprefix/bin
62 dnl --sbindir == eprefix/sbin
64 dnl If the user has not set -sysconfdir, we set our default as
67 if test x$sysconfdir = x'${prefix}/etc' ; then
68 sysconfdir='/etc/opt/apcupsd'
71 dnl If the user has not set -sbindir, we set our default as /sbin
73 if test x$sbindir = x'${exec_prefix}/sbin' ; then
74 sbindir='/etc/opt/apcupsd/sbin'
77 dnl Solaris often has interesting things in /usr/sfw
78 CPPFLAGS="${CPPFLAGS} -I/usr/sfw/include"
79 LDFLAGS="${LDFLAGS} -L/usr/sfw/lib"
81 dnl -------------------------------------------
82 dnl non Sun defaults (i.e. all other platforms
83 dnl -------------------------------------------
84 AC_PREFIX_DEFAULT(/usr)
86 dnl If the user has not set -sysconfdir, we set our default as /etc/apcupsd
88 if test x$sysconfdir = x'${prefix}/etc' ; then
89 sysconfdir='/etc/apcupsd'
93 dnl If the user has not set -sbindir, we set our default as /sbin
95 if test x$sbindir = x'${exec_prefix}/sbin' ; then
101 dnl Sets `host_cpu', `host_vendor', and `host_os' to the current host type.
106 dnl Check for programs.
109 AC_PROG_CXX dnl We require a C++ compiler now
110 AC_PROG_CC dnl Determine a C compiler to use.
111 AC_PROG_CPP dnl Determine a C pre-processor to use.
112 AC_PROG_INSTALL dnl Determine a BSD install program.
116 if test x$GCC = xyes; then
117 AM_CONDITIONAL(HAVE_GCC, $TRUEPRG)
120 AM_CONDITIONAL(HAVE_GCC, $FALSEPRG)
123 dnl Default linker is g++
125 #if test x$LD = x ; then
138 dnl Initialize pthreads inclusion: warn PTHREAD_LFLAGS must contain only
139 dnl the pthreads libraries, if needed. For linker flags, add them to
142 PTHREAD_LFLAGS="-lpthread"
145 AC_DEFINE(HAVE_PTHREADS)
146 AC_SUBST(PTHREAD_CFLAGS)
147 AC_SUBST(PTHREAD_LFLAGS)
156 dnl Now check for programs
157 AC_REQ_PATH_PROGS(SHUTDOWN, shutdown shutdown.bsd)
159 AC_PATH_PROGS(APCUPSD_MAIL, mail, no)
160 if test "$APCUPSD_MAIL" = "no"
162 AC_MSG_WARN([mail program not found !])
165 dnl Arrmo, force APCUPSD_MAIL (mail command)
166 APCUPSD_MAIL="sendmail -S server.home -f root"
168 AC_REQ_PATH_PROGS(WALL, wall)
169 AC_REQ_PATH_PROGS(SCRIPTSHELL, sh bash)
172 AC_REQ_PATH_PROGS(RANLIB, ranlib true)
173 AC_REQ_PATH_PROG(RM, rm)
174 AC_REQ_PATH_PROG(CP, cp)
175 AC_REQ_PATH_PROG(ECHO, echo)
176 AC_REQ_PATH_PROG(LN, ln)
177 AC_REQ_PATH_PROG(SED, sed)
178 AC_REQ_PATH_PROG(AR, ar)
179 AC_REQ_PATH_PROG(MV, mv)
181 AC_PATH_PROG(RST2HTML, rst2html.py,)
182 AC_PATH_PROG(RST2PDF, rst2pdf,)
184 # -------------------------------------------------------------------------
185 # If the user has not set --mandir, we default to /usr/share/man
186 # -------------------------------------------------------------------------
187 if test x$mandir = x'${prefix}/man' ; then
188 mandir=/usr/share/man
192 dnl Check for library functions.
194 dnl for fopen and friends I check only for fprintf. If it is there I suppose
195 dnl all the other function should be there.
196 dnl The same for open and friends: checking only for open.
197 dnl and for all the other function groups.
200 abort fork calloc getpid \
201 ioctl kill rewind select setsid signal strerror strncmp \
202 strncpy tcgetattr vfprintf setpgrp,,
203 [AC_MSG_ERROR([cannot find required function.])]
206 AC_CHECK_FUNCS(snprintf vsnprintf)
208 dnl Solaris hides nanosleep in one of two libraries depending on version
209 dnl If we can't find it at all we'll just use our own substitute.
210 AC_SEARCH_LIBS(nanosleep, [rt posix4], AC_DEFINE(HAVE_NANOSLEEP, 1,
211 [Define if you have the nanosleep function.]),
212 [LIBEXTRAOBJ="$LIBEXTRAOBJ sleep.o"
213 EXTRAOBJ="$EXTRAOBJ lib/sleep.o"])
215 AC_MSG_CHECKING([for syslog])
218 [#include <syslog.h>],
219 [syslog(0, "%s", "test");],
220 AC_MSG_RESULT([yes]),
221 AC_CHECK_LIB(socket, std_syslog,,
222 [AC_MSG_ERROR([cannot find required function.])])
224 [#include <syslog.h>],
225 [syslog(0, "%s", "test");], AC_MSG_RESULT([yes]),
226 [AC_MSG_ERROR([cannot find required function.])])
229 AC_FUNC_STRFTIME dnl check for strftime.
230 dnl AC_FUNC_SETPGRP dnl check for BSD setpgrp.
232 # Under sysV68, socket and friends are provided by the C library.
233 # -linet does not provide socket, but causes multiple definition
234 # errors at link-time. It is thus better to only use the C library.
235 # So don't add -linet to the link list unless it's necessary
237 # With Solaris socket and friends seem not to be in C library.
238 # I hope that if socket is found, all the BSD friends are in the same library
242 AC_SEARCH_LIBS(socket, [xnet socket inet])
243 AC_SEARCH_LIBS(gethostname, [xnet socket inet])
244 AC_SEARCH_LIBS(gethostbyname, [nsl resolv])
245 AC_SEARCH_LIBS(gethostbyname_r, [nsl resolv])
247 dnl --------------------------------------------------------------------------
248 dnl Check for socklen_t
249 dnl --------------------------------------------------------------------------
250 AC_CACHE_CHECK(for socklen_t, ba_cv_header_socklen_t,
252 #include <sys/types.h>
253 #include <sys/socket.h>],
255 ba_cv_header_socklen_t=yes, ba_cv_header_socklen_t=no)])
256 test $ba_cv_header_socklen_t = yes && AC_DEFINE(HAVE_SOCKLEN_T)
258 # The condition in this test copes with the presence of inet_addr in libc6.
259 AC_SEARCH_LIBS(inet_addr, nsl)
261 dnl Needed by Interactive UNIX System V/386 Release 3.2
262 AC_CHECK_FUNC(strchr,
263 AC_MSG_RESULT([using libc's strchr]),
264 AC_CHECK_LIB(cposix,strchr,
265 [EXTRADEFS="$EXTRADEFS -D_SYSV3"
266 LIBS="$LIBS -lcposix"]))
268 AC_CHECK_FUNC(strstr, AC_DEFINE(HAVE_STRSTR),
269 [LIBEXTRAOBJ="$LIBEXTRAOBJ strstr.o"
270 EXTRAOBJ="$EXTRAOBJ lib/strstr.o"])
272 AC_CHECK_FUNC(strcasecmp, AC_DEFINE(HAVE_STRCASECMP),
273 [LIBEXTRAOBJ="$LIBEXTRAOBJ strcasecmp.o"
274 EXTRAOBJ="$EXTRAOBJ lib/strcasecmp.o"])
276 AC_CHECK_FUNC(memmove, AC_DEFINE(HAVE_MEMMOVE),
277 [LIBEXTRAOBJ="$LIBEXTRAOBJ memmove.o"
278 EXTRAOBJ="$EXTRAOBJ lib/memmove.o"])
280 AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPTLONG),
281 [LIBEXTRAOBJ="$LIBEXTRAOBJ getopt.o getopt1.o"
282 EXTRAOBJ="$EXTRAOBJ lib/getopt.o lib/getopt1.o"])
284 AC_CHECK_FUNC(inet_pton, AC_DEFINE(HAVE_INETPTON),
285 [LIBEXTRAOBJ="$LIBEXTRAOBJ inet_pton.o"
286 EXTRAOBJ="$EXTRAOBJ lib/inet_pton.o"])
289 dnl Check for presence of localtime_r
291 AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R),
292 [LIBEXTRAOBJ="$LIBEXTRAOBJ localtime_r.o"
293 EXTRAOBJ="$EXTRAOBJ lib/localtime_r.o"])
296 dnl Check for header files.
299 arpa/inet.h ctype.h errno.h fcntl.h \
300 limits.h netdb.h netinet/in.h pwd.h signal.h \
301 stdarg.h stdio.h stdlib.h string.h strings.h sys/ioctl.h \
302 sys/socket.h sys/types.h syslog.h termios.h \
304 ,,[AC_MSG_WARN([at least 1 header file is missing. This may not compile.])])
306 AC_CHECK_HEADERS(arpa/nameser.h,AC_DEFINE(HAVE_NAMESER_H))
308 AC_HEADER_STAT dnl Check for S_ISDIR and S_ISREG macros.
309 AC_HEADER_TIME dnl Check for time.h and sys/time.h.
310 AC_HEADER_SYS_WAIT dnl Check for <sys/wait.h>
313 dnl Check for structures.
315 AC_STRUCT_TM dnl Check if time.h don't define struct tm.
316 AC_STRUCT_TIMEZONE dnl Check how to have current timezone.
330 dnl Not always true, but close enough for the few platforms
331 dnl that are missing this (Solaris 2.5.1).
332 AC_CHECK_TYPE(int32_t, int)
335 dnl Check for system services.
337 AC_EXEEXT dnl Check for EXE extension.
338 AC_PATH_XTRA dnl Is X Window System interesting ?. **GAPCMON**
339 AC_SYS_INTERPRETER dnl Check for '#!' in shell scripts.
345 AC_DEFINE_UNQUOTED(EXEEXT, "$EXEEXT")
348 *-*-sunos*) AC_DEFINE(HAVE_SUN_OS) ;;
349 *-*-solaris*) AC_DEFINE(HAVE_SUN_OS) ;;
350 *-*-osf*) AC_DEFINE(HAVE_OSF1_OS) ;;
351 *-*-aix*) AC_DEFINE(HAVE_AIX_OS) ;;
352 *-*-hpux*) AC_DEFINE(HAVE_HPUX_OS) ;;
353 *-*-linux*) AC_DEFINE(HAVE_LINUX_OS) ;;
354 *-*-freebsd*) AC_DEFINE(HAVE_FREEBSD_OS) ;;
355 *-*-netbsd*) AC_DEFINE(HAVE_NETBSD_OS) ;;
356 *-*-openbsd*) AC_DEFINE(HAVE_OPENBSD_OS) ;;
357 *-*-bsdi*) AC_DEFINE(HAVE_BSDI_OS) ;;
358 *-*-irix*) AC_DEFINE(HAVE_SGI_OS) ;;
359 *-*-darwin*) AC_DEFINE(HAVE_DARWIN_OS) ;;
360 *-*-nto*) AC_DEFINE(HAVE_QNX_OS) ;;
364 dnl Check for enable particular features.
368 AC_HELP_STRING([--enable-all], [Enable all optional modules])],
369 [ if test "$enableval" = "yes" ; then
381 dnl halpolicydir configuration
384 dnl Establish default
387 HALPOLICYDIR="/usr/share/hal/fdi/policy/20thirdparty"
394 dnl Allow user override
395 AC_ARG_WITH(halpolicydir,
396 [AC_HELP_STRING([--with-halpolicydir=DIR], [HAL policy directory (default is platform dependent)])],
397 HALPOLICYDIR=$withval)
400 if test "x$HALPOLICYDIR" != "x" ; then
401 AC_MSG_RESULT([Using halpolicydir=$HALPOLICYDIR])
403 AC_MSG_RESULT([Will not install HAL policy file])
405 AC_SUBST(HALPOLICYDIR)
407 #--------------------------------------------------------------------
408 # Check for TCP wrapper support, code taken from Bacula KES-7Nov03
409 #--------------------------------------------------------------------
412 [AC_HELP_STRING([--with-libwrap=DIR], [Compile in libwrap (tcp_wrappers) support])],
414 if test "x$withval" != "xno" ; then
416 LIBS="$saved_LIBS -lwrap"
417 AC_MSG_CHECKING([for libwrap])
420 int deny_severity = 0;
421 int allow_severity = 0;
422 struct request_info *req; ],
423 [ hosts_access(req); ],
424 [ AC_MSG_RESULT([yes])
425 AC_DEFINE(HAVE_LIBWRAP)
427 [ LIBS="$saved_LIBS -lwrap -lnsl"
430 int deny_severity = 0;
431 int allow_severity = 0;
432 struct request_info *req; ],
433 [ hosts_access(req); ],
434 [ AC_MSG_RESULT([yes])
435 AC_DEFINE(HAVE_LIBWRAP)
437 [AC_MSG_ERROR([*** libwrap missing]) ] ]
446 dnl Check for enable of cgi program builds
454 [AC_HELP_STRING([--enable-cgi], [Compile CGI programs])],
455 [ if test "$enableval" = "yes"
460 dnl Check for GD Library check disable (disable called = "no")
462 [AC_HELP_STRING([--disable-lgd], [Disable GD Library])],
463 [ if test "$enableval" = "no"
465 AC_MSG_RESULT([Disabled GD Library (and associated checks).])
472 dnl First search for system library that defines gdImagePng
473 if test "${SYS_GD_FOUND}" = "no"
475 AC_CHECK_LIB(gd, gdImagePng,
476 [ AC_MSG_RESULT([using PNG file format (/usr/lib).])
477 AC_DEFINE(SYS_IMGFMT_PNG)
485 dnl Second search for system library that defines gdImageGif
486 if test "${SYS_GD_FOUND}" = "no"
488 AC_CHECK_LIB(gd, gdImageGif,
489 [ AC_MSG_RESULT([using GIF file format (/usr/lib).])
490 AC_DEFINE(SYS_IMGFMT_GIF)
498 dnl Third in /usr/local search for system library that defines gdImagePng
499 if test "${SYS_GD_FOUND}" = "no"
501 CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
502 LDFLAGS="${LDFLAGS} -L/usr/local/lib"
504 dnl Destroy cached value
505 unset ac_cv_lib_gd_gdImagePng
506 AC_CHECK_LIB(gd, gdImagePng,
507 [ AC_MSG_RESULT([using PNG file format (/usr/local/lib).])
508 AC_DEFINE(SYS_IMGFMT_PNG)
516 dnl Fourth in /usr/local search for system library that defines gdImageGif
517 if test "${SYS_GD_FOUND}" = "no"
519 dnl Destroy cached value
520 unset ac_cv_lib_gd_gdImageGif
521 AC_CHECK_LIB(gd, gdImageGif,
522 [ AC_MSG_RESULT([using GIF file format (/usr/local/lib).])
523 AC_DEFINE(SYS_IMGFMT_GIF)
530 if test "${SYS_GD_FOUND}" = "no"
532 AC_MSG_ERROR([Your system lacks the GD library which is needed for
533 compiling the apcupsd CGI programs. Please install
534 libgd and re-run the ./configure script.
535 Alternatively you can disable the CGI support.])
538 if test "${SKIP_GDHDR_CHECK}" = "no"
540 AC_CHECK_HEADER(gd.h, [ GDHEAD= ],
541 [ AC_CHECK_HEADER(gd/gd.h, [ GDHEAD="gd/" ],
542 [ AC_CHECK_HEADER(gd2/gd.h, [ GDHEAD="gd2/" ],
543 [ AC_MSG_ERROR([Found system GD library but no header file.
544 Please find the file gd.h in your system
545 include directories and report its location
546 to apcupsd-users@lists.sourceforge.net]) ])
552 AC_MSG_RESULT([Not using GD Library - no check performed for header files.])
559 dnl Check for enable of drivers
561 AC_ARG_ENABLE(apcsmart, [
562 AC_HELP_STRING([--enable-apcsmart], [Compile APC SmartUPS serial driver (default)])
563 AC_HELP_STRING([--disable-apcsmart], [No APC SmartUPS serial driver])],
564 [ if test "$enableval" = "yes" ; then
565 dnl This is for C code inclusion
566 AC_DEFINE(HAVE_APCSMART_DRIVER)
568 dnl This is for Makefile.in inside src/drivers/
569 APCSMART_DRIVER="apcsmart"
570 AC_SUBST(APCSMART_DRIVER)
572 [ AC_DEFINE(HAVE_APCSMART_DRIVER)
573 APCSMART_DRIVER="apcsmart"
574 AC_SUBST(APCSMART_DRIVER) ])
576 AC_ARG_ENABLE(dumb, [
577 AC_HELP_STRING([--enable-dumb], [Compile dumb UPS driver (default)])
578 AC_HELP_STRING([--disable-dumb], [No dumb UPS driver])],
579 [ if test "$enableval" = "yes" ; then
580 AC_DEFINE(HAVE_DUMB_DRIVER)
582 AC_SUBST(DUMB_DRIVER)
584 [ AC_DEFINE(HAVE_DUMB_DRIVER)
586 AC_SUBST(DUMB_DRIVER) ])
588 dnl Allow user to force USB type to generic
590 AC_ARG_WITH(generic-usb,
591 [AC_HELP_STRING([--with-generic-usb], [Force use of generic USB driver]) ],
595 AC_HELP_STRING([--enable-usb], [Compile USB UPS code])
596 AC_HELP_STRING([--disable-usb], [No USB UPS code (default)])],
597 [ if test "$enableval" = "yes" ; then
598 dnl USB driver is usually determined by host system.
599 dnl But if user forces generic_usb then fake it out.
600 if test $GENERICUSB = "yes" ; then
606 dnl Also force generic_usb if this is FreeBSD 8.0 or newer
610 if test ${tmp%%.*} -ge 8 ; then
619 AC_MSG_RESULT([Using Linux USB driver.])
621 *-*-freebsd* | *-*-openbsd* | *-*-netbsd*)
622 LIBUSBHIDINC="-I\$(topdir)/src/libusbhid"
624 APCDRVLIBS="$APCDRVLIBS \$(topdir)/src/libusbhid/libusbhid.a"
626 AC_SUBST(LIBUSBHIDINC)
628 AC_MSG_RESULT([Using BSD USB driver.])
631 dnl Use libusb-config if found, otherwise fall back on AC_CHECK_LIB
632 AC_PATH_PROG(usbcfg, libusb-config)
633 if test x$usbcfg != x ; then
634 LIBUSB=`$usbcfg --libs`
635 LIBUSBH=`$usbcfg --prefix`/include/usb.h
637 AC_CHECK_LIB(usb, usb_init,
640 [AC_MSG_ERROR(Unable to find libusb)],
646 LIBUSBHIDINC="-I\$(topdir)/src/libusbhid"
648 DRVLIBS="$DRVLIBS $LIBUSB"
649 APCDRVLIBS="$APCDRVLIBS \$(topdir)/src/libusbhid/libusbhid.a"
651 AC_SUBST(LIBUSBHIDINC)
653 AC_MSG_RESULT([Using generic libusb USB driver.])
657 AC_DEFINE(HAVE_USB_DRIVER)
662 DISPLAY_USB_DRIVER=$USB_TYPE-$USB_DRIVER
667 AC_HELP_STRING([--enable-net], [Compile networking driver for slaves (default)])
668 AC_HELP_STRING([--disable-net], [No network driver for slaves])],
669 [ if test "$enableval" = "yes" ; then
670 AC_DEFINE(HAVE_NET_DRIVER)
674 [ AC_DEFINE(HAVE_NET_DRIVER)
676 AC_SUBST(NET_DRIVER) ])
678 AC_ARG_ENABLE(snmp, [
679 AC_HELP_STRING([--enable-snmp], [Compile SNMP driver (default)])
680 AC_HELP_STRING([--disable-snmp], [No SNMP driver])],
681 [ if test "$enableval" = "yes" ; then
682 AC_DEFINE(HAVE_SNMPLITE_DRIVER)
683 SNMPLITE_DRIVER="snmplite"
684 DISPLAY_SNMP_DRIVER="snmp"
685 AC_SUBST(SNMPLITE_DRIVER)
687 [ AC_DEFINE(HAVE_SNMPLITE_DRIVER)
688 SNMPLITE_DRIVER="snmplite"
689 DISPLAY_SNMP_DRIVER="snmp"
690 AC_SUBST(SNMPLITE_DRIVER) ])
692 AC_ARG_ENABLE(net-snmp, [
693 AC_HELP_STRING([--enable-net-snmp], [Compile NET-SNMP UPS code (OBSOLETE)])
694 AC_HELP_STRING([--disable-net-snmp], [No NET-SNMP UPS code (default)])],
695 [ if test "$enableval" = "yes" ; then
696 dnl Check for optional crypto lib
697 AC_CHECK_LIB(crypto, EVP_DigestInit,
698 [echo ' including crypto library for snmp.'
699 DRVLIBS="$DRVLIBS -lcrypto"],
705 dnl libsnmp is often in /usr/local
706 CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
707 LDFLAGS="${LDFLAGS} -L/usr/local/lib"
709 dnl Start by looking for libnetsnmp (net-snmp).
710 if test "$SNMP_LIB_FOUND" = "no" ; then
711 AC_CHECK_LIB(netsnmp, snmp_open,
712 [DRVLIBS="$DRVLIBS -lnetsnmp"
713 AC_DEFINE(HAVE_NET_SNMP)
714 SNMP_LIB_FOUND="yes"], [], [$DRVLIBS])
717 dnl If no lib yet, fall back on libsnmp (ucd-snmp)
718 if test "$SNMP_LIB_FOUND" = "no" ; then
719 AC_CHECK_LIB(snmp, snmp_open,
720 [DRVLIBS="$DRVLIBS -lsnmp"
721 AC_DEFINE(HAVE_UCD_SNMP)
722 SNMP_LIB_FOUND="yes"], [], [$DRVLIBS])
725 if test "$SNMP_LIB_FOUND" = "no" ; then
726 AC_MSG_ERROR([Cannot find SNMP libraries.])
729 dnl If we get this far, we found a valid lib
730 AC_DEFINE(HAVE_SNMP_DRIVER)
731 DISPLAY_NETSNMP_DRIVER="net-snmp"
734 AC_SUBST(SNMP_DRIVER)
738 dnl Enable test driver
739 AC_ARG_ENABLE(test, [
740 AC_HELP_STRING([--enable-test], [Compile TEST driver code])
741 AC_HELP_STRING([--disable-test], [No TEST driver (default)])],
742 [ if test "$enableval" = "yes" ; then
743 AC_DEFINE(HAVE_TEST_DRIVER)
745 AC_SUBST(TEST_DRIVER)
749 dnl Enable pcnet driver
750 AC_ARG_ENABLE(pcnet, [
751 AC_HELP_STRING([--enable-pcnet], [Compile PCNET driver code (default)])
752 AC_HELP_STRING([--disable-pcnet], [No PCNET driver])],
753 [ if test "$enableval" = "yes" ; then
754 AC_DEFINE(HAVE_PCNET_DRIVER)
756 AC_SUBST(PCNET_DRIVER)
758 [ AC_DEFINE(HAVE_PCNET_DRIVER)
760 AC_SUBST(PCNET_DRIVER) ])
762 dnl Force NIS to enabled since libnis is required by apcaccess.
763 dnl Users may still disable NIS at runtime in apcupsd.conf.
764 AC_DEFINE(HAVE_NISSERVER)
765 AC_DEFINE(HAVE_NISLIB)
768 dnl Allow setting of NISIP value
771 [AC_HELP_STRING([--with-nisip=IP-ADDRESS], [Specify the IP address to bind to (default=0.0.0.0)])],
776 CGIBIN="/etc/apcupsd"
778 [AC_HELP_STRING([--with-cgi-bin=DIR], [Specify cgi-bin directory (default=/etc/apcupsd)])],
779 [CGIBIN="$withval";])
782 dnl Check for enable of gapcmon
786 AC_ARG_ENABLE(gapcmon,
787 [AC_HELP_STRING([--enable-gapcmon], [Build GTK/GUI front-end to apcupsd (default=no)])],
788 [ if test "$enableval" = "yes" ; then
793 dnl Check for Gnome packages
795 PKG_CHECK_MODULES(GAPCMON, gtk+-2.0 >= 2.4.0 glib-2.0 gthread-2.0 gconf-2.0)
796 GAPCMON_CFLAGS="$GAPCMON_CFLAGS -DVERSION=\\\"$VERSION\\\""
802 dnl Check for enable of apcagent
806 AC_ARG_ENABLE(apcagent,
807 [AC_HELP_STRING([--enable-apcagent], [Build menubar app for Mac OS X (default=no)])],
808 [ if test "$enableval" = "yes" ; then
815 AC_MSG_ERROR([apcagent can only be built on Mac OS X])
828 dnl Figure out which gethostbyname_r() variant we have
830 AX_FUNC_WHICH_GETHOSTBYNAME_R
831 case "$ac_cv_func_which_gethostbyname_r" in
833 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_3)
834 GAPCMON_CFLAGS="$GAPCMON_CFLAGS -DHAVE_FUNC_GETHOSTBYNAME_R_3"
838 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_5)
839 GAPCMON_CFLAGS="$GAPCMON_CFLAGS -DHAVE_FUNC_GETHOSTBYNAME_R_5"
843 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_6)
844 GAPCMON_CFLAGS="$GAPCMON_CFLAGS -DHAVE_FUNC_GETHOSTBYNAME_R_6"
848 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_0)
849 GAPCMON_CFLAGS="$GAPCMON_CFLAGS -DHAVE_FUNC_GETHOSTBYNAME_R_0"
853 AC_MSG_ERROR([gethostbyname_r is required])
857 if test -n "$GCC"; then
858 # Starting with GCC 3.0, you must link C++ programs against either
859 # libstdc++ (shared by default), or libsupc++ (always static). If
860 # you care about binary portability between Linux distributions,
861 # you need to either 1) build your own GCC with static C++ libraries
862 # or 2) link using gcc and libsupc++. We choose the latter since
863 # CUPS doesn't (currently) use any of the stdc++ library.
865 # Previous versions of GCC do not have the reliance on the stdc++
866 # or g++ libraries, so the extra supc++ library is not needed.
867 AC_MSG_CHECKING(if libsupc++ is required)
869 SUPC="`$CXX -print-file-name=libsupc++.a 2>/dev/null`"
872 # Library not found, so this is and older GCC...
876 # This is gcc 3.x, and it knows of libsupc++, so we need it
877 LIBS="$LIBS -lsupc++"
880 # See if this system has a broken libsupc++ that requires
881 # a workaround (FreeBSD 5.x, 6.x)
884 AC_MSG_CHECKING(if libsupc++ is missing __terminate_handler)
885 nm -C --defined-only "$SUPC" 2>/dev/null | grep __terminate_handler > /dev/null
886 if test $? -eq 0 ; then
889 AC_MSG_RESULT(yes -- will attempt workaround)
890 CPPFLAGS="$CPPFLAGS -DFREEBSD_SUPCPP_FIX"
897 # See if GCC supports -fno-exceptions...
898 AC_MSG_CHECKING(if GCC supports -fno-exceptions)
899 OLDCXXFLAGS="$CXXFLAGS"
900 CXXFLAGS="$CXXFLAGS -fno-exceptions"
904 CXXFLAGS="$OLDCXXFLAGS")
906 # See if GCC supports -fno-rtti...
907 AC_MSG_CHECKING(if GCC supports -fno-rtti)
908 OLDCXXFLAGS="$CXXFLAGS"
909 CXXFLAGS="$CXXFLAGS -fno-rtti"
913 CXXFLAGS="$OLDCXXFLAGS")
915 # Use -Wall on gcc only
916 CFLAGS="$CFLAGS -Wall"
917 CXXFLAGS="$CXXFLAGS -Wall"
936 AC_DEFINE_UNQUOTED(SYSCONFDIR, "$sysconfdir")
941 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we will probably
942 dnl find the mkinstalldirs script in another subdir than ($topdir).
943 dnl Try to locate it.
945 if test -n "$ac_aux_dir"; then
946 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
948 if test x$MKINSTALLDIRS = x ; then
949 MKINSTALLDIRS="\$(topdir)/autoconf/mkinstalldirs"
951 AC_SUBST(MKINSTALLDIRS)
954 dnl AC_CHECK_FUNC calls that might hack the Makefile must precede
955 dnl the following AC_SUBSTs
958 AC_SUBST(LIBEXTRAOBJ)
961 dnl Check out the wait reality. We have to assume sys/wait.h is present.
962 AC_CHECK_FUNCS(wait waitpid wait3)
963 AC_MSG_CHECKING([for union wait]);
964 AC_TRY_LINK([#include <sys/types.h>
965 #include <sys/wait.h>],
966 [union wait status; int pid; pid = wait (&status);
968 /* Some POSIXoid systems have both the new-style macros and the old
969 union wait type, and they do not work together. If union wait
970 conflicts with WEXITSTATUS et al, we don't want to use it at all. */
971 if (WEXITSTATUS (status) != 0) pid = -1;
974 /* Make sure union wait works with waitpid. */
975 pid = waitpid (-1, &status, 0);
978 [AC_DEFINE(HAVE_UNION_WAIT) AC_MSG_RESULT([yes])],
981 if test "$ENABLE_CGI" = "yes"
983 AC_CHECK_FUNCS( snprintf,,
984 [AC_MSG_ERROR([cannot find required function.])])
985 echo 'Enabling cgi program support...'
987 echo 'Disabling cgi support...'
991 dnl Find out the distribution. NOTE!!! Only determine the
992 dnl distribution here. Do all additional work below.
995 # now allow user to specify DISTNAME
996 AC_ARG_WITH(distname,
997 [AC_HELP_STRING([--with-distname=NAME], [Specify DISTNAME])],
1000 if test "x$DISTNAME" != "x"
1002 echo "distname set to $DISTNAME"
1003 elif test $HAVE_UNAME=yes -a x`uname -s` = xOSF1
1006 elif test $HAVE_UNAME=yes -a x`uname -s` = xHP-UX
1009 elif test $HAVE_UNAME=yes -a x`uname -s` = xSunOS
1012 elif test $HAVE_UNAME=yes -a x`uname -s` = xFreeBSD
1015 elif test $HAVE_UNAME=yes -a x`uname -s` = xNetBSD
1018 elif test $HAVE_UNAME=yes -a x`uname -s` = xOpenBSD
1021 elif test $HAVE_UNAME=yes -a x`uname -s` = xBSD/OS
1024 elif test $HAVE_UNAME=yes -a x`uname -s` = xDarwin
1027 elif test $HAVE_UNAME=yes -a x`uname -s` = xQNX
1030 elif test -f /etc/SuSE-release
1033 elif test -d /etc/SuSEconfig
1036 elif test -f /etc/mandrake-release
1039 elif test -f /etc/whitebox-release
1042 elif test -f /etc/redhat-release
1045 elif test -f /etc/yellowdog-release
1048 elif test -f /etc/debian_version
1051 elif test -f /etc/slackware-version
1054 elif test -f /etc/gentoo-release
1057 elif test -f /etc/engarde-version
1065 dnl Check for enable install of distdir
1069 AC_ARG_ENABLE(install-distdir,
1070 [AC_HELP_STRING([--enable-install-distdir], [Install distribution])],
1071 [ if test "$enableval" = "no" ; then
1078 dnl At this point, we define the apcupsd defaults for a
1079 dnl number of different values (directories, ports, etc)
1080 dnl When the distribution is determined a bit lower, the
1081 dnl default can be reset to correspond to the standard for
1083 dnl Finally, after that any value that the user has set via
1084 dnl command line options will apply.
1087 # Define the default UPS
1090 # Define the default Cable
1093 # set the default nologin directory
1096 # Find the default directory to put the root-mode PID file in
1097 for PIDDIR in "/var/run" "/etc/apcupsd"
1105 # Find the default directory to put the apcupsd.events and apcupsd.status files
1106 for LOGDIR in "/var/log" "/etc/apcupsd"
1114 # set the default serial port lock director
1115 for LOCKDIR in "/var/lock" "/var/spool/locks" "/etc/apcupsd"
1123 # set the default PWRFAILDIR
1124 PWRFAILDIR=${sysconfdir}
1126 # define the default serial port device
1127 SERIALDEV=/dev/ttyS0
1129 # define the default NIS (Network Information Server -- CGI) port
1133 # Now we set appropriate distribution specific
1134 # variables and defaults
1138 PTHREAD_LFLAGS="-lpthread -lexc"
1140 SERIALDEV=/dev/tty01
1141 LOCKDIR=/var/spool/locks
1144 platforms/alpha/apcupsd \
1145 platforms/alpha/awkhaltprog"
1148 DISTVER=`uname -a |awk '{print $3}'`
1151 DISTVER=`cat /etc/debian_version`
1153 platforms/debian/apcupsd \
1154 platforms/debian/ups-monitor"
1157 DISTVER=`uname -a |awk '{print $3}'`
1158 SERIALDEV=/dev/cuaa0
1161 LOCKDIR=/var/spool/lock
1162 PTHREAD_CFLAGS="-pthread"
1164 LDFLAGS="$LDFLAGS -pthread"
1166 platforms/freebsd/apcupsd \
1167 platforms/freebsd/apccontrol"
1170 DISTVER=`awk '/version / {print $5}' < /etc/gentoo-release`
1172 platforms/gentoo/apcupsd \
1173 platforms/gentoo/halt"
1177 SERIALDEV=/dev/tty0p0
1178 PTHREAD_CFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_REENTRANT"
1180 platforms/hpux/apcupsd \
1181 platforms/hpux/halt"
1184 DISTVER=`uname -a |awk '{print $3}'`
1185 SERIALDEV=/dev/cua01
1186 PTHREAD_CFLAGS="-pthread"
1188 LDFLAGS="$LDFLAGS -pthread"
1190 platforms/netbsd/apcupsd"
1193 DISTVER=`uname -a |awk '{print $3}'`
1194 SERIALDEV=/dev/cua01
1195 LOCKDIR=/var/spool/lock
1196 PTHREAD_CFLAGS="-pthread"
1198 LDFLAGS="$LDFLAGS -pthread"
1200 platforms/openbsd/apcupsd \
1201 platforms/openbsd/apccontrol"
1204 DISTVER=`cat /etc/mandrake-release | grep release | cut -f 5 -d ' '`
1206 platforms/mandrake/apcupsd \
1207 platforms/mandrake/apcupsd.spec \
1208 platforms/mandrake/awkhaltprog"
1211 if test -f /etc/whitebox-release ; then
1212 f=/etc/whitebox-release
1214 f=/etc/redhat-release
1216 if test `cat $f | grep release | cut -f 3 -d ' '`x = "Enterprise"x ; then
1217 DISTVER="Enterprise "`cat $f | grep release | cut -f 6 -d ' '`
1219 DISTVER=`cat /etc/redhat-release | grep release | cut -f 5 -d ' '`
1222 platforms/redhat/apcupsd \
1223 platforms/redhat/apcupsd.spec \
1224 platforms/redhat/awkhaltprog"
1227 if test `cat /etc/yellowdog-release | grep release | cut -f 3 -d ' '`x = "Enterprise"x ; then
1228 DISTVER="Enterprise "`cat /etc/yellowdog-release | grep release | cut -f 6 -d ' '`
1230 DISTVER=`cat /etc/yellowdog-release | grep release | cut -f 5 -d ' '`
1233 platforms/yellowdog/apcupsd \
1234 platforms/yellowdog/apcupsd.spec \
1235 platforms/yellowdog/awkhaltprog"
1238 DISTVER=`cat /etc/engarde-release | grep ersion | cut -f 5 -d ' '`
1240 platforms/engarde/apcupsd \
1241 platforms/engarde/apcupsd.spec \
1242 platforms/engarde/awkhaltprog"
1245 DISTVER=`cat /etc/slackware-version`
1247 platforms/slackware/apcupsd \
1248 platforms/slackware/rc6.patch"
1255 LOCKDIR=/var/spool/locks
1256 LOGDIR=${sysconfdir}
1257 APCUPSD_MAIL=/usr/bin/mailx
1258 PTHREAD_CFLAGS="-D_POSIX_PTHREAD_SEMANTICS"
1260 platforms/sun/apcupsd \
1261 platforms/sun/rc0.solaris \
1262 platforms/sun/apccontrol"
1265 DISTVER=`cat /etc/SuSE-release |grep VERSION| cut -f 3 -d ' '`
1267 platforms/suse/apcupsd \
1268 platforms/suse/awkhaltprog"
1274 platforms/suse/apcupsd \
1275 platforms/suse/halt-setup.sh \
1276 platforms/suse/halt"
1286 platforms/darwin/apcupsd \
1287 platforms/darwin/apccontrol"
1294 platforms/qnx/apcupsd \
1295 platforms/qnx/apccontrol"
1300 platforms/unknown/apcupsd \
1301 platforms/unknown/halt"
1304 AC_MSG_WARN([Something went wrong. Unknown DISTNAME $DISTNAME])
1309 dnl Allow user to set nologdir
1311 AC_ARG_WITH(nologin,
1312 [AC_HELP_STRING([--with-nologin=DIR], [Specify nologin file directory (default /etc)])],
1313 [ nologdir="$withval"; ])
1315 # now allow the user to specify the PID directory
1316 AC_ARG_WITH(pid-dir,
1317 [AC_HELP_STRING([--with-pid-dir=DIR], [Specify PIDDIR directory (default is OS dependent)])],
1318 [PIDDIR="$withval";])
1320 # now allow user to specify LOGDIR
1321 AC_ARG_WITH(log-dir,
1322 [AC_HELP_STRING([--with-log-dir=DIR], [Specify EVENTS and STATUS directory (default is OS dependent)])],
1323 [LOGDIR="$withval";])
1325 # now allow user to specify LOCKDIR
1326 AC_ARG_WITH(lock-dir,
1327 [AC_HELP_STRING([--with-lock-dir=DIR], [Specify serial port lock directory (default is OS dependent)])],
1328 [LOCKDIR="$withval";])
1330 # now allow user to specify PWRFAILDIR
1331 AC_ARG_WITH(pwrfail-dir,
1332 [AC_HELP_STRING([--with-pwrfail-dir=DIR], [Specify power failure file directory (default is OS dependent)])],
1333 [PWRFAILDIR="$withval";])
1335 # now allow user to specify SERIALDEV
1336 AC_ARG_WITH(serial-dev,
1337 [AC_HELP_STRING([--with-serial-dev=DEV], [Specify serial port device])],
1338 [SERIALDEV="$withval";])
1341 [AC_HELP_STRING([--with-dev=DEV], [Specify port or device])],
1342 [SERIALDEV="$withval";])
1344 # now allow user to specify NISPORT
1345 AC_ARG_WITH(nis-port,
1346 [AC_HELP_STRING([--with-nis-port=PORT], [Specify NIS (CGI) port (default 3551 except Debian)])],
1347 [NISPORT="$withval";])
1349 # now allow user to specify UPSTYPE
1350 AC_ARG_WITH(upstype,
1351 [AC_HELP_STRING([--with-upstype=TYPE], [Specify the UPS type])],
1352 [UPSTYPE="$withval";])
1354 # now allow user to specify UPSCABLE
1355 AC_ARG_WITH(upscable,
1356 [AC_HELP_STRING([--with-upscable=CABLE], [Specify the UPS cable])],
1357 [UPSCABLE="$withval";])
1362 AC_DEFINE_UNQUOTED(PIDDIR, "$PIDDIR")
1364 AC_DEFINE_UNQUOTED(LOGDIR, "$LOGDIR")
1366 AC_DEFINE_UNQUOTED(NOLOGDIR, "$nologdir")
1368 AC_DEFINE_UNQUOTED(PWRFAILDIR, "$PWRFAILDIR")
1369 AC_SUBST(PWRFAILDIR)
1372 AC_DEFINE_UNQUOTED(NISPORT, $NISPORT)
1377 AC_DEFINE_UNQUOTED(HOST, "$HOST")
1381 dnl Find out gcc's installation directory and include files. Used in
1384 dnl Make sure a gccinclude variable exist.
1385 dnl '.' is innocuous.
1388 if test "$CC" = "gcc"
1391 $CC -v 2> $srcdir/gcc.v
1392 gccinclude=`cat $srcdir/gcc.v|grep specs|awk '{print $4}'| \
1393 sed -e 's|specs|include|g'`
1394 echo "gcc private include directory found."
1399 dnl First entry must always be "variables.mak"
1402 autoconf/variables.mak \
1403 platforms/apccontrol \
1404 platforms/etc/changeme \
1405 platforms/etc/commfailure \
1406 platforms/etc/commok \
1407 platforms/etc/offbattery \
1408 platforms/etc/onbattery \
1409 platforms/etc/apcupsd.conf \
1410 examples/safe.apccontrol \
1411 src/win32/Makefile \
1414 if test "$USB_TYPE"x = "generic"x
1416 GENERATE_FILES="$GENERATE_FILES \
1417 src/drivers/usb/generic/libusb.h"
1420 if test "$ENABLE_CGI" = "yes"
1422 GENERATE_FILES="$GENERATE_FILES src/cgi/cgiconfig.h"
1425 AC_OUTPUT([ ${GENERATE_FILES} ], [])
1427 chmod 755 examples/safe.apccontrol
1431 # A whole lot of hand springs to get the compiler version.
1432 # This is because gcc changed the output in version 3.0
1434 CXXVERSION=`${CXX} --version | tr '\n' ' ' | cut -f 3 -d ' '`
1435 if test "x${CXXVERSION}" = "x" ; then
1436 CXXVERSION=`${CXX} --version | tr '\n' ' ' | cut -f 1 -d ' '`
1439 eval srcdir=${srcdir}
1440 eval sbindir=${sbindir}
1441 eval sysconfdir=${sysconfdir}
1442 eval mandir=${mandir}
1446 Configuration on `date`:
1448 Host: $host -- ${DISTNAME} ${DISTVER}
1449 Apcupsd version: ${VERSION} (${DATE})
1450 Source code location: ${srcdir}
1451 Install binaries: ${sbindir}
1452 Install config files: ${sysconfdir}
1453 Install man files: ${mandir}
1454 Nologin file in: ${nologdir}
1455 PID directory: ${PIDDIR}
1456 LOG dir (events, status) ${LOGDIR}
1457 LOCK dir (for serial port) ${LOCKDIR}
1458 Power Fail dir ${PWRFAILDIR}
1459 Compiler: ${CXX} ${CXXVERSION}
1460 Compiler flags: ${CPPFLAGS} ${CXXFLAGS} ${PTHREAD_FLAGS}
1462 Linker flags: ${LDFLAGS}
1463 Host and version: ${DISTNAME} ${DISTVER}
1464 Shutdown Program: ${SHUTDOWN}
1465 Port/Device: ${SERIALDEV}
1466 Network Info Port (CGI): ${NISPORT}
1468 UPSCABLE ${UPSCABLE}
1470 drivers (no-* are disabled): ${APCSMART_DRIVER:-no-apcsmart} ${DUMB_DRIVER:-no-dumb} ${NET_DRIVER:-no-net} ${DISPLAY_USB_DRIVER:-no-usb} ${DISPLAY_SNMP_DRIVER:-no-snmp} ${DISPLAY_NETSNMP_DRIVER:-no-net-snmp} ${PCNET_DRIVER:-no-pcnet} ${TEST_DRIVER:-no-test}
1472 enable-nis: ${NISSRV_ENABLED}
1473 with-nisip: ${NISIP}
1474 enable-cgi: ${ENABLE_CGI}
1475 disable-lgd: ${SKIP_GDHDR_CHECK}
1476 with-cgi-bin: ${CGIBIN}
1477 with-libwrap: ${with_libwrap}
1478 enable-pthreads: ${with_pthreads}
1479 enable-dist-install: ${with_distdir}
1480 enable-gapcmon: ${GAPCMON_ENABLED}
1481 enable-apcagent: ${APCAGENT_ENABLED}
1486 echo Configuration complete: Run \'$MAKE\' to build apcuspd.
1489 echo $PATH | grep /usr/ucb >/dev/null
1490 if test $? = 0 ; then
1492 WARNING! You have /usr/ucb on your path. We STRONGLY recommend
1493 that you remove it and rerun configure. Otherwise
1494 apcupsd may be unable to shutdown your system.