diff mbox

[2/2] tools: move xl to a dedicated directory

Message ID 20170221155142.17288-3-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu Feb. 21, 2017, 3:51 p.m. UTC
It makes clear distinction between the client (xl) and library (libxl),
which should help design better APIs.  This will also help reduce the
code size in libxl directory.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 .gitignore                          |  2 +-
 tools/libxl/Makefile                | 22 ++++---------------
 tools/xl/Makefile                   | 43 +++++++++++++++++++++++++++++++++++++
 tools/{libxl => xl}/bash-completion |  0
 tools/{libxl => xl}/xl.c            |  0
 tools/{libxl => xl}/xl.h            |  0
 tools/{libxl => xl}/xl_cmdimpl.c    |  0
 tools/{libxl => xl}/xl_cmdtable.c   |  0
 tools/{libxl => xl}/xl_sxp.c        |  0
 9 files changed, 48 insertions(+), 19 deletions(-)
 create mode 100644 tools/xl/Makefile
 rename tools/{libxl => xl}/bash-completion (100%)
 rename tools/{libxl => xl}/xl.c (100%)
 rename tools/{libxl => xl}/xl.h (100%)
 rename tools/{libxl => xl}/xl_cmdimpl.c (100%)
 rename tools/{libxl => xl}/xl_cmdtable.c (100%)
 rename tools/{libxl => xl}/xl_sxp.c (100%)
diff mbox

Patch

diff --git a/.gitignore b/.gitignore
index c8d56d1bdb..a785006e44 100644
--- a/.gitignore
+++ b/.gitignore
@@ -189,7 +189,6 @@  tools/libxl/ssdt*
 tools/libxl/testenum
 tools/libxl/testenum.c
 tools/libxl/tmp.*
-tools/libxl/xl
 tools/misc/cpuperf/cpuperf-perfcntr
 tools/misc/cpuperf/cpuperf-xen
 tools/misc/xc_shadow
@@ -380,6 +379,7 @@  tools/firmware/etherboot/ipxe/
 tools/python/xen/lowlevel/xl/_pyxl_types.c
 tools/python/xen/lowlevel/xl/_pyxl_types.h
 tools/xenstore/xenstore-watch
+tools/xl/xl
 
 docs/txt/misc/*.txt
 docs/txt/man/*.txt
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 0f642cc57a..f00d9ef355 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -178,16 +178,9 @@  LIBXLU_OBJS = libxlu_cfg_y.o libxlu_cfg_l.o libxlu_cfg.o \
 	libxlu_disk_l.o libxlu_disk.o libxlu_vif.o libxlu_pci.o
 $(LIBXLU_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h
 
-CLIENTS = xl testidl libxl-save-helper
+$(TEST_PROG_OBJS) _libxl.api-for-check: CFLAGS += $(CFLAGS_libxentoollog)
 
-CFLAGS_XL += $(CFLAGS_libxenlight)
-CFLAGS_XL += -Wshadow
-
-XL_OBJS = xl.o xl_cmdimpl.o xl_cmdtable.o xl_sxp.o
-$(XL_OBJS) $(TEST_PROG_OBJS) _libxl.api-for-check: \
-            CFLAGS += $(CFLAGS_libxentoollog)
-$(XL_OBJS): CFLAGS += $(CFLAGS_XL)
-$(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it.
+CLIENTS = testidl libxl-save-helper
 
 libxl_dom.o: CFLAGS += -I$(XEN_ROOT)/tools  # include libacpi/x86.h
 libxl_x86_acpi.o: CFLAGS += -I$(XEN_ROOT)/tools
@@ -207,7 +200,7 @@  all: $(CLIENTS) $(TEST_PROGS) $(PKG_CONFIG) \
 		libxenlight.so libxenlight.a libxlutil.so libxlutil.a \
 	$(AUTOSRCS) $(AUTOINCS)
 
-$(LIBXL_OBJS) $(LIBXLU_OBJS) $(XL_OBJS) $(SAVE_HELPER_OBJS) \
+$(LIBXL_OBJS) $(LIBXLU_OBJS) $(SAVE_HELPER_OBJS) \
 		$(LIBXL_TEST_OBJS) $(TEST_PROG_OBJS): \
 	$(AUTOINCS) libxl.api-ok
 
@@ -249,7 +242,7 @@  libxl_internal_json.h: _libxl_types_internal_json.h
 xl.h: _paths.h
 
 $(LIBXL_OBJS) $(LIBXL_TEST_OBJS) $(LIBXLU_OBJS) \
-	$(XL_OBJS) $(TEST_PROG_OBJS) $(SAVE_HELPER_OBJS): libxl.h
+	$(TEST_PROG_OBJS) $(SAVE_HELPER_OBJS): libxl.h
 $(LIBXL_OBJS) $(LIBXL_TEST_OBJS): libxl_internal.h
 
 _libxl_type%.h _libxl_type%_json.h _libxl_type%_private.h _libxl_type%.c: libxl_type%.idl gentypes.py idl.py
@@ -288,9 +281,6 @@  libxlutil.so.$(XLUMAJOR).$(XLUMINOR): $(LIBXLU_OBJS) libxenlight.so
 libxlutil.a: $(LIBXLU_OBJS)
 	$(AR) rcs libxlutil.a $^
 
-xl: $(XL_OBJS) libxlutil.so libxenlight.so
-	$(CC) $(LDFLAGS) -o $@ $(XL_OBJS) $(LDLIBS_libxlutil) $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -lyajl $(APPEND_LDFLAGS)
-
 test_%: test_%.o test_common.o libxlutil.so libxenlight_test.so
 	$(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxentoollog) -lyajl $(APPEND_LDFLAGS)
 
@@ -306,13 +296,10 @@  $(PKG_CONFIG): % : %.in Makefile
 
 .PHONY: install
 install: all
-	$(INSTALL_DIR) $(DESTDIR)$(sbindir)
 	$(INSTALL_DIR) $(DESTDIR)$(libdir)
 	$(INSTALL_DIR) $(DESTDIR)$(includedir)
-	$(INSTALL_DIR) $(DESTDIR)$(BASH_COMPLETION_DIR)
 	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
 	$(INSTALL_DIR) $(DESTDIR)$(PKG_INSTALLDIR)
-	$(INSTALL_PROG) xl $(DESTDIR)$(sbindir)
 	$(INSTALL_PROG) libxl-save-helper $(DESTDIR)$(LIBEXEC_BIN)
 	$(INSTALL_SHLIB) libxenlight.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
 	$(SYMLINK_SHLIB) libxenlight.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenlight.so.$(MAJOR)
@@ -323,7 +310,6 @@  install: all
 	$(SYMLINK_SHLIB) libxlutil.so.$(XLUMAJOR) $(DESTDIR)$(libdir)/libxlutil.so
 	$(INSTALL_DATA) libxlutil.a $(DESTDIR)$(libdir)
 	$(INSTALL_DATA) libxl.h libxl_event.h libxl_json.h _libxl_types.h _libxl_types_json.h _libxl_list.h libxl_utils.h libxl_uuid.h libxlutil.h $(DESTDIR)$(includedir)
-	$(INSTALL_DATA) bash-completion $(DESTDIR)$(BASH_COMPLETION_DIR)/xl.sh
 	$(INSTALL_DATA) xenlight.pc $(DESTDIR)$(PKG_INSTALLDIR)
 	$(INSTALL_DATA) xlutil.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
diff --git a/tools/xl/Makefile b/tools/xl/Makefile
new file mode 100644
index 0000000000..32dff40584
--- /dev/null
+++ b/tools/xl/Makefile
@@ -0,0 +1,43 @@ 
+#
+# tools/xl/Makefile
+#
+
+XEN_ROOT = $(CURDIR)/../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations \
+	-Wno-declaration-after-statement -Wformat-nonliteral
+CFLAGS += -I. -fPIC
+
+CFLAGS += $(PTHREAD_CFLAGS)
+LDFLAGS += $(PTHREAD_LDFLAGS)
+
+CFLAGS_XL += $(CFLAGS_libxenlight)
+CFLAGS_XL += -Wshadow
+
+XL_OBJS = xl.o xl_cmdimpl.o xl_cmdtable.o xl_sxp.o
+$(XL_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
+$(XL_OBJS): CFLAGS += $(CFLAGS_XL)
+$(XL_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h # libxl_json.h needs it.
+
+.PHONY: all
+all: xl
+
+xl: $(XL_OBJS)
+	$(CC) $(LDFLAGS) -o $@ $(XL_OBJS) $(LDLIBS_libxlutil) $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -lyajl $(APPEND_LDFLAGS)
+
+.PHONY: install
+install: all
+	$(INSTALL_DIR) $(DESTDIR)$(sbindir)
+	$(INSTALL_DIR) $(DESTDIR)$(BASH_COMPLETION_DIR)
+	$(INSTALL_PROG) xl $(DESTDIR)$(sbindir)
+	$(INSTALL_DATA) bash-completion $(DESTDIR)$(BASH_COMPLETION_DIR)/xl.sh
+
+.PHONY: clean
+clean:
+	$(RM) -f *.o xl $(DEPS)
+
+distclean: clean
+
+
+-include $(DEPS)
diff --git a/tools/libxl/bash-completion b/tools/xl/bash-completion
similarity index 100%
rename from tools/libxl/bash-completion
rename to tools/xl/bash-completion
diff --git a/tools/libxl/xl.c b/tools/xl/xl.c
similarity index 100%
rename from tools/libxl/xl.c
rename to tools/xl/xl.c
diff --git a/tools/libxl/xl.h b/tools/xl/xl.h
similarity index 100%
rename from tools/libxl/xl.h
rename to tools/xl/xl.h
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/xl/xl_cmdimpl.c
similarity index 100%
rename from tools/libxl/xl_cmdimpl.c
rename to tools/xl/xl_cmdimpl.c
diff --git a/tools/libxl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
similarity index 100%
rename from tools/libxl/xl_cmdtable.c
rename to tools/xl/xl_cmdtable.c
diff --git a/tools/libxl/xl_sxp.c b/tools/xl/xl_sxp.c
similarity index 100%
rename from tools/libxl/xl_sxp.c
rename to tools/xl/xl_sxp.c