test: make t0014.fio time_based
[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
dc44588f 31 FIO_CFLAGS += -O3
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 \
910c72df 59 engines/ftruncate.c engines/fileoperations.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 100 libaio_SRCS = engines/libaio.c
e27b9ff0 101 cmdprio_SRCS = engines/cmdprio.c
04525c29 102 LIBS += -laio
25b9b58e 103 libaio_LIBS = -laio
25b9b58e 104 ENGINES += libaio
67bf9823
JA
105endif
106ifdef CONFIG_RDMA
5a8a6a03
YK
107 rdma_SRCS = engines/rdma.c
108 rdma_LIBS = -libverbs -lrdmacm
109 ENGINES += rdma
67bf9823 110endif
e4c4625f
JM
111ifdef CONFIG_LIBRPMA_APM
112 librpma_apm_SRCS = engines/librpma_apm.c
113 librpma_fio_SRCS = engines/librpma_fio.c
8fabefc1
KS
114 ifdef CONFIG_LIBPMEM2_INSTALLED
115 librpma_apm_LIBS = -lrpma -lpmem2
116 else
117 librpma_apm_LIBS = -lrpma -lpmem
118 endif
e4c4625f
JM
119 ENGINES += librpma_apm
120endif
121ifdef CONFIG_LIBRPMA_GPSPM
122 librpma_gpspm_SRCS = engines/librpma_gpspm.c engines/librpma_gpspm_flush.pb-c.c
123 librpma_fio_SRCS = engines/librpma_fio.c
8fabefc1
KS
124 ifdef CONFIG_LIBPMEM2_INSTALLED
125 librpma_gpspm_LIBS = -lrpma -lpmem2 -lprotobuf-c
126 else
127 librpma_gpspm_LIBS = -lrpma -lpmem -lprotobuf-c
128 endif
e4c4625f
JM
129 ENGINES += librpma_gpspm
130endif
131ifdef librpma_fio_SRCS
132 SOURCE += $(librpma_fio_SRCS)
133endif
67bf9823 134ifdef CONFIG_POSIXAIO
67bf9823
JA
135 SOURCE += engines/posixaio.c
136endif
137ifdef CONFIG_LINUX_FALLOCATE
138 SOURCE += engines/falloc.c
139endif
140ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
141 SOURCE += engines/e4defrag.c
142endif
10756b2c
BS
143ifdef CONFIG_LIBCUFILE
144 SOURCE += engines/libcufile.c
145endif
67bf9823 146ifdef CONFIG_LINUX_SPLICE
67bf9823
JA
147 SOURCE += engines/splice.c
148endif
67bf9823 149ifdef CONFIG_SOLARISAIO
67bf9823
JA
150 SOURCE += engines/solarisaio.c
151endif
4700b234 152ifdef CONFIG_WINDOWSAIO
4700b234
JA
153 SOURCE += engines/windowsaio.c
154endif
d5f9b0ea 155ifdef CONFIG_RADOS
5a8a6a03
YK
156 rados_SRCS = engines/rados.c
157 rados_LIBS = -lrados
158 ENGINES += rados
d5f9b0ea 159endif
fc5c0345 160ifdef CONFIG_RBD
5a8a6a03
YK
161 rbd_SRCS = engines/rbd.c
162 rbd_LIBS = -lrbd -lrados
163 ENGINES += rbd
fc5c0345 164endif
c2f6a13d 165ifdef CONFIG_HTTP
5a8a6a03
YK
166 http_SRCS = engines/http.c
167 http_LIBS = -lcurl -lssl -lcrypto
168 ENGINES += http
c2f6a13d 169endif
c363fdd7
JL
170ifdef CONFIG_DFS
171 dfs_SRCS = engines/dfs.c
172 dfs_LIBS = -luuid -ldaos -ldfs
173 ENGINES += dfs
174endif
44e8e956 175SOURCE += oslib/asprintf.c
67bf9823 176ifndef CONFIG_STRSEP
984f30c9 177 SOURCE += oslib/strsep.c
67bf9823 178endif
9ad8da82 179ifndef CONFIG_STRCASESTR
984f30c9 180 SOURCE += oslib/strcasestr.c
9ad8da82 181endif
5ad7be56 182ifndef CONFIG_STRLCAT
984f30c9 183 SOURCE += oslib/strlcat.c
5ad7be56 184endif
b29c71c4
JA
185ifndef CONFIG_HAVE_STRNDUP
186 SOURCE += oslib/strndup.c
187endif
67bf9823 188ifndef CONFIG_GETOPT_LONG_ONLY
984f30c9 189 SOURCE += oslib/getopt_long.c
67bf9823 190endif
67bf9823 191ifndef CONFIG_INET_ATON
984f30c9 192 SOURCE += oslib/inet_aton.c
67bf9823 193endif
95f31f7d
TK
194ifndef CONFIG_HAVE_STATX
195 SOURCE += oslib/statx.c
196endif
6e7d7dfb 197ifdef CONFIG_GFAPI
198 SOURCE += engines/glusterfs.c
cc47f094 199 SOURCE += engines/glusterfs_sync.c
200 SOURCE += engines/glusterfs_async.c
439c45af 201 LIBS += -lgfapi -lglusterfs
6fa14b99 202 ifdef CONFIG_GF_FADVISE
8a2cf08d 203 FIO_CFLAGS += "-DGFAPI_USE_FADVISE"
6fa14b99 204 endif
6e7d7dfb 205endif
65fa28ca
DE
206ifdef CONFIG_MTD
207 SOURCE += engines/mtd.c
984f30c9
JA
208 SOURCE += oslib/libmtd.c
209 SOURCE += oslib/libmtd_legacy.c
65fa28ca 210endif
43f3cec2 211ifdef CONFIG_PMEMBLK
5a8a6a03
YK
212 pmemblk_SRCS = engines/pmemblk.c
213 pmemblk_LIBS = -lpmemblk
214 ENGINES += pmemblk
43f3cec2 215endif
cbb15e42 216ifdef CONFIG_LINUX_DEVDAX
deae2fad
H
217 dev-dax_SRCS = engines/dev-dax.c
218 dev-dax_LIBS = -lpmem
5a8a6a03 219 ENGINES += dev-dax
cbb15e42 220endif
ae0db592 221ifdef CONFIG_LIBPMEM
25b9b58e
ES
222 libpmem_SRCS = engines/libpmem.c
223 libpmem_LIBS = -lpmem
224 ENGINES += libpmem
ae0db592 225endif
a40e7a59
GB
226ifdef CONFIG_IME
227 SOURCE += engines/ime.c
228endif
56a19325 229ifdef CONFIG_LIBZBC
25b9b58e
ES
230 libzbc_SRCS = engines/libzbc.c
231 libzbc_LIBS = -lzbc
232 ENGINES += libzbc
56a19325 233endif
a3ff873e
AK
234ifdef CONFIG_LIBXNVME
235 xnvme_SRCS = engines/xnvme.c
236 xnvme_LIBS = $(LIBXNVME_LIBS)
237 xnvme_CFLAGS = $(LIBXNVME_CFLAGS)
238 ENGINES += xnvme
239endif
53cd4eee 240ifeq ($(CONFIG_TARGET_OS), Linux)
67bf9823 241 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
b3d5e3fd 242 oslib/linux-dev-lookup.c engines/io_uring.c engines/nvme.c
e27b9ff0 243 cmdprio_SRCS = engines/cmdprio.c
b7694961
DLM
244ifdef CONFIG_HAS_BLKZONED
245 SOURCE += oslib/linux-blkzoned.c
246endif
67bf9823 247 LIBS += -lpthread -ldl
213a01b0 248 LDFLAGS += -rdynamic
d015e398 249endif
53cd4eee 250ifeq ($(CONFIG_TARGET_OS), Android)
3714a963 251 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c profiles/tiobench.c \
6a2ecfdb
BVA
252 oslib/linux-dev-lookup.c engines/io_uring.c engines/nvme.c \
253 engines/sg.c
5711325c 254 cmdprio_SRCS = engines/cmdprio.c
08541925
JA
255ifdef CONFIG_HAS_BLKZONED
256 SOURCE += oslib/linux-blkzoned.c
257endif
ad3e7e97 258 LIBS += -ldl -llog
ec5c6b12 259 LDFLAGS += -rdynamic
ec5c6b12 260endif
53cd4eee 261ifeq ($(CONFIG_TARGET_OS), SunOS)
7366ad05 262 LIBS += -lpthread -ldl
d015e398
BC
263 CPPFLAGS += -D__EXTENSIONS__
264endif
53cd4eee 265ifeq ($(CONFIG_TARGET_OS), FreeBSD)
0bf31987 266 SOURCE += trim.c
d015e398 267 LIBS += -lpthread -lrt
213a01b0 268 LDFLAGS += -rdynamic
d015e398 269endif
3cd4c66f
J
270ifeq ($(CONFIG_TARGET_OS), OpenBSD)
271 LIBS += -lpthread
272 LDFLAGS += -rdynamic
273endif
53cd4eee 274ifeq ($(CONFIG_TARGET_OS), NetBSD)
d015e398 275 LIBS += -lpthread -lrt
213a01b0 276 LDFLAGS += -rdynamic
d015e398 277endif
239b2882 278ifeq ($(CONFIG_TARGET_OS), DragonFly)
c9a4e0c8 279 SOURCE += trim.c
239b2882
JA
280 LIBS += -lpthread -lrt
281 LDFLAGS += -rdynamic
282endif
53cd4eee 283ifeq ($(CONFIG_TARGET_OS), AIX)
d015e398 284 LIBS += -lpthread -ldl -lrt
d015e398 285 CPPFLAGS += -D_LARGE_FILES -D__ppc__
48b35be0 286 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
d015e398 287endif
53cd4eee 288ifeq ($(CONFIG_TARGET_OS), HP-UX)
b5ffb752 289 LIBS += -lpthread -ldl -lrt
8a2cf08d 290 FIO_CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
c00a2289 291endif
53cd4eee 292ifeq ($(CONFIG_TARGET_OS), Darwin)
d015e398
BC
293 LIBS += -lpthread -ldl
294endif
53cd4eee 295ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
3d0d549a
BP
296 SOURCE += os/windows/cpu-affinity.c os/windows/posix.c os/windows/dlls.c
297 WINDOWS_OBJS = os/windows/cpu-affinity.o os/windows/posix.o os/windows/dlls.o lib/hweight.o
60ef6b02 298 LIBS += -lpthread -lpsapi -lws2_32 -lssp
8a2cf08d 299 FIO_CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
d015e398
BC
300endif
301
e27b9ff0
NC
302ifdef cmdprio_SRCS
303 SOURCE += $(cmdprio_SRCS)
304endif
305
5a8a6a03
YK
306ifdef CONFIG_DYNAMIC_ENGINES
307 DYNAMIC_ENGS := $(ENGINES)
308define engine_template =
309$(1)_OBJS := $$($(1)_SRCS:.c=.o)
f4bd2c3d 310$$($(1)_OBJS): CFLAGS := -fPIC $$($(1)_CFLAGS) $(CFLAGS)
25b9b58e 311engines/fio-$(1).so: $$($(1)_OBJS)
df597be6 312 $$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -rdynamic -fPIC -Wl,-soname,fio-$(1).so.1 -o $$@ $$< $$($(1)_LIBS)
25b9b58e 313ENGS_OBJS += engines/fio-$(1).so
5a8a6a03
YK
314endef
315else # !CONFIG_DYNAMIC_ENGINES
316define engine_template =
317SOURCE += $$($(1)_SRCS)
318LIBS += $$($(1)_LIBS)
7a9cc9c9 319override CFLAGS += $$($(1)_CFLAGS)
5a8a6a03
YK
320endef
321endif
322
a05cfbe3
JA
323FIO-VERSION-FILE: FORCE
324 @$(SHELL) $(SRCDIR)/FIO-VERSION-GEN
325-include FIO-VERSION-FILE
326
f4bd2c3d
ES
327override CFLAGS := -DFIO_VERSION='"$(FIO_VERSION)"' $(FIO_CFLAGS) $(CFLAGS)
328
5a8a6a03
YK
329$(foreach eng,$(ENGINES),$(eval $(call engine_template,$(eng))))
330
c61a3a44 331OBJS := $(SOURCE:.c=.o)
90b7a96d 332
8232e285 333FIO_OBJS = $(OBJS) fio.o
b470a02c 334
7efff409
JA
335GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
336 gclient.o gcompat.o cairo_text_helpers.o printing.o
337
b470a02c
SC
338ifdef CONFIG_ARITHMETIC
339FIO_OBJS += lex.yy.o y.tab.o
7efff409 340GFIO_OBJS += lex.yy.o y.tab.o
b470a02c
SC
341endif
342
f67d6ee2 343-include $(OBJS:.o=.d)
79d16311 344
61f78f3a 345T_SMALLOC_OBJS = t/stest.o
971caeb1 346T_SMALLOC_OBJS += gettime.o fio_sem.o pshared.o smalloc.o t/log.o t/debug.o \
ae626d4e 347 t/arch.o
61f78f3a
JA
348T_SMALLOC_PROGS = t/stest
349
350T_IEEE_OBJS = t/ieee754.o
84f43c6f 351T_IEEE_OBJS += lib/ieee754.o
61f78f3a
JA
352T_IEEE_PROGS = t/ieee754
353
6ff38856 354T_ZIPF_OBS = t/genzipf.o
2cac8fcb 355T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/pattern.o lib/zipf.o \
df27f9ac
JA
356 lib/strntol.o lib/gauss.o t/genzipf.o oslib/strcasestr.o \
357 oslib/strndup.o
aa7bc282 358T_ZIPF_PROGS = t/fio-genzipf
6ff38856 359
ad1f90aa 360T_AXMAP_OBJS = t/axmap.o
07e71598 361T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
ad1f90aa
JA
362T_AXMAP_PROGS = t/axmap
363
7a887ffe 364T_LFSR_TEST_OBJS = t/lfsr-test.o
17031c6d
BVA
365T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o fio_sem.o pshared.o \
366 t/log.o t/debug.o t/arch.o
7a887ffe
AP
367T_LFSR_TEST_PROGS = t/lfsr-test
368
323f2086 369T_GEN_RAND_OBJS = t/gen-rand.o
e91ba49a 370T_GEN_RAND_OBJS += t/log.o t/debug.o lib/rand.o lib/pattern.o lib/strntol.o \
df27f9ac 371 oslib/strcasestr.o oslib/strndup.o
323f2086
JA
372T_GEN_RAND_PROGS = t/gen-rand
373
40bafa33
JA
374ifeq ($(CONFIG_TARGET_OS), Linux)
375T_BTRACE_FIO_OBJS = t/btrace2fio.o
984f30c9 376T_BTRACE_FIO_OBJS += fifo.o lib/flist_sort.o t/log.o oslib/linux-dev-lookup.o
aa7bc282 377T_BTRACE_FIO_PROGS = t/fio-btrace2fio
40bafa33
JA
378endif
379
bf481692 380T_DEDUPE_OBJS = t/dedupe.o
971caeb1 381T_DEDUPE_OBJS += lib/rbtree.o t/log.o fio_sem.o pshared.o smalloc.o gettime.o \
ae626d4e
BVA
382 crc/md5.o lib/memalign.o lib/bloom.o t/debug.o crc/xxhash.o \
383 t/arch.o crc/murmur3.o crc/crc32c.o crc/crc32c-intel.o \
384 crc/crc32c-arm64.o crc/fnv.o
aa7bc282 385T_DEDUPE_PROGS = t/fio-dedupe
bf481692 386
214e2d56 387T_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
388T_VS_PROGS = t/fio-verify-state
389
6d5a9bc2
JA
390T_PIPE_ASYNC_OBJS = t/read-to-pipe-async.o
391T_PIPE_ASYNC_PROGS = t/read-to-pipe-async
392
9eff5320 393T_IOU_RING_OBJS = t/io_uring.o lib/rand.o lib/pattern.o lib/strntol.o
e31b8288 394T_IOU_RING_PROGS = t/io_uring
c9fb4c5b 395
ae46d0f5
JA
396T_MEMLOCK_OBJS = t/memlock.o
397T_MEMLOCK_PROGS = t/memlock
398
dcbc7841
VF
399T_TT_OBJS = t/time-test.o
400T_TT_PROGS = t/time-test
401
a77e8ab4 402ifneq (,$(findstring -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION,$(CFLAGS)))
1857e6b2
PA
403T_FUZZ_OBJS = t/fuzz/fuzz_parseini.o
404T_FUZZ_OBJS += $(OBJS)
405ifdef CONFIG_ARITHMETIC
406T_FUZZ_OBJS += lex.yy.o y.tab.o
407endif
a77e8ab4 408# For proper fio code teardown CFLAGS needs to include -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
1857e6b2
PA
409# in case there is no fuzz driver defined by environment variable LIB_FUZZING_ENGINE, use a simple one
410# For instance, with compiler clang, address sanitizer and libFuzzer as a fuzzing engine, you should define
a77e8ab4 411# export CFLAGS="-fsanitize=address,fuzzer-no-link -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"
1857e6b2
PA
412# export LIB_FUZZING_ENGINE="-fsanitize=address"
413# export CC=clang
414# before running configure && make
415# You can adapt this with different compilers, sanitizers, and fuzzing engines
416ifndef LIB_FUZZING_ENGINE
417T_FUZZ_OBJS += t/fuzz/onefile.o
418endif
419T_FUZZ_PROGS = t/fuzz/fuzz_parseini
a77e8ab4
VF
420else # CFLAGS includes -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
421T_FUZZ_OBJS =
422T_FUZZ_PROGS =
423endif
1857e6b2 424
61f78f3a
JA
425T_OBJS = $(T_SMALLOC_OBJS)
426T_OBJS += $(T_IEEE_OBJS)
6ff38856 427T_OBJS += $(T_ZIPF_OBJS)
ad1f90aa 428T_OBJS += $(T_AXMAP_OBJS)
7a887ffe 429T_OBJS += $(T_LFSR_TEST_OBJS)
323f2086 430T_OBJS += $(T_GEN_RAND_OBJS)
40bafa33 431T_OBJS += $(T_BTRACE_FIO_OBJS)
e5bf5a88 432T_OBJS += $(T_DEDUPE_OBJS)
98996ef9 433T_OBJS += $(T_VS_OBJS)
6d5a9bc2 434T_OBJS += $(T_PIPE_ASYNC_OBJS)
ae46d0f5 435T_OBJS += $(T_MEMLOCK_OBJS)
dcbc7841 436T_OBJS += $(T_TT_OBJS)
e31b8288 437T_OBJS += $(T_IOU_RING_OBJS)
1857e6b2 438T_OBJS += $(T_FUZZ_OBJS)
6ff38856 439
824d6ff4 440ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
a1957954
BVA
441 T_DEDUPE_OBJS += $(WINDOWS_OBJS)
442 T_SMALLOC_OBJS += $(WINDOWS_OBJS)
443 T_LFSR_TEST_OBJS += $(WINDOWS_OBJS)
824d6ff4
BC
444endif
445
aa7bc282
JA
446T_TEST_PROGS = $(T_SMALLOC_PROGS)
447T_TEST_PROGS += $(T_IEEE_PROGS)
6ff38856 448T_PROGS += $(T_ZIPF_PROGS)
aa7bc282
JA
449T_TEST_PROGS += $(T_AXMAP_PROGS)
450T_TEST_PROGS += $(T_LFSR_TEST_PROGS)
323f2086 451T_TEST_PROGS += $(T_GEN_RAND_PROGS)
40bafa33 452T_PROGS += $(T_BTRACE_FIO_PROGS)
dd75d6d0 453ifdef CONFIG_ZLIB
e5bf5a88 454T_PROGS += $(T_DEDUPE_PROGS)
dd75d6d0 455endif
98996ef9 456T_PROGS += $(T_VS_PROGS)
5ad80fa7 457T_TEST_PROGS += $(T_MEMLOCK_PROGS)
15eca9aa 458ifdef CONFIG_PREAD
5ad80fa7 459T_TEST_PROGS += $(T_PIPE_ASYNC_PROGS)
15eca9aa 460endif
5ad80fa7
BVA
461ifneq (,$(findstring Linux,$(CONFIG_TARGET_OS)))
462T_TEST_PROGS += $(T_IOU_RING_PROGS)
463endif
1857e6b2 464T_TEST_PROGS += $(T_FUZZ_PROGS)
e5bf5a88
JA
465
466PROGS += $(T_PROGS)
3427207d 467
b8b0e1ee
TK
468ifdef CONFIG_HAVE_CUNIT
469UT_OBJS = unittests/unittest.o
e37155ef 470UT_OBJS += unittests/lib/memalign.o
53916bbd 471UT_OBJS += unittests/lib/num2str.o
ce875031 472UT_OBJS += unittests/lib/strntol.o
cdcd7e99 473UT_OBJS += unittests/oslib/strlcat.o
2f84d0c7 474UT_OBJS += unittests/oslib/strndup.o
d2292c7d 475UT_OBJS += unittests/oslib/strcasestr.o
4d3c2cc5 476UT_OBJS += unittests/oslib/strsep.o
e37155ef 477UT_TARGET_OBJS = lib/memalign.o
53916bbd 478UT_TARGET_OBJS += lib/num2str.o
ce875031 479UT_TARGET_OBJS += lib/strntol.o
cdcd7e99 480UT_TARGET_OBJS += oslib/strlcat.o
2f84d0c7 481UT_TARGET_OBJS += oslib/strndup.o
d2292c7d 482UT_TARGET_OBJS += oslib/strcasestr.o
4d3c2cc5 483UT_TARGET_OBJS += oslib/strsep.o
b8b0e1ee
TK
484UT_PROGS = unittests/unittest
485else
486UT_OBJS =
487UT_TARGET_OBJS =
488UT_PROGS =
489endif
490
4c3ecec4
JA
491ifneq ($(findstring $(MAKEFLAGS),s),s)
492ifndef V
493 QUIET_CC = @echo ' ' CC $@;
79816cf7
JA
494 QUIET_LINK = @echo ' ' LINK $@;
495 QUIET_DEP = @echo ' ' DEP $@;
496 QUIET_YACC = @echo ' ' YACC $@;
497 QUIET_LEX = @echo ' ' LEX $@;
4c3ecec4
JA
498endif
499endif
500
a8168a22
JA
501ifeq ($(CONFIG_TARGET_OS), SunOS)
502 INSTALL = ginstall
503else
504 INSTALL = install
505endif
020d54bd 506prefix = $(INSTALL_PREFIX)
c1d5725e 507bindir = $(prefix)/bin
5a8a6a03 508libdir = $(prefix)/lib/fio
bcdf7c58 509
53cd4eee 510ifeq ($(CONFIG_TARGET_OS), Darwin)
bcdf7c58 511mandir = /usr/share/man
eab4af4e 512sharedir = /usr/share/fio
bcdf7c58 513else
d60e92d1 514mandir = $(prefix)/man
eab4af4e 515sharedir = $(prefix)/share/fio
bcdf7c58 516endif
c1d5725e 517
8a2cf08d 518all: $(PROGS) $(T_TEST_PROGS) $(UT_PROGS) $(SCRIPTS) $(ENGS_OBJS) FORCE
f84622e9 519
92ddd6b6 520.PHONY: all install clean test
3d43382c
JA
521.PHONY: FORCE cscope
522
9e85c34e 523%.o : %.c
c61a3a44 524 @mkdir -p $(dir $@)
4feafb1e 525 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
c61a3a44 526 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SRCDIR)/$*.c > $*.d
f67d6ee2
JA
527 @mv -f $*.d $*.d.tmp
528 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
97f3eddc
BVA
529 @if type -p fmt >/dev/null 2>&1; then \
530 sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -w 1 | \
531 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d; \
532 else \
533 sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | \
534 tr -cs "[:graph:]" "\n" | \
535 sed -e 's/^ *//' -e '/^$$/ d' -e 's/$$/:/' >> $*.d; \
536 fi
f67d6ee2 537 @rm -f $*.d.tmp
e52947d1 538
b470a02c 539ifdef CONFIG_ARITHMETIC
79816cf7 540lex.yy.c: exp/expression-parser.l
63bda378 541ifdef CONFIG_LEX_USE_O
c61a3a44 542 $(QUIET_LEX)$(LEX) -o $@ $<
63bda378
JA
543else
544 $(QUIET_LEX)$(LEX) $<
545endif
79816cf7 546
6f1a2459
AF
547ifneq (,$(findstring -Wimplicit-fallthrough,$(CFLAGS)))
548LEX_YY_CFLAGS := -Wno-implicit-fallthrough
549endif
550
b470a02c 551lex.yy.o: lex.yy.c y.tab.h
6f1a2459 552 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(LEX_YY_CFLAGS) -c $<
b470a02c
SC
553
554y.tab.o: y.tab.c y.tab.h
555 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
556
557y.tab.c: exp/expression-parser.y
c61a3a44 558 $(QUIET_YACC)$(YACC) -o $@ -l -d -b y $<
b470a02c 559
dc68fd2c 560y.tab.h: y.tab.c
b470a02c 561
c9fa1c8d
SC
562lexer.h: lex.yy.c
563
c879ba67
JA
564exp/test-expression-parser.o: exp/test-expression-parser.c
565 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
566exp/test-expression-parser: exp/test-expression-parser.o
d6e082e7 567 $(QUIET_LINK)$(CC) $(LDFLAGS) $< y.tab.o lex.yy.o -o $@ $(LIBS)
c879ba67 568
b470a02c
SC
569parse.o: lex.yy.o y.tab.o
570endif
571
c61a3a44 572init.o: init.c FIO-VERSION-FILE
32d4cc61 573
f762cef9 574gcompat.o: gcompat.c gcompat.h
c61a3a44 575 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
f762cef9 576
9af4a244 577goptions.o: goptions.c goptions.h
c61a3a44 578 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
9af4a244 579
53e0e85d 580ghelpers.o: ghelpers.c ghelpers.h
c61a3a44 581 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
53e0e85d 582
41666588 583gerror.o: gerror.c gerror.h
c61a3a44 584 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
41666588 585
1252d8f2 586gclient.o: gclient.c gclient.h
c61a3a44 587 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
1252d8f2 588
53e0e85d 589gfio.o: gfio.c ghelpers.c
c61a3a44 590 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
70d07ce1 591
53e0e85d 592graph.o: graph.c graph.h
c61a3a44 593 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
af58ef32 594
ee2f55b2 595cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
c61a3a44 596 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
ee2f55b2 597
bf3f7027 598printing.o: printing.c printing.h
c61a3a44 599 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
bf3f7027 600
f3e769a4 601t/io_uring.o: os/linux/io_uring.h
e31b8288 602t/io_uring: $(T_IOU_RING_OBJS)
d6e082e7 603 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_IOU_RING_OBJS) $(LIBS)
c9fb4c5b 604
6d5a9bc2 605t/read-to-pipe-async: $(T_PIPE_ASYNC_OBJS)
d6e082e7 606 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_PIPE_ASYNC_OBJS) $(LIBS)
6d5a9bc2 607
ae46d0f5 608t/memlock: $(T_MEMLOCK_OBJS)
d6e082e7 609 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_MEMLOCK_OBJS) $(LIBS)
ae46d0f5 610
61f78f3a 611t/stest: $(T_SMALLOC_OBJS)
d6e082e7 612 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
61f78f3a
JA
613
614t/ieee754: $(T_IEEE_OBJS)
d6e082e7 615 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
fbc2792b 616
33765372 617fio: $(FIO_OBJS)
d6e082e7 618 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(HDFSLIB)
4c3ecec4 619
1857e6b2
PA
620t/fuzz/fuzz_parseini: $(T_FUZZ_OBJS)
621ifndef LIB_FUZZING_ENGINE
622 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_FUZZ_OBJS) $(LIBS) $(HDFSLIB)
623else
624 $(QUIET_LINK)$(CXX) $(LDFLAGS) -o $@ $(T_FUZZ_OBJS) $(LIB_FUZZING_ENGINE) $(LIBS) $(HDFSLIB)
625endif
626
70d07ce1 627gfio: $(GFIO_OBJS)
1527dc50 628 $(QUIET_LINK)$(CC) $(filter-out -static, $(LDFLAGS)) -o gfio $(GFIO_OBJS) $(LIBS) $(GFIO_LIBS) $(GTK_LDFLAGS) $(HDFSLIB)
70d07ce1 629
aa7bc282 630t/fio-genzipf: $(T_ZIPF_OBJS)
d6e082e7 631 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
6ff38856 632
ad1f90aa 633t/axmap: $(T_AXMAP_OBJS)
d6e082e7 634 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
ad1f90aa 635
7a887ffe 636t/lfsr-test: $(T_LFSR_TEST_OBJS)
d6e082e7 637 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
7a887ffe 638
323f2086 639t/gen-rand: $(T_GEN_RAND_OBJS)
d6e082e7 640 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_GEN_RAND_OBJS) $(LIBS)
323f2086 641
40bafa33 642ifeq ($(CONFIG_TARGET_OS), Linux)
aa7bc282 643t/fio-btrace2fio: $(T_BTRACE_FIO_OBJS)
d6e082e7 644 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_BTRACE_FIO_OBJS) $(LIBS)
40bafa33
JA
645endif
646
dd75d6d0 647ifdef CONFIG_ZLIB
aa7bc282 648t/fio-dedupe: $(T_DEDUPE_OBJS)
d6e082e7 649 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_DEDUPE_OBJS) $(LIBS)
dd75d6d0 650endif
bf481692 651
98996ef9 652t/fio-verify-state: $(T_VS_OBJS)
d6e082e7 653 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_VS_OBJS) $(LIBS)
98996ef9 654
dcbc7841 655t/time-test: $(T_TT_OBJS)
d6e082e7 656 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_TT_OBJS) $(LIBS)
dcbc7841 657
b8b0e1ee
TK
658ifdef CONFIG_HAVE_CUNIT
659unittests/unittest: $(UT_OBJS) $(UT_TARGET_OBJS)
d6e082e7 660 $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(UT_OBJS) $(UT_TARGET_OBJS) -lcunit $(LIBS)
b8b0e1ee
TK
661endif
662
3d43382c 663clean: FORCE
c43992f7 664 @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] t/*/*.[do] unittests/*.[do] unittests/*/*.[do] config-host.mak config-host.h y.tab.[ch] lex.yy.c exp/*.[do] lexer.h
b084bde6 665 @rm -f t/fio-btrace2fio t/io_uring t/read-to-pipe-async
0b422574 666 @rm -rf doc/output
45f944b9
JA
667
668distclean: clean FORCE
d1f6fcad 669 @rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf fiologparser_hist.pdf
ebac4655 670
592ef98a 671cscope:
366badd3 672 @cscope -b -R
592ef98a 673
1378cc68
EV
674tools/plot/fio2gnuplot.1:
675 @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot > tools/plot/fio2gnuplot.1
676
7788b76f
JA
677doc: tools/plot/fio2gnuplot.1
678 @man -t ./fio.1 | ps2pdf - fio.pdf
679 @man -t tools/fio_generate_plots.1 | ps2pdf - fio_generate_plots.pdf
680 @man -t tools/plot/fio2gnuplot.1 | ps2pdf - fio2gnuplot.pdf
d1f6fcad 681 @man -t tools/hist/fiologparser_hist.py.1 | ps2pdf - fiologparser_hist.pdf
7788b76f 682
92ddd6b6 683test: fio
dbf2214c 684 ./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 685
36d108a4
BVA
686fulltest:
687 sudo modprobe null_blk && \
688 if [ ! -e /usr/include/libzbc/zbc.h ]; then \
7c8e6725 689 git clone https://github.com/westerndigitalcorporation/libzbc && \
36d108a4
BVA
690 (cd libzbc && \
691 ./autogen.sh && \
692 ./configure --prefix=/usr && \
693 make -j && \
694 sudo make install) \
695 fi && \
037b2b50 696 sudo t/zbd/run-tests-against-nullb -s 1 && \
36d108a4 697 if [ -e /sys/module/null_blk/parameters/zoned ]; then \
037b2b50
DF
698 sudo t/zbd/run-tests-against-nullb -s 2; \
699 sudo t/zbd/run-tests-against-nullb -s 4; \
36d108a4
BVA
700 fi
701
8a2cf08d 702install: $(PROGS) $(SCRIPTS) $(ENGS_OBJS) tools/plot/fio2gnuplot.1 FORCE
513ba3f7 703 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
ebac4655 704 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
5a8a6a03
YK
705ifdef CONFIG_DYNAMIC_ENGINES
706 $(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
707 $(INSTALL) -m 755 $(SRCDIR)/engines/*.so $(DESTDIR)$(libdir)
708endif
d60e92d1 709 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
c61a3a44
JF
710 $(INSTALL) -m 644 $(SRCDIR)/fio.1 $(DESTDIR)$(mandir)/man1
711 $(INSTALL) -m 644 $(SRCDIR)/tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
712 $(INSTALL) -m 644 $(SRCDIR)/tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1
d1f6fcad 713 $(INSTALL) -m 644 $(SRCDIR)/tools/hist/fiologparser_hist.py.1 $(DESTDIR)$(mandir)/man1
eab4af4e 714 $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
c61a3a44 715 $(INSTALL) -m 644 $(SRCDIR)/tools/plot/*gpm $(DESTDIR)$(sharedir)/
36d108a4
BVA
716
717.PHONY: test fulltest