xref: /freebsd/stand/libsa/zfs/Makefile.inc (revision 3a3af6b2a160bea72509a9d5ef84e25906b0478a)
1# $FreeBSD$
2
3.PATH:		${ZFSSRC}
4.PATH:		${SYSDIR}/crypto/skein
5.PATH:		${ZFSOSSRC}/spl
6.PATH:		${OZFS}/module/zstd
7.PATH:		${OZFS}/module/zstd/lib/common
8.PATH:		${OZFS}/module/zstd/lib/compress
9.PATH:		${OZFS}/module/zstd/lib/decompress
10.PATH:		${OZFS}/module/icp/algs/blake3
11ZFS_SRC=	zfs.c nvlist.c skein.c skein_block.c list.c
12ZFS_SRC+=	zfs_zstd.c
13ZFS_SRC+=	blake3.c blake3_generic.c blake3_impl_hack.c
14ZSTD_SRC+=	entropy_common.c error_private.c
15ZSTD_SRC+=	fse_compress.c fse_decompress.c hist.c
16ZSTD_SRC+=	huf_compress.c huf_decompress.c pool.c xxhash.c
17ZSTD_SRC+=	zstd_common.c zstd_compress.c zstd_compress_literals.c
18ZSTD_SRC+=	zstd_compress_sequences.c zstd_compress_superblock.c
19ZSTD_SRC+=	zstd_ddict.c zstd_decompress.c zstd_decompress_block.c
20ZSTD_SRC+=	zstd_double_fast.c zstd_fast.c zstd_lazy.c zstd_ldm.c
21ZSTD_SRC+=	zstd_opt.c
22
23SRCS+=		${ZFS_SRC} ${ZSTD_SRC}
24
25#
26# Any file that needs the FreeBSD overrides that are in
27# include/os/freebssd/spl/XXX needs to have these added to
28# CFLAGS_EARLY.file.c. In general, we try to build out of the OpenZFS tree
29# unaltered. There's a problem, though, that since we're building for a
30# standalone environment that's neither userland nor kernel, we sometimes need
31# special code and that's handled by the 'nested' includes where we either setup
32# something just-so before we include the include/XXX file, or if we need to
33# tweak something defined in that file.
34#
35
36ZFS_EARLY=	-I${ZFSSRC}/spl					\
37		-I${ZFSOSINC}					\
38		-I${ZFSOSINC}/spl				\
39		-I${ZFSOSINC}/zfs
40
41#
42# For all files, though, we prepend the sys/ccompile.h file to the build which
43# has a bunch of defines that are present in OpenSolaris / Illumos, but missing
44# from FreeBSD.
45#
46.for i in ${ZFS_SRC} ${ZSTD_SRC}
47CFLAGS.$i+=	-include ${ZFSOSINC}/spl/sys/ccompile.h -Wformat -Wall -I${OZFS}/include \
48	-DNEED_SOLARIS_BOOLEAN
49.endfor
50
51CFLAGS_EARLY.blake3.c+= ${ZFS_EARLY}
52CFLAGS_EARLY.blake3_generic.c+= ${ZFS_EARLY}
53CFLAGS_EARLY.blake3_impl_hack.c+= ${ZFS_EARLY}
54CFLAGS_EARLY.list.c+= ${ZFS_EARLY}
55CFLAGS_EARLY.zfs_zstd.c+= ${ZFS_EARLY}
56CFLAGS_EARLY.nvlist.c+= ${ZFS_EARLY}
57CFLAGS_EARLY.zfs.c += ${ZFS_EARLY}
58
59#
60# zfs.c is special: we need to define HAS_ZSTD_ZFS to get zfssubr.c to initialize zstd
61# properly. We need to have the cddl boot compat directory in the include path for zfssubr.c
62# to be found, and we need a couple of other include paths for skein and lz4. Finally we
63# temporarily need LDRSRC to pick up part.h until libsa has a way to look into partitions
64# or enumerate them...
65#
66CFLAGS.zfs.c+=	-DHAS_ZSTD_ZFS					\
67		-I${SYSDIR}/cddl/boot/zfs			\
68		-I${LDRSRC}					\
69		-I${SYSDIR}/crypto/skein			\
70		-I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4
71
72#
73# ZSTD coding style has some issues, so suppress clang's warnings. Also, zstd's
74# use of BMI instrucitons is broken in this environment, so avoid them.
75#
76.for i in ${ZSTD_SRC}
77CFLAGS.$i+=	-U__BMI__ ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
78.endfor
79
80CFLAGS.zfs_zstd.c+= -DIN_BASE -DIN_LIBSA
81
82# Do not unroll skein loops, reduce code size
83CFLAGS.skein_block.c+=	-DSKEIN_LOOP=111
84
85# To find blake3_impl.c in OpenZFS tree for our somehat ugly blake3_impl_hack.c
86# that's needed until the necessary tweaks can be upstreamed.
87CFLAGS.blake3_impl_hack.c+= -I${OZFS}/module/icp/algs/blake3
88