xref: /freebsd/sys/contrib/openzfs/module/Makefile.bsd (revision 3e8eb5c7f4909209c042403ddee340b2ee7003a5)
1.if !defined(WITH_CTF)
2WITH_CTF=1
3.endif
4
5.include <bsd.sys.mk>
6
7SRCDIR=${.CURDIR}
8INCDIR=${.CURDIR:H}/include
9
10KMOD=	openzfs
11
12.PATH:	${SRCDIR}/avl \
13	${SRCDIR}/lua \
14	${SRCDIR}/nvpair \
15	${SRCDIR}/icp/algs/edonr \
16	${SRCDIR}/os/freebsd/spl \
17	${SRCDIR}/os/freebsd/zfs \
18	${SRCDIR}/unicode \
19	${SRCDIR}/zcommon \
20	${SRCDIR}/zfs \
21	${SRCDIR}/zstd \
22	${SRCDIR}/zstd/lib/common \
23	${SRCDIR}/zstd/lib/compress \
24	${SRCDIR}/zstd/lib/decompress
25
26
27
28CFLAGS+= -I${.OBJDIR:H}/include
29CFLAGS+= -I${INCDIR}
30CFLAGS+= -I${INCDIR}/os/freebsd
31CFLAGS+= -I${INCDIR}/os/freebsd/spl
32CFLAGS+= -I${INCDIR}/os/freebsd/zfs
33CFLAGS+= -I${SRCDIR}/zstd/include
34CFLAGS+= -include ${INCDIR}/os/freebsd/spl/sys/ccompile.h
35
36CFLAGS+= -D__KERNEL__ -DFREEBSD_NAMECACHE -DBUILDING_ZFS  -D__BSD_VISIBLE=1 \
37	 -DHAVE_UIO_ZEROCOPY -DWITHOUT_NETDUMP -D__KERNEL -D_SYS_CONDVAR_H_ \
38	 -D_SYS_VMEM_H_ -DKDTRACE_HOOKS -DSMP -DCOMPAT_FREEBSD11
39
40.if ${MACHINE_ARCH} == "amd64"
41CFLAGS+= -DHAVE_AVX2 -DHAVE_AVX -D__x86_64 -DHAVE_SSE2 -DHAVE_AVX512F -DHAVE_SSSE3
42.endif
43
44.if defined(WITH_DEBUG) && ${WITH_DEBUG} == "true"
45CFLAGS+= -DZFS_DEBUG -g
46.if defined(WITH_INVARIANTS) && ${WITH_INVARIANTS} == "true"
47 CFLAGS+= -DINVARIANTS -DWITNESS -DOPENSOLARIS_WITNESS
48.endif
49.if defined(WITH_O0) && ${WITH_O0} == "true"
50 CFLAGS+= -O0
51.endif
52.else
53CFLAGS += -DNDEBUG
54.endif
55
56.if defined(WITH_VFS_DEBUG) && ${WITH_VFS_DEBUG} == "true"
57# kernel must also be built with this option for this to work
58CFLAGS+= -DDEBUG_VFS_LOCKS
59.endif
60
61.if defined(WITH_GCOV) && ${WITH_GCOV} == "true"
62CFLAGS+=	 -fprofile-arcs -ftest-coverage
63.endif
64
65DEBUG_FLAGS=-g
66
67.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
68	${MACHINE_ARCH} == "arm"
69CFLAGS+= -DBITS_PER_LONG=32
70.else
71CFLAGS+= -DBITS_PER_LONG=64
72.endif
73
74SRCS=	vnode_if.h device_if.h bus_if.h
75
76# avl
77SRCS+=	avl.c
78
79# icp
80SRCS+=  edonr.c
81
82#lua
83SRCS+=	lapi.c \
84	lauxlib.c \
85	lbaselib.c \
86	lcode.c \
87	lcompat.c \
88	lcorolib.c \
89	lctype.c \
90	ldebug.c \
91	ldo.c \
92	lfunc.c \
93	lgc.c \
94	llex.c \
95	lmem.c \
96	lobject.c \
97	lopcodes.c \
98	lparser.c \
99	lstate.c \
100	lstring.c \
101	lstrlib.c \
102	ltable.c \
103	ltablib.c \
104	ltm.c \
105	lvm.c \
106	lzio.c
107
108#nvpair
109SRCS+=	nvpair.c \
110	fnvpair.c \
111	nvpair_alloc_spl.c \
112	nvpair_alloc_fixed.c
113
114#os/freebsd/spl
115SRCS+=	acl_common.c \
116	callb.c \
117	list.c \
118	sha256c.c \
119	sha512c.c \
120	spl_acl.c \
121	spl_cmn_err.c \
122	spl_dtrace.c \
123	spl_kmem.c \
124	spl_kstat.c \
125	spl_misc.c \
126	spl_policy.c \
127	spl_procfs_list.c \
128	spl_string.c \
129	spl_sunddi.c \
130	spl_sysevent.c \
131	spl_taskq.c \
132	spl_uio.c \
133	spl_vfs.c \
134	spl_vm.c \
135	spl_zlib.c \
136	spl_zone.c
137
138
139.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
140	${MACHINE_ARCH} == "arm"
141SRCS+= spl_atomic.c
142.endif
143
144#os/freebsd/zfs
145SRCS+=	abd_os.c \
146	arc_os.c \
147	crypto_os.c \
148	dmu_os.c \
149	hkdf.c \
150	kmod_core.c \
151	spa_os.c \
152	sysctl_os.c \
153	vdev_file.c \
154	vdev_geom.c \
155	vdev_label_os.c \
156	zfs_acl.c \
157	zfs_ctldir.c \
158	zfs_debug.c \
159	zfs_dir.c \
160	zfs_ioctl_compat.c \
161	zfs_ioctl_os.c \
162	zfs_racct.c \
163	zfs_vfsops.c \
164	zfs_vnops_os.c \
165	zfs_znode.c \
166	zio_crypt.c \
167	zvol_os.c
168
169#unicode
170SRCS+=	uconv.c \
171	u8_textprep.c
172
173#zcommon
174SRCS+=	zfeature_common.c \
175	zfs_comutil.c \
176	zfs_deleg.c \
177	zfs_fletcher.c \
178	zfs_fletcher_avx512.c \
179	zfs_fletcher_intel.c \
180	zfs_fletcher_sse.c \
181	zfs_fletcher_superscalar.c \
182	zfs_fletcher_superscalar4.c \
183	zfs_namecheck.c \
184	zfs_prop.c \
185	zpool_prop.c \
186	zprop_common.c
187
188#zfs
189SRCS+=	abd.c \
190	aggsum.c \
191	arc.c \
192	blkptr.c \
193	bplist.c \
194	bpobj.c \
195	btree.c \
196	cityhash.c \
197	dbuf.c \
198	dbuf_stats.c \
199	bptree.c \
200	bqueue.c \
201	dataset_kstats.c \
202	ddt.c \
203	ddt_zap.c \
204	dmu.c \
205	dmu_diff.c \
206	dmu_object.c \
207	dmu_objset.c \
208	dmu_recv.c \
209	dmu_redact.c \
210	dmu_send.c \
211	dmu_traverse.c \
212	dmu_tx.c \
213	dmu_zfetch.c \
214	dnode.c \
215	dnode_sync.c \
216	dsl_dataset.c \
217	dsl_deadlist.c \
218	dsl_deleg.c \
219	dsl_bookmark.c \
220	dsl_dir.c \
221	dsl_crypt.c \
222	dsl_destroy.c \
223	dsl_pool.c \
224	dsl_prop.c \
225	dsl_scan.c \
226	dsl_synctask.c \
227	dsl_userhold.c \
228	edonr_zfs.c \
229	fm.c \
230	gzip.c \
231	lzjb.c \
232	lz4.c \
233	lz4_zfs.c \
234	metaslab.c \
235	mmp.c \
236	multilist.c \
237	objlist.c \
238	pathname.c \
239	range_tree.c \
240	refcount.c \
241	rrwlock.c \
242	sa.c \
243	sha256.c \
244	skein_zfs.c \
245	spa.c \
246	spa_boot.c \
247	spa_checkpoint.c \
248	spa_config.c \
249	spa_errlog.c \
250	spa_history.c \
251	spa_log_spacemap.c \
252	spa_misc.c \
253	spa_stats.c \
254	space_map.c \
255	space_reftree.c \
256	txg.c \
257	uberblock.c \
258	unique.c \
259	vdev.c \
260	vdev_cache.c \
261	vdev_draid.c \
262	vdev_draid_rand.c \
263	vdev_indirect.c \
264	vdev_indirect_births.c \
265	vdev_indirect_mapping.c \
266	vdev_initialize.c \
267	vdev_label.c \
268	vdev_mirror.c \
269	vdev_missing.c \
270	vdev_queue.c \
271	vdev_raidz.c \
272	vdev_raidz_math.c \
273	vdev_raidz_math_scalar.c \
274	vdev_raidz_math_avx2.c \
275	vdev_raidz_math_avx512bw.c \
276	vdev_raidz_math_avx512f.c \
277	vdev_raidz_math_sse2.c \
278	vdev_raidz_math_ssse3.c \
279	vdev_rebuild.c \
280	vdev_removal.c \
281	vdev_root.c \
282	vdev_trim.c \
283	zap.c \
284	zap_leaf.c \
285	zap_micro.c \
286	zcp.c \
287	zcp_get.c \
288	zcp_global.c \
289	zcp_iter.c \
290	zcp_set.c \
291	zcp_synctask.c \
292	zfeature.c \
293	zfs_byteswap.c \
294	zfs_file_os.c \
295	zfs_fm.c \
296	zfs_fuid.c \
297	zfs_ioctl.c \
298	zfs_log.c \
299	zfs_onexit.c \
300	zfs_quota.c \
301	zfs_ratelimit.c \
302	zfs_replay.c \
303	zfs_rlock.c \
304	zfs_sa.c \
305	zfs_vnops.c \
306	zil.c \
307	zio.c \
308	zio_checksum.c \
309	zio_compress.c \
310	zio_inject.c \
311	zle.c \
312	zrlock.c \
313	zthr.c \
314	zvol.c
315
316#zstd
317SRCS+=	zfs_zstd.c \
318	entropy_common.c \
319	error_private.c \
320	fse_decompress.c \
321	pool.c \
322	zstd_common.c \
323	fse_compress.c \
324	hist.c \
325	huf_compress.c \
326	zstd_compress.c \
327	zstd_compress_literals.c \
328	zstd_compress_sequences.c \
329	zstd_compress_superblock.c \
330	zstd_double_fast.c \
331	zstd_fast.c \
332	zstd_lazy.c \
333	zstd_ldm.c \
334	zstd_opt.c \
335	huf_decompress.c \
336	zstd_ddict.c \
337	zstd_decompress.c \
338	zstd_decompress_block.c
339
340
341
342beforeinstall:
343.if ${MK_DEBUG_FILES} != "no"
344	mtree -eu \
345	    -f /etc/mtree/BSD.debug.dist \
346	    -p ${DESTDIR}/usr/lib
347.endif
348
349.include <bsd.kmod.mk>
350
351
352CFLAGS.gcc+= -Wno-pointer-to-int-cast
353
354CFLAGS.lapi.c= -Wno-cast-qual
355CFLAGS.lcompat.c= -Wno-cast-qual
356CFLAGS.lobject.c= -Wno-cast-qual
357CFLAGS.ltable.c= -Wno-cast-qual
358CFLAGS.lvm.c= -Wno-cast-qual
359CFLAGS.nvpair.c= -DHAVE_RPC_TYPES -Wno-cast-qual
360CFLAGS.spl_string.c= -Wno-cast-qual
361CFLAGS.spl_vm.c= -Wno-cast-qual
362CFLAGS.spl_zlib.c= -Wno-cast-qual
363CFLAGS.abd.c= -Wno-cast-qual
364CFLAGS.zfs_log.c= -Wno-cast-qual
365CFLAGS.zfs_vnops_os.c= -Wno-pointer-arith
366CFLAGS.u8_textprep.c= -Wno-cast-qual
367CFLAGS.zfs_fletcher.c= -Wno-cast-qual -Wno-pointer-arith
368CFLAGS.zfs_fletcher_intel.c= -Wno-cast-qual -Wno-pointer-arith
369CFLAGS.zfs_fletcher_sse.c= -Wno-cast-qual -Wno-pointer-arith
370CFLAGS.zfs_fletcher_avx512.c= -Wno-cast-qual -Wno-pointer-arith
371CFLAGS.zprop_common.c= -Wno-cast-qual
372CFLAGS.ddt.c= -Wno-cast-qual
373CFLAGS.dmu.c= -Wno-cast-qual
374CFLAGS.dmu_traverse.c= -Wno-cast-qual
375CFLAGS.dsl_dir.c= -Wno-cast-qual
376CFLAGS.dsl_deadlist.c= -Wno-cast-qual
377CFLAGS.dsl_prop.c= -Wno-cast-qual
378CFLAGS.edonr.c=-Wno-cast-qual
379CFLAGS.fm.c= -Wno-cast-qual
380CFLAGS.lz4_zfs.c= -Wno-cast-qual
381CFLAGS.spa.c= -Wno-cast-qual
382CFLAGS.spa_misc.c= -Wno-cast-qual
383CFLAGS.sysctl_os.c= -include ../zfs_config.h
384CFLAGS.vdev_draid.c= -Wno-cast-qual
385CFLAGS.vdev_raidz.c= -Wno-cast-qual
386CFLAGS.vdev_raidz_math.c= -Wno-cast-qual
387CFLAGS.vdev_raidz_math_scalar.c= -Wno-cast-qual
388CFLAGS.vdev_raidz_math_avx2.c= -Wno-cast-qual -Wno-duplicate-decl-specifier
389CFLAGS.vdev_raidz_math_avx512f.c= -Wno-cast-qual -Wno-duplicate-decl-specifier
390CFLAGS.vdev_raidz_math_sse2.c= -Wno-cast-qual -Wno-duplicate-decl-specifier
391CFLAGS.zap_leaf.c= -Wno-cast-qual
392CFLAGS.zap_micro.c= -Wno-cast-qual
393CFLAGS.zcp.c= -Wno-cast-qual
394CFLAGS.zfs_fm.c= -Wno-cast-qual
395CFLAGS.zfs_ioctl.c= -Wno-cast-qual
396CFLAGS.zil.c= -Wno-cast-qual
397CFLAGS.zio.c= -Wno-cast-qual
398CFLAGS.zrlock.c= -Wno-cast-qual
399CFLAGS.zfs_zstd.c= -Wno-cast-qual -Wno-pointer-arith
400CFLAGS.entropy_common.c= -fno-tree-vectorize -U__BMI__
401CFLAGS.error_private.c= -fno-tree-vectorize -U__BMI__
402CFLAGS.fse_decompress.c= -fno-tree-vectorize -U__BMI__
403CFLAGS.pool.c= -fno-tree-vectorize -U__BMI__
404CFLAGS.xxhash.c= -fno-tree-vectorize -U__BMI__
405CFLAGS.zstd_common.c= -fno-tree-vectorize -U__BMI__
406CFLAGS.fse_compress.c= -fno-tree-vectorize -U__BMI__
407CFLAGS.hist.c= -fno-tree-vectorize -U__BMI__
408CFLAGS.huf_compress.c= -fno-tree-vectorize -U__BMI__
409CFLAGS.zstd_compress.c= -fno-tree-vectorize -U__BMI__
410CFLAGS.zstd_compress_literals.c= -fno-tree-vectorize -U__BMI__
411CFLAGS.zstd_compress_sequences.c= -fno-tree-vectorize -U__BMI__
412CFLAGS.zstd_compress_superblock.c= -fno-tree-vectorize -U__BMI__
413CFLAGS.zstd_double_fast.c= -fno-tree-vectorize -U__BMI__
414CFLAGS.zstd_fast.c= -fno-tree-vectorize -U__BMI__
415CFLAGS.zstd_lazy.c= -fno-tree-vectorize -U__BMI__
416CFLAGS.zstd_ldm.c= -fno-tree-vectorize -U__BMI__
417CFLAGS.zstd_opt.c= -fno-tree-vectorize -U__BMI__
418CFLAGS.huf_decompress.c= -fno-tree-vectorize -U__BMI__
419CFLAGS.zstd_ddict.c= -fno-tree-vectorize -U__BMI__
420CFLAGS.zstd_decompress.c= -fno-tree-vectorize -U__BMI__
421CFLAGS.zstd_decompress_block.c= -fno-tree-vectorize -U__BMI__
422