1#
2# Makefile for libcap
3#
4topdir=$(shell pwd)
5include Make.Rules
6
7#
8# flags
9#
10
11all install clean kdebug: %: %-here
12	$(MAKE) -C libcap $@
13ifneq ($(PAM_CAP),no)
14	$(MAKE) -C pam_cap $@
15endif
16ifeq ($(GOLANG),yes)
17	$(MAKE) -C go $@
18	rm -f cap/go.sum
19endif
20	$(MAKE) -C tests $@
21	$(MAKE) -C progs $@
22	$(MAKE) -C doc $@
23	$(MAKE) -C kdebug $@
24
25all-here:
26
27install-here:
28
29clean-here:
30	$(LOCALCLEAN)
31
32distclean: clean
33	$(DISTCLEAN)
34	@echo "CONFIRM Go package cap has right version dependency on cap/psx:"
35	for x in $$(find . -name go.mod); do grep -F -v "module" $$x | fgrep "kernel.org/pub/linux/libs/security/libcap" > /dev/null || continue ; grep -F "v$(GOMAJOR).$(VERSION).$(MINOR)" $$x  > /dev/null && continue ; echo "$$x is not updated to v$(GOMAJOR).$(VERSION).$(MINOR)" ; exit 1 ; done
36	@echo "ALL go.mod files updated"
37	@echo "Now validate that everything is checked in to a clean tree.."
38	test -z "$$(git status --ignored -s)"
39	@echo "All good!"
40
41release: distclean
42	cd .. && ln -s libcap libcap-$(VERSION).$(MINOR) && tar cvf libcap-$(VERSION).$(MINOR).tar --exclude patches libcap-$(VERSION).$(MINOR)/* && rm libcap-$(VERSION).$(MINOR)
43
44test: all
45	$(MAKE) -C libcap $@
46	$(MAKE) -C tests $@
47ifneq ($(PAM_CAP),no)
48	$(MAKE) -C pam_cap $@
49endif
50ifeq ($(GOLANG),yes)
51	$(MAKE) -C go $@
52endif
53	$(MAKE) -C progs $@
54
55sudotest: all
56	$(MAKE) -C tests $@
57ifneq ($(PAM_CAP),no)
58	$(MAKE) -C pam_cap $@
59endif
60ifeq ($(GOLANG),yes)
61	$(MAKE) -C go $@
62endif
63	$(MAKE) -C progs $@
64
65distcheck:
66	./distcheck.sh
67	$(MAKE) DYNAMIC=yes clean all test sudotest
68	$(MAKE) CC=/usr/local/musl/bin/musl-gcc clean all test sudotest
69	$(MAKE) clean all test sudotest
70	$(MAKE) distclean
71
72morgangodoc:
73	@echo "Now the release is made, you want to remember to run:"
74	@echo
75	@echo "GOPROXY=https://proxy.golang.org GO111MODULE=on go get kernel.org/pub/linux/libs/security/libcap/cap@v$(GOMAJOR).$(VERSION).$(MINOR)"
76	@echo
77	@echo "This will cause a go.dev documentation update."
78
79morganrelease: distcheck
80	@echo "sign the main library tag twice: older DSA key; and newer RSA (kernel.org) key"
81	git tag -u D41A6DF2 -s libcap-$(VERSION).$(MINOR) -m "This is libcap-$(VERSION).$(MINOR)"
82	git tag -u E2CCF3F4 -s libcap-korg-$(VERSION).$(MINOR) -m "This is libcap-$(VERSION).$(MINOR)"
83	@echo "The following are for the Go module tracking."
84	git tag -u D41A6DF2 -s v$(GOMAJOR).$(VERSION).$(MINOR) -m "This is the version tag for the 'libcap' Go base directory associated with libcap-$(VERSION).$(MINOR)."
85	git tag -u D41A6DF2 -s psx/v$(GOMAJOR).$(VERSION).$(MINOR) -m "This is the version tag for the 'psx' Go package associated with libcap-$(VERSION).$(MINOR)."
86	git tag -u D41A6DF2 -s cap/v$(GOMAJOR).$(VERSION).$(MINOR) -m "This is the version tag for the 'cap' Go package associated with libcap-$(VERSION).$(MINOR)."
87	$(MAKE) release
88	@echo "sign the tar file using korg key"
89	cd .. && gpg -sba -u E2CCF3F4 libcap-$(VERSION).$(MINOR).tar
90	$(MAKE) morgangodoc
91