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