Merge branch 'one-core' of https://github.com/ErwanAliasr1/fio
[fio.git] / Makefile
1 ifeq ($(SRCDIR),)
2 SRCDIR := .
3 endif
4
5 VPATH := $(SRCDIR)
6
7 all: fio
8
9 config-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
18 ifneq ($(MAKECMDGOALS),clean)
19 include config-host.mak
20 endif
21
22 DEBUGFLAGS = -DFIO_INC_DEBUG
23 CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INTERNAL $(DEBUGFLAGS)
24 OPTFLAGS= -g -ffast-math
25 FIO_CFLAGS= -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS) -I. -I$(SRCDIR)
26 LIBS    += -lm $(EXTLIBS)
27 PROGS   = fio
28 SCRIPTS = $(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)
29
30 ifndef CONFIG_FIO_NO_OPT
31   FIO_CFLAGS += -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
32 endif
33 ifdef CONFIG_BUILD_NATIVE
34   FIO_CFLAGS += -march=native
35 endif
36
37 ifdef CONFIG_PDB
38   LINK_PDBFILE ?= -Wl,-pdb,$(dir $@)/$(basename $(@F)).pdb
39   FIO_CFLAGS += -gcodeview
40   LDFLAGS += -fuse-ld=lld $(LINK_PDBFILE)
41 endif
42
43 # If clang, do not use builtin stpcpy as it breaks the build
44 ifeq ($(CC),clang)
45   FIO_CFLAGS += -fno-builtin-stpcpy
46 endif
47
48 ifdef CONFIG_GFIO
49   PROGS += gfio
50 endif
51
52 SOURCE :=       $(sort $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/crc/*.c)) \
53                 $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/lib/*.c))) \
54                 gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
55                 eta.c verify.c memory.c io_u.c parse.c fio_sem.c rwlock.c \
56                 pshared.c options.c \
57                 smalloc.c filehash.c profile.c debug.c engines/cpu.c \
58                 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
59                 engines/ftruncate.c engines/filecreate.c engines/filestat.c engines/filedelete.c \
60                 engines/exec.c \
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 \
63                 profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \
64                 workqueue.c rate-submit.c optgroup.c helper_thread.c \
65                 steadystate.c zone-dist.c zbd.c dedupe.c
66
67 ifdef CONFIG_LIBHDFS
68   HDFSFLAGS= -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux -I $(FIO_LIBHDFS_INCLUDE)
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
70   FIO_CFLAGS += $(HDFSFLAGS)
71   SOURCE += engines/libhdfs.c
72 endif
73
74 ifdef CONFIG_LIBISCSI
75   libiscsi_SRCS = engines/libiscsi.c
76   libiscsi_LIBS = $(LIBISCSI_LIBS)
77   libiscsi_CFLAGS = $(LIBISCSI_CFLAGS)
78   ENGINES += libiscsi
79 endif
80
81 ifdef CONFIG_LIBNBD
82   nbd_SRCS = engines/nbd.c
83   nbd_LIBS = $(LIBNBD_LIBS)
84   nbd_CFLAGS = $(LIBNBD_CFLAGS)
85   ENGINES += nbd
86 endif
87
88 ifdef CONFIG_LIBNFS
89   CFLAGS += $(LIBNFS_CFLAGS)
90   LIBS += $(LIBNFS_LIBS)
91   SOURCE += engines/nfs.c
92 endif
93
94 ifdef CONFIG_64BIT
95   CPPFLAGS += -DBITS_PER_LONG=64
96 else ifdef CONFIG_32BIT
97   CPPFLAGS += -DBITS_PER_LONG=32
98 endif
99 ifdef CONFIG_LIBAIO
100   libaio_SRCS = engines/libaio.c
101   libaio_LIBS = -laio
102   ENGINES += libaio
103 endif
104 ifdef CONFIG_RDMA
105   rdma_SRCS = engines/rdma.c
106   rdma_LIBS = -libverbs -lrdmacm
107   ENGINES += rdma
108 endif
109 ifdef 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
114 endif
115 ifdef 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
120 endif
121 ifdef librpma_fio_SRCS
122   SOURCE += $(librpma_fio_SRCS)
123 endif
124 ifdef CONFIG_POSIXAIO
125   SOURCE += engines/posixaio.c
126 endif
127 ifdef CONFIG_LINUX_FALLOCATE
128   SOURCE += engines/falloc.c
129 endif
130 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
131   SOURCE += engines/e4defrag.c
132 endif
133 ifdef CONFIG_LIBCUFILE
134   SOURCE += engines/libcufile.c
135 endif
136 ifdef CONFIG_LINUX_SPLICE
137   SOURCE += engines/splice.c
138 endif
139 ifdef CONFIG_SOLARISAIO
140   SOURCE += engines/solarisaio.c
141 endif
142 ifdef CONFIG_WINDOWSAIO
143   SOURCE += engines/windowsaio.c
144 endif
145 ifdef CONFIG_RADOS
146   rados_SRCS = engines/rados.c
147   rados_LIBS = -lrados
148   ENGINES += rados
149 endif
150 ifdef CONFIG_RBD
151   rbd_SRCS = engines/rbd.c
152   rbd_LIBS = -lrbd -lrados
153   ENGINES += rbd
154 endif
155 ifdef CONFIG_HTTP
156   http_SRCS = engines/http.c
157   http_LIBS = -lcurl -lssl -lcrypto
158   ENGINES += http
159 endif
160 ifdef CONFIG_DFS
161   dfs_SRCS = engines/dfs.c
162   dfs_LIBS = -luuid -ldaos -ldfs
163   ENGINES += dfs
164 endif
165 SOURCE += oslib/asprintf.c
166 ifndef CONFIG_STRSEP
167   SOURCE += oslib/strsep.c
168 endif
169 ifndef CONFIG_STRCASESTR
170   SOURCE += oslib/strcasestr.c
171 endif
172 ifndef CONFIG_STRLCAT
173   SOURCE += oslib/strlcat.c
174 endif
175 ifndef CONFIG_HAVE_STRNDUP
176   SOURCE += oslib/strndup.c
177 endif
178 ifndef CONFIG_GETOPT_LONG_ONLY
179   SOURCE += oslib/getopt_long.c
180 endif
181 ifndef CONFIG_INET_ATON
182   SOURCE += oslib/inet_aton.c
183 endif
184 ifndef CONFIG_HAVE_STATX
185   SOURCE += oslib/statx.c
186 endif
187 ifdef CONFIG_GFAPI
188   SOURCE += engines/glusterfs.c
189   SOURCE += engines/glusterfs_sync.c
190   SOURCE += engines/glusterfs_async.c
191   LIBS += -lgfapi -lglusterfs
192   ifdef CONFIG_GF_FADVISE
193     FIO_CFLAGS += "-DGFAPI_USE_FADVISE"
194   endif
195 endif
196 ifdef CONFIG_MTD
197   SOURCE += engines/mtd.c
198   SOURCE += oslib/libmtd.c
199   SOURCE += oslib/libmtd_legacy.c
200 endif
201 ifdef CONFIG_PMEMBLK
202   pmemblk_SRCS = engines/pmemblk.c
203   pmemblk_LIBS = -lpmemblk
204   ENGINES += pmemblk
205 endif
206 ifdef CONFIG_LINUX_DEVDAX
207   dev-dax_SRCS = engines/dev-dax.c
208   dev-dax_LIBS = -lpmem
209   ENGINES += dev-dax
210 endif
211 ifdef CONFIG_LIBPMEM
212   libpmem_SRCS = engines/libpmem.c
213   libpmem_LIBS = -lpmem
214   ENGINES += libpmem
215 endif
216 ifdef CONFIG_IME
217   SOURCE += engines/ime.c
218 endif
219 ifdef CONFIG_LIBZBC
220   libzbc_SRCS = engines/libzbc.c
221   libzbc_LIBS = -lzbc
222   ENGINES += libzbc
223 endif
224
225 ifeq ($(CONFIG_TARGET_OS), Linux)
226   SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
227                 oslib/linux-dev-lookup.c engines/io_uring.c
228 ifdef CONFIG_HAS_BLKZONED
229   SOURCE += oslib/linux-blkzoned.c
230 endif
231   LIBS += -lpthread -ldl
232   LDFLAGS += -rdynamic
233 endif
234 ifeq ($(CONFIG_TARGET_OS), Android)
235   SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c profiles/tiobench.c \
236                 oslib/linux-dev-lookup.c
237 ifdef CONFIG_HAS_BLKZONED
238   SOURCE += oslib/linux-blkzoned.c
239 endif
240   LIBS += -ldl -llog
241   LDFLAGS += -rdynamic
242 endif
243 ifeq ($(CONFIG_TARGET_OS), SunOS)
244   LIBS   += -lpthread -ldl
245   CPPFLAGS += -D__EXTENSIONS__
246 endif
247 ifeq ($(CONFIG_TARGET_OS), FreeBSD)
248   SOURCE += trim.c
249   LIBS   += -lpthread -lrt
250   LDFLAGS += -rdynamic
251 endif
252 ifeq ($(CONFIG_TARGET_OS), OpenBSD)
253   LIBS   += -lpthread
254   LDFLAGS += -rdynamic
255 endif
256 ifeq ($(CONFIG_TARGET_OS), NetBSD)
257   LIBS   += -lpthread -lrt
258   LDFLAGS += -rdynamic
259 endif
260 ifeq ($(CONFIG_TARGET_OS), DragonFly)
261   SOURCE += trim.c
262   LIBS   += -lpthread -lrt
263   LDFLAGS += -rdynamic
264 endif
265 ifeq ($(CONFIG_TARGET_OS), AIX)
266   LIBS   += -lpthread -ldl -lrt
267   CPPFLAGS += -D_LARGE_FILES -D__ppc__
268   LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
269 endif
270 ifeq ($(CONFIG_TARGET_OS), HP-UX)
271   LIBS   += -lpthread -ldl -lrt
272   FIO_CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
273 endif
274 ifeq ($(CONFIG_TARGET_OS), Darwin)
275   LIBS   += -lpthread -ldl
276 endif
277 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
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
280   LIBS   += -lpthread -lpsapi -lws2_32 -lssp
281   FIO_CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
282 endif
283
284 ifdef CONFIG_DYNAMIC_ENGINES
285  DYNAMIC_ENGS := $(ENGINES)
286 define engine_template =
287 $(1)_OBJS := $$($(1)_SRCS:.c=.o)
288 $$($(1)_OBJS): CFLAGS := -fPIC $$($(1)_CFLAGS) $(CFLAGS)
289 engines/fio-$(1).so: $$($(1)_OBJS)
290         $$(QUIET_LINK)$(CC) -shared -rdynamic -fPIC -Wl,-soname,fio-$(1).so.1 -o $$@ $$< $$($(1)_LIBS)
291 ENGS_OBJS += engines/fio-$(1).so
292 endef
293 else # !CONFIG_DYNAMIC_ENGINES
294 define engine_template =
295 SOURCE += $$($(1)_SRCS)
296 LIBS += $$($(1)_LIBS)
297 override CFLAGS += $$($(1)_CFLAGS)
298 endef
299 endif
300
301 FIO-VERSION-FILE: FORCE
302         @$(SHELL) $(SRCDIR)/FIO-VERSION-GEN
303 -include FIO-VERSION-FILE
304
305 override CFLAGS := -DFIO_VERSION='"$(FIO_VERSION)"' $(FIO_CFLAGS) $(CFLAGS)
306
307 $(foreach eng,$(ENGINES),$(eval $(call engine_template,$(eng))))
308
309 OBJS := $(SOURCE:.c=.o)
310
311 FIO_OBJS = $(OBJS) fio.o
312
313 GFIO_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
316 ifdef CONFIG_ARITHMETIC
317 FIO_OBJS += lex.yy.o y.tab.o
318 GFIO_OBJS += lex.yy.o y.tab.o
319 endif
320
321 -include $(OBJS:.o=.d)
322
323 T_SMALLOC_OBJS = t/stest.o
324 T_SMALLOC_OBJS += gettime.o fio_sem.o pshared.o smalloc.o t/log.o t/debug.o \
325                   t/arch.o
326 T_SMALLOC_PROGS = t/stest
327
328 T_IEEE_OBJS = t/ieee754.o
329 T_IEEE_OBJS += lib/ieee754.o
330 T_IEEE_PROGS = t/ieee754
331
332 T_ZIPF_OBS = t/genzipf.o
333 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/pattern.o lib/zipf.o \
334                 lib/strntol.o lib/gauss.o t/genzipf.o oslib/strcasestr.o \
335                 oslib/strndup.o
336 T_ZIPF_PROGS = t/fio-genzipf
337
338 T_AXMAP_OBJS = t/axmap.o
339 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
340 T_AXMAP_PROGS = t/axmap
341
342 T_LFSR_TEST_OBJS = t/lfsr-test.o
343 T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o fio_sem.o pshared.o \
344                     t/log.o t/debug.o t/arch.o
345 T_LFSR_TEST_PROGS = t/lfsr-test
346
347 T_GEN_RAND_OBJS = t/gen-rand.o
348 T_GEN_RAND_OBJS += t/log.o t/debug.o lib/rand.o lib/pattern.o lib/strntol.o \
349                         oslib/strcasestr.o oslib/strndup.o
350 T_GEN_RAND_PROGS = t/gen-rand
351
352 ifeq ($(CONFIG_TARGET_OS), Linux)
353 T_BTRACE_FIO_OBJS = t/btrace2fio.o
354 T_BTRACE_FIO_OBJS += fifo.o lib/flist_sort.o t/log.o oslib/linux-dev-lookup.o
355 T_BTRACE_FIO_PROGS = t/fio-btrace2fio
356 endif
357
358 T_DEDUPE_OBJS = t/dedupe.o
359 T_DEDUPE_OBJS += lib/rbtree.o t/log.o fio_sem.o pshared.o smalloc.o gettime.o \
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
363 T_DEDUPE_PROGS = t/fio-dedupe
364
365 T_VS_OBJS = t/verify-state.o t/log.o crc/crc32c.o crc/crc32c-intel.o crc/crc32c-arm64.o t/debug.o
366 T_VS_PROGS = t/fio-verify-state
367
368 T_PIPE_ASYNC_OBJS = t/read-to-pipe-async.o
369 T_PIPE_ASYNC_PROGS = t/read-to-pipe-async
370
371 T_IOU_RING_OBJS = t/io_uring.o
372 T_IOU_RING_OBJS += t/arch.o
373 T_IOU_RING_PROGS = t/io_uring
374
375 T_MEMLOCK_OBJS = t/memlock.o
376 T_MEMLOCK_PROGS = t/memlock
377
378 T_TT_OBJS = t/time-test.o
379 T_TT_PROGS = t/time-test
380
381 T_FUZZ_OBJS = t/fuzz/fuzz_parseini.o
382 T_FUZZ_OBJS += $(OBJS)
383 ifdef CONFIG_ARITHMETIC
384 T_FUZZ_OBJS += lex.yy.o y.tab.o
385 endif
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
393 ifndef LIB_FUZZING_ENGINE
394 T_FUZZ_OBJS += t/fuzz/onefile.o
395 endif
396 T_FUZZ_PROGS = t/fuzz/fuzz_parseini
397
398 T_OBJS = $(T_SMALLOC_OBJS)
399 T_OBJS += $(T_IEEE_OBJS)
400 T_OBJS += $(T_ZIPF_OBJS)
401 T_OBJS += $(T_AXMAP_OBJS)
402 T_OBJS += $(T_LFSR_TEST_OBJS)
403 T_OBJS += $(T_GEN_RAND_OBJS)
404 T_OBJS += $(T_BTRACE_FIO_OBJS)
405 T_OBJS += $(T_DEDUPE_OBJS)
406 T_OBJS += $(T_VS_OBJS)
407 T_OBJS += $(T_PIPE_ASYNC_OBJS)
408 T_OBJS += $(T_MEMLOCK_OBJS)
409 T_OBJS += $(T_TT_OBJS)
410 T_OBJS += $(T_IOU_RING_OBJS)
411 T_OBJS += $(T_FUZZ_OBJS)
412
413 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
414     T_DEDUPE_OBJS += $(WINDOWS_OBJS)
415     T_SMALLOC_OBJS += $(WINDOWS_OBJS)
416     T_LFSR_TEST_OBJS += $(WINDOWS_OBJS)
417 endif
418
419 T_TEST_PROGS = $(T_SMALLOC_PROGS)
420 T_TEST_PROGS += $(T_IEEE_PROGS)
421 T_PROGS += $(T_ZIPF_PROGS)
422 T_TEST_PROGS += $(T_AXMAP_PROGS)
423 T_TEST_PROGS += $(T_LFSR_TEST_PROGS)
424 T_TEST_PROGS += $(T_GEN_RAND_PROGS)
425 T_PROGS += $(T_BTRACE_FIO_PROGS)
426 T_PROGS += $(T_DEDUPE_PROGS)
427 T_PROGS += $(T_VS_PROGS)
428 T_TEST_PROGS += $(T_MEMLOCK_PROGS)
429 ifdef CONFIG_PREAD
430 T_TEST_PROGS += $(T_PIPE_ASYNC_PROGS)
431 endif
432 ifneq (,$(findstring Linux,$(CONFIG_TARGET_OS)))
433 T_TEST_PROGS += $(T_IOU_RING_PROGS)
434 endif
435 T_TEST_PROGS += $(T_FUZZ_PROGS)
436
437 PROGS += $(T_PROGS)
438
439 ifdef CONFIG_HAVE_CUNIT
440 UT_OBJS = unittests/unittest.o
441 UT_OBJS += unittests/lib/memalign.o
442 UT_OBJS += unittests/lib/num2str.o
443 UT_OBJS += unittests/lib/strntol.o
444 UT_OBJS += unittests/oslib/strlcat.o
445 UT_OBJS += unittests/oslib/strndup.o
446 UT_OBJS += unittests/oslib/strcasestr.o
447 UT_OBJS += unittests/oslib/strsep.o
448 UT_TARGET_OBJS = lib/memalign.o
449 UT_TARGET_OBJS += lib/num2str.o
450 UT_TARGET_OBJS += lib/strntol.o
451 UT_TARGET_OBJS += oslib/strlcat.o
452 UT_TARGET_OBJS += oslib/strndup.o
453 UT_TARGET_OBJS += oslib/strcasestr.o
454 UT_TARGET_OBJS += oslib/strsep.o
455 UT_PROGS = unittests/unittest
456 else
457 UT_OBJS =
458 UT_TARGET_OBJS =
459 UT_PROGS =
460 endif
461
462 ifneq ($(findstring $(MAKEFLAGS),s),s)
463 ifndef V
464         QUIET_CC        = @echo '   ' CC $@;
465         QUIET_LINK      = @echo ' ' LINK $@;
466         QUIET_DEP       = @echo '  ' DEP $@;
467         QUIET_YACC      = @echo ' ' YACC $@;
468         QUIET_LEX       = @echo '  ' LEX $@;
469 endif
470 endif
471
472 ifeq ($(CONFIG_TARGET_OS), SunOS)
473         INSTALL = ginstall
474 else
475         INSTALL = install
476 endif
477 prefix = $(INSTALL_PREFIX)
478 bindir = $(prefix)/bin
479 libdir = $(prefix)/lib/fio
480
481 ifeq ($(CONFIG_TARGET_OS), Darwin)
482 mandir = /usr/share/man
483 sharedir = /usr/share/fio
484 else
485 mandir = $(prefix)/man
486 sharedir = $(prefix)/share/fio
487 endif
488
489 all: $(PROGS) $(T_TEST_PROGS) $(UT_PROGS) $(SCRIPTS) $(ENGS_OBJS) FORCE
490
491 .PHONY: all install clean test
492 .PHONY: FORCE cscope
493
494 %.o : %.c
495         @mkdir -p $(dir $@)
496         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
497         @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SRCDIR)/$*.c > $*.d
498         @mv -f $*.d $*.d.tmp
499         @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
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
508         @rm -f $*.d.tmp
509
510 ifdef CONFIG_ARITHMETIC
511 lex.yy.c: exp/expression-parser.l
512 ifdef CONFIG_LEX_USE_O
513         $(QUIET_LEX)$(LEX) -o $@ $<
514 else
515         $(QUIET_LEX)$(LEX) $<
516 endif
517
518 lex.yy.o: lex.yy.c y.tab.h
519         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
520
521 y.tab.o: y.tab.c y.tab.h
522         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
523
524 y.tab.c: exp/expression-parser.y
525         $(QUIET_YACC)$(YACC) -o $@ -l -d -b y $<
526
527 y.tab.h: y.tab.c
528
529 lexer.h: lex.yy.c
530
531 exp/test-expression-parser.o: exp/test-expression-parser.c
532         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
533 exp/test-expression-parser: exp/test-expression-parser.o
534         $(QUIET_LINK)$(CC) $(LDFLAGS) $< y.tab.o lex.yy.o -o $@ $(LIBS)
535
536 parse.o: lex.yy.o y.tab.o
537 endif
538
539 init.o: init.c FIO-VERSION-FILE
540
541 gcompat.o: gcompat.c gcompat.h
542         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
543
544 goptions.o: goptions.c goptions.h
545         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
546
547 ghelpers.o: ghelpers.c ghelpers.h
548         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
549
550 gerror.o: gerror.c gerror.h
551         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
552
553 gclient.o: gclient.c gclient.h
554         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
555
556 gfio.o: gfio.c ghelpers.c
557         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
558
559 graph.o: graph.c graph.h
560         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
561
562 cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
563         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
564
565 printing.o: printing.c printing.h
566         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
567
568 t/io_uring.o: os/linux/io_uring.h
569 t/io_uring: $(T_IOU_RING_OBJS)
570         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_IOU_RING_OBJS) $(LIBS)
571
572 t/read-to-pipe-async: $(T_PIPE_ASYNC_OBJS)
573         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_PIPE_ASYNC_OBJS) $(LIBS)
574
575 t/memlock: $(T_MEMLOCK_OBJS)
576         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_MEMLOCK_OBJS) $(LIBS)
577
578 t/stest: $(T_SMALLOC_OBJS)
579         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
580
581 t/ieee754: $(T_IEEE_OBJS)
582         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
583
584 fio: $(FIO_OBJS)
585         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(HDFSLIB)
586
587 t/fuzz/fuzz_parseini: $(T_FUZZ_OBJS)
588 ifndef LIB_FUZZING_ENGINE
589         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_FUZZ_OBJS) $(LIBS) $(HDFSLIB)
590 else
591         $(QUIET_LINK)$(CXX) $(LDFLAGS) -o $@ $(T_FUZZ_OBJS) $(LIB_FUZZING_ENGINE) $(LIBS) $(HDFSLIB)
592 endif
593
594 gfio: $(GFIO_OBJS)
595         $(QUIET_LINK)$(CC) $(filter-out -static, $(LDFLAGS)) -o gfio $(GFIO_OBJS) $(LIBS) $(GFIO_LIBS) $(GTK_LDFLAGS) $(HDFSLIB)
596
597 t/fio-genzipf: $(T_ZIPF_OBJS)
598         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
599
600 t/axmap: $(T_AXMAP_OBJS)
601         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
602
603 t/lfsr-test: $(T_LFSR_TEST_OBJS)
604         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
605
606 t/gen-rand: $(T_GEN_RAND_OBJS)
607         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_GEN_RAND_OBJS) $(LIBS)
608
609 ifeq ($(CONFIG_TARGET_OS), Linux)
610 t/fio-btrace2fio: $(T_BTRACE_FIO_OBJS)
611         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_BTRACE_FIO_OBJS) $(LIBS)
612 endif
613
614 t/fio-dedupe: $(T_DEDUPE_OBJS)
615         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_DEDUPE_OBJS) $(LIBS)
616
617 t/fio-verify-state: $(T_VS_OBJS)
618         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_VS_OBJS) $(LIBS)
619
620 t/time-test: $(T_TT_OBJS)
621         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_TT_OBJS) $(LIBS)
622
623 ifdef CONFIG_HAVE_CUNIT
624 unittests/unittest: $(UT_OBJS) $(UT_TARGET_OBJS)
625         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(UT_OBJS) $(UT_TARGET_OBJS) -lcunit $(LIBS)
626 endif
627
628 clean: FORCE
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
630         @rm -f t/fio-btrace2fio t/io_uring t/read-to-pipe-async
631         @rm -rf  doc/output
632
633 distclean: clean FORCE
634         @rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf fiologparser_hist.pdf
635
636 cscope:
637         @cscope -b -R
638
639 tools/plot/fio2gnuplot.1:
640         @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot >  tools/plot/fio2gnuplot.1
641
642 doc: 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
646         @man -t tools/hist/fiologparser_hist.py.1 | ps2pdf - fiologparser_hist.pdf
647
648 test: fio
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
650
651 fulltest:
652         sudo modprobe null_blk &&                                       \
653         if [ ! -e /usr/include/libzbc/zbc.h ]; then                     \
654           git clone https://github.com/westerndigitalcorporation/libzbc && \
655           (cd libzbc &&                                                 \
656            ./autogen.sh &&                                              \
657            ./configure --prefix=/usr &&                                 \
658            make -j &&                                                   \
659            sudo make install)                                           \
660         fi &&                                                           \
661         sudo t/zbd/run-tests-against-nullb -s 1 &&                      \
662         if [ -e /sys/module/null_blk/parameters/zoned ]; then           \
663                 sudo t/zbd/run-tests-against-nullb -s 2;                \
664                 sudo t/zbd/run-tests-against-nullb -s 4;                \
665         fi
666
667 install: $(PROGS) $(SCRIPTS) $(ENGS_OBJS) tools/plot/fio2gnuplot.1 FORCE
668         $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
669         $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
670 ifdef CONFIG_DYNAMIC_ENGINES
671         $(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
672         $(INSTALL) -m 755 $(SRCDIR)/engines/*.so $(DESTDIR)$(libdir)
673 endif
674         $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
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
678         $(INSTALL) -m 644 $(SRCDIR)/tools/hist/fiologparser_hist.py.1 $(DESTDIR)$(mandir)/man1
679         $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
680         $(INSTALL) -m 644 $(SRCDIR)/tools/plot/*gpm $(DESTDIR)$(sharedir)/
681
682 .PHONY: test fulltest