LSMVER=-2.4

all:
	@echo "You must explicitly specify 'quickinstall'."
	@echo "Be sure to read the QUICK INSTALL instructions in the README first."

insert:
	@echo "Patching the LSM tree."
	cd module && make insert LSMVER=$(LSMVER)	
	touch insert

quickinstall: insert
	@echo "Configuring the SELinux kernel."
	cd ../lsm$(LSMVER) && make menuconfig 
	@echo "Building the SELinux kernel."
	cd ../lsm$(LSMVER) && make dep && make && make modules
	@echo "Installing the SELinux kernel."
	cd ../lsm$(LSMVER); make install; make modules_install
	@echo "Building and installing support files needed by the userland components."
	cd module && make install LSMVER=$(LSMVER)
	@echo "Building and installing the policy configuration."
	cd tools && make insert-policy
	cd policy && make install-src install
	@echo "Building and installing libsecure."
	cd libsecure && make install
	@echo "Building and installing the modified daemons and the new or modified utilities."
	cd utils && make install
	@echo "Building and installing the SELOPT utils."
	cd selopt && make LSMVER=$(LSMVER) && make install
	@echo "Building and installing SELinux tools"
	cd tools && make install
	@echo "Installing the application context configuration files."
	if [ ! -f /etc/security/default_contexts ]; then install -m 644 utils/appconfig/default_contexts /etc/security; fi
	if [ ! -f /etc/security/default_type ]; then install -m 644 utils/appconfig/default_type /etc/security; fi
	if [ ! -f /etc/security/initrc_context ]; then install -m 644 utils/appconfig/initrc_context /etc/security; fi
	if [ ! -f /etc/security/passwd_context ]; then install -m 644 utils/appconfig/passwd_context /etc/security; fi
	if [ ! -f /etc/security/shadow_context ]; then install -m 644 utils/appconfig/shadow_context /etc/security; fi
	@echo "Installing setfiles."
	cd setfiles && make install
	@echo "Setting the file security contexts."
	cd policy && make reset
	@echo "Done."
