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