Chris PeBenito 473ea7
# Installation directories.
Chris PeBenito 473ea7
PREFIX ?= $(DESTDIR)/usr
Chris PeBenito 473ea7
LIBDIR ?= $(PREFIX)/lib
Chris PeBenito 473ea7
SHLIBDIR ?= $(DESTDIR)/lib
Chris PeBenito 473ea7
Chris PeBenito 473ea7
LIBVERSION = 1
Chris PeBenito 473ea7
Chris PeBenito 473ea7
Chris PeBenito 473ea7
LIBA=libselinux.a 
Chris PeBenito 473ea7
TARGET=libselinux.so
Chris PeBenito 473ea7
LIBSO=$(TARGET).$(LIBVERSION)
Chris PeBenito 473ea7
OBJS= $(patsubst %.c,%.o,$(wildcard *.c))
Chris PeBenito 473ea7
LOBJS= $(patsubst %.c,%.lo,$(wildcard *.c))
Chris PeBenito 473ea7
CFLAGS ?= -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute
Chris PeBenito 473ea7
override CFLAGS += -I../include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
Chris PeBenito 473ea7
RANLIB=ranlib
Chris PeBenito 473ea7
Chris PeBenito 473ea7
all: $(LIBA) $(LIBSO)
Chris PeBenito 473ea7
Chris PeBenito 473ea7
$(LIBA):  $(OBJS)
Chris PeBenito 473ea7
	$(AR) rcs $@ $^
Chris PeBenito 473ea7
	$(RANLIB) $@
Chris PeBenito 473ea7
Chris PeBenito 473ea7
$(LIBSO): $(LOBJS)
Chris PeBenito 473ea7
	$(CC) $(LDFLAGS) -shared -o $@ $^ -ldl -lsepol -Wl,-soname,$(LIBSO),-z,defs
Chris PeBenito 473ea7
	ln -sf $@ $(TARGET) 
Chris PeBenito 473ea7
Chris PeBenito 473ea7
%.o:  %.c policy.h
Chris PeBenito 473ea7
	$(CC) $(CFLAGS) -c -o $@ $<
Chris PeBenito 473ea7
Chris PeBenito 473ea7
%.lo:  %.c policy.h
Chris PeBenito 473ea7
	$(CC) $(CFLAGS) -fpic -DSHARED -c -o $@ $<
Chris PeBenito 473ea7
Chris PeBenito 473ea7
install: all
Chris PeBenito 473ea7
	test -d $(LIBDIR) || install -m 755 -d $(LIBDIR)
Chris PeBenito 473ea7
	install -m 644 $(LIBA) $(LIBDIR)
Chris PeBenito 473ea7
	test -d $(SHLIBDIR) || install -m 755 -d $(SHLIBDIR)
Chris PeBenito 473ea7
	install -m 755 $(LIBSO) $(SHLIBDIR)
Chris PeBenito 473ea7
	cd $(LIBDIR) && ln -sf ../../`basename $(SHLIBDIR)`/$(LIBSO) $(TARGET)
Chris PeBenito 473ea7
Chris PeBenito 473ea7
relabel:
Chris PeBenito 473ea7
	/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
Chris PeBenito 473ea7
Chris PeBenito 473ea7
clean: 
Chris PeBenito 473ea7
	-rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(TARGET) 
Chris PeBenito 473ea7