Skip to content

Commit

Permalink
autogen.sh + configure.ac: try to support building on systems without…
Browse files Browse the repository at this point in the history
… Python or Perl
  • Loading branch information
jimklimov committed Nov 22, 2021
1 parent 6135bb6 commit 3f7d050
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 6 deletions.
19 changes: 17 additions & 2 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ else
done
fi

rm -f *.in.AUTOGEN_WITHOUT || true

# re-generate files needed by configure, and created otherwise at 'dist' time
if [ ! -f scripts/augeas/nutupsconf.aug.in ]
then
Expand All @@ -38,7 +40,13 @@ then
echo "Error: Python is not available."
echo "Unable to regenerate Augeas lens for ups.conf parsing."
echo "----------------------------------------------------------------------"
exit 1
if [ "${WITHOUT_NUT_AUGEAS-}" = true ]; then
echo "Proceeding without Augeas integration, be sure to not require it in configure script" >&2
touch scripts/augeas/nutupsconf.aug.in scripts/augeas/nutupsconf.aug.in.AUTOGEN_WITHOUT
else
echo "Aborting $0! To avoid this, please export WITHOUT_NUT_AUGEAS=true and re-run" >&2
exit 1
fi
fi
fi

Expand All @@ -56,7 +64,14 @@ then
echo "Error: Perl is not available."
echo "Unable to regenerate USB helper files."
echo "----------------------------------------------------------------------"
exit 1
if [ "${WITHOUT_NUT_USBINFO-}" = true ]; then
echo "Proceeding without NUT USB Info, be sure to not require it in configure script" >&2
touch scripts/udev/nut-usbups.rules.in scripts/udev/nut-usbups.rules.in.AUTOGEN_WITHOUT
touch scripts/devd/nut-usb.conf.in scripts/devd/nut-usb.conf.in.AUTOGEN_WITHOUT
else
echo "Aborting $0! To avoid this, please export WITHOUT_NUT_USBINFO=true and re-run" >&2
exit 1
fi
fi
fi

Expand Down
41 changes: 38 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1801,8 +1801,16 @@ AC_ARG_WITH(augeas-lenses-dir,
AC_MSG_RESULT(no)
AC_MSG_ERROR([augeas lenses directory requested but not found in default location])
fi
if ! test -s scripts/augeas/nutupsconf.aug.in ; then
AC_MSG_RESULT(no)
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])
fi
;;
auto)
if ! test -s scripts/augeas/nutupsconf.aug.in ; then
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])
auglensdir=""
fi
;;
no)
auglensdir=""
Expand Down Expand Up @@ -1867,8 +1875,16 @@ AC_ARG_WITH(udev-dir,
AC_MSG_RESULT(no)
AC_MSG_ERROR([udev directory requested but not found])
fi
if test "${nut_with_usb}" = yes && ! test -s scripts/udev/nut-usbups.rules.in ; then
AC_MSG_RESULT(no)
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])
fi
;;
auto)
if test "${nut_with_usb}" = yes && ! test -s scripts/udev/nut-usbups.rules.in ; then
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])
udevdir=""
fi
;;
no)
udevdir=""
Expand Down Expand Up @@ -1897,8 +1913,16 @@ AC_ARG_WITH(devd-dir,
AC_MSG_RESULT(no)
AC_MSG_ERROR([devd directory requested but not found])
fi
if test "${nut_with_usb}" = yes && ! test -s scripts/devd/nut-usbups.rules.in -a -s scripts/devd/nut-usb.conf.in ; then
AC_MSG_RESULT(no)
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])
fi
;;
auto)
if test "${nut_with_usb}" = yes && ! test -s scripts/devd/nut-usbups.rules.in -a -s scripts/devd/nut-usb.conf.in ; then
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])
devddir=""
fi
;;
no)
devddir=""
Expand Down Expand Up @@ -2364,7 +2388,6 @@ AC_CONFIG_FILES([
scripts/Aix/nut-aix.spec
scripts/augeas/Makefile
scripts/augeas/nutnutconf.aug
scripts/augeas/nutupsconf.aug
scripts/augeas/nutupsdconf.aug
scripts/augeas/nutupsdusers.aug
scripts/augeas/nutupsmonconf.aug
Expand All @@ -2373,7 +2396,6 @@ AC_CONFIG_FILES([
scripts/augeas/nutupssetconf.aug
scripts/avahi/nut.service
scripts/devd/Makefile
scripts/devd/nut-usb.conf
scripts/hotplug/Makefile
scripts/hotplug/libhidups
scripts/HP-UX/nut.psf
Expand All @@ -2396,7 +2418,6 @@ AC_CONFIG_FILES([
scripts/Solaris/pkginfo
scripts/udev/Makefile
scripts/udev/nut-ipmipsu.rules
scripts/udev/nut-usbups.rules
scripts/ufw/Makefile
scripts/ufw/nut.ufw.profile
scripts/Makefile
Expand Down Expand Up @@ -2435,6 +2456,20 @@ m4_foreach_w([SCRIPTFILE], [
AC_CONFIG_FILES(SCRIPTFILE, chmod +x "SCRIPTFILE")
])

AC_MSG_NOTICE([Generating templated script files whose templates might have been generated (or not) by autogen.sh calling our helper scripts])
m4_foreach_w([SCRIPTFILE], [
scripts/augeas/nutupsconf.aug
scripts/udev/nut-usbups.rules
scripts/devd/nut-usb.conf
], [
AC_MSG_CHECKING([whether to generate SCRIPTFILE])
AS_IF([test -s SCRIPTFILE.in && ! test -f SCRIPTFILE.in.AUTOGEN_WITHOUT],
[AC_MSG_RESULT(yes)
AC_CONFIG_FILES(SCRIPTFILE)],
[AC_MSG_RESULT(no)]
)
])

AC_OUTPUT

NUT_PRINT_FEATURE_REPORT
1 change: 1 addition & 0 deletions scripts/augeas/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*.aug
/nutupsconf.aug.in
/nutupsconf.aug.in.AUTOGEN_WITHOUT
/gen-nutupsconf-aug.py
2 changes: 2 additions & 0 deletions scripts/devd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ DISTCLEANFILES = nut-usb.conf
# (technically, generated by tools/nut-usbinfo.pl script among
# GENERATED_USB_OS_FILES):
MAINTAINERCLEANFILES += nut-usbups.rules.in
MAINTAINERCLEANFILES += nut-usbups.rules.in.AUTOGEN_WITHOUT
MAINTAINERCLEANFILES += nut-usb.conf.in
MAINTAINERCLEANFILES += nut-usb.conf.in.AUTOGEN_WITHOUT
1 change: 1 addition & 0 deletions scripts/udev/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/nut-ipmipsu.rules
/nut-usbups.rules
/nut-usbups.rules.in
/nut-usbups.rules.in.AUTOGEN_WITHOUT
2 changes: 1 addition & 1 deletion scripts/udev/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ CLEANFILES = 62-nut-usbups.rules 52-nut-ipmipsu.rules
# Generated by autogen.sh and needed to run the configure script
# (technically, generated by tools/nut-usbinfo.pl script among
# GENERATED_USB_OS_FILES):
MAINTAINERCLEANFILES += nut-usbups.rules.in
MAINTAINERCLEANFILES += nut-usbups.rules.in nut-usbups.rules.in.AUTOGEN_WITHOUT

0 comments on commit 3f7d050

Please sign in to comment.