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