Allow disabling use of u-boot environment

Not all systems have a writable u-boot environment, so add an autoconf
argument to disable the use of it.

Signed-off-by: Benjamin Fair <benjaminfair@google.com>
Change-Id: I04074c28f81214dd59a974440e51be0da50c5d63
diff --git a/configure.ac b/configure.ac
index 12d6caa..ee783e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,12 @@
 )
 AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])
 
+AC_ARG_WITH([uboot-env],
+              AS_HELP_STRING([--without-uboot-env], [Disable features that require a u-boot environment]))
+AS_IF([test "x$with_uboot_env" != "xno"], [
+     AC_DEFINE([HAVE_UBOOT_ENV], [1], [u-boot environment is available])
+])
+
 # Check/set gtest specific functions.
 AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-GTEST_HAS_PTHREAD=0"])
 AC_SUBST(GTEST_CPPFLAGS)
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index 6fc1e2e..f7343ad 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -979,12 +979,16 @@
         MacAddressIntf::mACAddress(value);
 
         auto interface = interfaceName();
+
+#ifdef HAVE_UBOOT_ENV
         auto envVar = interfaceToUbootEthAddr(interface.c_str());
         if (envVar)
         {
             execute("/sbin/fw_setenv", "fw_setenv", envVar->c_str(),
                     value.c_str());
         }
+#endif // HAVE_UBOOT_ENV
+
         // TODO: would remove the call below and
         //      just restart systemd-netwokd
         //      through https://github.com/systemd/systemd/issues/6696