xref: /aosp_15_r20/external/selinux/policycoreutils/setfiles/Makefile (revision 2d543d20722ada2425b5bdab9d0d1d29470e7bba)
1# Installation directories.
2LINGUAS ?=
3PREFIX ?= /usr
4SBINDIR ?= /sbin
5MANDIR = $(PREFIX)/share/man
6AUDITH ?= $(shell test -f /usr/include/libaudit.h && echo y)
7
8CFLAGS ?= -g -Werror -Wall -W
9override LDLIBS += -lselinux -lsepol -lpthread
10
11ifeq ($(AUDITH), y)
12	override CFLAGS += -DUSE_AUDIT
13	override LDLIBS += -laudit
14endif
15
16all: setfiles restorecon restorecon_xattr
17
18setfiles: setfiles.o restore.o
19
20restorecon: setfiles
21	ln -sf setfiles restorecon
22
23restorecon_xattr: restorecon_xattr.o restore.o
24
25install: all
26	[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
27	-mkdir -p $(DESTDIR)$(SBINDIR)
28	install -m 755 setfiles $(DESTDIR)$(SBINDIR)
29	(cd $(DESTDIR)$(SBINDIR) && ln -sf setfiles restorecon)
30	install -m 755 restorecon_xattr $(DESTDIR)$(SBINDIR)
31	install -m 644 setfiles.8 $(DESTDIR)$(MANDIR)/man8/setfiles.8
32	install -m 644 restorecon.8 $(DESTDIR)$(MANDIR)/man8/restorecon.8
33	install -m 644 restorecon_xattr.8 $(DESTDIR)$(MANDIR)/man8/restorecon_xattr.8
34	for lang in $(LINGUAS) ; do \
35		if [ -e $${lang} ] ; then \
36			[ -d $(DESTDIR)$(MANDIR)/$${lang}/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/$${lang}/man8 ; \
37			install -m 644 $${lang}/*.8 $(DESTDIR)$(MANDIR)/$${lang}/man8/ ; \
38		fi ; \
39	done
40
41clean:
42	rm -f setfiles restorecon restorecon_xattr *.o
43
44indent:
45	../../scripts/Lindent $(wildcard *.[ch])
46
47relabel: install
48	$(DESTDIR)$(SBINDIR)/restorecon $(DESTDIR)$(SBINDIR)/setfiles $(DESTDIR)$(SBINDIR)/restorecon_xattr
49