• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Installation directories.
2LINGUAS ?= ru
3PREFIX ?= /usr
4BINDIR ?= $(PREFIX)/bin
5MANDIR ?= $(PREFIX)/share/man
6ETCDIR ?= /etc
7LOCALEDIR = $(DESTDIR)$(PREFIX)/share/locale
8PAMH ?= $(shell test -f /usr/include/security/pam_appl.h && echo y)
9AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y)
10# Enable capabilities to permit newrole to generate audit records.
11# This will make newrole a setuid root program.
12# The capabilities used are: CAP_AUDIT_WRITE.
13AUDIT_LOG_PRIV ?= n
14# Enable capabilities to permit newrole to utilitize the pam_namespace module.
15# This will make newrole a setuid root program.
16# The capabilities used are: CAP_SYS_ADMIN, CAP_CHOWN, CAP_FOWNER and
17# CAP_DAC_OVERRIDE.
18NAMESPACE_PRIV ?= n
19# If LSPP_PRIV is y, then newrole will be made into setuid root program.
20# Enabling this option will force AUDIT_LOG_PRIV and NAMESPACE_PRIV to be y.
21LSPP_PRIV ?= n
22VERSION = $(shell cat ../VERSION)
23
24CFLAGS ?= -Werror -Wall -W
25EXTRA_OBJS =
26override CFLAGS += -DVERSION=\"$(VERSION)\" -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
27override LDLIBS += -lselinux
28ifeq ($(PAMH), y)
29	override CFLAGS += -DUSE_PAM
30	EXTRA_OBJS += hashtab.o
31	override LDLIBS += -lpam -lpam_misc
32else
33	override CFLAGS += -D_XOPEN_SOURCE=500
34	override LDLIBS += -lcrypt
35endif
36ifeq ($(AUDITH), y)
37	override CFLAGS += -DUSE_AUDIT
38	override LDLIBS += -laudit
39endif
40ifeq ($(LSPP_PRIV),y)
41	override AUDIT_LOG_PRIV=y
42	override NAMESPACE_PRIV=y
43endif
44ifeq ($(AUDIT_LOG_PRIV),y)
45	override CFLAGS += -DAUDIT_LOG_PRIV
46	IS_SUID=y
47endif
48ifeq ($(NAMESPACE_PRIV),y)
49	override CFLAGS += -DNAMESPACE_PRIV
50	IS_SUID=y
51endif
52ifeq ($(IS_SUID),y)
53	MODE := 4555
54	override LDLIBS += -lcap-ng
55else
56	MODE := 0555
57endif
58
59all: newrole
60
61newrole: newrole.o $(EXTRA_OBJS)
62	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
63
64install: all
65	test -d $(DESTDIR)$(BINDIR)      || install -m 755 -d $(DESTDIR)$(BINDIR)
66	test -d $(DESTDIR)$(ETCDIR)/pam.d || install -m 755 -d $(DESTDIR)$(ETCDIR)/pam.d
67	test -d $(DESTDIR)$(MANDIR)/man1 || install -m 755 -d $(DESTDIR)$(MANDIR)/man1
68	install -m $(MODE) newrole $(DESTDIR)$(BINDIR)
69	install -m 644 newrole.1 $(DESTDIR)$(MANDIR)/man1/
70	for lang in $(LINGUAS) ; do \
71		if [ -e $${lang} ] ; then \
72			test -d $(DESTDIR)$(MANDIR)/$${lang}/man1 || install -m 755 -d $(DESTDIR)$(MANDIR)/$${lang}/man1 ; \
73			install -m 644 $${lang}/*.1 $(DESTDIR)$(MANDIR)/$${lang}/man1/ ; \
74		fi ; \
75	done
76ifeq ($(PAMH), y)
77	test -d $(DESTDIR)$(ETCDIR)/pam.d || install -m 755 -d $(DESTDIR)$(ETCDIR)/pam.d
78ifeq ($(LSPP_PRIV),y)
79	install -m 644 newrole-lspp.pamd $(DESTDIR)$(ETCDIR)/pam.d/newrole
80else
81	install -m 644 newrole.pamd $(DESTDIR)$(ETCDIR)/pam.d/newrole
82endif
83endif
84
85clean:
86	rm -f newrole *.o
87
88indent:
89	../../scripts/Lindent $(wildcard *.[ch])
90
91relabel: install
92	/sbin/restorecon $(DESTDIR)$(BINDIR)/newrole
93