Make IANA PEN download configurable - fix uninitalized DOWNLOAD variable

Currently if you do not have wget and curl requirement met, you get
this error:
[   93s] configure: WARNING: ** Neither wget nor curl could be found.
[   93s] configure: WARNING: ** IANA PEN database will not be installed by `make install` !
[   93s] configure: WARNING: ** Download is:
[   93s] configure: WARNING: 
...
[  104s] configure: error: conditional "DOWNLOAD" was never defined.
[  104s] Usually this means the macro was only invoked conditionally.
[  104s] error: Bad exit status from /var/tmp/rpm-tmp.TYnvu5 (%build)


Internet download is restricted in most build environments.
So there must be a knob to enable/disable IANA PEN database download.
For security reasons and as a good manner for open source tools, the internet
download is by default set to off.

This patch initializes all needed variables and also introduces to make the
IANA PEN internet download configurable.

./configure
then has this additional feature:

  --enable-iana-download  Download IANA PEN database [default=no]

Depending on whether it has explicitly been enabled this additional output
is shown after build env is successfully set up via ./configure:

  Download IANA PEN database   : yes
  IANA PEN database URL        : http://www.iana.org/assignments/enterprise-numbers

The URL is unfortunately hardcoded in the message. I couldn't find a quick
way to show the IANA_PEN_URL variable there, so if this is ever changed (it is
not configurable right now, but maybe with a follow up patch in the future),
it has to be changed in the help string as well.


---
 Makefile.am  |    5 ++---
 configure.ac |   38 ++++++++++++++++++++++++++------------
 2 files changed, 28 insertions(+), 15 deletions(-)

--- a/Makefile.am
+++ b/Makefile.am
@@ -41,7 +41,6 @@
 	$(distdir).tar.gz $(distdir).tar.bz2
 
 SUBDIRS = lib src include doc contrib control
-IANA_PEN = http://www.iana.org/assignments/enterprise-numbers
 
 dist-hook:
 	cp control/ipmitool.spec $(distdir)
@@ -52,8 +51,8 @@
 
 enterprise-numbers:
 	@echo Downloading IANA PEN database...
-	@$(DOWNLOAD) "$(IANA_PEN)" > tmpfile.$$PPID || {\
-		echo "FAILED to download the IANA PEN database"; \
+	@$(DOWNLOAD) "$(IANA_PEN_URL)" > tmpfile.$$PPID || {\
+		echo "FAILED to download the IANA PEN database from $(IANA_PEN_URL)"; \
 		rm tmpfile.$$PPID; \
 		false; \
 	}
--- a/configure.ac
+++ b/configure.ac
@@ -56,23 +56,34 @@
 	exec_prefix="$prefix"
 fi
 
-if test "x$WGET" = "x"; then
-	if test "x$CURL" = "x"; then
-		AC_MSG_WARN([** Neither wget nor curl could be found.])
-		AC_MSG_WARN([** IANA PEN database will not be installed by `make install` !])
+xiana_pen_url="http://www.iana.org/assignments/enterprise-numbers"
+AC_SUBST(IANA_PEN_URL, xiana_pen_url)
+
+AC_ARG_ENABLE([iana-download],
+	[AC_HELP_STRING([--enable-iana-download],
+			[Download IANA PEN database [default=no]])],
+	[xenable_iana_download=$enableval],
+	[xenable_iana_download=no])
+if test "x$xenable_iana_download" = "xyes"; then
+	if test "x$WGET" = "x"; then
+		if test "x$CURL" = "x"; then
+			AC_MSG_WARN([** Neither wget nor curl could be found.])
+			AC_MSG_WARN([** IANA PEN database will not be installed by `make install` !])
+			xenable_iana_download="no"
+		else
+			DOWNLOAD="$CURL -#"
+		fi
 	else
-		DOWNLOAD="$CURL -#"
-		AM_CONDITIONAL([DOWNLOAD], [true])
+		DOWNLOAD="$WGET -c -nd -O -"
 	fi
-else
-	DOWNLOAD="$WGET -c -nd -O -"
+fi
+if test "x$xenable_iana_download" = "xyes"; then
 	AM_CONDITIONAL([DOWNLOAD], [true])
+	AC_SUBST(DOWNLOAD, $DOWNLOAD)
+else
+	AM_CONDITIONAL([DOWNLOAD], [false])
 fi
 
-AC_MSG_WARN([** Download is:])
-AC_MSG_WARN($DOWNLOAD)
-AC_SUBST(DOWNLOAD, $DOWNLOAD)
-
 dnl
 dnl set default option values
 dnl
@@ -776,4 +787,7 @@
 AC_MSG_RESULT([  ipmievd   : yes])
 AC_MSG_RESULT([  ipmishell : $xenable_ipmishell])
 AC_MSG_RESULT([])
+AC_MSG_RESULT([  Download IANA PEN database   : $xenable_iana_download])
+AC_MSG_RESULT([  IANA PEN database URL        : $xiana_pen_url])
+AC_MSG_RESULT([])
 
