On 08/22/2017 06:15 PM, [ext] Reichel Andreas wrote:
From: Andreas Reichel <[email protected]>

From: Reichel Andreas <[email protected]>

For API refactoring, storage backend should be configurable

Signed-off-by: Andreas Reichel <[email protected]>
---
  Makefile.am          |  4 ++--
  configure.ac         | 30 ++++++++++++++++++++++++++++--
  include/env_api.h    |  5 ++++-
  tools/tests/Makefile |  1 +
  4 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index f845c68..6c9197f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,7 +43,7 @@ BUILD_TESTS = @build_tests@
  lib_LIBRARIES = libebgenv.a libenv_api.a
libebgenv_a_SOURCES = \
-       env/env_api_fat.c \
+       env/@[email protected] \
        tools/ebgpart.c \
        swupdate-adapter/ebgenv.c
@@ -56,7 +56,7 @@ libebgenv_a_CFLAGS = \ libenv_api_a_SOURCES = \
        tools/ebgpart.c \
-       env/env_api_fat.c
+       env/@[email protected]
libenv_api_a_CFLAGS = \
        $(AM_CFLAGS)
diff --git a/configure.ac b/configure.ac
index e3eed7c..403ad4b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -144,6 +144,30 @@ AS_IF([test "x$enable_tests" != "xno"], [
                [enable_tests=yes])
  ])
+AC_ARG_WITH([env-type],
+           AS_HELP_STRING([--with-env-type=STRING],
+                          [specify the lds directory of gnuefi, defaults to 
"FAT"]),
+           [
+               case "$withval" in
+               FAT)
+               ENV_STORAGE=1
+               ENV_STORAGE_TYPE="FAT"
+               ENV_API_FILE="env_api_fat"
+               ;;
+               *)
+               AC_MSG_ERROR([bad value $withval for environment storage])
+               ;;
+               esac
+           ],
+           [
+               ENV_STORAGE=1
+               ENV_STORAGE_TYPE="FAT"
+               ENV_API_FILE="env_api_fat"
+           ])

I would rather put all the selection into C and header files instead of the configure and build script.

The configure script puts the string as a define into
the config.h and later while building the preprocessor chooses the right implementation to include into the binary.

This way switching can be done without reconfiguring the project, this makes for instance testing easier.

Also modifying build scripts it always something I like to avoid as much as possible.

Claudius

+
+AC_SUBST(ENV_STORAGE)
+AC_SUBST([env_api_file], [${ENV_API_FILE}])
+AC_DEFINE_UNQUOTED(ENV_STORAGE, [${ENV_STORAGE}], [The storage backend for 
environment data])
  # 
------------------------------------------------------------------------------
  AC_CONFIG_FILES([
          Makefile
@@ -157,13 +181,15 @@ AC_MSG_RESULT([
          machine type:            $MACHINE_TYPE_NAME
prefix: ${prefix}
-       exec_prefix:             ${exec_prefix}
+        exec_prefix:             ${exec_prefix}
          libexecdir:              ${libexecdir}
          libdir:                  ${libdir}
efi libs: ${GNUEFI_LIBS}
          efi lds:                 ${GNUEFI_LDS_DIR}
- build and run tests: ${enable_tests}
+       environment storage:     $ENV_STORAGE_TYPE
+
+       build and run tests:     $enable_tests
  ])
diff --git a/include/env_api.h b/include/env_api.h
index 70727e9..3e78ed3 100644
--- a/include/env_api.h
+++ b/include/env_api.h
@@ -26,8 +26,11 @@
  #include <fcntl.h>
  #include <sys/file.h>
  #include <sys/mount.h>
+#include "config.h"
-#include "ebgpart.h"
+#if ENV_STORAGE == 1
+#      include "ebgpart.h"
+#endif
#include <zlib.h>
  #include "envdata.h"
diff --git a/tools/tests/Makefile b/tools/tests/Makefile
index 1633a72..9c0af09 100644
--- a/tools/tests/Makefile
+++ b/tools/tests/Makefile
@@ -22,6 +22,7 @@ INCLUDE ?= /usr/include
  CFLAGS = \
        -I$(PROJECTDIR) \
        -I$(PROJECTDIR)/.. \
+       -I$(PROJECTDIR)/../.. \
        -I$(PROJECTDIR)/../../include \
        -I$(PROJECTDIR)/../../swupdate-adapter \
        -std=gnu99 \


--
You received this message because you are subscribed to the Google Groups "EFI Boot 
Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/486b94cd-35c3-1547-7043-22701fff89b1%40siemens.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to