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