libcap_makefile (2931B)
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 14 15 # make including file support something you can override (no libattr 16 # no support). 17 ifeq ($(LIBATTR),yes) 18 FILES += cap_file 19 LDFLAGS += -lattr 20 DEPS = -lattr 21 endif 22 23 INCLS=libcap.h cap_names.h $(INCS) 24 OBJS=$(addsuffix .o, $(FILES)) 25 #MAJLIBNAME=$(LIBNAME).$(VERSION) 26 #MINLIBNAME=$(MAJLIBNAME).$(MINOR) 27 GPERF_OUTPUT = _caps_output.gperf 28 29 all: $(STALIBNAME) 30 31 ifeq ($(shell gperf --version > /dev/null 2>&1 && echo yes),yes) 32 USE_GPERF_OUTPUT = $(GPERF_OUTPUT) 33 INCLUDE_GPERF_OUTPUT = -include $(GPERF_OUTPUT) 34 endif 35 36 libcap.pc: libcap.pc.in 37 sed -e 's,@prefix@,$(prefix),' \ 38 -e 's,@exec_prefix@,$(exec_prefix),' \ 39 -e 's,@libdir@,$(lib_prefix)/$(lib),' \ 40 -e 's,@includedir@,$(inc_prefix)/include,' \ 41 -e 's,@VERSION@,$(VERSION).$(MINOR),' \ 42 -e 's,@deps@,$(DEPS),' \ 43 $< >$@ 44 45 _makenames: _makenames.c cap_names.list.h 46 $(BUILD_CC) $(BUILD_CFLAGS) $< -o $@ 47 48 cap_names.h: _makenames 49 ./_makenames > cap_names.h 50 51 $(GPERF_OUTPUT): cap_names.list.h 52 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) > $@ 53 54 cap_names.list.h: Makefile $(KERNEL_HEADERS)/linux/capability.h 55 @echo "=> making $@ from $(KERNEL_HEADERS)/linux/capability.h" 56 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 > $@ 57 58 $(STALIBNAME): $(OBJS) 59 $(AR) rc $@ $^ 60 $(RANLIB) $@ 61 62 #$(MINLIBNAME): $(OBJS) 63 # $(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^ 64 # ln -sf $(MINLIBNAME) $(MAJLIBNAME) 65 # ln -sf $(MAJLIBNAME) $(LIBNAME) 66 67 %.o: %.c $(INCLS) 68 $(CC) $(CFLAGS) $(IPATH) -c $< -o $@ 69 70 cap_text.o: cap_text.c $(USE_GPERF_OUTPUT) $(INCLS) 71 $(CC) $(CFLAGS) $(IPATH) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@ 72 73 install: all 74 mkdir -p -m 0755 $(INCDIR)/sys 75 install -m 0644 include/sys/capability.h $(INCDIR)/sys 76 mkdir -p -m 0755 $(LIBDIR) 77 install -m 0644 $(STALIBNAME) $(LIBDIR)/$(STALIBNAME) 78 # install -m 0644 $(MINLIBNAME) $(LIBDIR)/$(MINLIBNAME) 79 # ln -sf $(MINLIBNAME) $(LIBDIR)/$(MAJLIBNAME) 80 # ln -sf $(MAJLIBNAME) $(LIBDIR)/$(LIBNAME) 81 ifeq ($(FAKEROOT),) 82 -/sbin/ldconfig 83 endif 84 # mkdir -p -m 0755 $(PKGCONFIGDIR) 85 # install -m 0644 libcap.pc $(PKGCONFIGDIR)/libcap.pc 86 87 clean: 88 $(LOCALCLEAN) 89 rm -f $(OBJS) $(LIBNAME)* $(STALIBNAME) libcap.pc 90 rm -f cap_names.h cap_names.list.h _makenames $(GPERF_OUTPUT) 91 cd include/sys && $(LOCALCLEAN)