1dnl +------------------------------------------------------------------+
2dnl | Network UPS Tools: configure.ac                                  |
3dnl +------------------------------------------------------------------+
4
5dnl NUT version number is defined here, with a Git suffixed macro like
6dnl    NUT_VERSION_MACRO "2.7.4-2838-gdfc3ac08"
7dnl in include/nut_version.h (generated by make)
8AC_INIT([nut],[2.7.4.1],[https://github.com/networkupstools/nut/issues])
9AC_CONFIG_AUX_DIR([.])
10AC_CONFIG_SRCDIR(server/upsd.c)
11AC_CONFIG_MACRO_DIR([m4])
12echo "Network UPS Tools version ${PACKAGE_VERSION}"
13AC_CANONICAL_TARGET
14NUT_CHECK_OS
15NUT_STASH_WARNINGS
16AC_CONFIG_HEADERS([include/config.h])
17AC_PREFIX_DEFAULT(/usr/local/ups)
18AM_INIT_AUTOMAKE([subdir-objects])
19
20dnl we need Autoconf 2.61 or better to enable features of Posix that are extensions to C
21AC_MSG_CHECKING(for autoconf macro to enable system extensions)
22m4_version_prereq(2.61, [
23	AC_MSG_RESULT(yes)
24	AC_USE_SYSTEM_EXTENSIONS
25], [
26	AC_MSG_RESULT(no)
27])
28
29dnl Use "./configure --enable-maintainer-mode" to keep Makefile.in and Makefile
30dnl in sync after Git updates.
31AM_MAINTAINER_MODE
32
33dnl Some systems have older autotools without direct macro support for PKG_CONF*
34NUT_CHECK_PKGCONFIG
35
36
37dnl Various version related processing
38dnl ----------------------------------
39
40dnl # the following is commented out, because the UPS_VERSION macro now
41dnl # resides in include/nut_version.h, which is generated by Makefile.am,
42dnl # rather than in include/config.h, which is generated by configure.  The
43dnl # reason is that the SVN revision should be computed at compile time,
44dnl # not configure time.
45dnl AC_DEFINE_UNQUOTED(UPS_VERSION, "${PACKAGE_VERSION}", [NUT version])
46
47dnl However, automatically define the tree version (mostly for AC_SUBST)
48TREE_VERSION="`echo ${PACKAGE_VERSION} | awk '{ print substr($0,1,3) }'`"
49AC_DEFINE_UNQUOTED(TREE_VERSION, "${TREE_VERSION}", [NUT tree version])
50
51dnl Should not be necessary, since old servers have well-defined errors for
52dnl unsupported commands:
53NUT_NETVERSION="1.2"
54AC_DEFINE_UNQUOTED(NUT_NETVERSION, "${NUT_NETVERSION}", [NUT network protocol version])
55
56
57dnl Fix this early so we can expand with eval later
58test "${prefix}" = "NONE" && prefix="${ac_default_prefix}"
59test "${exec_prefix}" = "NONE" && exec_prefix='${prefix}'
60
61CFLAGS=${CFLAGS-"-O"}
62
63dnl NOTE: for definition of NUT_* autoconf macros, see m4/ directory
64dnl and docs/macros.txt
65
66dnl +------------------------------------------------------------------+
67dnl | default values for things later on (can be overridden)           |
68
69STATEPATH="/var/state/ups"
70
71cgiexecdir='${exec_prefix}/cgi-bin'
72driverexecdir='${exec_prefix}/bin'
73htmldir='${prefix}/html'
74pkgconfigdir='${libdir}/pkgconfig'
75auglensdir='/usr/share/augeas/lenses/dist'
76if test ! -d "${auglensdir}"; then
77   auglensdir='/usr/share/augeas/lenses'
78   if test ! -d "${auglensdir}"; then
79      auglensdir=''
80   fi
81fi
82hotplugdir='/etc/hotplug'
83if test ! -d "${hotplugdir}"; then
84   hotplugdir=''
85fi
86udevdir='/lib/udev'
87if test ! -d "${udevdir}"; then
88   udevdir='/etc/udev'
89   if test ! -d "${udevdir}"; then
90      udevdir=''
91   fi
92fi
93
94devddir='/usr/local/etc/devd'
95if test ! -d "${devddir}"; then
96   devddir='/etc/devd'
97   if test ! -d "${devddir}"; then
98      devddir=''
99   fi
100fi
101
102RUN_AS_USER="nobody"
103RUN_AS_GROUP="nobody"
104PIDPATH="/var/run"
105
106dnl Define directory where LIBOBJS replacement functions are
107AC_CONFIG_LIBOBJ_DIR([common])
108
109dnl +-------------------------------------------------------------------
110
111dnl AC_PROG_CC
112dnl Macro AC_PROG_CC_C99 is obsolete; use AC_PROG_CC
113dnl Note that NUT does not support building with C89 anyway
114dnl AC_PROG_CC_C99
115dnl Needed for per-target flags
116AM_PROG_CC_C_O
117AC_PROG_CPP
118AC_PROG_CXX
119AC_PROG_CXX_C_O
120AC_PROG_INSTALL
121AC_PROG_MKDIR_P
122AC_PROG_LN_S
123AC_PROG_EGREP
124AC_PATH_PROG(AR, ar)
125AC_CHECK_TOOL(RANLIB, ranlib, :)
126dnl Postpone call to LT_INIT/AC_CONFIG_FILES to allow disabling static lib
127AC_C_BIGENDIAN
128AC_C_INLINE
129AC_C_FLEXIBLE_ARRAY_MEMBER
130AC_C_VARARRAYS
131dnl Note: the compiler/pragma/attr methods below are custom for NUT codebase:
132NUT_COMPILER_FAMILY
133NUT_COMPILER_FAMILY_FLAGS
134AX_C_PRAGMAS
135AX_C___ATTRIBUTE__
136AX_C_PRINTF_STRING_NULL
137AC_CHECK_FUNCS(flock lockf fcvt fcvtl pow10 round abs_val abs)
138
139AC_CHECK_HEADER([float.h],
140    [AC_DEFINE([HAVE_FLOAT_H], [1],
141        [Define to 1 if you have <float.h>.])])
142AC_CHECK_HEADER([math.h],
143    [AC_DEFINE([HAVE_MATH_H], [1],
144        [Define to 1 if you have <math.h>.])])
145AC_CHECK_FUNCS(fabs fabsf fabsl, [], [],
146[#ifdef HAVE_MATH_H
147# include <math.h>
148#endif
149#ifdef HAVE_FLOAT_H
150# include <float.h>
151#endif])
152
153AC_CHECK_HEADER([limits.h],
154    [AC_DEFINE([HAVE_LIMITS_H], [1],
155        [Define to 1 if you have <limits.h>.])])
156
157AC_CHECK_HEADER([sys/resource.h],
158    [AC_MSG_CHECKING([for struct rlimit and getrlimit()])
159     AC_LANG_PUSH([C])
160     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
161#include <sys/resource.h>
162],
163[struct rlimit limit;
164getrlimit(RLIMIT_NOFILE, &limit);
165/* Do not care about actual return value in this test,
166 * normally check for non-zero meaning to look in errno */
167]
168        )],
169        [AC_DEFINE([HAVE_SYS_RESOURCE_H], [1],
170            [Define to 1 if you have <sys/resource.h> with usable struct rlimit and getrlimit().])
171         AC_MSG_RESULT([ok])
172        ],
173        [AC_MSG_RESULT([no])]
174     )
175     AC_LANG_POP([C])
176    ]
177)
178
179AC_CHECK_HEADER([semaphore.h],
180    [AC_DEFINE([HAVE_SEMAPHORE_H], [1],
181        [Define to 1 if you have <sys/semaphore.h>.])
182     AC_MSG_CHECKING([for sem_t, sem_init() and sem_destroy()])
183     AC_LANG_PUSH([C])
184     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
185#include <semaphore.h>
186],
187[sem_t semaphore;
188sem_init(&semaphore, 0, 4);
189sem_destroy(&semaphore);
190/* Do not care about actual return value in this test,
191 * normally check for non-zero meaning to look in errno */
192]
193        )],
194        [AC_DEFINE([HAVE_SEMAPHORE], [1],
195            [Define to 1 if you have <sys/semaphore.h> with usable sem_t sem_init() and sem_destroy().])
196         AC_MSG_RESULT([ok])
197        ],
198        [AC_MSG_RESULT([no])]
199     )
200     AC_LANG_POP([C])
201    ]
202)
203
204AC_CHECK_FUNCS(cfsetispeed tcsendbreak)
205AC_CHECK_FUNCS(seteuid setsid getpassphrase)
206AC_CHECK_FUNCS(on_exit strptime setlogmask)
207AC_CHECK_DECLS(LOG_UPTO, [], [], [#include <syslog.h>])
208
209dnl These common routines are not available in strict C standard library
210dnl compilation modes, only in GNU, POSIX or other extension modes:
211AC_MSG_NOTICE(
212[-----------------------------------------------------------------------
213The next few tests look for required C library routines; if something is
214not found, you may need to enable a different C standard or extension macro
215version. You may also have to configure without extreme warning levels
216since autotools tests fail those on their own and assume system lacks
217stuff (although note we try to not involve standard -W* flags here).
218-----------------------------------------------------------------------])
219AC_CHECK_FUNCS(strcasecmp strncasecmp,
220	[], [AC_MSG_WARN([Required C library routine not found; try adding __EXTENSIONS__])])
221dnl These appear with CFLAGS="-std=c99 -D_POSIX_C_SOURCE=200112L":
222AC_CHECK_FUNCS(strtok_r strdup fileno usleep localtime_r sigemptyset sigaction,
223	[], [AC_MSG_WARN([Required C library routine not found; try adding -D_POSIX_C_SOURCE=200112L])])
224
225dnl These routines' arg types differ in strict C standard mode
226dnl from what they use in the modes expected by NUT codebase:
227dnl   bind() :     /usr/include/x86_64-linux-gnu/sys/socket.h:123:12: note: expected '__CONST_SOCKADDR_ARG {aka union <anonymous>}' but argument is of type 'struct sockaddr *'
228dnl   accept() :   /usr/include/x86_64-linux-gnu/sys/socket.h:243:12: note: expected '__SOCKADDR_ARG {aka union <anonymous>}' but argument is of type 'struct sockaddr *'
229dnl   connect() :  /usr/include/x86_64-linux-gnu/sys/socket.h:137:12: note: expected '__CONST_SOCKADDR_ARG {aka union <anonymous>}' but argument is of type 'const struct sockaddr *'
230dnl   sendto() :   /usr/include/x86_64-linux-gnu/sys/socket.h:163:16: note: expected '__CONST_SOCKADDR_ARG {aka union <anonymous>}' but argument is of type 'struct sockaddr *'
231dnl   recvfrom() : /usr/include/x86_64-linux-gnu/bits/socket2.h:64:1: note: expected '__SOCKADDR_ARG {aka union <anonymous>}' but argument is of type 'struct sockaddr *'
232
233AC_MSG_CHECKING([whether ln -sr works])
234dnl We need to relative-symlink some files. Or hardlink. Or copy...
235LN_S_R="cp -pR"
236if test "$as_ln_s" = "ln -s" ; then
237    LN_S_R="ln"
238    DIR1="$(mktemp -d "dir1.XXXXXXX")" && \
239    DIR2="$(mktemp -d "dir2.XXXXXXX")" && \
240    touch "${DIR1}/a" && \
241    $as_ln_s -r "${DIR1}/a" "${DIR2}/b" && \
242    ls -la "${DIR2}/b" | grep '\.\./' > /dev/null && \
243    LN_S_R="$as_ln_s -r"
244    rm -rf "${DIR1}" "${DIR2}"
245fi
246AC_SUBST([LN_S_R], [${LN_S_R}])
247if test "$LN_S_R" = "ln -s -r" ; then
248  AC_MSG_RESULT([yes])
249else
250  AC_MSG_RESULT([no, using $LN_S_R])
251fi
252
253dnl the following may add stuff to LIBOBJS (is this still needed?)
254AC_CHECK_FUNCS(vsnprintf snprintf, [], [
255	AC_LIBOBJ(snprintf)
256	AC_TYPE_LONG_DOUBLE
257	AC_TYPE_LONG_LONG_INT
258])
259
260AC_REPLACE_FUNCS(setenv strerror atexit)
261
262case ${target_os} in
263   solaris2* )
264      dnl On Solaris, this allows errno to use thread local storage
265      CFLAGS="${CFLAGS} -D_REENTRANT"
266      ;;
267   aix* )
268      dnl On AIX, this allows errno to use thread local storage
269      CFLAGS="${CFLAGS} -D_REENTRANT"
270      ;;
271   hpux11* )
272      dnl It seems like the thread safe string functions will not be included
273      dnl on 64 bit HP-UX unless we define _REENTRANT
274      CFLAGS="${CFLAGS} -D_REENTRANT"
275      ;;
276esac
277
278dnl optind handling:
279dnl need to check if unistd.h is enough, else try getopt.h, else need decls
280AC_CHECK_DECLS(optind, [], [
281	AC_CHECK_HEADERS(getopt.h, [
282		AC_DEFINE(NEED_GETOPT_H, 1, [Define if getopt.h is needed])
283	], [
284		AC_DEFINE(NEED_GETOPT_DECLS, 1, [Define to use explicit getopt declarations])
285	], [AC_INCLUDES_DEFAULT])
286], [AC_INCLUDES_DEFAULT])
287
288dnl do a 2nd check to ensure inclusion of getopt.h, in case optind is known
289AC_CHECK_HEADERS(getopt.h, [
290	AC_DEFINE(NEED_GETOPT_H, 1, [Define if getopt.h is needed])
291], [
292	AC_DEFINE(NEED_GETOPT_DECLS, 1, [Define to use explicit getopt declarations])
293], [AC_INCLUDES_DEFAULT])
294
295dnl also check for getopt_long
296AC_CHECK_FUNCS(getopt_long)
297
298dnl FreeBSD serial locking compatibility - look for uu_lock in libutil.h
299AC_CHECK_DECLS(uu_lock, [
300	AC_DEFINE(HAVE_UU_LOCK, 1, [Use uu_lock for locking (FreeBSD)])
301	SERLIBS="-lutil"
302	dnl put in some better defaults for FreeBSD
303	RUN_AS_USER="uucp"
304], [
305	SERLIBS=""
306], [
307#include <sys/types.h>
308#include <libutil.h>
309])
310
311AC_CHECK_DECLS(__func__, [], [
312	AC_CHECK_DECLS(__FUNCTION__, [
313		AC_DEFINE(__func__, __FUNCTION__, [Replace missing __func__ declaration])
314	], [
315		AC_DEFINE(__func__, __LINE__, [Replace missing  __func__ declaration])
316	], [AC_INCLUDES_DEFAULT])
317], [AC_INCLUDES_DEFAULT])
318
319dnl Solaris compatibility - check for -lnsl and -lsocket
320AC_SEARCH_LIBS(gethostbyname, nsl)
321AC_SEARCH_LIBS(connect, socket)
322
323dnl All current systems provide time.h; it need not be checked for.
324dnl Not all systems provide sys/time.h, but those that do, all allow
325dnl you to include it and time.h simultaneously.
326dnl NUT codebase provides the include/timehead.h to wrap these nuances.
327AC_CHECK_HEADERS_ONCE([sys/time.h time.h sys/types.h sys/socket.h netdb.h])
328AS_IF([test "$ac_cv_header_sys_time_h" = yes],
329    [AC_DEFINE([TIME_WITH_SYS_TIME],[1],[Define to 1 if you can safely include both <sys/time.h>
330	     and <time.h>.  This macro is deemed obsolete by autotools.])
331    ], [])
332
333AC_CHECK_HEADERS(sys/modem.h stdarg.h varargs.h, [], [], [AC_INCLUDES_DEFAULT])
334
335
336dnl pthread related checks
337dnl Note: pthread_tryjoin_np() should be available since glibc 2.3.3, according
338dnl to https://man7.org/linux/man-pages/man3/pthread_tryjoin_np.3.html
339AC_SEARCH_LIBS([pthread_create], [pthread],
340       [AC_DEFINE(HAVE_PTHREAD, 1, [Define to enable pthread support code])
341        AC_SEARCH_LIBS([pthread_tryjoin_np], [pthread],
342               [AC_DEFINE(HAVE_PTHREAD_TRYJOIN, 1, [Define to enable pthread_tryjoin support code])],
343               [])
344       ],
345       [])
346
347dnl ----------------------------------------------------------------------
348dnl Check for types and define possible replacements
349NUT_TYPE_SOCKLEN_T
350NUT_FUNC_GETNAMEINFO_ARGTYPES
351
352dnl ----------------------------------------------------------------------
353dnl Check for python binary program names per language version
354dnl to embed into scripts and Make rules
355NUT_CHECK_PYTHON
356NUT_CHECK_PYTHON2
357NUT_CHECK_PYTHON3
358
359dnl ----------------------------------------------------------------------
360dnl check for --with-all (or --without-all, or --with-all=auto) flag
361
362AC_MSG_CHECKING(for --with-all)
363AC_ARG_WITH(all,
364	AS_HELP_STRING([--with-all], [enable serial, usb, snmp, neon, ipmi, powerman, modbus, cgi, dev, avahi, linux_i2c]),
365[
366	if test -n "${withval}"; then
367		dnl Note: we allow "no" as a positive value, because
368		dnl this is what the user expects from --without-all
369		if test -z "${with_serial}"; then with_serial="${withval}"; fi
370		if test -z "${with_usb}"; then with_usb="${withval}"; fi
371		if test -z "${with_snmp}"; then with_snmp="${withval}"; fi
372		if test -z "${with_neon}"; then with_neon="${withval}"; fi
373		if test -z "${with_powerman}"; then with_powerman="${withval}"; fi
374		if test -z "${with_modbus}"; then with_modbus="${withval}"; fi
375		if test -z "${with_cgi}"; then with_cgi="${withval}"; fi
376		if test -z "${with_dev}"; then with_dev="${withval}"; fi
377		if test -z "${with_avahi}"; then with_avahi="${withval}"; fi
378		if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi
379		if test -z "${with_linux_i2c}"; then with_linux_i2c="${withval}"; fi
380		AC_MSG_RESULT("${withval}")
381	else
382		AC_MSG_RESULT(not given)
383	fi
384], [
385	AC_MSG_RESULT(not given)
386])
387
388dnl ----------------------------------------------------------------------
389dnl declare a number of --with-FEATURE options. Do this early, so that
390dnl they are listed near the top by "./configure --help"
391
392NUT_ARG_WITH([dev], [build and install the development files], [no])
393NUT_ARG_WITH([serial], [build and install serial drivers], [yes])
394NUT_ARG_WITH([usb], [build and install USB drivers], [auto])
395NUT_ARG_WITH([avahi], [build and install Avahi support], [auto])
396dnl The NUT legacy option was --with-doc; however to simplify configuration
397dnl in some common packaging frameworks, we also allow --with-docs as
398dnl a second-class citizen (if both are set, the old option name wins).
399dnl Also note that the legacy default was "man=yes" due to requirements
400dnl of the "make distcheck", but it was reduced to "man=auto" so that
401dnl the usual builds can pass by default on systems without asciidoc.
402NUT_ARG_WITH([docs], [build and install documentation (alias to --with-doc)], [man=auto])
403NUT_ARG_WITH([doc], [build and install documentation (see docs/configure.txt for many variants of the option)], [${nut_with_docs}])
404NUT_ARG_ENABLE([warnings], [enable warning presets that were picked as useful in maintainership and CI practice (variants include gcc-minimal, gcc-medium, gcc-hard, clang-minimal, clang-medium, clang-hard, all; auto-choosers: hard, medium, minimal, yes=auto='gcc or clang or all at hardcoded default difficulty')], [legacy])
405NUT_ARG_ENABLE([Werror], [fail the build if compiler emits any warnings (treat them as errors)], [no])
406
407dnl ----------------------------------------------------------------------
408dnl Check for presence and compiler flags of various libraries
409
410dnl These checks are performed unconditionally, even if the corresponding
411dnl --with-* options are not given. This is because we cannot predict
412dnl what will be in the --with-drivers argument.
413
414NUT_CHECK_LIBNETSNMP
415NUT_CHECK_LIBUSB
416NUT_ARG_WITH([snmp], [build and install SNMP drivers], [auto])
417NUT_CHECK_LIBNETSNMP
418NUT_ARG_WITH([neon], [build and install neon based XML/HTTP driver], [auto])
419NUT_CHECK_LIBNEON
420NUT_ARG_WITH([powerman], [build and install Powerman PDU client driver], [auto])
421NUT_CHECK_LIBPOWERMAN
422NUT_ARG_WITH([modbus], [build and install modbus drivers], [auto])
423NUT_CHECK_LIBMODBUS
424NUT_CHECK_LIBAVAHI
425
426dnl ----------------------------------------------------------------------
427dnl additional USB-related checks
428
429dnl Solaris 10/11 USB handling (need librt and libusb runtime path)
430dnl HPUX, since v11, needs an explicit activation of pthreads
431case ${target_os} in
432   solaris2.1* )
433      AC_MSG_CHECKING([for Solaris 10 / 11 specific configuration for usb drivers])
434      AC_SEARCH_LIBS(nanosleep, rt)
435      LIBUSB_LIBS="-R/usr/sfw/lib ${LIBUSB_LIBS}"
436      dnl FIXME: Sun's libusb doesn't support timeout (so blocks notification)
437      dnl and need to call libusb close upon reconnection
438      AC_DEFINE(SUN_LIBUSB, 1, [Define to 1 for Sun version of the libusb.])
439      SUN_LIBUSB=1
440      AC_MSG_RESULT([${LIBUSB_LIBS}])
441      ;;
442    hpux11*)
443      CFLAGS="${CFLAGS} -lpthread"
444      ;;
445esac
446
447
448dnl ----------------------------------------------------------------------
449dnl checks related to --with-serial
450
451dnl ${nut_with_serial}: any value except "yes" or "no" is treated as "auto".
452dnl Below we try to detect if we can build serial drivers, and if we must?
453AS_IF([test "${nut_with_serial}" != "no"],
454    [AS_IF([test "${nut_with_serial}" != "yes"],[nut_with_serial="auto"])
455
456    CFLAGS_SAVED_SERIAL="${CFLAGS}"
457    AS_IF([test "${GCC}" = yes],
458        [CFLAGS_SAVED_WERROR="${CFLAGS} -Wall -Werror"
459         CFLAGS_SAVED_WNOERROR="${CFLAGS} -Wno-error"
460        ],
461        [CFLAGS_SAVED_WERROR="${CFLAGS}"
462         CFLAGS_SAVED_WNOERROR="${CFLAGS}"
463        ])
464
465    dnl At least recent *BSD distros have deprecated sys/termios.h and spew
466    dnl warnings that termios.h should be used instead. This is redundantly
467    dnl fatal for pedantic builds where we aim to have no warnings in code.
468    dnl So there AC_CHECK_HEADERS does find the header, but we don't really
469    dnl want to use it unless we have no choice: if there is a warning while
470    dnl trying sys/ version, try the plain header path (without fatal warnings),
471    dnl and only if that is missing - retry with the sys/ version again (and
472    dnl no warnings still).
473
474    CFLAGS="${CFLAGS_SAVED_WERROR}"
475    AC_CHECK_HEADERS(sys/termios.h, [], [
476        CFLAGS="${CFLAGS_SAVED_WNOERROR}"
477        AC_CHECK_HEADERS(termios.h, [], [
478            AC_CHECK_HEADERS(sys/termios.h, [], [], [AC_INCLUDES_DEFAULT])
479            ], [AC_INCLUDES_DEFAULT])
480        ], [AC_INCLUDES_DEFAULT])
481
482    dnl CFLAGS at this point suffice for surviving a compilation with termios.h
483
484    dnl Don't mind the stupid code below, it just probes the tokens and
485    dnl sails around compiler warnings
486    AC_MSG_CHECKING([for struct termios and speed_t])
487    AC_LANG_PUSH([C])
488    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
489#if defined(HAVE_SYS_TERMIOS_H)
490#  include <sys/termios.h>      /* for speed_t */
491#else
492# if defined(HAVE_TERMIOS_H)
493#  include <termios.h>
494# endif /* HAVE_TERMIOS_H */
495#endif /* HAVE_SYS_TERMIOS_H */
496void getspeed(speed_t* b) { *b = B19200; }
497],
498[struct termios tio;
499if (!tcgetattr(0, &tio)) { return 1; }
500speed_t baudrate;
501getspeed(&baudrate);
502]
503        )],
504        [AC_MSG_RESULT([ok])
505         nut_have_serial_types=yes
506        ],
507        [AC_MSG_RESULT([no, struct termios and/or speed_t not found in discovered headers])
508         nut_have_serial_types=no
509        ]
510     )
511     AC_LANG_POP([C])
512
513     dnl Restore common set-or-discovered CFLAGS
514     CFLAGS="${CFLAGS_SAVED_SERIAL}"
515
516     AC_MSG_CHECKING([whether we can build serial drivers])
517     AS_IF([test "${nut_have_serial_types}" = yes],
518        [AS_IF([test "${nut_with_serial}" = "auto"],[nut_with_serial="yes"])],
519        [AS_IF([test "${nut_with_serial}" = "auto"],[nut_with_serial="no"])
520         AS_IF([test "${nut_with_serial}" = "yes"],[AC_MSG_ERROR([no, and were required to])])
521        ])
522     AS_IF([test "${nut_with_serial}" = "yes"],
523        [AC_MSG_RESULT([yes])],
524        [AC_MSG_RESULT([no])])
525])
526
527NUT_REPORT_FEATURE([build serial drivers], [${nut_with_serial}], [],
528					[WITH_SERIAL], [Define to enable serial support])
529
530dnl ----------------------------------------------------------------------
531dnl checks related to --with-usb
532
533dnl ${nut_with_usb}: any value except "yes" or "no" is treated as "auto".
534if test "${nut_with_usb}" = "yes" -a "${nut_have_libusb}" != "yes"; then
535   AC_MSG_ERROR([USB drivers requested, but libusb not found.])
536fi
537
538if test "${nut_with_usb}" != "no"; then
539   nut_with_usb="${nut_have_libusb}"
540fi
541
542NUT_REPORT_FEATURE([build USB drivers], [${nut_with_usb}], [],
543					[WITH_USB], [Define to enable USB support])
544
545dnl ----------------------------------------------------------------------
546dnl checks related to --with-neon
547
548dnl ${nut_with_neon}: any value except "yes" or "no" is treated as "auto".
549if test "${nut_with_neon}" = "yes" -a "${nut_have_neon}" != "yes"; then
550   AC_MSG_ERROR([neon libraries not found, required for neon based XML/HTTP driver])
551fi
552
553if test "${nut_with_neon}" != "no"; then
554   nut_with_neon="${nut_have_neon}"
555fi
556
557NUT_REPORT_FEATURE([build neon based XML driver], [${nut_with_neon}], [],
558					[WITH_NEON], [Define to enable Neon HTTP support])
559AM_CONDITIONAL([HAVE_NEON], [test "${nut_have_neon}" = "yes"])
560
561dnl ----------------------------------------------------------------------
562dnl checks related to --with-avahi
563
564dnl ${nut_with_avahi}: any value except "yes" or "no" is treated as "auto".
565if test "${nut_with_avahi}" = "yes" -a "${nut_have_avahi}" != "yes"; then
566   AC_MSG_ERROR([avahi libraries not found])
567fi
568
569if test "${nut_with_avahi}" != "no"; then
570   nut_with_avahi="${nut_have_avahi}"
571fi
572
573NUT_REPORT_FEATURE([enable Avahi support], [${nut_with_avahi}], [],
574					[WITH_AVAHI], [Define to enable Avahi support])
575
576dnl ----------------------------------------------------------------------
577
578dnl checks related to --with-powerman
579
580dnl ${nut_with_powerman}: any value except "yes" or "no" is treated as "auto".
581if test "${nut_with_powerman}" = "yes" -a "${nut_have_libpowerman}" != "yes"; then
582   AC_MSG_ERROR([Powerman client libraries not found, required for Powerman PDU client driver])
583fi
584
585if test "${nut_with_powerman}" != "no"; then
586   nut_with_powerman="${nut_have_libpowerman}"
587fi
588
589NUT_REPORT_FEATURE([build Powerman PDU client driver], [${nut_with_powerman}], [],
590					[WITH_LIBPOWERMAN], [Define to enable Powerman PDU support])
591
592dnl ----------------------------------------------------------------------
593dnl checks related to --with-modbus
594
595dnl ${nut_with_modbus}: any value except "yes" or "no" is treated as "auto".
596if test "${nut_with_modbus}" = "yes" -a "${nut_have_libmodbus}" != "yes"; then
597   AC_MSG_ERROR([modbus library not found, required for Modbus driver])
598fi
599
600if test "${nut_with_modbus}" != "no"; then
601   nut_with_modbus="${nut_have_libmodbus}"
602fi
603
604NUT_REPORT_FEATURE([build Modbus driver], [${nut_with_modbus}], [],
605                                       [WITH_MODBUS], [Define to enable Modbus support])
606dnl ----------------------------------------------------------------------
607dnl Check for with-ipmi, and --with-freeipmi (or --with-openipmi)
608dnl Only one can be enabled at a time, with a preference for FreeIPMI
609dnl if both are available (since it is the only one supported ATM!!)
610
611nut_ipmi_lib=""
612
613NUT_ARG_WITH([ipmi], [build and install IPMI PSU driver], [auto])
614NUT_ARG_WITH([freeipmi], [enable IPMI support using FreeIPMI], [auto])
615dnl NUT_ARG_WITH([openipmi], [enable IPMI support using OpenIPMI], [auto])
616
617dnl ${nut_with_ipmi}: any value except "yes" or "no" is treated as "auto".
618if test "${nut_with_ipmi}" != "no"; then
619   dnl check if FreeIPMI (and maybe later OpenIPMI) was explicitly requested
620   if test "${nut_with_freeipmi}" = "yes"; then
621      NUT_CHECK_LIBFREEIPMI
622      if test "${nut_have_freeipmi}" != "yes"; then
623         AC_MSG_ERROR([FreeIPMI not found, required for IPMI support])
624      fi
625      dnl Implies --with-ipmi
626      nut_with_ipmi="yes"
627   dnl elif test "${nut_with_openipmi}" = "yes"; then
628      dnl AC_MSG_ERROR([OpenIPMI is not yet supported])
629      dnl NUT_CHECK_LIBOPENIPMI
630      dnl if test "${nut_have_openipmi}" != "yes"; then
631      dnl    AC_MSG_ERROR([OpenIPMI not found, required for IPMI support])
632      dnl fi
633      dnl    Implies --with-ipmi
634      dnl    nut_with_ipmi="yes"
635      dnl    AC_DEFINE(WITH_OPENIPMI, 1, [Define to enable IPMI support using OpenIPMI])
636   else
637      dnl Prefer FreeIPMI over OpenIPMI otherwise
638      NUT_CHECK_LIBFREEIPMI
639      if test "${nut_have_freeipmi}" != "yes"; then
640         if test "${nut_with_ipmi}" = "yes"; then
641            AC_MSG_ERROR([FreeIPMI not found, required for IPMI support])
642         fi
643         nut_with_ipmi="no"
644         dnl NUT_CHECK_OPENIPMI
645         dnl if test "${nut_have_openipmi}" != "yes"; then
646         dnl    if test "${nut_with_ipmi}" = "yes"; then
647         dnl       AC_MSG_ERROR([Neither GNU FreeIPMI nor OpenIPMI was found (required for IPMI support)])
648         dnl    fi
649         dnl    nut_with_ipmi="no"
650         dnl else
651         dnl    Implies --with-ipmi
652         dnl    nut_with_ipmi="yes"
653         dnl    nut_with_openipmi="yes"
654         dnl fi
655      else
656         dnl Implies --with-ipmi
657         nut_with_ipmi="yes"
658         nut_with_freeipmi="yes"
659         AC_DEFINE(WITH_FREEIPMI, 1, [Define to enable IPMI support using FreeIPMI])
660      fi
661   fi
662fi
663
664
665NUT_REPORT_FEATURE([build IPMI driver], [${nut_with_ipmi}], [${nut_ipmi_lib}],
666					[WITH_IPMI], [Define to enable IPMI support])
667
668dnl Note: we still have to manually enable complementary AC_DEFINEs (see above)
669dnl and AM_CONDITIONALs (see below)...
670AM_CONDITIONAL(WITH_FREEIPMI, test "${nut_with_freeipmi}" = "yes")
671dnl AM_CONDITIONAL(WITH_OPENIPMI, test "${nut_with_openipmi}" = "yes")
672
673
674dnl ----------------------------------------------------------------------
675dnl The Mac OS X meta-driver looks at IOKit Power Sources keys managed by
676dnl the internal USB UPS driver.
677dnl
678dnl FIXME: be slightly more clever here:
679
680NUT_ARG_WITH([macosx_ups], [build and install Mac OS X Power Sources meta-driver], [auto])
681if test "${nut_with_macosx_ups}" != no; then
682   if test -d /System/Library/Frameworks/IOKit.framework/ ; then
683      nut_with_macosx_ups="yes"
684   else
685      nut_with_macosx_ups="no"
686   fi
687fi
688
689NUT_REPORT_FEATURE([build Mac OS X meta-driver],
690			[${nut_with_macosx_ups}], [${nut_macosx_ups_lib}],
691			[WITH_MACOSX], [Define to enable Mac OS X meta-driver])
692
693dnl ----------------------------------------------------------------------
694dnl checks related to --with_linux_i2c
695dnl Check for i2c header on Linux, used for ASEM UPS driver
696NUT_ARG_WITH([linux_i2c], [build and install i2c drivers], [auto])
697if test "${nut_with_linux_i2c}" != no; then
698    case ${target_os} in
699        linux* )
700            AC_CHECK_HEADER(
701                [linux/i2c-dev.h],
702                [AC_DEFINE([HAVE_LINUX_I2C_DEV_H], [1],
703                    [Define to 1 if you have <linux/i2c-dev.h>.])]
704            )
705            AC_CHECK_HEADER(
706                [i2c/smbus.h],
707                [AC_DEFINE([HAVE_LINUX_SMBUS_H], [1],
708                    [Define to 1 if you have <i2c/smbus.h>.])]
709            )
710            AC_CHECK_DECLS(
711                [i2c_smbus_access, i2c_smbus_read_byte_data, i2c_smbus_write_byte_data, i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data],
712                [], dnl # nut_with_linux_i2c="yes"
713                [AS_IF([test "${nut_with_linux_i2c}" = "yes"],
714                    [AC_MSG_ERROR(i2c was required but can not be fulfilled for this build)],
715                    [nut_with_linux_i2c="no"])],
716                [#include <stdio.h>
717                 #ifdef HAVE_LINUX_I2C_DEV_H
718                 #include <linux/i2c-dev.h>
719                 #endif
720                 #ifdef HAVE_LINUX_SMBUS_H
721                 #include <i2c/smbus.h>
722                 #endif
723                ]
724            )
725            dnl Builds for bitness/arch other than system default can be
726            dnl "compromised" by lack of respective binary library, so
727            dnl even if we have the right headers, ultimate link fails.
728            dnl Note: here we keep the verdict from above, or make it worse.
729            AC_SEARCH_LIBS([i2c_smbus_read_byte, i2c_smbus_access, i2c_smbus_read_byte_data, i2c_smbus_write_byte_datai2c_smbus_write_byte_data, i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data],
730                [i2c],
731                [nut_with_linux_i2c="yes"],
732                [AS_IF([test "${nut_with_linux_i2c}" = "yes"],
733                    [AC_MSG_ERROR(i2c was required but can not be fulfilled for this build)],
734                    [nut_with_linux_i2c="no"])
735                ])
736            ;;
737        * )
738            nut_with_linux_i2c="no"
739            ;;
740    esac
741fi
742NUT_REPORT_FEATURE(
743    [build i2c based drivers],
744    [${nut_with_linux_i2c}],
745    [],
746    [WITH_LINUX_I2C],
747    [Define to enable I2C support]
748)
749
750dnl ----------------------------------------------------------------------
751dnl Check for with-ssl, and --with-nss or --with-openssl
752dnl Only one can be enabled at a time, with a preference for OpenSSL
753dnl if both are available
754
755nut_ssl_lib=""
756
757NUT_ARG_WITH([ssl], [enable SSL support (either NSS or OpenSSL)], [auto])
758NUT_ARG_WITH([nss], [enable SSL support using Mozilla NSS], [auto])
759NUT_ARG_WITH([openssl], [enable SSL support using OpenSSL], [auto])
760
761dnl ${nut_with_ssl}: any value except "yes" or "no" is treated as "auto".
762if test "${nut_with_ssl}" != "no"; then
763   dnl check if either NSS or OpenSSL was explicitly requested
764   if test "${nut_with_nss}" = "yes"; then
765      NUT_CHECK_LIBNSS
766      if test "${nut_have_libnss}" != "yes"; then
767         AC_MSG_ERROR([Mozilla NSS not found (required for SSL support)])
768      fi
769   elif test "${nut_with_openssl}" = "yes"; then
770      NUT_CHECK_LIBOPENSSL
771      if test "${nut_have_openssl}" != "yes"; then
772         AC_MSG_ERROR([OpenSSL not found (required for SSL support)])
773      fi
774   else
775      dnl Prefer OpenSSL over NSS otherwise
776      NUT_CHECK_LIBOPENSSL
777      if test "${nut_have_openssl}" != "yes"; then
778         NUT_CHECK_LIBNSS
779         if test "${nut_have_libnss}" != "yes"; then
780            dnl Only abort if SSL has been explicitly requested by the user
781            if test "${nut_with_ssl}" = "yes"; then
782               AC_MSG_ERROR([Neither Mozilla NSS nor OpenSSL was found, but one is needed for the requested SSL support.])
783            else
784               AC_MSG_WARN([Neither Mozilla NSS nor OpenSSL was found (required for SSL support)])
785            fi
786            nut_with_ssl="no"
787         else
788            nut_with_nss="${nut_have_libnss}"
789         fi
790      else
791         nut_with_openssl="${nut_have_openssl}"
792      fi
793   fi
794fi
795
796AM_CONDITIONAL(WITH_NSS, test "${nut_with_nss}" = "yes")
797AM_CONDITIONAL(WITH_OPENSSL, test "${nut_with_openssl}" = "yes")
798
799NUT_REPORT_FEATURE([enable SSL support], [${nut_with_ssl}], [${nut_ssl_lib}],
800					[WITH_SSL], [Define to enable SSL])
801
802dnl ----------------------------------------------------------------------
803dnl Check for --with-wrap
804
805NUT_ARG_WITH([wrap], [enable libwrap (tcp-wrappers) support], [auto])
806
807dnl ${nut_with_wrap}: any value except "yes" or "no" is treated as "auto".
808if test "${nut_with_wrap}" != "no"; then
809   dnl check for libwrap compiler flags
810   NUT_CHECK_LIBWRAP
811fi
812
813if test "${nut_with_wrap}" = "yes" -a "${nut_have_libwrap}" != "yes"; then
814   AC_MSG_ERROR([libwrap not found])
815fi
816
817if test "${nut_with_wrap}" != "no"; then
818   nut_with_wrap="${nut_have_libwrap}"
819fi
820
821NUT_REPORT_FEATURE([enable libwrap (tcp-wrappers) support], [${nut_with_wrap}], [],
822					[WITH_WRAP], [Define to enable libwrap (tcp-wrappers) support])
823
824
825dnl ----------------------------------------------------------------------
826dnl Check for --with-libltdl
827
828NUT_ARG_WITH([libltdl], [enable libltdl (Libtool dlopen abstraction) support], [auto])
829
830dnl ${nut_with_libltdl}: any value except "yes" or "no" is treated as "auto".
831if test "${nut_with_libltdl}" != "no"; then
832   dnl check for libltdl compiler flags
833   NUT_CHECK_LIBLTDL
834fi
835
836if test "${nut_with_libltdl}" = "yes" -a "${nut_have_libltdl}" != "yes"; then
837   AC_MSG_ERROR([libltdl not found])
838fi
839
840if test "${nut_with_libltdl}" != "no"; then
841   nut_with_libltdl="${nut_have_libltdl}"
842fi
843
844NUT_REPORT_FEATURE([enable libltdl (Libtool dlopen abstraction) support], [${nut_with_libltdl}], [],
845					[WITH_LIBLTDL], [Define to enable libltdl (Libtool dlopen abstraction) support])
846
847dnl Explicitly report if we are building nut-scanner or not
848dnl since it requires libltdl
849NUT_REPORT([build nut-scanner], [${nut_with_libltdl}])
850
851dnl ----------------------------------------------------------------------
852dnl checks related to --with-cgi
853
854NUT_ARG_WITH([cgi], [build and install the CGI programs], [no])
855
856dnl ${nut_with_cgi}: any value except "yes" or "no" is treated as "auto".
857if test "${nut_with_cgi}" != "no"; then
858   dnl check for libgd compiler flags
859   NUT_CHECK_LIBGD
860fi
861
862if test "${nut_with_cgi}" = "yes" -a "${nut_have_libgd}" != "yes"; then
863   AC_MSG_ERROR([libgd not found, required for CGI build])
864fi
865
866if test "${nut_with_cgi}" != "no"; then
867   nut_with_cgi="${nut_have_libgd}"
868fi
869
870NUT_REPORT_FEATURE([build CGI programs], [${nut_with_cgi}], [],
871					[WITH_CGI], [Define to enable CGI (HTTP) support])
872
873
874dnl ----------------------------------------------------------------------
875dnl checks related to --enable-cppcheck
876
877dnl Currently this is experimental; maybe change default to auto in the future
878dnl At that point, see also defaults in ci_build.sh then (to avoid the workload
879dnl unless desired).
880NUT_ARG_ENABLE([cppcheck], [Run a cppcheck on the codebase among checks], [no])
881NUT_CHECK_CPPCHECK
882
883case "${nut_enable_cppcheck}" in
884	yes) if test "${nut_have_cppcheck}" = "no" ; then
885	        AC_MSG_ERROR([Requested to --enable-cppcheck but did not find a good one])
886	     fi
887	     WITH_CPPCHECK=yes
888	     ;;
889	no)  WITH_CPPCHECK=no ;;
890	auto) if test "${nut_have_cppcheck}" = "yes" ; then
891	        WITH_CPPCHECK=no
892	    else
893	        WITH_CPPCHECK=no
894	    fi
895	    ;;
896esac
897
898AM_CONDITIONAL(WITH_CPPCHECK, test "${WITH_CPPCHECK}" = "yes")
899
900dnl ----------------------------------------------------------------------
901dnl checks related to --with-doc
902
903dnl Always check for AsciiDoc prerequisites, since even if --with-doc
904dnl is set to 'no', we may still want to build some doc targets manually
905dnl (so enable the Makefile recipes for those targets if tools are available)
906NUT_CHECK_ASCIIDOC
907
908NUT_REPORT_FEATURE([build and install documentation], [${nut_with_doc}], [],
909					[WITH_ASCIIDOC], [Define to enable Asciidoc support])
910
911DOC_INSTALL_DISTED_MANS=no
912
913case "${nut_with_doc}" in
914	yes|all|all=yes)
915		nut_doc_build_list="man html-single html-chunked pdf"
916		;;
917	auto|all=auto)
918		nut_doc_build_list="man=auto html-single=auto html-chunked=auto pdf=auto"
919		;;
920	skip|all=skip)
921		nut_doc_build_list="man=skip html-single=skip html-chunked=skip pdf=skip"
922		;;
923	no|all=no)
924		nut_doc_build_list=""
925		;;
926dnl If user passed --with-doc='' they they want nothing, right?
927	"")
928		nut_doc_build_list=""
929		AC_MSG_NOTICE([Got explicit empty list of document formats to build; nothing will be generated])
930		;;
931	*)
932		nut_doc_build_list="`echo ${nut_with_doc} | sed 's/,/ /g'`"
933		AC_MSG_NOTICE([Got explicit list of document formats to build or not: ${nut_doc_build_list}; formats not listed will be silently skipped])
934		;;
935esac
936
937if test -z "${abs_srcdir}" ; then
938	case "${srcdir}" in
939		/*) abs_srcdir="${srcdir}";;
940		"") AC_MSG_ERROR([Can not detect 'srcdir']) ;;
941		*)  abs_srcdir="$(cd "${srcdir}" && pwd)" || AC_MSG_ERROR([Can not detect 'srcdir']) ;;
942	esac
943fi
944DOCTESTDIR="$(mktemp -d configure-test.docbuild.$$.XXXXXXX)" && \
945DOCTESTDIR="$(cd "$DOCTESTDIR" && pwd)"
946
947dnl Note: Do not cover ${nut_doc_build_list} in braces or quotes here,
948dnl to ensure that it is processed as several space-separated tokens
949for nut_doc_build_target in $nut_doc_build_list; do
950	case "${nut_doc_build_target}" in
951	*=*=*)	rm -rf "${DOCTESTDIR}"
952		AC_MSG_ERROR([Invalid documentation format option: ${nut_doc_build_target}]) ;;
953	*=*)
954		nut_doc_build_target_base="`echo "${nut_doc_build_target}" | sed 's,=.*$,,'`"
955		nut_doc_build_target_flag="`echo "${nut_doc_build_target}" | sed 's,^.*=,,'`"
956		;;
957	*)
958		nut_doc_build_target_base="${nut_doc_build_target}"
959		nut_doc_build_target_flag="yes"
960		;;
961	esac
962	case "${nut_doc_build_target_flag}" in
963	yes|no|auto|skip) ;;
964	"") nut_doc_build_target_flag="yes" ;;
965	*)	rm -rf "${DOCTESTDIR}"
966		AC_MSG_ERROR([Invalid documentation format option: ${nut_doc_build_target}]) ;;
967	esac
968	AC_MSG_CHECKING([desire and ability to build ${nut_doc_build_target_base} documentation])
969	AC_MSG_RESULT([${nut_doc_build_target_flag}])
970
971	case "${nut_doc_build_target}" in
972	*=no|*=skip)
973		DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}"
974		;;
975
976dnl Notes: Document options below assume either no flag value (which
977dnl by default means "yes"), "yes" which is a requirement, or "auto"
978dnl to detect if we can build the wanted documentation format and yet
979dnl not fail if we have no tools to generate it (so add to SKIP list).
980
981	html-single*)
982		AC_MSG_CHECKING([if asciidoc version can build ${nut_doc_build_target_base} (minimum required ${ASCIIDOC_MIN_VERSION})])
983		can_build_doc_html_single=no
984		AX_COMPARE_VERSION([${ASCIIDOC_VERSION}], [ge], [${ASCIIDOC_MIN_VERSION}], [
985			( cd "$DOCTESTDIR" && ${A2X} --attribute=xhtml11_format --format=xhtml --xsl-file="${abs_srcdir}"/docs/xhtml.xsl --destination-dir=. "${abs_srcdir}"/docs/asciidoc.txt && test -s asciidoc.html ) && can_build_doc_html_single=yes
986			rm -f "$DOCTESTDIR"/asciidoc*.htm*
987		], [])
988		if test "${can_build_doc_html_single}" = yes ; then
989			AC_MSG_RESULT(yes)
990			DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}"
991		else
992			AC_MSG_RESULT(no)
993			if test "${nut_doc_build_target_flag}" = "yes" ; then
994				DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}"
995				AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested])
996			else
997				DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}"
998			fi
999		fi
1000		;;
1001
1002	html-chunked*)
1003		AC_MSG_CHECKING([if a2x version can build ${nut_doc_build_target_base} (minimum required ${ASCIIDOC_MIN_VERSION})])
1004		can_build_doc_html_chunked=no
1005		AX_COMPARE_VERSION([${A2X_VERSION}], [ge], [${ASCIIDOC_MIN_VERSION}], [
1006			( cd "$DOCTESTDIR" && ${A2X} --attribute=chunked_format --format=chunked --xsl-file="${abs_srcdir}"/docs/chunked.xsl --destination-dir=. "${abs_srcdir}"/docs/FAQ.txt && test -s FAQ.chunked/index.html ) && can_build_doc_html_chunked=yes
1007			rm -rf "${DOCTESTDIR}"/FAQ*.chunked*
1008		], [])
1009		if test "${can_build_doc_html_chunked}" = yes ; then
1010			AC_MSG_RESULT(yes)
1011			DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}"
1012		else
1013			AC_MSG_RESULT(no)
1014			if test "${nut_doc_build_target_flag}" = "yes" ; then
1015				DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}"
1016				AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested])
1017			else
1018				DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}"
1019			fi
1020		fi
1021		;;
1022
1023	pdf*)
1024		AC_MSG_CHECKING([if dblatex version can build ${nut_doc_build_target_base} (minimum required ${DBLATEX_MIN_VERSION})])
1025		can_build_doc_pdf=no
1026		AX_COMPARE_VERSION([${DBLATEX_VERSION}], [ge], [${DBLATEX_MIN_VERSION}], [
1027			( cd "$DOCTESTDIR" && ${A2X} --format=pdf --destination-dir=. "${abs_srcdir}"/docs/asciidoc.txt && test -s asciidoc.pdf ) && can_build_doc_pdf=yes
1028			rm -f "${DOCTESTDIR}"/asciidoc.pdf
1029		], [])
1030		if test "${can_build_doc_pdf}" = yes ; then
1031			AC_MSG_RESULT(yes)
1032			DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}"
1033		else
1034			AC_MSG_RESULT(no)
1035			if test "${nut_doc_build_target_flag}" = "yes" ; then
1036				DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}"
1037				AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested])
1038			else
1039				DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}"
1040			fi
1041		fi
1042		;;
1043
1044	man*)
1045		AC_MSG_CHECKING([if we can build ${nut_doc_build_target_base}])
1046		can_build_doc_man=no
1047		if test "${nut_have_asciidoc}" = yes ; then
1048			( cd "$DOCTESTDIR" && ${A2X} --format manpage --destination-dir=. --xsltproc-opts="--nonet" "${abs_srcdir}"/docs/man/snmp-ups.txt && test -s snmp-ups.8 ) && can_build_doc_man=yes
1049			rm -f "${DOCTESTDIR}"/snmp-ups.8
1050		fi
1051		if test "${can_build_doc_man}" = yes ; then
1052			AC_MSG_RESULT(yes)
1053			DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}"
1054		else
1055			AC_MSG_RESULT(no)
1056			if test "${nut_doc_build_target_flag}" = "yes" ; then
1057				DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}"
1058				AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested])
1059			else
1060				DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}"
1061				if test "${nut_doc_build_target_flag}" = "auto" ; then
1062dnl Test that groff files exist (building from distributed tarball, not git repo)
1063					if test -s "${abs_srcdir}"/docs/man/snmp-ups.8 ; then
1064						AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation, but can install pre-built distributed copies])
1065						DOC_INSTALL_DISTED_MANS="yes"
1066					else
1067						AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation, and unable to install pre-built distributed copies because they are absent])
1068					fi
1069				fi  # Other variants include "no", "skip"...
1070			fi
1071		fi
1072		;;
1073
1074	*)	rm -rf "${DOCTESTDIR}"
1075		AC_MSG_ERROR([--with-doc option refers to unknown documentation format: $nut_doc_build_target]) ;;
1076
1077	esac
1078done
1079rm -rf "${DOCTESTDIR}"
1080
1081case "${nut_with_doc}" in
1082auto)
1083	if test -n "${DOC_BUILD_LIST}"; then
1084		nut_with_doc="yes"
1085	else
1086		nut_with_doc="no"
1087	fi
1088	;;
1089no)
1090	;;
1091*)
1092	if test -n "${DOC_CANNOTBUILD_LIST}"; then
1093		AC_MSG_ERROR([Unable to build${DOC_CANNOTBUILD_LIST} documentation (check for 'no' results above)])
1094	fi
1095
1096	if test -n "${DOC_SKIPBUILD_LIST}"; then
1097		AC_MSG_NOTICE([Skipping build of${DOC_SKIPBUILD_LIST} documentation (check for 'skip' results above)])
1098	fi
1099
1100	if test -n "${DOC_BUILD_LIST}"; then
1101		nut_with_doc="yes"
1102	else
1103		nut_with_doc="no"
1104	fi
1105	;;
1106esac
1107
1108NUT_REPORT_FEATURE([build specific documentation format(s)], [${nut_with_doc}], [${DOC_BUILD_LIST}],
1109					[WITH_DOCS], [Define to enable overall documentation generation])
1110
1111# To cater for less portable make's, precalculate the target list
1112# for "make check" in "docs/" here...
1113DOC_CHECK_LIST=""
1114if test "${nut_with_doc}" = yes ; then
1115    for V in $DOC_BUILD_LIST ; do
1116        DOC_CHECK_LIST="$DOC_CHECK_LIST check-$V"
1117    done
1118fi
1119
1120WITH_MANS=no
1121SKIP_MANS=no
1122if echo "${DOC_BUILD_LIST}" | grep -w "man" >/dev/null || test "${DOC_INSTALL_DISTED_MANS}" = "yes" ; then
1123	WITH_MANS=yes
1124fi
1125if echo "${DOC_SKIPBUILD_LIST}" | grep -w "man" >/dev/null ; then
1126	SKIP_MANS=yes
1127fi
1128dnl Generally WITH_MANS=no is intentionally fatal for "make distcheck"
1129dnl But some larger distcheck suites check mans once and then focus on
1130dnl other aspects of the project, so they can explicitly skip docs (or
1131dnl just mans) instead. Note that for WITH_MANS=yes the SKIP_MANS value
1132dnl is effectively ignored by docs/man/Makefile.am at this time.
1133AM_CONDITIONAL(WITH_MANS, test "${WITH_MANS}" = "yes")
1134AM_CONDITIONAL(SKIP_MANS, test "${SKIP_MANS}" = "yes")
1135AM_CONDITIONAL(DOC_INSTALL_DISTED_MANS, test "${DOC_INSTALL_DISTED_MANS}" = "yes")
1136
1137dnl ----------------------------------------------------------------------
1138dnl checks related to --with-dev
1139
1140dnl We only init libtool there to allow AC_DISABLE_STATIC
1141if ( test "${GCC}" = "yes" )
1142then
1143	dnl # Avoid new compilers' warnings/errors about libtool distro flaws in this test like:
1144	dnl #   error: ISO C forbids conversion of function pointer to object pointer type [-Werror=pedantic]
1145	dnl #   {"nm_test_func", (void *) &nm_test_func},
1146	dnl # or ones about LTO (-flto -fno-common) as discussed and suggested
1147	dnl # in https://www.mail-archive.com/libtool@gnu.org/msg14037.html -
1148	dnl # all leading to undefined "global_symbol_pipe" in the generated
1149	dnl # libtool script, and resulting in errors like `... | | ...` below :
1150	dnl # libtool: link: /usr/bin/nm -B .libs/upsclient.o \
1151	dnl #   ../common/.libs/libcommonclient.a |  | /usr/bin/sed 's/.* //' \
1152	dnl #   | sort | uniq > .libs/libupsclient.exp
1153	dnl # ../libtool: syntax error: `|' unexpected
1154
1155	CFLAGS_SAVED_NOPEDANTIC="$CFLAGS"
1156	AS_CASE(["${CFLAGS}"],[*"-pedantic"*],[CFLAGS="${CFLAGS} -Wno-pedantic"])
1157	AS_CASE(["${CFLAGS}"],[*"-Werror"*],[CFLAGS="${CFLAGS} -Wno-error"])
1158	AS_CASE(["${CFLAGS}"],[*"-flto"*],[CFLAGS="${CFLAGS} -ffat-lto-objects"])
1159fi
1160
1161dnl See https://www.gnu.org/software/libtool/manual/html_node/LT_005fINIT.html
1162dnl #OBSOLETED:# LT_INIT and AC_PROG_LIBTOOL
1163
1164dnl # Hack around the libtool script: as of version 58 (current in 2021),
1165dnl # they use code like below to detect library paths:
1166dnl #   if test yes = "$GCC"; then ... lt_search_path_spec=`$CC -print-search-dirs | ...
1167dnl # which explodes when non-default architecture is used for the build,
1168dnl # where e.g. "CC=gcc" and "CFLAGS=-m32" on a 64-bit capable system.
1169dnl # And similarly for compilation-checks to link third-party libraries.
1170SAVED_GCC="$GCC"
1171SAVED_CC="$CC"
1172if ( test "${GCC}" = "yes" )
1173then
1174    case "$CFLAGS$LDFLAGS" in
1175        *-m32*) CC="$CC -m32" ;;
1176        *-m64*) CC="$CC -m64" ;;
1177    esac
1178fi
1179LT_INIT
1180AC_SUBST([LIBTOOL_DEPS])
1181GCC="$SAVED_GCC"
1182CC="$SAVED_CC"
1183
1184if ( test "${GCC}" = "yes" )
1185then
1186	CFLAGS="$CFLAGS_SAVED_NOPEDANTIC"
1187fi
1188
1189dnl ${nut_with_dev}: any value except "yes" or "no" is treated as "auto".
1190if test "${nut_with_dev}" != "no"; then
1191  nut_with_dev="yes"
1192else
1193  AC_DISABLE_STATIC
1194fi
1195AM_CONDITIONAL(WITH_DEV, test "${nut_with_dev}" = "yes")
1196NUT_REPORT_FEATURE([build and install the development files], [${nut_with_dev}], [],
1197					[WITH_DEV], [Define to enable development files support])
1198
1199dnl ----------------------------------------------------------------------
1200
1201
1202AC_MSG_CHECKING(state path)
1203AC_ARG_WITH(statepath,
1204	AS_HELP_STRING([--with-statepath=PATH], [path for ups state files (/var/state/ups)]),
1205[
1206	case "${withval}" in
1207	yes|no)
1208		AC_MSG_ERROR(invalid option --with(out)-statepath - see docs/configure.txt)
1209		;;
1210	*)
1211		STATEPATH="${withval}"
1212		;;
1213	esac
1214], [])
1215AC_DEFINE_UNQUOTED(STATEPATH, "${STATEPATH}", [Path for UPS driver state files])
1216AC_MSG_RESULT(${STATEPATH})
1217
1218dnl ---------------------------------------------------------------------
1219dnl The 'alt pid path' is used by the drivers (via main.c) and upsd, since
1220dnl ideally they do not run as root and will not be able to write to the usual
1221dnl /var/run path.  This defaults to the STATEPATH since they should be
1222dnl able to write there.
1223dnl
1224
1225AC_MSG_CHECKING(alt pid path)
1226AC_ARG_WITH(altpidpath,
1227	AS_HELP_STRING([--with-altpidpath=PATH], [path for driver/upsd .pid files (<statepath>)]),
1228[
1229	case "${withval}" in
1230	yes|no)
1231		AC_MSG_ERROR(invalid option --with(out)-altpidpath - see docs/configure.txt)
1232		;;
1233	*)
1234		ALTPIDPATH="${withval}"
1235		;;
1236	esac
1237], [
1238	ALTPIDPATH="${STATEPATH}"
1239])
1240AC_DEFINE_UNQUOTED(ALTPIDPATH, "${ALTPIDPATH}", [Path for pid files of drivers and upsd (usually STATEPATH)])
1241AC_MSG_RESULT(${ALTPIDPATH})
1242
1243AC_MSG_CHECKING(driver path)
1244AC_ARG_WITH(drvpath,
1245	AS_HELP_STRING([--with-drvpath=PATH], [where to install UPS drivers (EPREFIX/bin)]),
1246[
1247	case "${withval}" in
1248	yes|no)
1249		AC_MSG_ERROR(invalid option --with(out)-drvpath - see docs/configure.txt)
1250		;;
1251	*)
1252		driverexecdir="${withval}"
1253		;;
1254	esac
1255], [])
1256conftemp="${driverexecdir}"
1257eval conftemp=\"${conftemp}\"
1258eval conftemp=\"${conftemp}\"
1259AC_DEFINE_UNQUOTED(DRVPATH, "${conftemp}", [Default path for UPS drivers])
1260AC_MSG_RESULT(${driverexecdir})
1261
1262AC_MSG_CHECKING(cgi path)
1263AC_ARG_WITH(cgipath,
1264	AS_HELP_STRING([--with-cgipath=PATH], [where to install CGI programs (EPREFIX/cgi-bin)]),
1265[
1266	case "${withval}" in
1267	yes|no)
1268		AC_MSG_ERROR(invalid option --with(out)-cgipath - see docs/configure.txt)
1269		;;
1270	*)
1271		cgiexecdir="${withval}"
1272		;;
1273	esac
1274], [])
1275conftemp="${cgiexecdir}"
1276eval conftemp=\"${conftemp}\"
1277eval conftemp=\"${conftemp}\"
1278AC_DEFINE_UNQUOTED(CGIPATH, "${conftemp}", [Default path for CGI programs])
1279AC_MSG_RESULT(${cgiexecdir})
1280
1281AC_MSG_CHECKING(html path)
1282AC_ARG_WITH(htmlpath,
1283	AS_HELP_STRING([--with-htmlpath=PATH], [where to install HTML files (PREFIX/html)]),
1284[
1285	case "${withval}" in
1286	yes|no)
1287		AC_MSG_ERROR(invalid option --with(out)-htmlpath - see docs/configure.txt)
1288		;;
1289	*)
1290		htmldir="${withval}"
1291		;;
1292	esac
1293], [])
1294conftemp="${htmldir}"
1295eval conftemp=\"${conftemp}\"
1296eval conftemp=\"${conftemp}\"
1297AC_DEFINE_UNQUOTED(HTMLPATH, "${conftemp}", [Default path for HTML files])
1298AC_MSG_RESULT(${htmldir})
1299
1300AC_MSG_CHECKING(pidpath)
1301AC_ARG_WITH(pidpath,
1302	AS_HELP_STRING([--with-pidpath=PATH], [path for .pid files (/var/run)]),
1303[
1304	case "${withval}" in
1305	yes|no)
1306		AC_MSG_ERROR(invalid option --with(out)-pidpath - see docs/configure.txt)
1307		;;
1308	*)
1309		PIDPATH="${withval}"
1310		;;
1311	esac
1312], [])
1313AC_DEFINE_UNQUOTED(PIDPATH, "${PIDPATH}", [Path where the pid files should go])
1314AC_MSG_RESULT(${PIDPATH})
1315
1316AC_MSG_CHECKING(network port number)
1317AC_ARG_WITH(port,
1318	AS_HELP_STRING([--with-port=PORT], [port for network communications (3493)]),
1319[
1320	case "${withval}" in
1321	yes|no)
1322		AC_MSG_ERROR(invalid option --with(out)-port - see docs/configure.txt)
1323		;;
1324	*)
1325		PORT="${withval}"
1326		;;
1327	esac
1328], [
1329	PORT="3493"
1330])
1331AC_DEFINE_UNQUOTED(PORT, ${PORT}, [Port for network communications])
1332AC_MSG_RESULT(${PORT})
1333
1334AC_MSG_CHECKING(user to run as)
1335AC_ARG_WITH(user,
1336	AS_HELP_STRING([--with-user=username], [user for programs started as root (nobody)]),
1337[
1338	case "${withval}" in
1339	yes|no)
1340		AC_MSG_ERROR(invalid option --with(out)-user - see docs/configure.txt)
1341		;;
1342	*)
1343		RUN_AS_USER="${withval}"
1344		nut_user_given=yes
1345		;;
1346	esac
1347], [
1348	nut_user_given=no
1349])
1350AC_DEFINE_UNQUOTED(RUN_AS_USER, "${RUN_AS_USER}", [User to switch to if started as root])
1351AC_MSG_RESULT(${RUN_AS_USER})
1352
1353AC_MSG_CHECKING(group membership of user to run as)
1354AC_ARG_WITH(group,
1355	AS_HELP_STRING([--with-group=groupname], [group membership of user for programs started as root (nogroup)]),
1356[
1357	case "${withval}" in
1358	yes|no)
1359		AC_MSG_ERROR(invalid option --with(out)-group - see docs/configure.txt)
1360		;;
1361	*)
1362		RUN_AS_GROUP="${withval}"
1363		nut_group_given=yes
1364		;;
1365	esac
1366], [
1367	nut_group_given=no
1368])
1369AC_DEFINE_UNQUOTED(RUN_AS_GROUP, "${RUN_AS_GROUP}", [Group membership of user to switch to if started as root])
1370AC_MSG_RESULT(${RUN_AS_GROUP})
1371
1372dnl check that --with-user is given if --with-group is given.
1373if test "${nut_user_given}" = "yes" -a "${nut_group_given}" = "no"; then
1374	AC_MSG_ERROR([If you specify --with-user, you also must specify --with-group])
1375elif test "${nut_user_given}" = "no" -a "${nut_group_given}" = "yes"; then
1376	AC_MSG_ERROR([If you specify --with-group, you also must specify --with-user])
1377fi
1378
1379AC_MSG_CHECKING(facility for syslog)
1380AC_ARG_WITH(logfacility,
1381	AS_HELP_STRING([--with-logfacility=FACILITY], [facility for log messages (LOG_DAEMON)]),
1382[
1383	case "${withval}" in
1384	yes|no)
1385		AC_MSG_ERROR(invalid option --with(out)-logfacility - see docs/configure.txt)
1386		;;
1387	*)
1388		LOGFACILITY="${withval}"
1389		;;
1390	esac
1391], [
1392	LOGFACILITY="LOG_DAEMON"
1393])
1394AC_DEFINE_UNQUOTED(LOG_FACILITY, ${LOGFACILITY}, [Desired syslog facility - see syslog(3)])
1395AC_MSG_RESULT(${LOGFACILITY})
1396
1397dnl Autoconf versions before 2.62 do not allow consecutive quadrigraphs,
1398dnl so the help string depends on the version used
1399AC_MSG_CHECKING(which drivers to build)
1400AC_ARG_WITH(drivers,
1401	AS_HELP_STRING([m4_version_prereq(2.62,
1402		[@<:@--with-drivers=driver@<:@,driver@:>@@:>@],
1403		[[[[--with-drivers=driver@<:@,driver@:>@]]]])],
1404	[Only build specific drivers (all)]),
1405[
1406	case "${withval}" in
1407	yes|no)
1408		AC_MSG_ERROR(invalid option --with(out)-drivers - see docs/configure.txt)
1409		;;
1410	*)
1411		DRIVER_BUILD_LIST=`echo ${withval} | sed "s/,/ /g"`
1412		AC_MSG_RESULT(${DRIVER_BUILD_LIST})
1413		;;
1414	esac
1415], [
1416	DRIVER_BUILD_LIST="all"
1417	AC_MSG_RESULT(all available)
1418])
1419AM_CONDITIONAL(SOME_DRIVERS, test "${DRIVER_BUILD_LIST}" != "all")
1420
1421if test "${DRIVER_BUILD_LIST}" != "all"; then
1422	NUT_REPORT([only build specific drivers], [${DRIVER_BUILD_LIST}])
1423fi
1424
1425AC_MSG_CHECKING(which driver man pages to install)
1426if test "${WITH_MANS}" = "yes"; then
1427	if test "${DRIVER_BUILD_LIST}" = "all"; then
1428		DRIVER_MAN_LIST=all
1429		AC_MSG_RESULT(all available)
1430	else
1431		DRIVER_MAN_LIST=""
1432		for i in ${DRIVER_BUILD_LIST}; do
1433			if test -f ${srcdir}/docs/man/$i.8; then
1434				DRIVER_MAN_LIST="${DRIVER_MAN_LIST} $i.8"
1435			fi
1436		done
1437		AC_MSG_RESULT(${DRIVER_MAN_LIST})
1438	fi
1439else
1440	DRIVER_MAN_LIST=""
1441	AC_MSG_RESULT([none (manpages disabled)])
1442fi
1443
1444AC_MSG_CHECKING(whether to strip debug symbols)
1445AC_ARG_ENABLE(strip,
1446	AS_HELP_STRING([--enable-strip], [Strip debugging symbols from binaries (no)]),
1447[
1448	case "${withval}" in
1449	no)
1450		AC_MSG_RESULT(no)
1451		;;
1452	*)
1453		AC_MSG_RESULT(yes)
1454		CFLAGS="${CFLAGS} -s"
1455		;;
1456	esac
1457], [
1458	AC_MSG_RESULT(no)
1459])
1460
1461AC_MSG_CHECKING(whether to install pkg-config *.pc files)
1462AC_ARG_WITH(pkgconfig-dir,
1463	AS_HELP_STRING([--with-pkgconfig-dir=PATH], [where to install pkg-config *.pc files (EPREFIX/lib/pkgconfig)]),
1464[
1465	case "${withval}" in
1466	yes|auto)
1467		;;
1468	no)
1469		pkgconfigdir=""
1470		;;
1471	*)
1472		pkgconfigdir="${withval}"
1473		;;
1474	esac
1475], [])
1476if test -n "${pkgconfigdir}"; then
1477	AC_MSG_RESULT(using ${pkgconfigdir})
1478else
1479	AC_MSG_RESULT(no)
1480fi
1481AM_CONDITIONAL(WITH_PKG_CONFIG, test -n "${pkgconfigdir}")
1482
1483AC_MSG_CHECKING(whether to install Solaris SMF files)
1484solarissmf="auto"
1485AC_ARG_WITH([solaris-smf],
1486	AS_HELP_STRING([--with-solaris-smf=(yes|auto|no)], [Enable installation of NUT scripts and manifests for Solaris Service Management Framework (auto)]),
1487[
1488	case "${withval}" in
1489	auto|"")
1490		solarissmf="auto"
1491		;;
1492	yes|no)
1493		solarissmf="${withval}"
1494		;;
1495	*)
1496		AC_MSG_ERROR([Unexpected argument for --with-solaris-smf=${withval}])
1497		;;
1498	esac
1499], [])
1500
1501if test x"$solarissmf" = xauto ; then
1502	if test -x /usr/sbin/svcadm && test -x /usr/sbin/svccfg && test -x /usr/bin/svcs ; then
1503		solarissmf="yes"
1504	else
1505		solarissmf="no"
1506	fi
1507fi
1508AC_MSG_RESULT([${solarissmf}])
1509AM_CONDITIONAL(WITH_SOLARIS_SMF, test x"$solarissmf" = x"yes")
1510
1511AC_MSG_CHECKING(whether to make Solaris SVR4 packages)
1512solarispkg_svr4="auto"
1513AC_ARG_WITH([solaris-pkg-svr4],
1514	AS_HELP_STRING([--with-solaris-pkg-svr4=(yes|auto|no)], [Enable construction of Solaris SVR4 packages (auto)]),
1515[
1516	case "${withval}" in
1517	auto|"")
1518		solarispkg_svr4="auto"
1519		;;
1520	yes|no)
1521		solarispkg_svr4="${withval}"
1522		;;
1523	*)
1524		AC_MSG_ERROR([Unexpected argument for --with-solaris-pkg-svr4=${withval}])
1525		;;
1526	esac
1527], [])
1528
1529if test x"$solarispkg_svr4" = xauto ; then
1530	if test -x /usr/bin/pkgtrans && test -x /usr/bin/pkgmk && test -x /usr/bin/pkgproto ; then
1531		solarispkg_svr4="yes"
1532	else
1533		solarispkg_svr4="no"
1534	fi
1535fi
1536AC_MSG_RESULT([${solarispkg_svr4}])
1537AM_CONDITIONAL(WITH_SOLARIS_PKG_SVR4, test x"$solarispkg_svr4" = x"yes")
1538
1539AC_MSG_CHECKING(whether to make Solaris IPS packages)
1540solarispkg_ips="auto"
1541AC_ARG_WITH([solaris-pkg-ips],
1542	AS_HELP_STRING([--with-solaris-pkg-ips=(yes|auto|no)], [Enable construction of Solaris IPS packages (auto)]),
1543[
1544	case "${withval}" in
1545	auto|"")
1546		solarispkg_ips="auto"
1547		;;
1548	yes|no)
1549		solarispkg_ips="${withval}"
1550		;;
1551	*)
1552		AC_MSG_ERROR([Unexpected argument for --with-solaris-pkg-ips=${withval}])
1553		;;
1554	esac
1555], [])
1556
1557if test x"$solarispkg_ips" = xauto ; then
1558	if test -x /usr/bin/pkg && test -x /usr/bin/pkgmogrify && test -x /usr/bin/pkgdepend ; then
1559		solarispkg_ips="yes"
1560	else
1561		solarispkg_ips="no"
1562	fi
1563fi
1564AC_MSG_RESULT([${solarispkg_ips}])
1565AM_CONDITIONAL(WITH_SOLARIS_PKG_IPS, test x"$solarispkg_ips" = x"yes")
1566
1567dnl Note: Currently there is no automatic detection enabled -
1568dnl users have to ask they want systemd units installed.
1569dnl It may be changed based on popular demand to just always
1570dnl run the "case" below for ${systemdsystemunitdir} values,
1571dnl like we do for systemdtmpfilesdir further below.
1572AC_MSG_CHECKING(whether to install systemd unit files)
1573AC_ARG_WITH([systemdsystemunitdir],
1574	AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files (auto)]),
1575[
1576	case "${withval}" in
1577	yes|auto|"")
1578		AS_IF([test x"$have_PKG_CONFIG" = xyes],
1579			[systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`"],
1580			[AS_IF([test "${withval}" = yes],
1581				[AC_MSG_ERROR([--with-systemdsystemunitdir=${withval} was requested, but PKG_CONFIG could not be queried for the system settings])])
1582			 systemdsystemunitdir=""
1583			])
1584		;;
1585	no)
1586		systemdsystemunitdir=""
1587		;;
1588	*)
1589		systemdsystemunitdir="${withval}"
1590		;;
1591	esac
1592], [])
1593if test -n "${systemdsystemunitdir}"; then
1594	AC_MSG_RESULT(using ${systemdsystemunitdir})
1595else
1596	AC_MSG_RESULT(no)
1597fi
1598AM_CONDITIONAL(HAVE_SYSTEMD, test "$systemdsystemunitdir" != "")
1599dnl This option is only provided so that make distcheck can override it,
1600dnl otherwise we ask pkg-config whenever --with-systemdsystemunitdir is
1601dnl given
1602
1603AC_MSG_CHECKING(whether to install systemd shutdown files)
1604AC_ARG_WITH([systemdshutdowndir],
1605	AS_HELP_STRING([--with-systemdshutdowndir=DIR], [Directory for systemd shutdown scripts (auto)]),
1606	[systemdshutdowndir=${withval}])
1607dnl Note: this option is enabled only if systemdsystemunitdir is not trivial
1608if test -n "${systemdsystemunitdir}"; then
1609	case "${systemdshutdowndir}" in
1610	yes|auto|"")
1611		AS_IF([test x"$have_PKG_CONFIG" = xyes],
1612			[systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir systemd`"],
1613			[AS_IF([test "${systemdshutdowndir}" = yes],
1614				[AC_MSG_ERROR([--with-systemdshutdowndir=${systemdshutdowndir} was requested, but PKG_CONFIG could not be queried for the system settings])])
1615			 systemdshutdowndir=""
1616			])
1617		;;
1618	no)
1619		systemdshutdowndir=""
1620		;;
1621	*)
1622		systemdshutdowndir="${withval}"
1623		;;
1624	esac
1625fi
1626if test -n "${systemdshutdowndir}"; then
1627	AC_MSG_RESULT(using ${systemdshutdowndir})
1628else
1629	AC_MSG_RESULT(no)
1630fi
1631
1632dnl Note: if (systemd-)tmpfiles tech is present, it can be useful even for
1633dnl daemons starting not as systemd units
1634AC_MSG_CHECKING([whether to install systemd tmpfiles files])
1635AC_ARG_WITH([systemdtmpfilesdir],
1636	AS_HELP_STRING([--with-systemdtmpfilesdir=DIR], [Directory for systemd tmpfiles scripts (auto)]),
1637	[systemdtmpfilesdir=${withval}])
1638case "${systemdtmpfilesdir}" in
1639	yes|auto|"")
1640		AS_IF([test x"$have_PKG_CONFIG" = xyes],
1641			[systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir systemd`"],
1642			[AS_IF([test "${systemdtmpfilesdir}" = yes],
1643				[AC_MSG_ERROR([--with-systemdtmpfilesdir=${systemdtmpfilesdir} was requested, but PKG_CONFIG could not be queried for the system settings])])
1644			 systemdtmpfilesdir=""
1645			])
1646		;;
1647	no)
1648		systemdtmpfilesdir=""
1649		;;
1650	*)
1651		systemdtmpfilesdir="${withval}"
1652		;;
1653esac
1654if test -n "${systemdtmpfilesdir}"; then
1655	AC_MSG_RESULT(using ${systemdtmpfilesdir})
1656else
1657	AC_MSG_RESULT(no)
1658fi
1659
1660dnl
1661dnl Tests for CppUnit availability and usability (will be built if we can,
1662dnl and if valgrind is enabled for this configuration - reported below).
1663dnl Using CppUnit implies C++ support!
1664dnl Theoretically, libcppunit-dev will pull up to g++, through libstdc++...
1665dnl AM_PATH_CPPUNIT(1.9.6)
1666
1667dnl # Tests with gcc-4.8 require this C++11 option to be provided explicitly
1668dnl # gcc-4.6 does not support this yet; newer gcc's should be ok by default.
1669dnl # Could use `AX_CXX_COMPILE_STDCXX_11([noext], [optional])` if it were
1670dnl # available everywhere. Or AX_CHECK_COMPILE_FLAG if it was ubiquitous:
1671dnl ###AX_CHECK_COMPILE_FLAG([-std=c++11],
1672dnl ###    [CXXFLAGS="$CXXFLAGS -std=c++11"
1673dnl ###     have_cxx11=yes],
1674dnl ###    [have_cxx11=no])
1675
1676AC_MSG_CHECKING(for C++11 support in current compiler)
1677have_cxx11=unknown
1678my_CXXFLAGS="$CXXFLAGS"
1679AC_LANG_PUSH([C++])
1680
1681CPLUSPLUS_DECL='
1682#include <stdio.h>
1683#if __cplusplus < 201103L
1684  #error This library needs at least a C++11 compliant compiler
1685#endif
1686'
1687CPLUSPLUS_MAIN='printf("%ld\n", __cplusplus);'
1688
1689AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[${CPLUSPLUS_DECL}]], [[${CPLUSPLUS_MAIN}]])],
1690    [AC_MSG_RESULT([yes, out of the box])
1691     have_cxx11=yes],
1692    [AS_CASE(["${CXXFLAGS}"],
1693        [*"-std="*], [
1694            AC_MSG_RESULT([no, not with the standard already set in CXXFLAGS='${CXXFLAGS}'])
1695            have_cxx11=no,
1696        ],[
1697            CXXFLAGS="$CXXFLAGS -std=c++11"
1698            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[${CPLUSPLUS_DECL}]], [[${CPLUSPLUS_MAIN}]])],
1699                [AC_MSG_RESULT([yes, GCC-style (as C++11)])
1700                 have_cxx11=yes],
1701                [CXXFLAGS="$CXXFLAGS -std=c++0x"
1702                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[${CPLUSPLUS_DECL}]], [[${CPLUSPLUS_MAIN}]])],
1703                    [AC_MSG_RESULT([yes, GCC-style (as C++0X)])
1704                     have_cxx11=yes],
1705                    [AC_MSG_RESULT([no])
1706                     CXXFLAGS="$my_CXXFLAGS"
1707                     have_cxx11=no])])])])
1708AM_CONDITIONAL(HAVE_CXX11, test "${have_cxx11}" = "yes")
1709AC_LANG_POP([C++])
1710unset CPLUSPLUS_MAIN
1711unset CPLUSPLUS_DECL
1712
1713AC_MSG_CHECKING(for have_cppunit)
1714have_cppunit="no"
1715CPPUNIT_NUT_CXXFLAGS=""
1716AS_IF([test x"$have_PKG_CONFIG" = xyes],
1717    [AS_IF([test x"${have_cxx11}" = xyes],
1718        [ifdef([PKG_CHECK_MODULES], [PKG_CHECK_MODULES(CPPUNIT, cppunit, have_cppunit=yes, have_cppunit=no)], [have_cppunit=no])
1719         AS_IF([test "${have_cppunit}" != "yes"],
1720            [AC_MSG_WARN([libcppunit not found - those C++ tests will not be built.])
1721             have_cppunit=no],
1722            [AS_IF([test -n "$CXX"],
1723                [AS_IF([$CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null],
1724                    [CPPUNIT_NUT_CXXFLAGS="-g -O0"])])
1725            ])
1726        ])
1727    ], [AC_MSG_WARN([pkg-config not found, can not look properly for libcppunit - those C++ tests will not be built.])
1728        have_cppunit=no]
1729)
1730AC_MSG_RESULT(${have_cppunit})
1731
1732dnl On some systems, CppUnit inexplicably fails with trivial assertions
1733dnl so it should not be enabled with those environments, corrupting the
1734dnl test results with misleading errors.
1735dnl Tracked in https://github.com/networkupstools/nut/issues/1126
1736dnl One such situation was e.g. "clang++ + arm64(QEMU) + -m64" while
1737dnl this was not seen with other compilers or bitness on same system.
1738AS_IF([test "${have_cppunit}" = "yes"],
1739    [AC_MSG_CHECKING([if current toolkit can build and run cppunit tests (e.g. no ABI issues, related segfaults, etc.)])
1740     dnl Code below is largely a stripped variant of our tests/example.cpp and cpputest.cpp
1741     CPLUSPLUS_DECL='
1742#include <stdexcept>
1743#include <cppunit/extensions/HelperMacros.h>
1744#include <cppunit/CompilerOutputter.h>
1745#include <cppunit/extensions/TestFactoryRegistry.h>
1746#include <cppunit/ui/text/TestRunner.h>
1747
1748class ExampleTest : public CppUnit::TestFixture
1749{
1750  CPPUNIT_TEST_SUITE( ExampleTest );
1751    CPPUNIT_TEST( testOne );
1752  CPPUNIT_TEST_SUITE_END();
1753public:
1754  void setUp() {};
1755  void tearDown() {};
1756  void testOne();
1757};
1758CPPUNIT_TEST_SUITE_REGISTRATION( ExampleTest );
1759void ExampleTest::testOne()
1760{
1761  int i = 1;
1762  float f = 1.0;
1763  int cast = static_cast<int>(f);
1764  CPPUNIT_ASSERT_EQUAL_MESSAGE("Casted float is not the expected int (assert_eq)", i, cast );
1765  CPPUNIT_ASSERT_MESSAGE("Casted float is not the expected int (assert)", (i == cast) );
1766}
1767'
1768
1769     CPLUSPLUS_MAIN='
1770CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
1771CppUnit::TextUi::TestRunner runner;
1772runner.addTest( suite );
1773runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) );
1774bool res = runner.run();
1775return res ? 0 : 1;
1776'
1777
1778     my_CXXFLAGS="$CXXFLAGS"
1779     CXXFLAGS="$myCXXFLAGS $pkg_cv_CPPUNIT_CFLAGS $pkg_cv_CPPUNIT_LIBS"
1780     AC_LANG_PUSH([C++])
1781     AC_RUN_IFELSE([AC_LANG_PROGRAM([[${CPLUSPLUS_DECL}]], [[${CPLUSPLUS_MAIN}]])],
1782        [have_cppunit=yes], [have_cppunit=no])
1783     CXXFLAGS="$my_CXXFLAGS"
1784     AC_LANG_POP([C++])
1785     unset CPLUSPLUS_MAIN
1786     unset CPLUSPLUS_DECL
1787     ])
1788AC_MSG_RESULT(${have_cppunit})
1789
1790dnl # By default keep the originally detected have_cppunit value
1791AC_MSG_CHECKING(for impact from --enable-cppunit option - should we build cppunit tests?)
1792AC_ARG_ENABLE(cppunit,
1793	[AS_HELP_STRING([--enable-cppunit], [enable CPPUNIT tests for C++ bindings])],
1794	[AS_CASE(["${enableval}"],
1795		["yes"], [AS_IF([test x"${have_cppunit}" = xyes], [], [AC_MSG_ERROR([--with-cppunit=yes can not be satisfied])])],
1796		["no"], [have_cppunit=no]
1797	)])
1798AC_MSG_RESULT(${have_cppunit})
1799
1800AM_CONDITIONAL(HAVE_CPPUNIT, test "${have_cppunit}" = "yes")
1801AC_DEFINE_UNQUOTED(CPPUNIT_NUT_CXXFLAGS, $CPPUNIT_NUT_CXXFLAGS, [Compiler flags for cppunit tests])
1802
1803AC_MSG_CHECKING(whether to install Augeas configuration-management lenses)
1804AC_ARG_WITH(augeas-lenses-dir,
1805	AS_HELP_STRING([--with-augeas-lenses-dir=PATH], [where to install Augeas configuration-management lenses (/usr/share/augeas/lenses{/dist,/})]),
1806[
1807	case "${withval}" in
1808	yes)
1809		if test -z "${auglensdir}"; then
1810			AC_MSG_RESULT(no)
1811			AC_MSG_ERROR([augeas lenses directory requested but not found in default location])
1812		fi
1813		if ! test -s scripts/augeas/nutupsconf.aug.in ; then
1814			AC_MSG_RESULT(no)
1815			AC_MSG_ERROR([augeas lenses directory requested but a non-trivial scripts/augeas/nutupsconf.aug.in was not provided by autogen.sh or dist archive])
1816		fi
1817		;;
1818	auto)
1819		if ! test -s scripts/augeas/nutupsconf.aug.in ; then
1820			AC_MSG_WARN([augeas lenses directory skipped because a non-trivial scripts/augeas/nutupsconf.aug.in was not provided by autogen.sh or dist archive])
1821			auglensdir=""
1822		fi
1823		;;
1824	no)
1825		auglensdir=""
1826		;;
1827	*)
1828		auglensdir="${withval}"
1829		;;
1830	esac
1831], [])
1832if test -n "${auglensdir}"; then
1833	AC_MSG_RESULT(using ${auglensdir})
1834else
1835	AC_MSG_RESULT(no)
1836fi
1837AM_CONDITIONAL(WITH_AUGLENS, test -n "${auglensdir}")
1838
1839AC_PATH_PROGS([AUGPARSE], [augparse], [none])
1840AM_CONDITIONAL([HAVE_AUGPARSE], [test "x${AUGPARSE}" != "xnone"])
1841AC_MSG_CHECKING([whether to enable Augeas configuration-management lenses tests])
1842if test "x${AUGPARSE}" != xnone ; then
1843	AC_MSG_RESULT(yes)
1844else
1845	AC_MSG_RESULT(no)
1846fi
1847
1848
1849AC_MSG_CHECKING(whether to install hotplug rules)
1850AC_ARG_WITH(hotplug-dir,
1851	AS_HELP_STRING([--with-hotplug-dir=PATH], [where to install hotplug rules (/etc/hotplug)]),
1852[
1853	case "${withval}" in
1854	yes)
1855		if test -z "${hotplugdir}"; then
1856			AC_MSG_RESULT(no)
1857			AC_MSG_ERROR([hotplug directory requested but not found])
1858		fi
1859		;;
1860	auto)
1861		;;
1862	no)
1863		hotplugdir=""
1864		;;
1865	*)
1866		hotplugdir="${withval}"
1867		;;
1868	esac
1869], [])
1870if test -n "${hotplugdir}"; then
1871	AC_MSG_RESULT(using ${hotplugdir})
1872else
1873	AC_MSG_RESULT(no)
1874fi
1875AM_CONDITIONAL(WITH_HOTPLUG, test -n "${hotplugdir}")
1876
1877AC_MSG_CHECKING(whether to install udev rules)
1878AC_ARG_WITH(udev-dir,
1879	AS_HELP_STRING([--with-udev-dir=PATH], [where to install udev rules (/lib/udev or /etc/udev)]),
1880[
1881	case "${withval}" in
1882	yes)
1883		if test -z "${udevdir}"; then
1884			AC_MSG_RESULT(no)
1885			AC_MSG_ERROR([udev directory requested but not found])
1886		fi
1887		if test "${nut_with_usb}" = yes && ! test -s scripts/udev/nut-usbups.rules.in ; then
1888			AC_MSG_RESULT(no)
1889			AC_MSG_ERROR([udev directory and USB driver support requested but a non-trivial scripts/udev/nut-usbups.rules.in was not provided by autogen.sh or dist archive])
1890		fi
1891		;;
1892	auto)
1893		if test "${nut_with_usb}" = yes && ! test -s scripts/udev/nut-usbups.rules.in ; then
1894			AC_MSG_WARN([udev directory skipped because a non-trivial scripts/udev/nut-usbups.rules.in was not provided by autogen.sh or dist archive])
1895			udevdir=""
1896		fi
1897		;;
1898	no)
1899		udevdir=""
1900		;;
1901	*)
1902		udevdir="${withval}"
1903		;;
1904	esac
1905], [])
1906if test -n "${udevdir}"; then
1907	AC_MSG_RESULT(using ${udevdir})
1908else
1909	AC_MSG_RESULT(no)
1910fi
1911AM_CONDITIONAL(WITH_UDEV, test -n "${udevdir}")
1912
1913dnl FreeBSD devd support:
1914
1915AC_MSG_CHECKING(whether to install FreeBSD devd.conf file)
1916AC_ARG_WITH(devd-dir,
1917	AS_HELP_STRING([--with-devd-dir=PATH], [where to install devd.conf file (/usr/local/etc/devd or /etc/devd)]),
1918[
1919	case "${withval}" in
1920	yes)
1921		if test -z "${devddir}"; then
1922			AC_MSG_RESULT(no)
1923			AC_MSG_ERROR([devd directory requested but not found])
1924		fi
1925		if test "${nut_with_usb}" = yes && ! test -s scripts/devd/nut-usbups.rules.in -a -s scripts/devd/nut-usb.conf.in ; then
1926			AC_MSG_RESULT(no)
1927			AC_MSG_ERROR([devd directory and USB driver support requested but non-trivial scripts/devd/nut-usbups.rules.in and scripts/devd/nut-usb.conf.in were not provided by autogen.sh or dist archive])
1928		fi
1929		;;
1930	auto)
1931		if test "${nut_with_usb}" = yes && ! test -s scripts/devd/nut-usbups.rules.in -a -s scripts/devd/nut-usb.conf.in ; then
1932			AC_MSG_WARN([devd directory skipped because non-trivial scripts/devd/nut-usbups.rules.in and scripts/devd/nut-usb.conf.in were not provided by autogen.sh or dist archive])
1933			devddir=""
1934		fi
1935		;;
1936	no)
1937		devddir=""
1938		;;
1939	*)
1940		devddir="${withval}"
1941		;;
1942	esac
1943], [])
1944if test -n "${devddir}"; then
1945	AC_MSG_RESULT(using ${devddir})
1946else
1947	AC_MSG_RESULT(no)
1948fi
1949AM_CONDITIONAL(WITH_DEVD, test -n "${devddir}")
1950
1951dnl
1952
1953dnl AIX system
1954AM_CONDITIONAL([SYSTEM_AIX], [test "xAIX" = "x`uname -s 2>/dev/null`"])
1955
1956dnl processor type
1957AC_DEFINE_UNQUOTED(CPU_TYPE, ["$target_cpu"], [Define processor type])
1958
1959dnl Can use valgrind for memory-leak testing, if present
1960AC_PATH_PROGS([VALGRIND], [valgrind], [none])
1961dnl Even if the tool is installed, it may be not usable on build platform.
1962dnl QEMU may further complicate things, providing CPUs that formally match
1963dnl a supported family but crash in practice, or hopefully rejected early:
1964dnl valgrind: fatal error: unsupported CPU.
1965dnl    Supported CPUs are:
1966dnl    * x86 (practically any; Pentium-I or above), AMD Athlon or above)
1967dnl    * AMD Athlon64/Opteron
1968dnl    * ARM (armv7)
1969dnl    * MIPS (mips32 and above; mips64 and above)
1970dnl    * PowerPC (most; ppc405 and above)
1971dnl    * System z (64bit only - s390x; z990 and above)
1972dnl Even if the tool does basically start, on some QEMU systems it crashes
1973dnl later (e.g. claims Signal 11 in tear-down after a successful test), so
1974dnl we support an explicit --without-valgrind (aka --with-valgrind=no) too.
1975AS_IF([test -n "${VALGRIND}"], [
1976	AC_MSG_CHECKING([whether valgrind is usable on current platform])
1977	AS_IF([( ${VALGRIND} --help >/dev/null 2>/dev/null )],
1978		[AS_IF([( ${VALGRIND} /bin/sh -c true >/dev/null 2>/dev/null )],
1979			[AC_MSG_RESULT([yes])],
1980			[AC_MSG_RESULT([no])
1981			 VALGRIND="none"
1982			])],
1983		[AC_MSG_RESULT([no])
1984		 VALGRIND="none"
1985		])
1986])
1987AC_MSG_CHECKING(whether to use valgrind for memory-leak testing)
1988AC_ARG_WITH(valgrind,
1989	AS_HELP_STRING([--with-valgrind=PATH], [whether to use valgrind for memory-leak testing]),
1990[
1991	dnl ### echo "Caller said: '${withval}'... Discovered tool: '${VALGRIND}'... "
1992	case "${withval}" in
1993	yes)
1994		if test "x$VALGRIND" = "xnone"; then
1995			AC_MSG_RESULT(no)
1996			AC_MSG_ERROR([valgrind requested but not found])
1997		fi
1998		with_valgrind="yes"
1999		;;
2000	auto)
2001		with_valgrind="auto"
2002		;;
2003	no)
2004		with_valgrind="no"
2005		;;
2006	*)
2007		AC_PATH_PROGS([VALGRIND], ["${withval}"], [none])
2008		if test "x$VALGRIND" = "xnone"; then
2009			AC_MSG_RESULT(no)
2010			AC_MSG_ERROR([valgrind requested but not found])
2011		fi
2012		with_valgrind="yes"
2013		;;
2014	esac
2015], [])
2016
2017if test "x${with_valgrind}" = xauto; then
2018	if test "x$VALGRIND" = "xnone"; then
2019		with_valgrind="no"
2020	else
2021		with_valgrind="yes"
2022	fi
2023fi
2024
2025if test "x${with_valgrind}" = xyes; then
2026	AC_MSG_RESULT(using ${VALGRIND})
2027	AC_MSG_NOTICE([Do not forget to build with debug (e.g. pass '-g' in CFLAGS for GCC) for best results with valgrind tests])
2028else
2029	AC_MSG_RESULT(no)
2030fi
2031AM_CONDITIONAL([HAVE_VALGRIND], [test "x${VALGRIND}" != "xnone"])
2032AM_CONDITIONAL([WITH_VALGRIND], [test "x${with_valgrind}" = "xyes"])
2033
2034AC_MSG_CHECKING([whether to build cppunit tests using valgrind support])
2035if test "x${with_valgrind}" = xyes && test "x${have_cppunit}" = xyes ; then
2036	AC_MSG_RESULT(yes)
2037else
2038	AC_MSG_RESULT(no)
2039fi
2040
2041dnl expand ${sysconfdir} and write it out - note that most packages
2042dnl override it to be /etc/nut, /etc/ups or similar, while the
2043dnl autotools default would be $prefix/etc
2044conftemp="${sysconfdir}"
2045eval conftemp=\"${conftemp}\"
2046eval conftemp=\"${conftemp}\"
2047CONFPATH=${conftemp}
2048AC_DEFINE_UNQUOTED(CONFPATH, "${conftemp}", [Default path for configuration files])
2049
2050dnl same for datadir
2051conftemp="${datadir}"
2052eval conftemp=\"${conftemp}\"
2053eval conftemp=\"${conftemp}\"
2054DATADIR=${conftemp}
2055NUT_DATADIR=${conftemp}
2056AC_DEFINE_UNQUOTED(DATADIR, "${conftemp}", [Default path for data files])
2057
2058dnl same for bindir
2059conftemp="${bindir}"
2060eval conftemp=\"${conftemp}\"
2061eval conftemp=\"${conftemp}\"
2062BINDIR=${conftemp}
2063AC_DEFINE_UNQUOTED(BINDIR, "${conftemp}", [Default path for user executables])
2064
2065dnl same for sbindir
2066conftemp="${sbindir}"
2067eval conftemp=\"${conftemp}\"
2068eval conftemp=\"${conftemp}\"
2069SBINDIR=${conftemp}
2070AC_DEFINE_UNQUOTED(SBINDIR, "${conftemp}", [Default path for system executables])
2071
2072dnl same for libdir
2073conftemp="${libdir}"
2074eval conftemp=\"${conftemp}\"
2075eval conftemp=\"${conftemp}\"
2076LIBDIR=${conftemp}
2077AC_DEFINE_UNQUOTED(LIBDIR, "${conftemp}", [Default path for system libraries])
2078
2079dnl same for libexecdir
2080conftemp="${libexecdir}"
2081eval conftemp=\"${conftemp}\"
2082eval conftemp=\"${conftemp}\"
2083LIBEXECDIR=${conftemp}
2084AC_DEFINE_UNQUOTED(LIBEXECDIR, "${conftemp}", [Default path for system exec-libraries])
2085
2086
2087dnl checks related to --with-snmp enabled on command-line
2088
2089dnl ${nut_with_snmp}: any value except "yes" or "no" is treated as "auto".
2090if test "${nut_with_snmp}" = "yes" -a "${nut_have_libnetsnmp}" != "yes"; then
2091   AC_MSG_ERROR([Net-SNMP libraries not found, required for SNMP drivers])
2092fi
2093
2094if test "${nut_with_snmp}" != "no"; then
2095   nut_with_snmp="${nut_have_libnetsnmp}"
2096fi
2097
2098NUT_REPORT_FEATURE([build SNMP drivers], [${nut_with_snmp}], [],
2099					[WITH_SNMP], [Define to enable SNMP support])
2100AM_CONDITIONAL([HAVE_SNMP], [test "${nut_have_libsnmp}" = "yes"])
2101
2102
2103if test -n "${host_alias}" ; then
2104	AC_DEFINE_UNQUOTED(AUTOTOOLS_HOST_ALIAS, "${host_alias}", [host env spec we run on])
2105else
2106	if test -n "${host}" ; then
2107		AC_DEFINE_UNQUOTED(AUTOTOOLS_HOST_ALIAS, "${host}", [host env spec we run on])
2108	fi
2109fi
2110if test -n "${build_alias}" ; then
2111	AC_DEFINE_UNQUOTED(AUTOTOOLS_BUILD_ALIAS, "${build_alias}", [host env spec we built on])
2112else
2113	if test -n "${build}" ; then
2114	AC_DEFINE_UNQUOTED(AUTOTOOLS_BUILD_ALIAS, "${build}", [host env spec we built on])
2115	fi
2116fi
2117if test -n "${target_alias}" ; then
2118	AC_DEFINE_UNQUOTED(AUTOTOOLS_TARGET_ALIAS, "${target_alias}", [host env spec we built for])
2119else
2120	if test -n "${target}" ; then
2121	AC_DEFINE_UNQUOTED(AUTOTOOLS_TARGET_ALIAS, "${target}", [host env spec we built for])
2122	fi
2123fi
2124
2125if test -n "${host_cpu}" -a -n "${host_os}" ; then
2126	AC_DEFINE_UNQUOTED(AUTOTOOLS_HOST_SHORT_ALIAS, "${host_cpu}-${host_os}", [host OS short spec we run on])
2127fi
2128if test -n "${build_cpu}" -a -n "${build_os}" ; then
2129	AC_DEFINE_UNQUOTED(AUTOTOOLS_BUILD_SHORT_ALIAS, "${build_cpu}-${build_os}", [host OS short spec we built on])
2130fi
2131if test -n "${target_cpu}" -a -n "${target_os}" ; then
2132	AC_DEFINE_UNQUOTED(AUTOTOOLS_TARGET_SHORT_ALIAS, "${target_cpu}-${target_os}", [host OS short spec we built for])
2133fi
2134
2135dnl ----------------------------------------------------------------------
2136
2137dnl Current date
2138now=`TZ=UTC date +%Y-%m-%d`
2139
2140AC_SUBST(now)
2141AC_SUBST(OS_NAME)
2142AC_SUBST(TREE_VERSION)
2143AC_SUBST(NUT_NETVERSION)
2144AC_SUBST(LIBSSL_CFLAGS)
2145AC_SUBST(LIBSSL_LIBS)
2146AC_SUBST(LIBSSL_REQUIRES)
2147AC_SUBST(LIBGD_CFLAGS)
2148AC_SUBST(LIBGD_LDFLAGS)
2149AC_SUBST(LIBNETSNMP_CFLAGS)
2150AC_SUBST(LIBNETSNMP_LIBS)
2151AC_SUBST(LIBUSB_CFLAGS)
2152AC_SUBST(LIBUSB_LIBS)
2153AC_SUBST(LIBNEON_CFLAGS)
2154AC_SUBST(LIBNEON_LIBS)
2155AC_SUBST(LIBAVAHI_CFLAGS)
2156AC_SUBST(LIBAVAHI_LIBS)
2157AC_SUBST(LIBPOWERMAN_CFLAGS)
2158AC_SUBST(LIBPOWERMAN_LIBS)
2159AC_SUBST(LIBMODBUS_CFLAGS)
2160AC_SUBST(LIBMODBUS_LIBS)
2161AC_SUBST(LIBIPMI_CFLAGS)
2162AC_SUBST(LIBIPMI_LIBS)
2163AC_SUBST(DOC_BUILD_LIST)
2164AC_SUBST(DOC_CHECK_LIST)
2165AC_SUBST(LIBWRAP_CFLAGS)
2166AC_SUBST(LIBWRAP_LIBS)
2167AC_SUBST(LIBLTDL_CFLAGS)
2168AC_SUBST(LIBLTDL_LIBS)
2169AC_SUBST(DRIVER_BUILD_LIST)
2170AC_SUBST(DRIVER_MAN_LIST)
2171AC_SUBST(DRIVER_INSTALL_TARGET)
2172AC_SUBST(NETLIBS)
2173AC_SUBST(SERLIBS)
2174AC_SUBST(PIDPATH)
2175AC_SUBST(STATEPATH)
2176AC_SUBST(CONFPATH)
2177AC_SUBST(BINDIR)
2178AC_SUBST(LIBDIR)
2179AC_SUBST(NUT_DATADIR, [`eval echo "${DATADIR}"`])
2180AC_SUBST(NUT_LIBEXECDIR, [`eval echo "${LIBEXECDIR}"`])
2181AC_SUBST(DRVPATH)
2182AC_SUBST(SBINDIR)
2183AC_SUBST(PORT)
2184AC_SUBST(RUN_AS_USER)
2185AC_SUBST(RUN_AS_GROUP)
2186AC_SUBST(SUN_LIBUSB)
2187AC_SUBST(WORDS_BIGENDIAN)
2188AC_SUBST(cgiexecdir)
2189AC_SUBST(devddir)
2190AC_SUBST(driverexecdir)
2191AC_SUBST(htmldir)
2192AC_SUBST(pkgconfigdir)
2193AC_SUBST(systemdsystemunitdir)
2194AC_SUBST(systemdshutdowndir)
2195AC_SUBST(systemdtmpfilesdir)
2196AC_SUBST(auglensdir)
2197AC_SUBST(hotplugdir)
2198AC_SUBST(udevdir)
2199
2200dnl Filter through known variants first, so automatic choices can be made.
2201dnl Note that clang identifies as gcc-compatible so should be probed first.
2202dnl TODO: Flip this default to "hard" when we clear existing codebase.
2203dnl Note: the "gcc-legacy" option is intentionally undocumented, it acts as
2204dnl least-surprise default if caller did not specify any --enable-warnings.
2205dnl Note: Currently the "gcc-minimal" mode below adapts to builds with
2206dnl C89/C90/ANSI mode to be less noisy. Keep this in mind if changing the
2207dnl default "nut_warning_difficulty" and/or the case handling below.
2208nut_warning_difficulty="minimal"
2209AC_MSG_CHECKING([whether to pre-set warnings])
2210AS_CASE(["${nut_enable_warnings}"],
2211    [no|all|gcc-legacy|gcc-minimal|clang-minimal|gcc-medium|clang-medium|gcc-hard|clang-hard], [],
2212    [clang], [nut_enable_warnings="${nut_enable_warnings}-${nut_warning_difficulty}"],
2213    [gcc], [
2214        AS_CASE(["${CFLAGS}"],
2215            [*89*|*90*|*ansi*], [nut_enable_warnings="${nut_enable_warnings}-minimal"],
2216            [nut_enable_warnings="${nut_enable_warnings}-${nut_warning_difficulty}"]
2217        )],
2218    [yes|auto|""], [
2219        AS_IF([test "${CLANGCC}" = "yes"], [nut_enable_warnings="clang-${nut_warning_difficulty}"],
2220            [AS_IF([test "${GCC}" = "yes"], [
2221                AS_CASE(["${CFLAGS}"],
2222                    [*89*|*90*|*ansi*], [nut_enable_warnings="gcc-minimal"],
2223                    [nut_enable_warnings="gcc-${nut_warning_difficulty}"]
2224                )], [nut_enable_warnings="all"])
2225            ])
2226        ],
2227    [hard|auto-hard|auto=hard], [
2228        AS_IF([test "${CLANGCC}" = "yes"], [nut_enable_warnings="clang-hard"],
2229            [AS_IF([test "${GCC}" = "yes"], [nut_enable_warnings="gcc-hard"], [nut_enable_warnings="all"])
2230            ])
2231        ],
2232    [medium|auto-medium|auto=medium], [
2233        AS_IF([test "${CLANGCC}" = "yes"], [nut_enable_warnings="clang-medium"],
2234            [AS_IF([test "${GCC}" = "yes"], [nut_enable_warnings="gcc-medium"], [nut_enable_warnings="all"])
2235            ])
2236        ],
2237    [minimal|auto-minimal|auto=minimal], [
2238        AS_IF([test "${CLANGCC}" = "yes"], [nut_enable_warnings="clang-minimal"],
2239            [AS_IF([test "${GCC}" = "yes"], [nut_enable_warnings="gcc-minimal"], [nut_enable_warnings="all"])
2240            ])
2241        ],
2242    [legacy], [AS_IF([test "${GCC}" = "yes"], [nut_enable_warnings="gcc-legacy"], [nut_enable_warnings="no"])],
2243    [AC_MSG_WARN([Unsupported variant for --enable-warnings=${nut_enable_warnings}, ignored])
2244     nut_enable_warnings="no"
2245    ]
2246)
2247AC_MSG_RESULT(["${nut_enable_warnings}"])
2248
2249dnl # Nothing special for gcc - we tend to survive it with GNU standard >= 99
2250dnl # and fail with strict C standard. Suggestions welcome for "gcc-hard" to
2251dnl # make a difference.
2252dnl # Some of the compiler flags (including those added by pkg-config of some
2253dnl # third-party dependency packages) can upset older compiler releases which
2254dnl # did not yet support those. Flags like "-Wno-unknown-warning" for GCC or
2255dnl # "-Wno-unknown-warning-option" for CLANG should take care of that at least
2256dnl # for toolkit versions that support these - set in NUT_COMPILER_FAMILY_FLAGS
2257dnl # Majority of sanity checks are enabled by "-Wextra" on both GCC and CLANG
2258dnl # and "-Weverything" additionally on CLANG. They are impractically picky,
2259dnl # especially with fallout from system headers that we can not impact anyway
2260dnl # so the "difficulty level" pre-sets exclude certain warning classes from
2261dnl # that report.
2262dnl ### Special exclusion picks for clang-hard:
2263dnl # -Wno-unused-macros -- system headers define a lot of stuff we do not use,
2264dnl #    gotta be fatal right?
2265dnl # -Wno-reserved-id-macro -- configure script tends to define _GNU_SOURCE_,
2266dnl #    __EXTENSIONS__ etc. which are underscored and reserved for compilers
2267dnl # -Wno-padded -- NSPR and NSS headers get to issue lots of that
2268dnl # -Wno-c++98-compat-pedantic -Wno-c++98-compat -- our C++ code uses nullptr
2269dnl #    as requested by newer linters, and C++98 does not. We require C++11
2270dnl #    or newer anyway, and skip building C++ library and test otherwise.
2271dnl ### Special exclusion picks for clang-medium (same as hard, plus...):
2272dnl # -Wno-float-conversion -Wno-double-promotion -Wno-implicit-float-conversion
2273dnl #    -- reduce noise due to floating-point literals like "3.14" being a C
2274dnl #    double type (a "3.14f" literal is a C float) cast implicitly into
2275dnl #    float variables. Also variadic functions like printf() cast their
2276dnl #    floating-point arguments into double (and small integer types into
2277dnl #    "int") which then confuses pedantic checks of printf("%f", floatval).
2278dnl # -Wno-cast-qual -- our code calls some library methods in ways which use
2279dnl #    a "const char *" as a "char *" or vice-versa. Sometimes these method
2280dnl #    signatures differ between dependency releases; sometimes they just
2281dnl #    happened too hard to unravel cleanly and add more warnings.
2282dnl #    This exclusion may be removed after common warnings are solved,
2283dnl #    to allow progress on rectifying these cases next.
2284AS_CASE(["${nut_enable_warnings}"],
2285    [all], [
2286        CFLAGS="${CFLAGS} -Wall"
2287        CXXFLAGS="${CXXFLAGS} -Wall"
2288        ],
2289    [clang-hard], [
2290        CFLAGS="${CFLAGS} -ferror-limit=0 -Wall -Wextra -Weverything -Wno-unused-macros -Wno-reserved-id-macro -Wno-padded -Wno-documentation -Wno-cast-qual -pedantic"
2291        CXXFLAGS="${CXXFLAGS} -ferror-limit=0 -Wall -Wextra -Weverything -Wno-unused-macros -Wno-reserved-id-macro -Wno-padded -Wno-documentation -Wno-cast-qual -Wno-c++98-compat-pedantic -Wno-c++98-compat"
2292        ],
2293    [clang-medium], [
2294        CFLAGS="${CFLAGS} -ferror-limit=0 -Wall -Wextra -Weverything -Wno-unused-macros -Wno-reserved-id-macro -Wno-padded -Wno-documentation -Wno-cast-qual -pedantic -Wno-float-conversion -Wno-double-promotion -Wno-implicit-float-conversion"
2295        CXXFLAGS="${CXXFLAGS} -ferror-limit=0 -Wall -Wextra -Weverything -Wno-unused-macros -Wno-reserved-id-macro -Wno-padded -Wno-documentation -Wno-cast-qual -Wno-c++98-compat-pedantic -Wno-c++98-compat"
2296        ],
2297    [clang-minimal], [
2298        CFLAGS="${CFLAGS} -ferror-limit=0 -Wall -Wextra -Wno-documentation"
2299        CXXFLAGS="${CXXFLAGS} -ferror-limit=0 -Wall -Wextra -Wno-documentation"
2300        ],
2301    [gcc-legacy], [CFLAGS="${CFLAGS} -Wall -Wsign-compare"],
2302    [gcc-minimal], [
2303        dnl Builds with C89 (and aliases) are quite noisy for C99+ syntax used
2304        dnl in NUT. The minimal-warnings should not complain in these builds.
2305        CFLAGS="${CFLAGS} -Wall -Wsign-compare"
2306        CXXFLAGS="${CXXFLAGS} -Wall -Wextra"
2307        AS_CASE(["${CFLAGS}"],
2308            [*89*|*90*|*ansi*], [],
2309            [CFLAGS="${CFLAGS} -Wextra -pedantic"]
2310        )
2311        ],
2312    [gcc-medium|gcc-hard], [
2313        CFLAGS="${CFLAGS} -Wall -Wextra -Wsign-compare -pedantic"
2314        CXXFLAGS="${CXXFLAGS} -Wall -Wextra"
2315        ]
2316)
2317
2318AC_MSG_CHECKING([whether to make warnings fatal])
2319AS_CASE(["${nut_enable_Werror}"],
2320    [yes|auto], [
2321        CFLAGS="${CFLAGS} -Werror"
2322        CXXFLAGS="${CXXFLAGS} -Werror"
2323        ],
2324    [no], [
2325        CFLAGS="${CFLAGS} -Wno-error"
2326        CXXFLAGS="${CXXFLAGS} -Wno-error"
2327        ]
2328)
2329AC_MSG_RESULT(["${nut_enable_Werror}"])
2330
2331dnl Finally restore warnings settings that the caller might have provided in CFLAGS etc
2332NUT_POP_WARNINGS
2333
2334dnl Due to possibly repetitive content, generate unique settings
2335dnl relative to the top_builddir (distcheck and all):
2336AC_MSG_CHECKING([for top build dir for this configure run])
2337TOP_BUILDDIR=""
2338AS_IF([test -n "${ac_abs_top_builddir}" && test -d "${ac_abs_top_builddir}"],
2339    [TOP_BUILDDIR="${ac_abs_top_builddir}"],
2340    [AS_IF([test -n "${ac_pwd}" && test -d "${ac_pwd}"],
2341        [TOP_BUILDDIR="${ac_pwd}"],
2342        [TOP_BUILDDIR="`dirname "$0"`"
2343         TOP_BUILDDIR="`cd "$TOP_BUILDDIR" && pwd`" || AC_MSG_ERROR([Can not detect TOP_BUILDDIR])]
2344    )]
2345)
2346AC_MSG_RESULT(["${TOP_BUILDDIR}"])
2347
2348ABS_TOP_BUILDDIR="`cd "${TOP_BUILDDIR}" && pwd`" || AC_MSG_ERROR([Can not detect ABS_TOP_BUILDDIR])
2349ABS_TOP_SRCDIR="`cd "${abs_srcdir}" && pwd`" || AC_MSG_ERROR([Can not detect ABS_TOP_SRCDIR])
2350AM_CONDITIONAL([BUILDING_IN_TREE], [test "${ABS_TOP_BUILDDIR}" = "${ABS_TOP_SRCDIR}"])
2351
2352AC_MSG_CHECKING([whether to customize ${TOP_BUILDDIR}/scripts/systemd/nut-common.tmpfiles.in for this system])
2353AS_IF([test -n "$systemdtmpfilesdir"],
2354    [mkdir -p "${TOP_BUILDDIR}"/scripts/systemd
2355     cat > "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF
2356# State file (e.g. upsd to driver) and pidfile location for NUT:
2357d @STATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
2358X @STATEPATH@/nut
2359EOF
2360    AS_IF([test "$STATEPATH" != "$PIDPATH"],
2361        [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF
2362d @PIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
2363X @PIDPATH@/nut
2364EOF])
2365    AS_IF([test -n "$ALTPIDPATH" && test "$STATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTPIDPATH"],
2366        [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF
2367d @ALTPIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
2368X @ALTPIDPATH@/nut
2369EOF])
2370    AS_IF([test -n "$ALTSTATEPATH" && test "$STATEPATH" != "$ALTSTATEPATH" && test "$ALTSTATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTSTATEPATH"],
2371        [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF
2372d @ALTSTATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
2373X @ALTSTATEPATH@/nut
2374EOF])
2375])
2376AC_MSG_RESULT([done])
2377
2378AC_MSG_NOTICE([Generating "data" files from templates, see below for executable scripts])
2379AC_CONFIG_FILES([
2380 clients/Makefile
2381 common/Makefile
2382 conf/Makefile
2383 conf/upsmon.conf.sample
2384 conf/upssched.conf.sample
2385 data/html/header.html
2386 data/html/Makefile
2387 data/Makefile
2388 data/driver.list
2389 docs/Makefile
2390 docs/cables/Makefile
2391 docs/docinfo.xml
2392 docs/man/Makefile
2393 drivers/Makefile
2394 include/Makefile
2395 lib/libupsclient-config
2396 lib/libupsclient.pc
2397 lib/libnutclient.pc
2398 lib/libnutclientstub.pc
2399 lib/libnutscan.pc
2400 lib/Makefile
2401 scripts/Aix/nut-aix.spec
2402 scripts/augeas/Makefile
2403 scripts/augeas/nutnutconf.aug
2404 scripts/augeas/nutupsdconf.aug
2405 scripts/augeas/nutupsdusers.aug
2406 scripts/augeas/nutupsmonconf.aug
2407 scripts/augeas/nutupsschedconf.aug
2408 scripts/augeas/nuthostsconf.aug
2409 scripts/augeas/nutupssetconf.aug
2410 scripts/avahi/nut.service
2411 scripts/devd/Makefile
2412 scripts/hotplug/Makefile
2413 scripts/hotplug/libhidups
2414 scripts/HP-UX/nut.psf
2415 scripts/python/Makefile
2416 scripts/python/module/PyNUT.py
2417 scripts/upsdrvsvcctl/Makefile
2418 scripts/systemd/Makefile
2419 scripts/systemd/nut-common.tmpfiles
2420 scripts/systemd/nut-driver@.service
2421 scripts/systemd/nut-monitor.service
2422 scripts/systemd/nut-server.service
2423 scripts/systemd/nut-driver-enumerator.service
2424 scripts/systemd/nut-driver-enumerator.path
2425 scripts/Solaris/nut-driver-enumerator.xml
2426 scripts/Solaris/nut-driver.xml
2427 scripts/Solaris/nut-monitor.xml
2428 scripts/Solaris/nut-server.xml
2429 scripts/Solaris/nut.xml
2430 scripts/Solaris/Makefile
2431 scripts/Solaris/pkginfo
2432 scripts/udev/Makefile
2433 scripts/udev/nut-ipmipsu.rules
2434 scripts/ufw/Makefile
2435 scripts/ufw/nut.ufw.profile
2436 scripts/Makefile
2437 server/Makefile
2438 tools/Makefile
2439 tools/nut-scanner/Makefile
2440 tests/Makefile
2441 Makefile
2442])
2443
2444AC_MSG_NOTICE([Generating templated script files that should be marked executable])
2445m4_foreach_w([SCRIPTFILE], [
2446 scripts/Aix/nut.init
2447 scripts/HP-UX/postinstall
2448 scripts/python/app/NUT-Monitor
2449 scripts/augeas/gen-nutupsconf-aug.py
2450 scripts/python/module/test_nutclient.py
2451 scripts/upsdrvsvcctl/nut-driver-enumerator.sh
2452 scripts/upsdrvsvcctl/upsdrvsvcctl
2453 scripts/systemd/nutshutdown
2454 scripts/Solaris/svc-nut-server
2455 scripts/Solaris/svc-nut-monitor
2456 scripts/Solaris/precheck.py
2457 scripts/Solaris/preinstall
2458 scripts/Solaris/postinstall
2459 scripts/Solaris/preremove
2460 scripts/Solaris/postremove
2461 scripts/Solaris/preproto.pl
2462 scripts/Solaris/nut
2463 tools/gitlog2changelog.py
2464 tools/nut-snmpinfo.py
2465], [
2466 dnl Autoconf substitutes the token above specified in plain text,
2467 dnl e.g. the brace below is empty and bracket gives verbatim varname
2468 dnl AC_MSG_NOTICE([Script: SCRIPTFILE brace:(${SCRIPTFILE}) bracket:([SCRIPTFILE])])
2469 AC_CONFIG_FILES(SCRIPTFILE, chmod +x "SCRIPTFILE")
2470])
2471
2472AC_MSG_NOTICE([Generating templated script files whose templates might have been generated (or not) by autogen.sh calling our helper scripts])
2473m4_foreach_w([SCRIPTFILE], [
2474 scripts/augeas/nutupsconf.aug
2475 scripts/udev/nut-usbups.rules
2476 scripts/devd/nut-usb.conf
2477], [
2478	AC_MSG_CHECKING([whether to generate SCRIPTFILE])
2479	AS_IF([test -s SCRIPTFILE.in && ! test -f SCRIPTFILE.in.AUTOGEN_WITHOUT],
2480		[AC_MSG_RESULT(yes)
2481		 AC_CONFIG_FILES(SCRIPTFILE)],
2482		[AC_MSG_RESULT(no)]
2483	)
2484])
2485
2486AC_OUTPUT
2487
2488NUT_PRINT_FEATURE_REPORT
2489