# grsecurity - access control and security hardening for Linux
# Copyright (C) 2001-2020 Bradley Spengler, Open Source Security, Inc.
# http://www.grsecurity.net spender@grsecurity.net
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# This program 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

KBUILD_CFLAGS += -Werror

obj-$(CONFIG_GRKERNSEC_BRUTE)           += grsec_brute.o
obj-$(CONFIG_GRKERNSEC)                 += grsec_cap.o
obj-$(CONFIG_GRKERNSEC_AUDIT_CHDIR)     += grsec_chdir.o
obj-$(CONFIG_GRKERNSEC_CHROOT)          += grsec_chroot.o
obj-$(CONFIG_GRKERNSEC_EXECLOG)         += grsec_exec.o
obj-$(CONFIG_GRKERNSEC_FIFO)            += grsec_fifo.o
obj-$(CONFIG_GRKERNSEC_FORKFAIL)        += grsec_fork.o
obj-$(CONFIG_GRKERNSEC_HARDEN_IPC)      += grsec_ipc.o
obj-$(CONFIG_GRKERNSEC_LINK)            += grsec_link.o
obj-$(CONFIG_GRKERNSEC_SYMLINKOWN)      += grsec_link.o
obj-$(CONFIG_GRKERNSEC_KERN_LOCKOUT)    += grsec_lockout.o
obj-$(CONFIG_GRKERNSEC)                 += grsec_mem.o
obj-$(CONFIG_GRKERNSEC_AUDIT_MOUNT)     += grsec_mount.o
obj-$(CONFIG_GRKERNSEC_RWXMAP_LOG)      += grsec_pax.o
obj-$(CONFIG_GRKERNSEC_PROC_USER)       += grsec_proc.o
obj-$(CONFIG_GRKERNSEC_PROC_USERGROUP)  += grsec_proc.o
obj-$(CONFIG_GRKERNSEC_AUDIT_PTRACE)    += grsec_ptrace.o
obj-$(CONFIG_GRKERNSEC_PTRACE_READEXEC) += grsec_ptrace.o
obj-$(CONFIG_GRKERNSEC_ROFS)            += grsec_rofs.o
obj-$(CONFIG_GRKERNSEC)                 += grsec_sig.o
obj-$(CONFIG_GRKERNSEC_SYSCTL_CORE)     += grsec_sysctl.o
obj-$(CONFIG_GRKERNSEC_SYSFS_RESTRICT)  += grsec_sysfs.o
obj-$(CONFIG_GRKERNSEC_TIME)            += grsec_time.o
obj-$(CONFIG_GRKERNSEC)                 += grsec_tpe.o
obj-$(CONFIG_GRKERNSEC_HARDEN_TTY)      += grsec_tty.o
obj-$(CONFIG_GRKERNSEC_DENYUSB)         += grsec_usb.o
obj-$(CONFIG_GRKERNSEC_FUSE_RESTRICT)   += grsec_fuse.o

obj-$(CONFIG_GRKERNSEC) += grsec_init.o gracl.o gracl_segv.o \
	gracl_cap.o gracl_alloc.o gracl_shm.o gracl_fs.o \
	gracl_learn.o grsec_log.o gracl_policy.o
ifdef CONFIG_COMPAT
obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
endif

obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o

ifdef CONFIG_NET
obj-$(CONFIG_GRKERNSEC) += grsec_sock.o
obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
endif

ifndef CONFIG_GRKERNSEC
obj-y += grsec_disabled.o
endif

ifdef CONFIG_WANTS_HIDDEN_OBJECT_PATHS
extra-y := grsec_hidesym.o
$(obj)/grsec_hidesym.o:
	@-chmod -f 500 /boot || true
	@-chmod -f 500 /lib/modules || true
	@-chmod -f 500 /lib64/modules || true
	@-chmod -f 500 /lib32/modules || true
	@-chmod -f 700 . || true
	@-chmod -f 700 $(objtree) || true
	@echo '  grsec: protected kernel image paths'
endif
