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