# Top-level install Makefile for selinux/tools directory

# Set to y if MLS is enabled in the build process.
MLS=n

ifeq ($(MLS),y)
SYS_OPTIONS = -DCONFIG_SECURITY_SELINUX_MLS
else
SYS_OPTIONS = 
endif

# Find location to put tool policy and fc files into
CURR_DIR = $(shell pwd)
TE_FILE_INSTALL_DIR = $(CURR_DIR)/../policy/domains/program
FC_FILE_INSTALL_DIR = $(CURR_DIR)/../policy/file_contexts/program

export TE_FILE_INSTALL_DIR FC_FILE_INSTALL_DIR SYS_OPTIONS

################################################################
# NOTE TO PACKAGE DEVELOPERS
#
# This Makefile allows tool packages that are designed as
# separate install packages to be installed as part of the
# SE Linux install process.  
#
# The top-level Makefile for each package to be installed 
# via the system install build process must have provide these 
# make targets:
#
# insert-policy: This target allows the package to insert 
#	policy program modules into system policy source
#	directory.  This target will be called before the 
#	system build process makes and installs the policy.
#	It is also called before the required sys-install
#	target below is called (i.e., before the tool package
#	itself is built).  
#
#	A policy module should have a .te and .fc file, each with
#	the same root name.  The target should copy the .te file
#	in $(TE_FILE_INSTALL_DIR) directory and the .fc in the
#	$(FC_FILE_INSTALL_DIR) directory.  If your package does not 
#	have a policy module, just have an empty target.
#
# sys-all: This target should build the tool but NOT install
#	it.  Tool packages should assume that the build
#	is being performed on a Linux (and NOT an SE Linux)
#	kernel, although the SE Linux kernel and utilies will have 
#	already been built and installed.
#
# sys-install: This target should build the tool (if necessary) and 
#	install it on the system.  Tool packages should assume that the
#	compile is being performed on a Linux (and NOT an SE Linux)
#	kernel, although the SE Linux kernel and utilies will have 
#	already been built and installed.  This target should
#	also assume that any package policy modules have been installed
#	and a relabel will occur after the package installs (i.e.,
#	no need to worry about file context labeling).
#
# NOTE: for sys-all and sys-install, additional system compile options 
# (such as -DCONFIG_SECURITY_SELINUX_MLS) are passed down to the individual 
# tools through the SYS_OPTIONS environment variable.
#
# clean: Cleans up interim files.
#
################################################################


# Tool package directories.  Include each new package as a subdirectory
# to the directory in which this Makefile resides.  Each package must
# have the two make targets described above in their top-level Makefile

PACKAGES_DIR = setools 



# The targets are exposed from this Makefile:
# 
#	all (default): will build, but not install each package.
#
# 	insert-policy: will ensure that the policy module files for 
#		each package is installed in the policy source 
#		directory.  This should be called before the policy
#		is installed.
#
#	install: will install each packages.  
#
#	clean: remove interim files


# default target
all:
	@for subdir in $(PACKAGES_DIR); do \
		(cd $$subdir && $(MAKE) sys-all ) \
	done

insert-policy:
	@for subdir in $(PACKAGES_DIR); do \
		(cd $$subdir && $(MAKE) $@ ) \
	done

install:
	@for subdir in $(PACKAGES_DIR); do \
		(cd $$subdir && $(MAKE) sys-install ) \
	done

clean:
	@for subdir in $(PACKAGES_DIR); do \
		(cd $$subdir && $(MAKE) $@ ) \
	done



