/*
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
2011,2012 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
ChibiOS/RT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/RT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
XEN_ROOT = ../..
include $(XEN_ROOT)/tools/Rules.mk
CFLAGS += -Werror
CFLAGS += -fno-strict-aliasing
CFLAGS += -I. $(CFLAGS_libxenctrl)
CPPFLAGS += -MMD -MF .$*.d
PROG_DEPS = .*.d
XML2VERSION = $(shell xml2-config --version )
CFLAGS += $(shell xml2-config --cflags )
CFLAGS += $(shell if [[ $(XML2VERSION) < 2.6.20 ]]; then echo ""; else echo "-DVALIDATE_SCHEMA"; fi )
LDFLAGS += $(shell xml2-config --libs ) # if this does not work, try -L/usr/lib -lxml2 -lz -lpthread -lm
SRCS_TOOL = secpol_tool.c
OBJS_TOOL := $(patsubst %.c,%.o,$(filter %.c,$(SRCS_TOOL)))
ACM_INST_TOOLS = xensec_tool xensec_gen
ACM_EZPOLICY = xensec_ezpolicy
ACM_OBJS = $(OBJS_TOOL) $(OBJS_GETD)
ACM_SCRIPTS = python/xensec_tools/acm_getlabel
ACM_CONFIG_DIR = /etc/xen/acm-security
ACM_POLICY_DIR = $(ACM_CONFIG_DIR)/policies
ACM_SCRIPT_DIR = $(ACM_CONFIG_DIR)/scripts
ACM_INST_HTML = python/xensec_gen/index.html
ACM_INST_CGI = python/xensec_gen/cgi-bin/policy.cgi
ACM_SECGEN_HTMLDIR= /var/lib/xensec_gen
ACM_SECGEN_CGIDIR = $(ACM_SECGEN_HTMLDIR)/cgi-bin
ACM_SCHEMA = security_policy.xsd
ACM_EXAMPLES = client_v1 test
ACM_DEF_POLICIES =
ACM_POLICY_SUFFIX = security_policy.xml
ifeq ($(ACM_SECURITY),y)
.PHONY: all
all: build
.PHONY: install
ifndef XEN_PYTHON_NATIVE_INSTALL
install: LIBPATH=$(shell PYTHONPATH=../python/xen/util python -c "import auxbin; print auxbin.libpath()")
endif
install: all $(ACM_CONFIG_FILE)
$(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
$(INSTALL_PROG) $(ACM_INST_TOOLS) $(DESTDIR)$(SBINDIR)
$(INSTALL_PROG) $(ACM_EZPOLICY) $(DESTDIR)$(SBINDIR)
$(INSTALL_DIR) $(DESTDIR)$(ACM_CONFIG_DIR)
$(INSTALL_DIR) $(DESTDIR)$(ACM_POLICY_DIR)
$(INSTALL_DATA) policies/$(ACM_SCHEMA) $(DESTDIR)$(ACM_POLICY_DIR)
$(INSTALL_DIR) $(DESTDIR)$(ACM_POLICY_DIR)/example
set -e; for i in $(ACM_EXAMPLES); do \
$(INSTALL_DATA) policies/example/$$i-$(ACM_POLICY_SUFFIX) $(DESTDIR)$(ACM_POLICY_DIR)/example/; \
done
set -e; for i in $(ACM_DEF_POLICIES); do \
$(INSTALL_DATA) policies/$$i-$(ACM_POLICY_SUFFIX) $(DESTDIR)$(ACM_POLICY_DIR); \
done
$(INSTALL_DIR) $(DESTDIR)$(ACM_SCRIPT_DIR)
$(INSTALL_PROG) $(ACM_SCRIPTS) $(DESTDIR)$(ACM_SCRIPT_DIR)
$(INSTALL_DIR) $(DESTDIR)$(ACM_SECGEN_HTMLDIR)
$(INSTALL_DATA) $(ACM_INST_HTML) $(DESTDIR)$(ACM_SECGEN_HTMLDIR)
$(INSTALL_DIR) $(DESTDIR)$(ACM_SECGEN_CGIDIR)
$(INSTALL_PROG) $(ACM_INST_CGI) $(DESTDIR)$(ACM_SECGEN_CGIDIR)
ifndef XEN_PYTHON_NATIVE_INSTALL
python python/setup.py install --install-lib="$(DESTDIR)$(LIBPATH)/python"
else
python python/setup.py install --root="$(DESTDIR)"
endif
else
.PHONY: all
all:
.PHONY: install
install:
endif
.PHONY: build
build: $(ACM_INST_TOOLS) $(ACM_NOINST_TOOLS)
python python/setup.py build
chmod 700 $(ACM_SCRIPTS)
xensec_tool: $(OBJS_TOOL)
$(CC) -g $(CFLAGS) $(LDFLAGS) -O0 -o $@ $^ $(LDFLAGS_libxenctrl)
xensec_gen: xensec_gen.py
cp -f $^ $@
.PHONY: clean
clean:
$(RM) $(ACM_INST_TOOLS) $(ACM_NOINST_TOOLS)
$(RM) $(ACM_OBJS)
$(RM) $(PROG_DEPS)
$(RM) -r build
.PHONY: mrproper
mrproper: clean
-include $(PROG_DEPS)