Merge branch 'sigbreak' of https://github.com/bjpaupor/fio
[fio.git] / Makefile
CommitLineData
c61a3a44
JF
1ifeq ($(SRCDIR),)
2SRCDIR := .
3endif
4
5VPATH := $(SRCDIR)
6
84546b83
BVA
7all: fio
8
9config-host.mak: configure
10 @if [ ! -e "$@" ]; then \
11 echo "Running configure ..."; \
12 ./configure; \
13 else \
14 echo "$@ is out-of-date, running configure"; \
15 sed -n "/.*Configured with/s/[^:]*: //p" "$@" | sh; \
16 fi
17
d443abcf 18ifneq ($(MAKECMDGOALS),clean)
67bf9823
JA
19include config-host.mak
20endif
21
0d60927f 22DEBUGFLAGS = -DFIO_INC_DEBUG
9195552e 23CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INTERNAL $(DEBUGFLAGS)
61054f0d 24OPTFLAGS= -g -ffast-math
8a2cf08d 25FIO_CFLAGS= -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS) -I. -I$(SRCDIR)
af4862b3
JA
26LIBS += -lm $(EXTLIBS)
27PROGS = fio
6f4e03b0 28SCRIPTS = $(addprefix $(SRCDIR)/,tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio tools/fiologparser.py tools/hist/fiologparser_hist.py tools/hist/fio-histo-log-pctiles.py tools/fio_jsonplus_clat2csv)
af4862b3 29
61054f0d 30ifndef CONFIG_FIO_NO_OPT
8a2cf08d 31 FIO_CFLAGS += -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
61054f0d 32endif
a817dc3b 33ifdef CONFIG_BUILD_NATIVE
8a2cf08d 34 FIO_CFLAGS += -march=native
a817dc3b 35endif
61054f0d 36
76bc30ca
SW
37ifdef CONFIG_PDB
38 LINK_PDBFILE ?= -Wl,-pdb,$(dir $@)/$(basename $(@F)).pdb
8a2cf08d 39 FIO_CFLAGS += -gcodeview
76bc30ca
SW
40 LDFLAGS += -fuse-ld=lld $(LINK_PDBFILE)
41endif
42
4b0e335a
EV
43# If clang, do not use builtin stpcpy as it breaks the build
44ifeq ($(CC),clang)
45 FIO_CFLAGS += -fno-builtin-stpcpy
46endif
47
91f94d5b
JA
48ifdef CONFIG_GFIO
49 PROGS += gfio
50endif
51
785e49c6
BW
52SOURCE := $(sort $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/crc/*.c)) \
53 $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/lib/*.c))) \
e2d53995 54 gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
971caeb1 55 eta.c verify.c memory.c io_u.c parse.c fio_sem.c rwlock.c \
ae626d4e 56 pshared.c options.c \
e2d53995 57 smalloc.c filehash.c profile.c debug.c engines/cpu.c \
d48a9799 58 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
5561e9dd 59 engines/ftruncate.c engines/filecreate.c engines/filestat.c engines/filedelete.c \
b50590bc 60 engines/exec.c \
e2d53995
JA
61 server.c client.c iolog.c backend.c libfio.c flow.c cconv.c \
62 gettime-thread.c helpers.c json.c idletime.c td_error.c \
aee2ab67 63 profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \
16e56d25 64 workqueue.c rate-submit.c optgroup.c helper_thread.c \
0d71aa98 65 steadystate.c zone-dist.c zbd.c dedupe.c
67bf9823 66
1b10477b
MM
67ifdef CONFIG_LIBHDFS
68 HDFSFLAGS= -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux -I $(FIO_LIBHDFS_INCLUDE)
d1773f5b 69 HDFSLIB= -Wl,-rpath $(JAVA_HOME)/lib/$(FIO_HDFS_CPU)/server -L$(JAVA_HOME)/lib/$(FIO_HDFS_CPU)/server $(FIO_LIBHDFS_LIB)/libhdfs.a -ljvm
8a2cf08d 70 FIO_CFLAGS += $(HDFSFLAGS)
1b10477b
MM
71 SOURCE += engines/libhdfs.c
72endif
73
247ef2aa 74ifdef CONFIG_LIBISCSI
25b9b58e
ES
75 libiscsi_SRCS = engines/libiscsi.c
76 libiscsi_LIBS = $(LIBISCSI_LIBS)
77 libiscsi_CFLAGS = $(LIBISCSI_CFLAGS)
78 ENGINES += libiscsi
247ef2aa
KZ
79endif
80
d643a1e2 81ifdef CONFIG_LIBNBD
5a8a6a03
YK
82 nbd_SRCS = engines/nbd.c
83 nbd_LIBS = $(LIBNBD_LIBS)
84 nbd_CFLAGS = $(LIBNBD_CFLAGS)
85 ENGINES += nbd
d643a1e2
RJ
86endif
87
9326926b
TG
88ifdef CONFIG_LIBNFS
89 CFLAGS += $(LIBNFS_CFLAGS)
90 LIBS += $(LIBNFS_LIBS)
91 SOURCE += engines/nfs.c
92endif
93
67bf9823 94ifdef CONFIG_64BIT
8a2cf08d
SW
95 CPPFLAGS += -DBITS_PER_LONG=64
96else ifdef CONFIG_32BIT
97 CPPFLAGS += -DBITS_PER_LONG=32
67bf9823 98endif
67bf9823 99ifdef CONFIG_LIBAIO
25b9b58e
ES
100 libaio_SRCS = engines/libaio.c
101 libaio_LIBS = -laio
25b9b58e 102 ENGINES += libaio
67bf9823
JA
103endif
104ifdef CONFIG_RDMA
5a8a6a03
YK
105 rdma_SRCS = engines/rdma.c
106 rdma_LIBS = -libverbs -lrdmacm
107 ENGINES += rdma
67bf9823 108endif
e4c4625f
JM
109ifdef CONFIG_LIBRPMA_APM
110 librpma_apm_SRCS = engines/librpma_apm.c
111 librpma_fio_SRCS = engines/librpma_fio.c
112 librpma_apm_LIBS = -lrpma -lpmem
113 ENGINES += librpma_apm
114endif
115ifdef CONFIG_LIBRPMA_GPSPM
116 librpma_gpspm_SRCS = engines/librpma_gpspm.c engines/librpma_gpspm_flush.pb-c.c
117 librpma_fio_SRCS = engines/librpma_fio.c
118 librpma_gpspm_LIBS = -lrpma -lpmem -lprotobuf-c
119 ENGINES += librpma_gpspm
120endif
121ifdef librpma_fio_SRCS
122 SOURCE += $(librpma_fio_SRCS)
123endif
67bf9823 124ifdef CONFIG_POSIXAIO
67bf9823
JA
125 SOURCE += engines/posixaio.c
126endif
127ifdef CONFIG_LINUX_FALLOCATE
128 SOURCE += engines/falloc.c
129endif
130ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
131 SOURCE += engines/e4defrag.c
132endif
10756b2c
BS
133ifdef CONFIG_LIBCUFILE
134 SOURCE += engines/libcufile.c
135endif
67bf9823 136ifdef CONFIG_LINUX_SPLICE
67bf9823
JA
137 SOURCE += engines/splice.c
138endif
67bf9823 139ifdef CONFIG_SOLARISAIO
67bf9823
JA
140 SOURCE += engines/solarisaio.c
141endif
4700b234 142ifdef CONFIG_WINDOWSAIO
4700b234
JA
143 SOURCE += engines/windowsaio.c
144endif
d5f9b0ea 145ifdef CONFIG_RADOS
5a8a6a03
YK
146 rados_SRCS = engines/rados.c
147 rados_LIBS = -lrados
148 ENGINES += rados
d5f9b0ea 149endif
fc5c0345 150ifdef CONFIG_RBD
5a8a6a03
YK
151 rbd_SRCS = engines/rbd.c
152 rbd_LIBS = -lrbd -lrados
153 ENGINES += rbd
fc5c0345 154endif
c2f6a13d 155ifdef CONFIG_HTTP
5a8a6a03
YK
156 http_SRCS = engines/http.c
157 http_LIBS = -lcurl -lssl -lcrypto
158 ENGINES += http
c2f6a13d 159endif
c363fdd7
JL
160ifdef CONFIG_DFS
161 dfs_SRCS = engines/dfs.c
162 dfs_LIBS = -luuid -ldaos -ldfs
163 ENGINES += dfs
164endif
44e8e956 165SOURCE += oslib/asprintf.c
67bf9823 166ifndef CONFIG_STRSEP
984f30c9 167 SOURCE += oslib/strsep.c
67bf9823 168endif
9ad8da82 169ifndef CONFIG_STRCASESTR
984f30c9 170 SOURCE += oslib/strcasestr.c
9ad8da82 171endif
5ad7be56 172ifndef CONFIG_STRLCAT
984f30c9 173 SOURCE += oslib/strlcat.c
5ad7be56 174endif
b29c71c4
JA
175ifndef CONFIG_HAVE_STRNDUP
176 SOURCE += oslib/strndup.c
177endif
67bf9823 178ifndef CONFIG_GETOPT_LONG_ONLY
984f30c9 179 SOURCE += oslib/getopt_long.c
67bf9823 180endif
67bf9823 181ifndef CONFIG_INET_ATON
984f30c9 182 SOURCE += oslib/inet_aton.c
67bf9823 183endif
95f31f7d
TK
184ifndef CONFIG_HAVE_STATX
185 SOURCE += oslib/statx.c
186endif
6e7d7dfb 187ifdef CONFIG_GFAPI
188 SOURCE += engines/glusterfs.c
cc47f094 189 SOURCE += engines/glusterfs_sync.c
190 SOURCE += engines/glusterfs_async.c
439c45af 191 LIBS += -lgfapi -lglusterfs
6fa14b99 192 ifdef CONFIG_GF_FADVISE
8a2cf08d 193 FIO_CFLAGS += "-DGFAPI_USE_FADVISE"
6fa14b99 194 endif
6e7d7dfb 195endif
65fa28ca
DE
196ifdef CONFIG_MTD
197 SOURCE += engines/mtd.c
984f30c9
JA
198 SOURCE += oslib/libmtd.c
199 SOURCE += oslib/libmtd_legacy.c
65fa28ca 200endif
43f3cec2 201ifdef CONFIG_PMEMBLK
5a8a6a03
YK
202 pmemblk_SRCS = engines/pmemblk.c
203 pmemblk_LIBS = -lpmemblk
204 ENGINES += pmemblk
43f3cec2 205endif
cbb15e42 206ifdef CONFIG_LINUX_DEVDAX
deae2fad
H
207 dev-dax_SRCS = engines/dev-dax.c
208 dev-dax_LIBS = -lpmem
5a8a6a03 209 ENGINES += dev-dax
cbb15e42 210endif
ae0db592 211ifdef CONFIG_LIBPMEM
25b9b58e
ES
212 libpmem_SRCS = engines/libpmem.c
213 libpmem_LIBS = -lpmem
214 ENGINES += libpmem
ae0db592 215endif
a40e7a59
GB
216ifdef CONFIG_IME
217 SOURCE += engines/ime.c
218endif
56a19325 219ifdef CONFIG_LIBZBC
25b9b58e
ES
220 libzbc_SRCS = engines/libzbc.c
221 libzbc_LIBS = -lzbc
222 ENGINES += libzbc
56a19325 223endif
d015e398 224
53cd4eee 225ifeq ($(CONFIG_TARGET_OS), Linux)
67bf9823 226 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
bffad86f 227 oslib/linux-dev-lookup.c engines/io_uring.c
b7694961
DLM
228ifdef CONFIG_HAS_BLKZONED
229 SOURCE += oslib/linux-blkzoned.c
230endif
67bf9823 231 LIBS += -lpthread -ldl
213a01b0 232 LDFLAGS += -rdynamic
d015e398 233endif
53cd4eee 234ifeq ($(CONFIG_TARGET_OS), Android)
3714a963 235 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c profiles/tiobench.c \
984f30c9 236 oslib/linux-dev-lookup.c
08541925
JA
237ifdef CONFIG_HAS_BLKZONED
238 SOURCE += oslib/linux-blkzoned.c
239endif
ad3e7e97 240 LIBS += -ldl -llog
ec5c6b12 241 LDFLAGS += -rdynamic
ec5c6b12 242endif
53cd4eee 243ifeq ($(CONFIG_TARGET_OS), SunOS)
7366ad05 244 LIBS += -lpthread -ldl
d015e398
BC
245 CPPFLAGS += -D__EXTENSIONS__
246endif
53cd4eee 247ifeq ($(CONFIG_TARGET_OS), FreeBSD)
0bf31987 248 SOURCE += trim.c
d015e398 249 LIBS += -lpthread -lrt
213a01b0 250 LDFLAGS += -rdynamic
d015e398 251endif
3cd4c66f
J
252ifeq ($(CONFIG_TARGET_OS), OpenBSD)
253 LIBS += -lpthread
254 LDFLAGS += -rdynamic
255endif
53cd4eee 256ifeq ($(CONFIG_TARGET_OS), NetBSD)
d015e398 257 LIBS += -lpthread -lrt
213a01b0 258 LDFLAGS += -rdynamic
d015e398 259endif
239b2882 260ifeq ($(CONFIG_TARGET_OS), DragonFly)
c9a4e0c8 261 SOURCE += trim.c
239b2882
JA
262 LIBS += -lpthread -lrt
263 LDFLAGS += -rdynamic
264endif
53cd4eee 265ifeq ($(CONFIG_TARGET_OS), AIX)
d015e398 266 LIBS += -lpthread -ldl -lrt
d015e398 267 CPPFLAGS += -D_LARGE_FILES -D__ppc__
48b35be0 268 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
d015e398 269endif
53cd4eee 270ifeq ($(CONFIG_TARGET_OS), HP-UX)
b5ffb752 271 LIBS += -lpthread -ldl -lrt
8a2cf08d 272 FIO_CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
c00a2289 273endif
53cd4eee 274ifeq ($(CONFIG_TARGET_OS), Darwin)
d015e398
BC
275 LIBS += -lpthread -ldl
276endif
53cd4eee 277ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
a1957954
BVA
278 SOURCE += os/windows/cpu-affinity.c os/windows/posix.c
279 WINDOWS_OBJS = os/windows/cpu-affinity.o os/windows/posix.o lib/hweight.o
60ef6b02 280 LIBS += -lpthread -lpsapi -lws2_32 -lssp
8a2cf08d 281 FIO_CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
d015e398
BC
282endif
283
5a8a6a03
YK
284ifdef CONFIG_DYNAMIC_ENGINES
285 DYNAMIC_ENGS := $(ENGINES)
286define engine_template =
287$(1)_OBJS := $$($(1)_SRCS:.c=.o)
f4bd2c3d 288$$($(1)_OBJS): CFLAGS := -fPIC $$($(1)_CFLAGS) $(CFLAGS)
25b9b58e 289engines/fio-$(1).so: $$($(1)_OBJS)
ff61a9c8 290 $$(QUIET_LINK)$(CC) -shared -rdynamic -fPIC -Wl,-soname,fio-$(1).so.1 -o $$@ $$< $$($(1)_LIBS)
25b9b58e 291ENGS_OBJS += engines/fio-$(1).so
5a8a6a03
YK
292endef
293else # !CONFIG_DYNAMIC_ENGINES
294define engine_template =
295SOURCE += $$($(1)_SRCS)
296LIBS += $$($(1)_LIBS)
7a9cc9c9 297override CFLAGS += $$($(1)_CFLAGS)
5a8a6a03
YK
298endef
299endif
300
a05cfbe3
JA
301FIO-VERSION-FILE: FORCE
302 @$(SHELL) $(SRCDIR)/FIO-VERSION-GEN
303-include FIO-VERSION-FILE
304
f4bd2c3d
ES
305override CFLAGS := -DFIO_VERSION='"$(FIO_VERSION)"' $(FIO_CFLAGS) $(CFLAGS)
306
5a8a6a03
YK
307$(foreach eng,$(ENGINES),$(eval $(call engine_template,$(eng))))
308
c61a3a44 309OBJS := $(SOURCE:.c=.o)
90b7a96d 310
8232e285 311FIO_OBJS = $(OBJS) fio.o
b470a02c 312
7efff409
JA
313GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
314 gclient.o gcompat.o cairo_text_helpers.o printing.o
315
b470a02c
SC
316ifdef CONFIG_ARITHMETIC
317FIO_OBJS += lex.yy.o y.tab.o
7efff409 318GFIO_OBJS += lex.yy.o y.tab.o
b470a02c
SC
319endif
320
f67d6ee2 321-include $(OBJS:.o=.d)
79d16311 322
61f78f3a 323T_SMALLOC_OBJS = t/stest.o
971caeb1 324T_SMALLOC_OBJS += gettime.o fio_sem.o pshared.o smalloc.o t/log.o t/debug.o \
ae626d4e 325 t/arch.o
61f78f3a
JA
326T_SMALLOC_PROGS = t/stest
327
328T_IEEE_OBJS = t/ieee754.o
84f43c6f 329T_IEEE_OBJS += lib/ieee754.o
61f78f3a
JA
330T_IEEE_PROGS = t/ieee754
331
6ff38856 332T_ZIPF_OBS = t/genzipf.o
2cac8fcb 333T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/pattern.o lib/zipf.o \
df27f9ac
JA
334 lib/strntol.o lib/gauss.o t/genzipf.o oslib/strcasestr.o \
335 oslib/strndup.o
aa7bc282 336T_ZIPF_PROGS = t/fio-genzipf
6ff38856 337
ad1f90aa 338T_AXMAP_OBJS = t/axmap.o
07e71598 339T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
ad1f90aa
JA
340T_AXMAP_PROGS = t/axmap
341
7a887ffe 342T_LFSR_TEST_OBJS = t/lfsr-test.o
17031c6d
BVA
343T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o fio_sem.o pshared.o \
344 t/log.o t/debug.o t/arch.o
7a887ffe
AP
345T_LFSR_TEST_PROGS = t/lfsr-test
346
323f2086 347T_GEN_RAND_OBJS = t/gen-rand.o
e91ba49a 348T_GEN_RAND_OBJS += t/log.o t/debug.o lib/rand.o lib/pattern.o lib/strntol.o \
df27f9ac 349 oslib/strcasestr.o oslib/strndup.o
323f2086
JA
350T_GEN_RAND_PROGS = t/gen-rand
351
40bafa33
JA
352ifeq ($(CONFIG_TARGET_OS), Linux)
353T_BTRACE_FIO_OBJS = t/btrace2fio.o
984f30c9 354T_BTRACE_FIO_OBJS += fifo.o lib/flist_sort.o t/log.o oslib/linux-dev-lookup.o
aa7bc282 355T_BTRACE_FIO_PROGS = t/fio-btrace2fio
40bafa33
JA
356endif
357
bf481692 358T_DEDUPE_OBJS = t/dedupe.o
971caeb1 359T_DEDUPE_OBJS += lib/rbtree.o t/log.o fio_sem.o pshared.o smalloc.o gettime.o \
ae626d4e
BVA
360 crc/md5.o lib/memalign.o lib/bloom.o t/debug.o crc/xxhash.o \
361 t/arch.o crc/murmur3.o crc/crc32c.o crc/crc32c-intel.o \
362 crc/crc32c-arm64.o crc/fnv.o
aa7bc282 363T_DEDUPE_PROGS = t/fio-dedupe
bf481692 364
214e2d56 365T_VS_OBJS = t/verify-state.o t/log.o crc/crc32c.o crc/crc32c-intel.o crc/crc32c-arm64.o t/debug.o
98996ef9
JA
366T_VS_PROGS = t/fio-verify-state
367
6d5a9bc2
JA
368T_PIPE_ASYNC_OBJS = t/read-to-pipe-async.o
369T_PIPE_ASYNC_PROGS = t/read-to-pipe-async
370
e31b8288 371T_IOU_RING_OBJS = t/io_uring.o
e1985f90 372T_IOU_RING_OBJS += t/arch.o
e31b8288 373T_IOU_RING_PROGS = t/io_uring
c9fb4c5b 374
ae46d0f5
JA
375T_MEMLOCK_OBJS = t/memlock.o
376T_MEMLOCK_PROGS = t/memlock
377
dcbc7841
VF
378T_TT_OBJS = t/time-test.o
379T_TT_PROGS = t/time-test
380
1857e6b2
PA
381T_FUZZ_OBJS = t/fuzz/fuzz_parseini.o
382T_FUZZ_OBJS += $(OBJS)
383ifdef CONFIG_ARITHMETIC
384T_FUZZ_OBJS += lex.yy.o y.tab.o
385endif
386# in case there is no fuzz driver defined by environment variable LIB_FUZZING_ENGINE, use a simple one
387# For instance, with compiler clang, address sanitizer and libFuzzer as a fuzzing engine, you should define
388# export CFLAGS="-fsanitize=address,fuzzer-no-link"
389# export LIB_FUZZING_ENGINE="-fsanitize=address"
390# export CC=clang
391# before running configure && make
392# You can adapt this with different compilers, sanitizers, and fuzzing engines
393ifndef LIB_FUZZING_ENGINE
394T_FUZZ_OBJS += t/fuzz/onefile.o
395endif
396T_FUZZ_PROGS = t/fuzz/fuzz_parseini
397
61f78f3a
JA
398T_OBJS = $(T_SMALLOC_OBJS)
399T_OBJS += $(T_IEEE_OBJS)
6ff38856 400T_OBJS += $(T_ZIPF_OBJS)
ad1f90aa 401T_OBJS += $(T_AXMAP_OBJS)
7a887ffe 402T_OBJS += $(T_LFSR_TEST_OBJS)
323f2086 403T_OBJS += $(T_GEN_RAND_OBJS)
40bafa33 404T_OBJS += $(T_BTRACE_FIO_OBJS)
e5bf5a88 405T_OBJS += $(T_DEDUPE_OBJS)
98996ef9 406T_OBJS += $(T_VS_OBJS)
6d5a9bc2 407T_OBJS += $(T_PIPE_ASYNC_OBJS)
ae46d0f5 408T_OBJS += $(T_MEMLOCK_OBJS)
dcbc7841 409T_OBJS += $(T_TT_OBJS)
e31b8288 410T_OBJS += $(T_IOU_RING_OBJS)
1857e6b2 411T_OBJS += $(T_FUZZ_OBJS)
6ff38856 412
824d6ff4 413ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
a1957954
BVA
414 T_DEDUPE_OBJS += $(WINDOWS_OBJS)
415 T_SMALLOC_OBJS += $(WINDOWS_OBJS)
416 T_LFSR_TEST_OBJS += $(WINDOWS_OBJS)
824d6ff4
BC
417endif
418
aa7bc282
JA
419T_TEST_PROGS = $(T_SMALLOC_PROGS)
420T_TEST_PROGS += $(T_IEEE_PROGS)
6ff38856 421T_PROGS += $(T_ZIPF_PROGS)
aa7bc282
JA
422T_TEST_PROGS += $(T_AXMAP_PROGS)
423T_TEST_PROGS += $(T_LFSR_TEST_PROGS)
323f2086 424T_TEST_PROGS += $(T_GEN_RAND_PROGS)
40bafa33 425T_PROGS += $(T_BTRACE_FIO_PROGS)
e5bf5a88 426T_PROGS += $(T_DEDUPE_PROGS)
98996ef9 427T_PROGS += $(T_VS_PROGS)
5ad80fa7 428T_TEST_PROGS += $(T_MEMLOCK_PROGS)
15eca9aa 429ifdef CONFIG_PREAD
5ad80fa7 430T_TEST_PROGS += $(T_PIPE_ASYNC_PROGS)
15eca9aa 431endif
5ad80fa7
BVA
432ifneq (,$(findstring Linux,$(CONFIG_TARGET_OS)))
433T_TEST_PROGS += $(T_IOU_RING_PROGS)
434endif
1857e6b2 435T_TEST_PROGS += $(T_FUZZ_PROGS)
e5bf5a88
JA
436
437PROGS += $(T_PROGS)
3427207d 438
b8b0e1ee
TK
439ifdef CONFIG_HAVE_CUNIT
440UT_OBJS = unittests/unittest.o
e37155ef 441UT_OBJS += unittests/lib/memalign.o
53916bbd 442UT_OBJS += unittests/lib/num2str.o
ce875031 443UT_OBJS += unittests/lib/strntol.o
cdcd7e99 444UT_OBJS += unittests/oslib/strlcat.o
2f84d0c7 445UT_OBJS += unittests/oslib/strndup.o
d2292c7d 446UT_OBJS += unittests/oslib/strcasestr.o
4d3c2cc5 447UT_OBJS += unittests/oslib/strsep.o
e37155ef 448UT_TARGET_OBJS = lib/memalign.o
53916bbd 449UT_TARGET_OBJS += lib/num2str.o
ce875031 450UT_TARGET_OBJS += lib/strntol.o
cdcd7e99 451UT_TARGET_OBJS += oslib/strlcat.o
2f84d0c7 452UT_TARGET_OBJS += oslib/strndup.o
d2292c7d 453UT_TARGET_OBJS += oslib/strcasestr.o
4d3c2cc5 454UT_TARGET_OBJS += oslib/strsep.o
b8b0e1ee
TK
455UT_PROGS = unittests/unittest
456else
457UT_OBJS =
458UT_TARGET_OBJS =
459UT_PROGS =
460endif
461
4c3ecec4
JA
462ifneq ($(findstring $(MAKEFLAGS),s),s)
463ifndef V
464 QUIET_CC = @echo ' ' CC $@;
79816cf7
JA
465 QUIET_LINK = @echo ' ' LINK $@;
466 QUIET_DEP = @echo ' ' DEP $@;
467 QUIET_YACC = @echo ' ' YACC $@;
468 QUIET_LEX = @echo ' ' LEX $@;
4c3ecec4
JA
469endif
470endif
471
a8168a22
JA
472ifeq ($(CONFIG_TARGET_OS), SunOS)
473 INSTALL = ginstall
474else
475 INSTALL = install
476endif
020d54bd 477prefix = $(INSTALL_PREFIX)
c1d5725e 478bindir = $(prefix)/bin
5a8a6a03 479libdir = $(prefix)/lib/fio
bcdf7c58 480
53cd4eee 481ifeq ($(CONFIG_TARGET_OS), Darwin)
bcdf7c58 482mandir = /usr/share/man
eab4af4e 483sharedir = /usr/share/fio
bcdf7c58 484else
d60e92d1 485mandir = $(prefix)/man
eab4af4e 486sharedir = $(prefix)/share/fio
bcdf7c58 487endif
c1d5725e 488
8a2cf08d 489all: $(PROGS) $(T_TEST_PROGS) $(UT_PROGS) $(SCRIPTS) $(ENGS_OBJS) FORCE
f84622e9 490
92ddd6b6 491.PHONY: all install clean test
3d43382c
JA
492.PHONY: FORCE cscope
493
9e85c34e 494%.o : %.c
c61a3a44 495 @mkdir -p $(dir $@)
4feafb1e 496 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
c61a3a44 497 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SRCDIR)/$*.c > $*.d
f67d6ee2
JA
498 @mv -f $*.d $*.d.tmp
499 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
97f3eddc
BVA
500 @if type -p fmt >/dev/null 2>&1; then \
501 sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -w 1 | \
502 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d; \
503 else \
504 sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | \
505 tr -cs "[:graph:]" "\n" | \
506 sed -e 's/^ *//' -e '/^$$/ d' -e 's/$$/:/' >> $*.d; \
507 fi
f67d6ee2 508 @rm -f $*.d.tmp
e52947d1 509
b470a02c 510ifdef CONFIG_ARITHMETIC
79816cf7 511lex.yy.c: exp/expression-parser.l
63bda378 512ifdef CONFIG_LEX_USE_O
c61a3a44 513 $(QUIET_LEX)$(LEX) -o $@ $<
63bda378
JA
514else
515 $(QUIET_LEX)$(LEX) $<
516endif
79816cf7 517
b470a02c
SC
518lex.yy.o: lex.yy.c y.tab.h
519 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
520
521y.tab.o: y.tab.c y.tab.h
522 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
523
524y.tab.c: exp/expression-parser.y
c61a3a44 525 $(QUIET_YACC)$(YACC) -o $@ -l -d -b y $<
b470a02c 526
dc68fd2c 527y.tab.h: y.tab.c
b470a02c 528
c9fa1c8d
SC
529lexer.h: lex.yy.c
530
c879ba67
JA
531exp/test-expression-parser.o: exp/test-expression-parser.c
532 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
533exp/test-expression-parser: exp/test-expression-parser.o
d6e082e7 534 $(QUIET_LINK)$(CC) $(LDFLAGS) $< y.tab.o lex.yy.o -o $@ $(LIBS)
c879ba67 535
b470a02c
SC
536parse.o: lex.yy.o y.tab.o
537endif
538
c61a3a44 539init.o: init.c FIO-VERSION-FILE
32d4cc61 540
f762cef9 541gcompat.o: gcompat.c gcompat.h
c61a3a44 542 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
f762cef9 543
9af4a244 544goptions.o: goptions.c goptions.h
c61a3a44 545 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
9af4a244 546
53e0e85d 547ghelpers.o: ghelpers.c ghelpers.h
c61a3a44 548 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
53e0e85d 549
41666588 550gerror.o: gerror.c gerror.h
c61a3a44 551 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
41666588 552
1252d8f2 553gclient.o: gclient.c gclient.h
c61a3a44 554 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
1252d8f2 555
53e0e85d 556gfio.o: gfio.c ghelpers.c
c61a3a44 557 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
70d07ce1 558
53e0e85d 559graph.o: graph.c graph.h
c61a3a44 560 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
af58ef32 561
ee2f55b2 562cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
c61a3a44 563 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
ee2f55b2 564
bf3f7027 565printing.o: printing.c printing.h
c61a3a44 566 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
bf3f7027 567
f3e769a4 568t/io_uring.o: os/linux/io_uring.h
e31b8288 569t/io_uring: $(T_IOU_RING_OBJS)
d6e082e7 570 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_IOU_RING_OBJS) $(LIBS)
c9fb4c5b 571
6d5a9bc2 572t/read-to-pipe-async: $(T_PIPE_ASYNC_OBJS)
d6e082e7 573 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_PIPE_ASYNC_OBJS) $(LIBS)
6d5a9bc2 574
ae46d0f5 575t/memlock: $(T_MEMLOCK_OBJS)
d6e082e7 576 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_MEMLOCK_OBJS) $(LIBS)
ae46d0f5 577
61f78f3a 578t/stest: $(T_SMALLOC_OBJS)
d6e082e7 579 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
61f78f3a
JA
580
581t/ieee754: $(T_IEEE_OBJS)
d6e082e7 582 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
fbc2792b 583
33765372 584fio: $(FIO_OBJS)
d6e082e7 585 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(HDFSLIB)
4c3ecec4 586
1857e6b2
PA
587t/fuzz/fuzz_parseini: $(T_FUZZ_OBJS)
588ifndef LIB_FUZZING_ENGINE
589 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_FUZZ_OBJS) $(LIBS) $(HDFSLIB)
590else
591 $(QUIET_LINK)$(CXX) $(LDFLAGS) -o $@ $(T_FUZZ_OBJS) $(LIB_FUZZING_ENGINE) $(LIBS) $(HDFSLIB)
592endif
593
70d07ce1 594gfio: $(GFIO_OBJS)
1527dc50 595 $(QUIET_LINK)$(CC) $(filter-out -static, $(LDFLAGS)) -o gfio $(GFIO_OBJS) $(LIBS) $(GFIO_LIBS) $(GTK_LDFLAGS) $(HDFSLIB)
70d07ce1 596
aa7bc282 597t/fio-genzipf: $(T_ZIPF_OBJS)
d6e082e7 598 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
6ff38856 599
ad1f90aa 600t/axmap: $(T_AXMAP_OBJS)
d6e082e7 601 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
ad1f90aa 602
7a887ffe 603t/lfsr-test: $(T_LFSR_TEST_OBJS)
d6e082e7 604 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
7a887ffe 605
323f2086 606t/gen-rand: $(T_GEN_RAND_OBJS)
d6e082e7 607 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_GEN_RAND_OBJS) $(LIBS)
323f2086 608
40bafa33 609ifeq ($(CONFIG_TARGET_OS), Linux)
aa7bc282 610t/fio-btrace2fio: $(T_BTRACE_FIO_OBJS)
d6e082e7 611 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_BTRACE_FIO_OBJS) $(LIBS)
40bafa33
JA
612endif
613
aa7bc282 614t/fio-dedupe: $(T_DEDUPE_OBJS)
d6e082e7 615 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_DEDUPE_OBJS) $(LIBS)
bf481692 616
98996ef9 617t/fio-verify-state: $(T_VS_OBJS)
d6e082e7 618 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_VS_OBJS) $(LIBS)
98996ef9 619
dcbc7841 620t/time-test: $(T_TT_OBJS)
d6e082e7 621 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_TT_OBJS) $(LIBS)
dcbc7841 622
b8b0e1ee
TK
623ifdef CONFIG_HAVE_CUNIT
624unittests/unittest: $(UT_OBJS) $(UT_TARGET_OBJS)
d6e082e7 625 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(UT_OBJS) $(UT_TARGET_OBJS) -lcunit $(LIBS)
b8b0e1ee
TK
626endif
627
3d43382c 628clean: FORCE
5a8a6a03 629 @rm -f .depend $(FIO_OBJS) $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(UT_OBJS) $(PROGS) $(T_PROGS) $(T_TEST_PROGS) core.* core gfio unittests/unittest FIO-VERSION-FILE *.[do] lib/*.d oslib/*.[do] crc/*.d engines/*.[do] engines/*.so profiles/*.[do] t/*.[do] unittests/*.[do] unittests/*/*.[do] config-host.mak config-host.h y.tab.[ch] lex.yy.c exp/*.[do] lexer.h
b084bde6 630 @rm -f t/fio-btrace2fio t/io_uring t/read-to-pipe-async
0b422574 631 @rm -rf doc/output
45f944b9
JA
632
633distclean: clean FORCE
d1f6fcad 634 @rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf fiologparser_hist.pdf
ebac4655 635
592ef98a 636cscope:
366badd3 637 @cscope -b -R
592ef98a 638
1378cc68
EV
639tools/plot/fio2gnuplot.1:
640 @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot > tools/plot/fio2gnuplot.1
641
7788b76f
JA
642doc: tools/plot/fio2gnuplot.1
643 @man -t ./fio.1 | ps2pdf - fio.pdf
644 @man -t tools/fio_generate_plots.1 | ps2pdf - fio_generate_plots.pdf
645 @man -t tools/plot/fio2gnuplot.1 | ps2pdf - fio2gnuplot.pdf
d1f6fcad 646 @man -t tools/hist/fiologparser_hist.py.1 | ps2pdf - fiologparser_hist.pdf
7788b76f 647
92ddd6b6 648test: fio
dbf2214c 649 ./fio --minimal --thread --exitall_on_error --runtime=1s --name=nulltest --ioengine=null --rw=randrw --iodepth=2 --norandommap --random_generator=tausworthe64 --size=16T --name=verifyfstest --filename=fiotestfile.tmp --unlink=1 --rw=write --verify=crc32c --verify_state_save=0 --size=16K
3894b8e1 650
36d108a4
BVA
651fulltest:
652 sudo modprobe null_blk && \
653 if [ ! -e /usr/include/libzbc/zbc.h ]; then \
7c8e6725 654 git clone https://github.com/westerndigitalcorporation/libzbc && \
36d108a4
BVA
655 (cd libzbc && \
656 ./autogen.sh && \
657 ./configure --prefix=/usr && \
658 make -j && \
659 sudo make install) \
660 fi && \
037b2b50 661 sudo t/zbd/run-tests-against-nullb -s 1 && \
36d108a4 662 if [ -e /sys/module/null_blk/parameters/zoned ]; then \
037b2b50
DF
663 sudo t/zbd/run-tests-against-nullb -s 2; \
664 sudo t/zbd/run-tests-against-nullb -s 4; \
36d108a4
BVA
665 fi
666
8a2cf08d 667install: $(PROGS) $(SCRIPTS) $(ENGS_OBJS) tools/plot/fio2gnuplot.1 FORCE
513ba3f7 668 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
ebac4655 669 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
5a8a6a03
YK
670ifdef CONFIG_DYNAMIC_ENGINES
671 $(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
672 $(INSTALL) -m 755 $(SRCDIR)/engines/*.so $(DESTDIR)$(libdir)
673endif
d60e92d1 674 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
c61a3a44
JF
675 $(INSTALL) -m 644 $(SRCDIR)/fio.1 $(DESTDIR)$(mandir)/man1
676 $(INSTALL) -m 644 $(SRCDIR)/tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
677 $(INSTALL) -m 644 $(SRCDIR)/tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1
d1f6fcad 678 $(INSTALL) -m 644 $(SRCDIR)/tools/hist/fiologparser_hist.py.1 $(DESTDIR)$(mandir)/man1
eab4af4e 679 $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
c61a3a44 680 $(INSTALL) -m 644 $(SRCDIR)/tools/plot/*gpm $(DESTDIR)$(sharedir)/
36d108a4
BVA
681
682.PHONY: test fulltest