]> xenbits.xensource.com Git - people/jgross/xen.git/commitdiff
tools: add a copy of library headers in tools/include
authorJuergen Gross <jgross@suse.com>
Sun, 23 Aug 2020 08:00:11 +0000 (10:00 +0200)
committerWei Liu <wl@xen.org>
Thu, 27 Aug 2020 12:59:46 +0000 (12:59 +0000)
The headers.chk target in tools/Rules.mk tries to compile all headers
stand alone for testing them not to include any internal header.

Unfortunately the headers tested against are not complete, as any
header for a Xen library is not included in the include path of the
test compile run, resulting in a failure in case any of the tested
headers in including an official Xen library header.

Fix that by copying the official headers located in
tools/libs/*/include to tools/include.

In order to support libraries with header name other than xen<lib>.h
or with multiple headers add a LIBHEADER make variable a lib specific
Makefile can set in that case.

Move the headers.chk target from Rules.mk to libs.mk as it is used
for libraries in tools/libs only.

Add NO_HEADERS_CHK variable to skip checking headers as this will be
needed e.g. for libxenctrl.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
.gitignore
tools/Rules.mk
tools/libs/libs.mk

index 0f03518f917847ec945c59d4ae551ae1d4c9c7d6..823f4743dc75993d7bb55c8c699833cfd80af44c 100644 (file)
@@ -188,6 +188,7 @@ tools/hotplug/Linux/xendomains
 tools/hotplug/NetBSD/rc.d/xencommons
 tools/hotplug/NetBSD/rc.d/xendriverdomain
 tools/include/acpi
+tools/include/*.h
 tools/include/xen/*
 tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
index b42e50ebf696662e0afe6b8c578ba62dbb59d406..5d699cfd399431c95bae45d15a686577c4c56e1b 100644 (file)
@@ -225,14 +225,6 @@ INSTALL_PYTHON_PROG = \
 %.opic: %.S
        $(CC) $(CPPFLAGS) -DPIC $(CFLAGS) $(CFLAGS.opic) -fPIC -c -o $@ $< $(APPEND_CFLAGS)
 
-headers.chk:
-       for i in $(filter %.h,$^); do \
-           $(CC) -x c -ansi -Wall -Werror $(CFLAGS_xeninclude) \
-                 -S -o /dev/null $$i || exit 1; \
-           echo $$i; \
-       done >$@.new
-       mv $@.new $@
-
 subdirs-all subdirs-clean subdirs-install subdirs-distclean subdirs-uninstall: .phony
        @set -e; for subdir in $(SUBDIRS) $(SUBDIRS-y); do \
                $(MAKE) subdir-$(patsubst subdirs-%,%,$@)-$$subdir; \
index 8027ae7400540dafaf5d71f7a2ecb431d0b9fddc..8045c00e9a5433d205a1de45597fddbdd35bcc75 100644 (file)
@@ -34,6 +34,10 @@ endif
 
 PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
 
+LIBHEADER ?= xen$(LIBNAME).h
+LIBHEADERS = $(foreach h, $(LIBHEADER), include/$(h))
+LIBHEADERSGLOB = $(foreach h, $(LIBHEADER), $(XEN_ROOT)/tools/include/$(h))
+
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 
@@ -47,7 +51,22 @@ build:
 .PHONY: libs
 libs: headers.chk $(LIB) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL)
 
-headers.chk: $(wildcard include/*.h) $(AUTOINCS)
+ifneq ($(NO_HEADERS_CHK),y)
+headers.chk:
+       for i in $(filter %.h,$^); do \
+           $(CC) -x c -ansi -Wall -Werror $(CFLAGS_xeninclude) \
+                 -S -o /dev/null $$i || exit 1; \
+           echo $$i; \
+       done >$@.new
+       mv $@.new $@
+else
+.PHONY: headers.chk
+endif
+
+headers.chk: $(LIBHEADERSGLOB) $(AUTOINCS)
+
+$(LIBHEADERSGLOB): $(LIBHEADERS)
+       for i in $(realpath $(LIBHEADERS)); do ln -sf $$i $(XEN_ROOT)/tools/include; done
 
 libxen$(LIBNAME).a: $(LIB_OBJS)
        $(AR) rc $@ $^
@@ -68,13 +87,13 @@ install: build
        $(INSTALL_DATA) libxen$(LIBNAME).a $(DESTDIR)$(libdir)
        $(SYMLINK_SHLIB) libxen$(LIBNAME).so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxen$(LIBNAME).so.$(MAJOR)
        $(SYMLINK_SHLIB) libxen$(LIBNAME).so.$(MAJOR) $(DESTDIR)$(libdir)/libxen$(LIBNAME).so
-       $(INSTALL_DATA) include/xen$(LIBNAME).h $(DESTDIR)$(includedir)
+       for i in $(LIBHEADERS); do $(INSTALL_DATA) $$i $(DESTDIR)$(includedir); done
        $(INSTALL_DATA) xen$(LIBNAME).pc $(DESTDIR)$(PKG_INSTALLDIR)
 
 .PHONY: uninstall
 uninstall:
        rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xen$(LIBNAME).pc
-       rm -f $(DESTDIR)$(includedir)/xen$(LIBNAME).h
+       for i in $(LIBHEADER); do rm -f $(DESTDIR)$(includedir)/$(LIBHEADER); done
        rm -f $(DESTDIR)$(libdir)/libxen$(LIBNAME).so
        rm -f $(DESTDIR)$(libdir)/libxen$(LIBNAME).so.$(MAJOR)
        rm -f $(DESTDIR)$(libdir)/libxen$(LIBNAME).so.$(MAJOR).$(MINOR)
@@ -90,6 +109,7 @@ clean:
        rm -f libxen$(LIBNAME).so.$(MAJOR).$(MINOR) libxen$(LIBNAME).so.$(MAJOR)
        rm -f headers.chk
        rm -f xen$(LIBNAME).pc
+       rm -f $(LIBHEADERSGLOB)
 
 .PHONY: distclean
 distclean: clean