1 # 2 # defines 3 # 4 topdir=$(shell pwd)/.. 5 include ../Make.Rules 6 # 7 # Library version 8 # 9 LIBNAME=$(LIBTITLE).so 10 STALIBNAME=$(LIBTITLE).a 11 # 12 13 FILES=cap_alloc cap_proc cap_extint cap_flag cap_text cap_file 14 15 INCLS=libcap.h cap_names.h $(INCS) 16 OBJS=$(addsuffix .o, $(FILES)) 17 MAJLIBNAME=$(LIBNAME).$(VERSION) 18 MINLIBNAME=$(MAJLIBNAME).$(MINOR) 19 GPERF_OUTPUT = _caps_output.gperf 20 21 all: $(MINLIBNAME) $(STALIBNAME) libcap.pc 22 23 ifeq ($(BUILD_GPERF),yes) 24 USE_GPERF_OUTPUT = $(GPERF_OUTPUT) 25 INCLUDE_GPERF_OUTPUT = -include $(GPERF_OUTPUT) 26 endif 27 28 libcap.pc: libcap.pc.in 29 sed -e 's,@prefix@,$(prefix),' \ 30 -e 's,@exec_prefix@,$(exec_prefix),' \ 31 -e 's,@libdir@,$(lib_prefix)/$(lib),' \ 32 -e 's,@includedir@,$(inc_prefix)/include,' \ 33 -e 's,@VERSION@,$(VERSION).$(MINOR),' \ 34 -e 's,@deps@,$(DEPS),' \ 35 $< >$@ 36 37 _makenames: _makenames.c cap_names.list.h 38 $(BUILD_CC) $(BUILD_CFLAGS) $< -o $@ 39 40 cap_names.h: _makenames 41 ./_makenames > cap_names.h 42 43 $(GPERF_OUTPUT): cap_names.list.h 44 perl -e 'print "struct __cap_token_s { const char *name; int index; };\n%{\nconst struct __cap_token_s *__cap_lookup_name(const char *, unsigned int);\n%}\n%%\n"; while ($$l = <>) { $$l =~ s/[\{\"]//g; $$l =~ s/\}.*// ; print $$l; }' < $< | gperf --ignore-case --language=ANSI-C --readonly --null-strings --global-table --hash-function-name=__cap_hash_name --lookup-function-name="__cap_lookup_name" -c -t -m20 $(INDENT) > $@ 45 46 cap_names.list.h: Makefile $(KERNEL_HEADERS)/linux/capability.h 47 @echo "=> making $@ from $(KERNEL_HEADERS)/linux/capability.h" 48 perl -e 'while ($$l=<>) { if ($$l =~ /^\#define[ \t](CAP[_A-Z]+)[ \t]+([0-9]+)\s+$$/) { $$tok=$$1; $$val=$$2; $$tok =~ tr/A-Z/a-z/; print "{\"$$tok\",$$val},\n"; } }' $(KERNEL_HEADERS)/linux/capability.h | fgrep -v 0x > $@ 49 50 $(STALIBNAME): $(OBJS) 51 $(AR) rcs $@ $^ 52 $(RANLIB) $@ 53 54 $(MINLIBNAME): $(OBJS) 55 $(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^ 56 ln -sf $(MINLIBNAME) $(MAJLIBNAME) 57 ln -sf $(MAJLIBNAME) $(LIBNAME) 58 59 %.o: %.c $(INCLS) 60 $(CC) $(CFLAGS) $(IPATH) -c $< -o $@ 61 62 cap_text.o: cap_text.c $(USE_GPERF_OUTPUT) $(INCLS) 63 $(CC) $(CFLAGS) $(IPATH) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@ 64 65 install: all 66 mkdir -p -m 0755 $(FAKEROOT)$(INCDIR)/sys 67 install -m 0644 include/sys/capability.h $(FAKEROOT)$(INCDIR)/sys 68 mkdir -p -m 0755 $(FAKEROOT)$(LIBDIR) 69 install -m 0644 $(STALIBNAME) $(FAKEROOT)$(LIBDIR)/$(STALIBNAME) 70 install -m 0644 $(MINLIBNAME) $(FAKEROOT)$(LIBDIR)/$(MINLIBNAME) 71 ln -sf $(MINLIBNAME) $(FAKEROOT)$(LIBDIR)/$(MAJLIBNAME) 72 ln -sf $(MAJLIBNAME) $(FAKEROOT)$(LIBDIR)/$(LIBNAME) 73 ifeq ($(FAKEROOT),) 74 -/sbin/ldconfig 75 endif 76 mkdir -p -m 0755 $(FAKEROOT)$(PKGCONFIGDIR) 77 install -m 0644 libcap.pc $(FAKEROOT)$(PKGCONFIGDIR)/libcap.pc 78 79 clean: 80 $(LOCALCLEAN) 81 rm -f $(OBJS) $(LIBNAME)* $(STALIBNAME) libcap.pc 82 rm -f cap_names.h cap_names.list.h _makenames $(GPERF_OUTPUT) 83 cd include/sys && $(LOCALCLEAN) 84