1 ifneq ($(wildcard config-host.mak),)
3 include config-host.mak
4 config-host-mak: configure
5 @echo $@ is out-of-date, running configure
6 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
9 ifneq ($(MAKECMDGOALS),clean)
10 @echo "Running configure for you..."
14 include config-host.mak
17 DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
18 CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INTERNAL $(DEBUGFLAGS)
19 OPTFLAGS= -O3 -g -ffast-math
20 CFLAGS = -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS)
21 LIBS += -lm $(EXTLIBS)
23 SCRIPTS = tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio
29 SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
30 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
31 lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
32 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
33 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
34 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
35 cconv.c lib/prio_tree.c json.c lib/zipf.c lib/axmap.c \
36 lib/lfsr.c gettime-thread.c helpers.c lib/flist_sort.c \
37 lib/hweight.c lib/getrusage.c idletime.c td_error.c \
38 profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \
39 lib/tp.c lib/bloom.c lib/gauss.c workqueue.c
42 HDFSFLAGS= -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux -I $(FIO_LIBHDFS_INCLUDE)
43 HDFSLIB= -Wl,-rpath $(JAVA_HOME)/jre/lib/amd64/server -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm $(FIO_LIBHDFS_LIB)/libhdfs.a
44 CFLAGS += $(HDFSFLAGS)
45 SOURCE += engines/libhdfs.c
48 ifdef CONFIG_64BIT_LLP64
49 CFLAGS += -DBITS_PER_LONG=32
52 CFLAGS += -DBITS_PER_LONG=64
55 CFLAGS += -DBITS_PER_LONG=32
58 SOURCE += engines/libaio.c
61 SOURCE += engines/rdma.c
64 SOURCE += engines/posixaio.c
66 ifdef CONFIG_LINUX_FALLOCATE
67 SOURCE += engines/falloc.c
69 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
70 SOURCE += engines/e4defrag.c
72 ifdef CONFIG_LINUX_SPLICE
73 SOURCE += engines/splice.c
76 SOURCE += engines/guasi.c
78 ifdef CONFIG_FUSION_AW
79 SOURCE += engines/fusion-aw.c
81 ifdef CONFIG_SOLARISAIO
82 SOURCE += engines/solarisaio.c
84 ifdef CONFIG_WINDOWSAIO
85 SOURCE += engines/windowsaio.c
88 SOURCE += engines/rbd.c
91 SOURCE += lib/strsep.c
93 ifndef CONFIG_STRCASESTR
94 SOURCE += lib/strcasestr.c
96 ifndef CONFIG_GETOPT_LONG_ONLY
97 SOURCE += lib/getopt_long.c
99 ifndef CONFIG_INET_ATON
100 SOURCE += lib/inet_aton.c
103 SOURCE += engines/glusterfs.c
104 SOURCE += engines/glusterfs_sync.c
105 SOURCE += engines/glusterfs_async.c
106 ifdef CONFIG_GF_FADVISE
107 CFLAGS += "-DGFAPI_USE_FADVISE"
111 SOURCE += engines/mtd.c
112 SOURCE += lib/libmtd.c
113 SOURCE += lib/libmtd_legacy.c
116 ifeq ($(CONFIG_TARGET_OS), Linux)
117 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
118 engines/binject.c lib/linux-dev-lookup.c
119 LIBS += -lpthread -ldl
122 ifeq ($(CONFIG_TARGET_OS), Android)
123 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c \
124 lib/linux-dev-lookup.c
128 ifeq ($(CONFIG_TARGET_OS), SunOS)
129 LIBS += -lpthread -ldl
130 CPPFLAGS += -D__EXTENSIONS__
132 ifeq ($(CONFIG_TARGET_OS), FreeBSD)
133 LIBS += -lpthread -lrt
136 ifeq ($(CONFIG_TARGET_OS), OpenBSD)
140 ifeq ($(CONFIG_TARGET_OS), NetBSD)
141 LIBS += -lpthread -lrt
144 ifeq ($(CONFIG_TARGET_OS), DragonFly)
145 LIBS += -lpthread -lrt
148 ifeq ($(CONFIG_TARGET_OS), AIX)
149 LIBS += -lpthread -ldl -lrt
150 CPPFLAGS += -D_LARGE_FILES -D__ppc__
151 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
153 ifeq ($(CONFIG_TARGET_OS), HP-UX)
154 LIBS += -lpthread -ldl -lrt
155 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
157 ifeq ($(CONFIG_TARGET_OS), Darwin)
158 LIBS += -lpthread -ldl
160 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
161 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
162 SOURCE += os/windows/posix.c
163 LIBS += -lpthread -lpsapi -lws2_32
164 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format -static
167 OBJS = $(SOURCE:.c=.o)
169 FIO_OBJS = $(OBJS) fio.o
171 GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
172 gclient.o gcompat.o cairo_text_helpers.o printing.o
174 ifdef CONFIG_ARITHMETIC
175 FIO_OBJS += lex.yy.o y.tab.o
176 GFIO_OBJS += lex.yy.o y.tab.o
179 -include $(OBJS:.o=.d)
181 T_SMALLOC_OBJS = t/stest.o
182 T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o t/debug.o
183 T_SMALLOC_PROGS = t/stest
185 T_IEEE_OBJS = t/ieee754.o
186 T_IEEE_OBJS += lib/ieee754.o
187 T_IEEE_PROGS = t/ieee754
189 T_ZIPF_OBS = t/genzipf.o
190 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o lib/gauss.o t/genzipf.o
191 T_ZIPF_PROGS = t/fio-genzipf
193 T_AXMAP_OBJS = t/axmap.o
194 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
195 T_AXMAP_PROGS = t/axmap
197 T_LFSR_TEST_OBJS = t/lfsr-test.o
198 T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o t/log.o t/debug.o
199 T_LFSR_TEST_PROGS = t/lfsr-test
201 ifeq ($(CONFIG_TARGET_OS), Linux)
202 T_BTRACE_FIO_OBJS = t/btrace2fio.o
203 T_BTRACE_FIO_OBJS += fifo.o lib/flist_sort.o t/log.o lib/linux-dev-lookup.o
204 T_BTRACE_FIO_PROGS = t/fio-btrace2fio
207 T_DEDUPE_OBJS = t/dedupe.o
208 T_DEDUPE_OBJS += lib/rbtree.o t/log.o mutex.o smalloc.o gettime.o crc/md5.o \
209 memalign.o lib/bloom.o t/debug.o crc/xxhash.o crc/murmur3.o \
210 crc/crc32c.o crc/crc32c-intel.o crc/fnv.o
211 T_DEDUPE_PROGS = t/fio-dedupe
213 T_OBJS = $(T_SMALLOC_OBJS)
214 T_OBJS += $(T_IEEE_OBJS)
215 T_OBJS += $(T_ZIPF_OBJS)
216 T_OBJS += $(T_AXMAP_OBJS)
217 T_OBJS += $(T_LFSR_TEST_OBJS)
218 T_OBJS += $(T_BTRACE_FIO_OBJS)
219 T_OBJS += $(T_DEDUPE_OBJS)
221 T_TEST_PROGS = $(T_SMALLOC_PROGS)
222 T_TEST_PROGS += $(T_IEEE_PROGS)
223 T_PROGS += $(T_ZIPF_PROGS)
224 T_TEST_PROGS += $(T_AXMAP_PROGS)
225 T_TEST_PROGS += $(T_LFSR_TEST_PROGS)
226 T_PROGS += $(T_BTRACE_FIO_PROGS)
227 T_PROGS += $(T_DEDUPE_PROGS)
231 ifneq ($(findstring $(MAKEFLAGS),s),s)
233 QUIET_CC = @echo ' ' CC $@;
234 QUIET_LINK = @echo ' ' LINK $@;
235 QUIET_DEP = @echo ' ' DEP $@;
236 QUIET_YACC = @echo ' ' YACC $@;
237 QUIET_LEX = @echo ' ' LEX $@;
241 ifeq ($(CONFIG_TARGET_OS), SunOS)
247 bindir = $(prefix)/bin
249 ifeq ($(CONFIG_TARGET_OS), Darwin)
250 mandir = /usr/share/man
251 sharedir = /usr/share/fio
253 mandir = $(prefix)/man
254 sharedir = $(prefix)/share/fio
257 all: $(PROGS) $(T_TEST_PROGS) $(SCRIPTS) FORCE
259 .PHONY: all install clean
262 FIO-VERSION-FILE: FORCE
263 @$(SHELL) ./FIO-VERSION-GEN
264 -include FIO-VERSION-FILE
266 override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
269 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
270 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
272 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
273 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
274 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
277 ifdef CONFIG_ARITHMETIC
278 lex.yy.c: exp/expression-parser.l
279 $(QUIET_LEX)$(LEX) exp/expression-parser.l
281 lex.yy.o: lex.yy.c y.tab.h
282 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
284 y.tab.o: y.tab.c y.tab.h
285 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
287 y.tab.c: exp/expression-parser.y
288 $(QUIET_YACC)$(YACC) -l -d -b y exp/expression-parser.y
294 exp/test-expression-parser.o: exp/test-expression-parser.c
295 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
296 exp/test-expression-parser: exp/test-expression-parser.o
297 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) $< y.tab.o lex.yy.o -o $@ $(LIBS)
299 parse.o: lex.yy.o y.tab.o
302 init.o: FIO-VERSION-FILE init.c
303 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
305 gcompat.o: gcompat.c gcompat.h
306 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
308 goptions.o: goptions.c goptions.h
309 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
311 ghelpers.o: ghelpers.c ghelpers.h
312 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
314 gerror.o: gerror.c gerror.h
315 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
317 gclient.o: gclient.c gclient.h
318 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
320 gfio.o: gfio.c ghelpers.c
321 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
323 graph.o: graph.c graph.h
324 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
326 cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
327 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c
329 printing.o: printing.c printing.h
330 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
332 t/stest: $(T_SMALLOC_OBJS)
333 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
335 t/ieee754: $(T_IEEE_OBJS)
336 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
339 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(HDFSLIB)
342 $(QUIET_LINK)$(CC) $(filter-out -static, $(LDFLAGS)) -o gfio $(GFIO_OBJS) $(LIBS) $(GFIO_LIBS) $(GTK_LDFLAGS) $(HDFSLIB)
344 t/fio-genzipf: $(T_ZIPF_OBJS)
345 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
347 t/axmap: $(T_AXMAP_OBJS)
348 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
350 t/lfsr-test: $(T_LFSR_TEST_OBJS)
351 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
353 ifeq ($(CONFIG_TARGET_OS), Linux)
354 t/fio-btrace2fio: $(T_BTRACE_FIO_OBJS)
355 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_BTRACE_FIO_OBJS) $(LIBS)
358 t/fio-dedupe: $(T_DEDUPE_OBJS)
359 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_DEDUPE_OBJS) $(LIBS)
362 @rm -f .depend $(FIO_OBJS) $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) $(T_TEST_PROGS) core.* core gfio FIO-VERSION-FILE *.d lib/*.d crc/*.d engines/*.d profiles/*.d t/*.d config-host.mak config-host.h y.tab.[ch] lex.yy.c exp/*.[do] lexer.h
364 distclean: clean FORCE
365 @rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf
370 tools/plot/fio2gnuplot.1:
371 @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot > tools/plot/fio2gnuplot.1
373 doc: tools/plot/fio2gnuplot.1
374 @man -t ./fio.1 | ps2pdf - fio.pdf
375 @man -t tools/fio_generate_plots.1 | ps2pdf - fio_generate_plots.pdf
376 @man -t tools/plot/fio2gnuplot.1 | ps2pdf - fio2gnuplot.pdf
378 install: $(PROGS) $(SCRIPTS) tools/plot/fio2gnuplot.1 FORCE
379 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
380 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
381 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
382 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
383 $(INSTALL) -m 644 tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
384 $(INSTALL) -m 644 tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1
385 $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
386 $(INSTALL) -m 644 tools/plot/*gpm $(DESTDIR)$(sharedir)/