1 # Installation directories. 2 PREFIX ?= /usr 3 SBINDIR ?= /sbin 4 INITDIR ?= /etc/rc.d/init.d 5 SYSTEMDDIR ?= $(PREFIX)/lib/systemd 6 7 # If no specific libsepol.a is specified, fall back on LDFLAGS search path 8 # Otherwise, as $(LIBSEPOLA) already appears in the dependencies, there 9 # is no need to define a value for LDLIBS_LIBSEPOLA 10 ifeq ($(LIBSEPOLA),) 11 LDLIBS_LIBSEPOLA := -l:libsepol.a 12 endif 13 14 PROG_SRC=mcstrans.c mcscolor.c mcstransd.c mls_level.c 15 PROG_OBJS= $(patsubst %.c,%.o,$(PROG_SRC)) 16 PROG=mcstransd 17 INITSCRIPT=mcstrans 18 CFLAGS ?= -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute 19 20 all: $(PROG) 21 22 $(PROG): $(PROG_OBJS) $(LIBSEPOLA) 23 $(CC) $(LDFLAGS) -pie -o $@ $^ -lselinux -lcap -lpcre $(LDLIBS_LIBSEPOLA) 24 25 %.o: %.c 26 $(CC) $(CFLAGS) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIE -c -o $@ $< 27 28 install: all 29 test -d $(DESTDIR)$(SBINDIR) || install -m 755 -d $(DESTDIR)$(SBINDIR) 30 install -m 755 $(PROG) $(DESTDIR)$(SBINDIR) 31 test -d $(DESTDIR)$(INITDIR) || install -m 755 -d $(DESTDIR)$(INITDIR) 32 install -m 755 $(INITSCRIPT).init $(DESTDIR)$(INITDIR)/$(INITSCRIPT) 33 test -d $(DESTDIR)$(SYSTEMDDIR)/system || install -m 755 -d $(DESTDIR)$(SYSTEMDDIR)/system 34 install -m 644 mcstrans.service $(DESTDIR)$(SYSTEMDDIR)/system/ 35 36 clean: 37 -rm -f $(OBJS) $(LOBJS) $(TARGET) $(PROG) $(PROG_OBJS) *~ \#* 38 39