• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Installation directories.
2PREFIX ?= $(DESTDIR)/usr
3SBINDIR ?= $(DESTDIR)/sbin
4MANDIR = $(PREFIX)/share/man
5LIBDIR ?= $(PREFIX)/lib
6AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
7
8ABORT_ON_ERRORS=$(shell grep "^\#define ABORT_ON_ERRORS" setfiles.c | awk -S '{ print $$3 }')
9
10CFLAGS ?= -g -Werror -Wall -W
11override CFLAGS += -I$(PREFIX)/include
12LDLIBS = -lselinux -lsepol -L$(LIBDIR)
13
14ifeq ($(AUDITH), /usr/include/libaudit.h)
15	override CFLAGS += -DUSE_AUDIT
16	LDLIBS += -laudit
17endif
18
19all: setfiles restorecon restorecon_xattr man
20
21setfiles:  setfiles.o restore.o
22
23restorecon: setfiles
24	ln -sf setfiles restorecon
25
26restorecon_xattr:  restorecon_xattr.o restore.o
27
28man:
29	@cp -af setfiles.8 setfiles.8.man
30	@sed -i "s/ABORT_ON_ERRORS/$(ABORT_ON_ERRORS)/g" setfiles.8.man
31
32install: all
33	[ -d $(MANDIR)/man8 ] || mkdir -p $(MANDIR)/man8
34	-mkdir -p $(SBINDIR)
35	install -m 755 setfiles $(SBINDIR)
36	(cd $(SBINDIR) && ln -sf setfiles restorecon)
37	install -m 755 restorecon_xattr $(SBINDIR)
38	install -m 644 setfiles.8.man $(MANDIR)/man8/setfiles.8
39	install -m 644 restorecon.8 $(MANDIR)/man8/restorecon.8
40	install -m 644 restorecon_xattr.8 $(MANDIR)/man8/restorecon_xattr.8
41
42clean:
43	rm -f setfiles restorecon restorecon_xattr *.o setfiles.8.man
44
45indent:
46	../../scripts/Lindent $(wildcard *.[ch])
47
48relabel: install
49	$(SBINDIR)/restorecon $(SBINDIR)/setfiles $(SBINDIR)/restorecon_xattr
50