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