Home | History | Annotate | Download | only in src
      1 # Installation directories.
      2 PREFIX ?= $(DESTDIR)/usr
      3 INCLUDEDIR ?= $(PREFIX)/include
      4 LIBDIR ?= $(PREFIX)/lib
      5 SHLIBDIR ?= $(DESTDIR)/lib
      6 LIBBASE=$(shell basename $(LIBDIR))
      7 
      8 VERSION = $(shell cat ../VERSION)
      9 LIBVERSION = 1
     10 
     11 LIBA=libsepol.a 
     12 TARGET=libsepol.so
     13 LIBPC=libsepol.pc
     14 LIBSO=$(TARGET).$(LIBVERSION)
     15 OBJS= $(patsubst %.c,%.o,$(wildcard *.c))
     16 LOBJS= $(patsubst %.c,%.lo,$(wildcard *.c))
     17 CFLAGS ?= -Werror -Wall -W -Wundef -Wshadow -Wmissing-noreturn -Wmissing-format-attribute
     18 override CFLAGS += -I. -I../include -D_GNU_SOURCE
     19 
     20 all: $(LIBA) $(LIBSO) $(LIBPC)
     21 
     22 $(LIBA):  $(OBJS)
     23 	$(AR) rcs $@ $^
     24 	ranlib $@
     25 
     26 $(LIBSO): $(LOBJS)
     27 	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -Wl,-soname,$(LIBSO),--version-script=libsepol.map,-z,defs
     28 	ln -sf $@ $(TARGET) 
     29 
     30 $(LIBPC): $(LIBPC).in ../VERSION
     31 	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
     32 
     33 %.o:  %.c 
     34 	$(CC) $(CFLAGS) -fPIC -c -o $@ $<
     35 
     36 %.lo:  %.c
     37 	$(CC) $(CFLAGS) -fPIC -DSHARED -c -o $@ $<
     38 
     39 install: all
     40 	test -d $(LIBDIR) || install -m 755 -d $(LIBDIR)
     41 	install -m 644 $(LIBA) $(LIBDIR)
     42 	test -d $(SHLIBDIR) || install -m 755 -d $(SHLIBDIR)
     43 	install -m 755 $(LIBSO) $(SHLIBDIR)
     44 	test -d $(LIBDIR)/pkgconfig || install -m 755 -d $(LIBDIR)/pkgconfig
     45 	install -m 644 $(LIBPC) $(LIBDIR)/pkgconfig
     46 	cd $(LIBDIR) && ln -sf ../../`basename $(SHLIBDIR)`/$(LIBSO) $(TARGET)
     47 
     48 relabel:
     49 	/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
     50 
     51 clean: 
     52 	-rm -f $(LIBPC) $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(TARGET)
     53 
     54 indent:
     55 	../../scripts/Lindent $(wildcard *.[ch])
     56 
     57