• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# defines
3#
4topdir=$(shell pwd)/..
5include ../Make.Rules
6#
7# Library version
8#
9LIBNAME=$(LIBTITLE).so
10STALIBNAME=$(LIBTITLE).a
11#
12
13FILES=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).
17ifeq ($(LIBATTR),yes)
18FILES += cap_file
19LDFLAGS += -lattr
20DEPS = -lattr
21endif
22
23INCLS=libcap.h cap_names.h $(INCS)
24OBJS=$(addsuffix .o, $(FILES))
25MAJLIBNAME=$(LIBNAME).$(VERSION)
26MINLIBNAME=$(MAJLIBNAME).$(MINOR)
27GPERF_OUTPUT = _caps_output.gperf
28
29all: $(MINLIBNAME) $(STALIBNAME) libcap.pc
30
31ifeq ($(BUILD_GPERF),yes)
32USE_GPERF_OUTPUT = $(GPERF_OUTPUT)
33INCLUDE_GPERF_OUTPUT = -include $(GPERF_OUTPUT)
34endif
35
36libcap.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
48cap_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
54cap_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) rcs $@ $^
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
70cap_text.o: cap_text.c $(USE_GPERF_OUTPUT) $(INCLS)
71	$(CC) $(CFLAGS) $(IPATH) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@
72
73install: all
74	mkdir -p -m 0755 $(FAKEROOT)$(INCDIR)/sys
75	install -m 0644 include/sys/capability.h $(FAKEROOT)$(INCDIR)/sys
76	mkdir -p -m 0755 $(FAKEROOT)$(LIBDIR)
77	install -m 0644 $(STALIBNAME) $(FAKEROOT)$(LIBDIR)/$(STALIBNAME)
78	install -m 0644 $(MINLIBNAME) $(FAKEROOT)$(LIBDIR)/$(MINLIBNAME)
79	ln -sf $(MINLIBNAME) $(FAKEROOT)$(LIBDIR)/$(MAJLIBNAME)
80	ln -sf $(MAJLIBNAME) $(FAKEROOT)$(LIBDIR)/$(LIBNAME)
81ifeq ($(FAKEROOT),)
82	-/sbin/ldconfig
83endif
84	mkdir -p -m 0755 $(FAKEROOT)$(PKGCONFIGDIR)
85	install -m 0644 libcap.pc $(FAKEROOT)$(PKGCONFIGDIR)/libcap.pc
86
87clean:
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)
92