xref: /freebsd/sys/contrib/openzfs/config/Rules.am (revision 1323ec571215a77ddd21294f0871979d5ad6b992)
1#
2# Default build rules for all user space components, every Makefile.am
3# should include these rules and override or extend them as needed.
4#
5
6PHONY =
7DEFAULT_INCLUDES = \
8	-include $(top_builddir)/zfs_config.h \
9	-I$(top_builddir)/include \
10	-I$(top_srcdir)/include \
11	-I$(top_srcdir)/module/icp/include \
12	-I$(top_srcdir)/lib/libspl/include
13
14if BUILD_LINUX
15DEFAULT_INCLUDES += \
16	-I$(top_srcdir)/lib/libspl/include/os/linux
17endif
18
19if BUILD_FREEBSD
20DEFAULT_INCLUDES += \
21	-I$(top_srcdir)/lib/libspl/include/os/freebsd
22endif
23
24AM_LIBTOOLFLAGS = --silent
25
26AM_CFLAGS  = -std=gnu99 -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wno-sign-compare -Wno-missing-field-initializers
27AM_CFLAGS += -fno-strict-aliasing
28AM_CFLAGS += $(NO_OMIT_FRAME_POINTER)
29AM_CFLAGS += $(IMPLICIT_FALLTHROUGH)
30AM_CFLAGS += $(DEBUG_CFLAGS)
31AM_CFLAGS += $(ASAN_CFLAGS)
32AM_CFLAGS += $(UBSAN_CFLAGS)
33AM_CFLAGS += $(CODE_COVERAGE_CFLAGS) $(NO_FORMAT_ZERO_LENGTH)
34if BUILD_FREEBSD
35AM_CFLAGS += -fPIC -Werror -Wno-unknown-pragmas -Wno-enum-conversion
36AM_CFLAGS += -include $(top_srcdir)/include/os/freebsd/spl/sys/ccompile.h
37AM_CFLAGS += -I/usr/include -I/usr/local/include
38endif
39
40AM_CPPFLAGS  = -D_GNU_SOURCE
41AM_CPPFLAGS += -D_REENTRANT
42AM_CPPFLAGS += -D_FILE_OFFSET_BITS=64
43AM_CPPFLAGS += -D_LARGEFILE64_SOURCE
44AM_CPPFLAGS += -DLIBEXECDIR=\"$(libexecdir)\"
45AM_CPPFLAGS += -DRUNSTATEDIR=\"$(runstatedir)\"
46AM_CPPFLAGS += -DSBINDIR=\"$(sbindir)\"
47AM_CPPFLAGS += -DSYSCONFDIR=\"$(sysconfdir)\"
48AM_CPPFLAGS += -DPKGDATADIR=\"$(pkgdatadir)\"
49AM_CPPFLAGS += $(DEBUG_CPPFLAGS)
50AM_CPPFLAGS += $(CODE_COVERAGE_CPPFLAGS)
51if BUILD_LINUX
52AM_CPPFLAGS += -DTEXT_DOMAIN=\"zfs-linux-user\"
53endif
54if BUILD_FREEBSD
55AM_CPPFLAGS += -DTEXT_DOMAIN=\"zfs-freebsd-user\"
56endif
57AM_CPPFLAGS += -D"strtok(...)=strtok(__VA_ARGS__) __attribute__((deprecated(\"Use strtok_r(3) instead!\")))"
58AM_CPPFLAGS += -D"__xpg_basename(...)=__xpg_basename(__VA_ARGS__) __attribute__((deprecated(\"basename(3) is underspecified. Use zfs_basename() instead!\")))"
59AM_CPPFLAGS += -D"basename(...)=basename(__VA_ARGS__) __attribute__((deprecated(\"basename(3) is underspecified. Use zfs_basename() instead!\")))"
60AM_CPPFLAGS += -D"dirname(...)=dirname(__VA_ARGS__) __attribute__((deprecated(\"dirname(3) is underspecified. Use zfs_dirnamelen() instead!\")))"
61AM_CPPFLAGS += -D"bcopy(...)=__attribute__((deprecated(\"bcopy(3) is deprecated. Use memcpy(3)/memmove(3) instead!\"))) bcopy(__VA_ARGS__)"
62AM_CPPFLAGS += -D"bcmp(...)=__attribute__((deprecated(\"bcmp(3) is deprecated. Use memcmp(3) instead!\"))) bcmp(__VA_ARGS__)"
63AM_CPPFLAGS += -D"bzero(...)=__attribute__((deprecated(\"bzero(3) is deprecated. Use memset(3) instead!\"))) bzero(__VA_ARGS__)"
64
65if ASAN_ENABLED
66AM_CPPFLAGS += -DZFS_ASAN_ENABLED
67endif
68
69if UBSAN_ENABLED
70AM_CPPFLAGS += -DZFS_UBSAN_ENABLED
71endif
72
73AM_LDFLAGS  = $(DEBUG_LDFLAGS)
74AM_LDFLAGS += $(ASAN_LDFLAGS)
75AM_LDFLAGS += $(UBSAN_LDFLAGS)
76
77if BUILD_FREEBSD
78AM_LDFLAGS += -fstack-protector-strong -shared
79AM_LDFLAGS += -Wl,-x -Wl,--fatal-warnings -Wl,--warn-shared-textrel
80AM_LDFLAGS += -lm
81endif
82