mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
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>
116 lines
3.5 KiB
Makefile
116 lines
3.5 KiB
Makefile
# Common Makefile for building a lib.
|
|
#
|
|
# Variables taken as input:
|
|
# LIBNAME: name of lib to build, will be prepended with "libxen"
|
|
# MAJOR: major version of lib
|
|
# MINOR: minor version of lib
|
|
# USELIBS: xen libs to use (e.g. "toolcore toollog")
|
|
|
|
SHLIB_LDFLAGS += -Wl,--version-script=libxen$(LIBNAME).map
|
|
|
|
CFLAGS += -Werror -Wmissing-prototypes
|
|
CFLAGS += -I./include $(CFLAGS_xeninclude)
|
|
CFLAGS += $(foreach lib, $(USELIBS), $(CFLAGS_libxen$(lib)))
|
|
|
|
LDUSELIBS = $(foreach lib, $(USELIBS), $(LDLIBS_libxen$(lib)))
|
|
|
|
LIB_OBJS := $(SRCS-y:.c=.o)
|
|
PIC_OBJS := $(SRCS-y:.c=.opic)
|
|
|
|
LIB := libxen$(LIBNAME).a
|
|
ifneq ($(nosharedlibs),y)
|
|
LIB += libxen$(LIBNAME).so
|
|
endif
|
|
|
|
PKG_CONFIG := xen$(LIBNAME).pc
|
|
PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
|
|
|
|
ifneq ($(CONFIG_LIBXC_MINIOS),y)
|
|
PKG_CONFIG_INST := $(PKG_CONFIG)
|
|
$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
|
|
$(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
|
|
$(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
|
|
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)
|
|
|
|
.PHONY: all
|
|
all: build
|
|
|
|
.PHONY: build
|
|
build:
|
|
$(MAKE) libs
|
|
|
|
.PHONY: libs
|
|
libs: headers.chk $(LIB) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL)
|
|
|
|
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 $@ $^
|
|
|
|
libxen$(LIBNAME).so: libxen$(LIBNAME).so.$(MAJOR)
|
|
$(SYMLINK_SHLIB) $< $@
|
|
libxen$(LIBNAME).so.$(MAJOR): libxen$(LIBNAME).so.$(MAJOR).$(MINOR)
|
|
$(SYMLINK_SHLIB) $< $@
|
|
|
|
libxen$(LIBNAME).so.$(MAJOR).$(MINOR): $(PIC_OBJS) libxen$(LIBNAME).map
|
|
$(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxen$(LIBNAME).so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDUSELIBS) $(APPEND_LDFLAGS)
|
|
|
|
.PHONY: install
|
|
install: build
|
|
$(INSTALL_DIR) $(DESTDIR)$(libdir)
|
|
$(INSTALL_DIR) $(DESTDIR)$(includedir)
|
|
$(INSTALL_SHLIB) libxen$(LIBNAME).so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
|
|
$(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
|
|
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
|
|
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)
|
|
rm -f $(DESTDIR)$(libdir)/libxen$(LIBNAME).a
|
|
|
|
.PHONY: TAGS
|
|
TAGS:
|
|
etags -t *.c *.h
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm -rf *.rpm $(LIB) *~ $(DEPS_RM) $(LIB_OBJS) $(PIC_OBJS)
|
|
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
|