Make MEDIA_DIR configurable

MEDIA_DIR was configured as "/media", it works on ubi-fs systems.

On static layout systems, "/media" is in rwfs, and thus is persistent
after BMC reboot or code update (if rwfs is not updated).
This makes the dirs/files in MEDIA_DIR persistent, and it causes an
issue that BMC uses the incorrect versionId of the image that is the
persistent one in MEDIA_DIR, while it should generate the versionID from
the functional BMC version.

Making MEDIA_DIR configurable, so static layout system could configure
it to a tmpfs, and the above issue is fixed.

Partly resolves openbmc/phosphor-bmc-code-mgmt#3

Tested: Verify that MEDIA_DIR could be configured via configure
        argument.

Change-Id: I10d46ea00b79677bec16ac69d2a3375597665f0c
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/configure.ac b/configure.ac
index deaf110..f768d45 100755
--- a/configure.ac
+++ b/configure.ac
@@ -87,10 +87,6 @@
     [The common file path interface])
 AC_DEFINE(OS_RELEASE_FILE, "/etc/os-release",
     [The name of the BMC table of contents file])
-AC_DEFINE(MEDIA_DIR, "/media/",
-    [The base dir where all RO partitions are mounted])
-AC_DEFINE(BMC_ROFS_PREFIX, "/media/rofs-",
-    [The prefix path for the versioned read-only bmc partitions])
 AC_DEFINE(ALT_RWFS, "/media/alt/var/persist",
     [The path of the alt rwfs overlay])
 AC_DEFINE(PERSIST_DIR, "/var/lib/obmc/phosphor-bmc-code-mgmt/",
@@ -102,6 +98,13 @@
 AC_DEFINE(SYSTEMD_INTERFACE, "org.freedesktop.systemd1.Manager",
     [The systemd interface])
 
+AC_ARG_VAR(MEDIA_DIR, [The base dir where all RO partitions are mounted])
+AS_IF([test "x$MEDIA_DIR" == "x"], [MEDIA_DIR="/media"])
+AC_DEFINE_UNQUOTED([MEDIA_DIR], ["$MEDIA_DIR"], [The base dir where all RO partitions are mounted])
+
+AC_DEFINE_UNQUOTED(BMC_ROFS_PREFIX, "$MEDIA_DIR/rofs-",
+    [The prefix path for the versioned read-only bmc partitions])
+
 AC_ARG_VAR(IMG_UPLOAD_DIR, [Directory where downloaded software images are placed])
 AS_IF([test "x$IMG_UPLOAD_DIR" == "x"], [IMG_UPLOAD_DIR="/tmp/images"])
 AC_DEFINE_UNQUOTED([IMG_UPLOAD_DIR], ["$IMG_UPLOAD_DIR"], [Directory where downloaded software images are placed])