xref: /freebsd/sys/contrib/openzfs/Makefile.am (revision 13ec1e3155c7e9bf037b12af186351b7fa9b9450)
1include $(top_srcdir)/config/Shellcheck.am
2
3ACLOCAL_AMFLAGS = -I config
4
5SUBDIRS = include
6if BUILD_LINUX
7SUBDIRS += rpm
8endif
9
10if CONFIG_USER
11SUBDIRS += man scripts lib tests cmd etc contrib
12if BUILD_LINUX
13SUBDIRS += udev
14endif
15endif
16if CONFIG_KERNEL
17SUBDIRS += module
18
19extradir = $(prefix)/src/zfs-$(VERSION)
20extra_HEADERS = zfs.release.in zfs_config.h.in
21
22if BUILD_LINUX
23kerneldir = $(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION)
24nodist_kernel_HEADERS = zfs.release zfs_config.h module/$(LINUX_SYMBOLS)
25endif
26endif
27
28AUTOMAKE_OPTIONS = foreign
29EXTRA_DIST  = autogen.sh copy-builtin
30EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am
31EXTRA_DIST += AUTHORS CODE_OF_CONDUCT.md COPYRIGHT LICENSE META NEWS NOTICE
32EXTRA_DIST += README.md RELEASES.md
33EXTRA_DIST += module/lua/README.zfs module/os/linux/spl/README.md
34
35# Include all the extra licensing information for modules
36EXTRA_DIST += module/icp/algs/skein/THIRDPARTYLICENSE
37EXTRA_DIST += module/icp/algs/skein/THIRDPARTYLICENSE.descrip
38EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman
39EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman.descrip
40EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl
41EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl.descrip
42EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.cryptogams
43EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.cryptogams.descrip
44EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.openssl
45EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.openssl.descrip
46EXTRA_DIST += module/os/linux/spl/THIRDPARTYLICENSE.gplv2
47EXTRA_DIST += module/os/linux/spl/THIRDPARTYLICENSE.gplv2.descrip
48EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash
49EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash.descrip
50
51@CODE_COVERAGE_RULES@
52
53GITREV = include/zfs_gitrev.h
54
55PHONY = gitrev
56gitrev:
57	$(AM_V_GEN)$(top_srcdir)/scripts/make_gitrev.sh $(GITREV)
58
59all: gitrev
60
61# Double-colon rules are allowed; there are multiple independent definitions.
62maintainer-clean-local::
63	-$(RM) $(GITREV)
64
65distclean-local::
66	-$(RM) -R autom4te*.cache build
67	-find . \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
68		-o -name .pc -o -name .hg -o -name .git \) -prune -o \
69		\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
70		-o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
71		-o -name '.*.rej' -o -size 0 -o -name '*%' -o -name '.*.cmd' \
72		-o -name 'core' -o -name 'Makefile' -o -name 'Module.symvers' \
73		-o -name '*.order' -o -name '*.markers' -o -name '*.gcda' \
74		-o -name '*.gcno' \) \
75		-type f -print | xargs $(RM)
76
77all-local:
78	-[ -x ${top_builddir}/scripts/zfs-tests.sh ] && \
79	    ${top_builddir}/scripts/zfs-tests.sh -c
80
81dist-hook:
82	$(AM_V_GEN)$(top_srcdir)/scripts/make_gitrev.sh -D $(distdir) $(GITREV)
83	$(SED) ${ac_inplace} -e 's/Release:[[:print:]]*/Release:      $(RELEASE)/' \
84		$(distdir)/META
85
86if BUILD_LINUX
87# For compatibility, create a matching spl-x.y.z directly which contains
88# symlinks to the updated header and object file locations.  These
89# compatibility links will be removed in the next major release.
90if CONFIG_KERNEL
91install-data-hook:
92	rm -rf $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \
93	mkdir $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \
94	cd $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \
95	ln -s ../zfs-$(VERSION)/include/spl include && \
96	ln -s ../zfs-$(VERSION)/$(LINUX_VERSION) $(LINUX_VERSION) && \
97	ln -s ../zfs-$(VERSION)/zfs_config.h.in spl_config.h.in && \
98	ln -s ../zfs-$(VERSION)/zfs.release.in spl.release.in && \
99	cd $(DESTDIR)$(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION) && \
100	ln -fs zfs_config.h spl_config.h && \
101	ln -fs zfs.release spl.release
102endif
103endif
104
105PHONY += codecheck
106codecheck: cstyle shellcheck checkbashisms flake8 mancheck testscheck vcscheck
107
108PHONY += checkstyle
109checkstyle: codecheck commitcheck
110
111PHONY += commitcheck
112commitcheck:
113	@if git rev-parse --git-dir > /dev/null 2>&1; then \
114		${top_srcdir}/scripts/commitcheck.sh; \
115	fi
116
117if HAVE_PARALLEL
118cstyle_line = -print0 | parallel -X0 ${top_srcdir}/scripts/cstyle.pl -cpP {}
119else
120cstyle_line = -exec ${top_srcdir}/scripts/cstyle.pl -cpP {} +
121endif
122PHONY += cstyle
123cstyle:
124	@find ${top_srcdir} -name build -prune \
125		-o -type f -name '*.[hc]' \
126		! -name 'zfs_config.*' ! -name '*.mod.c' \
127		! -name 'opt_global.h' ! -name '*_if*.h' \
128		! -path './module/zstd/lib/*' \
129		! -path './module/zfs/lz4.c' \
130		$(cstyle_line)
131
132filter_executable = -exec test -x '{}' \; -print
133
134SHELLCHECKDIRS = cmd contrib etc scripts tests
135SHELLCHECKSCRIPTS = autogen.sh
136
137PHONY += checkabi storeabi
138
139checklibabiversion:
140	libabiversion=`abidw -v | $(SED) 's/[^0-9]//g'`; \
141	if test $$libabiversion -lt "200"; then \
142        /bin/echo -e "\n" \
143        "*** Please use libabigail 2.0.0 version or newer;\n" \
144        "*** otherwise results are not consistent!\n" \
145        "(or see https://github.com/openzfs/libabigail-docker )\n"; \
146        exit 1; \
147    fi;
148
149checkabi: checklibabiversion lib
150	$(MAKE) -C lib checkabi
151
152storeabi: checklibabiversion lib
153	$(MAKE) -C lib storeabi
154
155PHONY += mancheck
156mancheck:
157	${top_srcdir}/scripts/mancheck.sh ${top_srcdir}/man ${top_srcdir}/tests/test-runner/man
158
159if BUILD_LINUX
160stat_fmt = -c '%A %n'
161else
162stat_fmt = -f '%Sp %N'
163endif
164
165PHONY += testscheck
166testscheck:
167	@find ${top_srcdir}/tests/zfs-tests -type f \
168		\( -name '*.ksh' -not ${filter_executable} \) -o \
169		\( -name '*.kshlib' ${filter_executable} \) -o \
170		\( -name '*.shlib' ${filter_executable} \) -o \
171		\( -name '*.cfg' ${filter_executable} \) | \
172		xargs -r stat ${stat_fmt} | \
173		awk '{c++; print} END {if(c>0) exit 1}'
174
175PHONY += vcscheck
176vcscheck:
177	@if git rev-parse --git-dir > /dev/null 2>&1; then \
178		git ls-files . --exclude-standard --others | \
179		awk '{c++; print} END {if(c>0) exit 1}' ; \
180	fi
181
182PHONY += lint
183lint: cppcheck paxcheck
184
185CPPCHECKDIRS = cmd lib module
186PHONY += cppcheck
187cppcheck: $(CPPCHECKDIRS)
188	@if test -n "$(CPPCHECK)"; then \
189		set -e ; for dir in $(CPPCHECKDIRS) ; do \
190			$(MAKE) -C $$dir cppcheck ; \
191		done \
192	else \
193		echo "skipping cppcheck because cppcheck is not installed"; \
194	fi
195
196PHONY += paxcheck
197paxcheck:
198	@if type scanelf > /dev/null 2>&1; then \
199		${top_srcdir}/scripts/paxcheck.sh ${top_builddir}; \
200	else \
201		echo "skipping paxcheck because scanelf is not installed"; \
202	fi
203
204PHONY += flake8
205flake8:
206	@if type flake8 > /dev/null 2>&1; then \
207		flake8 ${top_srcdir}; \
208	else \
209		echo "skipping flake8 because flake8 is not installed"; \
210	fi
211
212PHONY += ctags
213ctags:
214	$(RM) tags
215	find $(top_srcdir) -name '.?*' -prune \
216		-o -type f -name '*.[hcS]' -print | xargs ctags -a
217
218PHONY += etags
219etags:
220	$(RM) TAGS
221	find $(top_srcdir) -name '.?*' -prune \
222		-o -type f -name '*.[hcS]' -print | xargs etags -a
223
224PHONY += cscopelist
225cscopelist:
226	find $(top_srcdir) -name '.?*' -prune \
227		-o -type f -name '*.[hc]' -print >cscope.files
228
229PHONY += tags
230tags: ctags etags
231
232PHONY += pkg pkg-dkms pkg-kmod pkg-utils
233pkg: @DEFAULT_PACKAGE@
234pkg-dkms: @DEFAULT_PACKAGE@-dkms
235pkg-kmod: @DEFAULT_PACKAGE@-kmod
236pkg-utils: @DEFAULT_PACKAGE@-utils
237
238include config/rpm.am
239include config/deb.am
240include config/tgz.am
241
242.PHONY: $(PHONY)
243