diff mbox

[02/17] oxenstored: generate a paths module

Message ID 1465804155-14469-3-git-send-email-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu June 13, 2016, 7:49 a.m. UTC
That file includes all paths generated by configure. It will be used to
get rid of hard-coded paths in code.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: David Scot <dave@recoil.org>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: David Scot <dave@recoil.org>
---
 .gitignore                     |  1 +
 tools/ocaml/Makefile.rules     | 11 +++++++++++
 tools/ocaml/xenstored/Makefile |  8 +++++++-
 3 files changed, 19 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/.gitignore b/.gitignore
index 39deb2d..e4afda3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -347,6 +347,7 @@  tools/ocaml/libs/xentoollog/xentoollog.ml
 tools/ocaml/libs/xentoollog/xentoollog.mli
 tools/ocaml/xenstored/oxenstored
 tools/ocaml/xenstored/oxenstored.conf
+tools/ocaml/xenstored/paths.ml
 tools/ocaml/test/xtl
 tools/ocaml/test/send_debug_keys
 tools/ocaml/test/list_domains
diff --git a/tools/ocaml/Makefile.rules b/tools/ocaml/Makefile.rules
index 1796060..a893c42 100644
--- a/tools/ocaml/Makefile.rules
+++ b/tools/ocaml/Makefile.rules
@@ -95,3 +95,14 @@  $(foreach lib,$(OCAML_LIBRARY),$(eval $(call OCAML_LIBRARY_template,$(lib))))
 $(foreach lib,$(OCAML_NOC_LIBRARY),$(eval $(call OCAML_NOC_LIBRARY_template,$(lib))))
 $(foreach p,$(OCAML_PROGRAM),$(eval $(call OCAML_PROGRAM_template,$(p))))
 $(foreach p,$(C_PROGRAM),$(eval $(call C_PROGRAM_template,$(p))))
+
+buildmakevars2module = $(eval $(call buildmakevars2module-closure,$(1)))
+define buildmakevars2module-closure
+    $(1): .phony
+	rm -f $(1).tmp; \
+	$(foreach var, $(BUILD_MAKE_VARS), \
+	          printf "let %s = \"%s\";;\n" \
+                      $(shell echo $(var) | tr '[:upper:]' '[:lower:]') \
+                      $($(var)) >>$(1).tmp;) \
+	$(call move-if-changed,$(1).tmp,$(1))
+endef
diff --git a/tools/ocaml/xenstored/Makefile b/tools/ocaml/xenstored/Makefile
index dce9e70..939dcaa 100644
--- a/tools/ocaml/xenstored/Makefile
+++ b/tools/ocaml/xenstored/Makefile
@@ -32,7 +32,8 @@  OCAML_LIBRARY += systemd
 
 LIBS_systemd += $(LDFLAGS-y)
 
-OBJS = define \
+OBJS = paths \
+	define \
 	stdext \
 	trie \
 	config \
@@ -87,3 +88,8 @@  install: all
 	$(INSTALL_DATA) oxenstored.conf $(DESTDIR)$(XEN_CONFIG_DIR)
 
 include $(OCAML_TOPLEVEL)/Makefile.rules
+
+genpath-target = $(call buildmakevars2module,paths.ml)
+$(eval $(genpath-target))
+
+GENERATED_FILES += paths.ml