1ifneq ($(wildcard config-host.mak),) 2all: 3include config-host.mak 4config-host-mak: configure 5 @echo $@ is out-of-date, running configure 6 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh 7else 8config-host.mak: 9ifneq ($(MAKECMDGOALS),clean) 10 @echo "Running configure for you..." 11 @./configure 12endif 13all: 14include config-host.mak 15endif 16 17DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG 18CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INTERNAL $(DEBUGFLAGS) 19OPTFLAGS= -O3 -g -ffast-math 20CFLAGS = -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS) 21LIBS += -lm $(EXTLIBS) 22PROGS = fio 23SCRIPTS = tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio 24 25ifdef CONFIG_GFIO 26 PROGS += gfio 27endif 28 29SOURCE := 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 40 41ifdef CONFIG_LIBHDFS 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 46endif 47 48ifdef CONFIG_64BIT_LLP64 49 CFLAGS += -DBITS_PER_LONG=32 50endif 51ifdef CONFIG_64BIT 52 CFLAGS += -DBITS_PER_LONG=64 53endif 54ifdef CONFIG_32BIT 55 CFLAGS += -DBITS_PER_LONG=32 56endif 57ifdef CONFIG_LIBAIO 58 SOURCE += engines/libaio.c 59endif 60ifdef CONFIG_RDMA 61 SOURCE += engines/rdma.c 62endif 63ifdef CONFIG_POSIXAIO 64 SOURCE += engines/posixaio.c 65endif 66ifdef CONFIG_LINUX_FALLOCATE 67 SOURCE += engines/falloc.c 68endif 69ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT 70 SOURCE += engines/e4defrag.c 71endif 72ifdef CONFIG_LINUX_SPLICE 73 SOURCE += engines/splice.c 74endif 75ifdef CONFIG_GUASI 76 SOURCE += engines/guasi.c 77endif 78ifdef CONFIG_FUSION_AW 79 SOURCE += engines/fusion-aw.c 80endif 81ifdef CONFIG_SOLARISAIO 82 SOURCE += engines/solarisaio.c 83endif 84ifdef CONFIG_WINDOWSAIO 85 SOURCE += engines/windowsaio.c 86endif 87ifdef CONFIG_RBD 88 SOURCE += engines/rbd.c 89endif 90ifndef CONFIG_STRSEP 91 SOURCE += lib/strsep.c 92endif 93ifndef CONFIG_STRCASESTR 94 SOURCE += lib/strcasestr.c 95endif 96ifndef CONFIG_GETOPT_LONG_ONLY 97 SOURCE += lib/getopt_long.c 98endif 99ifndef CONFIG_INET_ATON 100 SOURCE += lib/inet_aton.c 101endif 102ifdef CONFIG_GFAPI 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" 108 endif 109endif 110 111ifeq ($(CONFIG_TARGET_OS), Linux) 112 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \ 113 engines/binject.c lib/linux-dev-lookup.c 114 LIBS += -lpthread -ldl 115 LDFLAGS += -rdynamic 116endif 117ifeq ($(CONFIG_TARGET_OS), Android) 118 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c \ 119 lib/linux-dev-lookup.c 120 LIBS += -ldl 121 LDFLAGS += -rdynamic 122endif 123ifeq ($(CONFIG_TARGET_OS), SunOS) 124 LIBS += -lpthread -ldl 125 CPPFLAGS += -D__EXTENSIONS__ 126endif 127ifeq ($(CONFIG_TARGET_OS), FreeBSD) 128 LIBS += -lpthread -lrt 129 LDFLAGS += -rdynamic 130endif 131ifeq ($(CONFIG_TARGET_OS), OpenBSD) 132 LIBS += -lpthread 133 LDFLAGS += -rdynamic 134endif 135ifeq ($(CONFIG_TARGET_OS), NetBSD) 136 LIBS += -lpthread -lrt 137 LDFLAGS += -rdynamic 138endif 139ifeq ($(CONFIG_TARGET_OS), DragonFly) 140 LIBS += -lpthread -lrt 141 LDFLAGS += -rdynamic 142endif 143ifeq ($(CONFIG_TARGET_OS), AIX) 144 LIBS += -lpthread -ldl -lrt 145 CPPFLAGS += -D_LARGE_FILES -D__ppc__ 146 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000 147endif 148ifeq ($(CONFIG_TARGET_OS), HP-UX) 149 LIBS += -lpthread -ldl -lrt 150 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED 151endif 152ifeq ($(CONFIG_TARGET_OS), Darwin) 153 LIBS += -lpthread -ldl 154endif 155ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS))) 156 SOURCE := $(filter-out engines/mmap.c,$(SOURCE)) 157 SOURCE += os/windows/posix.c 158 LIBS += -lpthread -lpsapi -lws2_32 159 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format -static 160endif 161 162OBJS = $(SOURCE:.c=.o) 163 164FIO_OBJS = $(OBJS) fio.o 165 166GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \ 167 gclient.o gcompat.o cairo_text_helpers.o printing.o 168 169ifdef CONFIG_ARITHMETIC 170FIO_OBJS += lex.yy.o y.tab.o 171GFIO_OBJS += lex.yy.o y.tab.o 172endif 173 174-include $(OBJS:.o=.d) 175 176T_SMALLOC_OBJS = t/stest.o 177T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o t/debug.o 178T_SMALLOC_PROGS = t/stest 179 180T_IEEE_OBJS = t/ieee754.o 181T_IEEE_OBJS += lib/ieee754.o 182T_IEEE_PROGS = t/ieee754 183 184T_ZIPF_OBS = t/genzipf.o 185T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o 186T_ZIPF_PROGS = t/fio-genzipf 187 188T_AXMAP_OBJS = t/axmap.o 189T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o 190T_AXMAP_PROGS = t/axmap 191 192T_LFSR_TEST_OBJS = t/lfsr-test.o 193T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o t/log.o t/debug.o 194T_LFSR_TEST_PROGS = t/lfsr-test 195 196ifeq ($(CONFIG_TARGET_OS), Linux) 197T_BTRACE_FIO_OBJS = t/btrace2fio.o 198T_BTRACE_FIO_OBJS += fifo.o lib/flist_sort.o t/log.o lib/linux-dev-lookup.o 199T_BTRACE_FIO_PROGS = t/fio-btrace2fio 200endif 201 202T_DEDUPE_OBJS = t/dedupe.o 203T_DEDUPE_OBJS += lib/rbtree.o t/log.o mutex.o smalloc.o gettime.o crc/md5.o \ 204 memalign.o lib/bloom.o t/debug.o crc/xxhash.o crc/murmur3.o \ 205 crc/crc32c.o crc/crc32c-intel.o crc/fnv.o 206T_DEDUPE_PROGS = t/fio-dedupe 207 208T_OBJS = $(T_SMALLOC_OBJS) 209T_OBJS += $(T_IEEE_OBJS) 210T_OBJS += $(T_ZIPF_OBJS) 211T_OBJS += $(T_AXMAP_OBJS) 212T_OBJS += $(T_LFSR_TEST_OBJS) 213T_OBJS += $(T_BTRACE_FIO_OBJS) 214T_OBJS += $(T_DEDUPE_OBJS) 215 216T_TEST_PROGS = $(T_SMALLOC_PROGS) 217T_TEST_PROGS += $(T_IEEE_PROGS) 218T_PROGS += $(T_ZIPF_PROGS) 219T_TEST_PROGS += $(T_AXMAP_PROGS) 220T_TEST_PROGS += $(T_LFSR_TEST_PROGS) 221T_PROGS += $(T_BTRACE_FIO_PROGS) 222T_PROGS += $(T_DEDUPE_PROGS) 223 224PROGS += $(T_PROGS) 225 226ifneq ($(findstring $(MAKEFLAGS),s),s) 227ifndef V 228 QUIET_CC = @echo ' ' CC $@; 229 QUIET_LINK = @echo ' ' LINK $@; 230 QUIET_DEP = @echo ' ' DEP $@; 231 QUIET_YACC = @echo ' ' YACC $@; 232 QUIET_LEX = @echo ' ' LEX $@; 233endif 234endif 235 236ifeq ($(CONFIG_TARGET_OS), SunOS) 237 INSTALL = ginstall 238else 239 INSTALL = install 240endif 241prefix = /usr/local 242bindir = $(prefix)/bin 243 244ifeq ($(CONFIG_TARGET_OS), Darwin) 245mandir = /usr/share/man 246sharedir = /usr/share/fio 247else 248mandir = $(prefix)/man 249sharedir = $(prefix)/share/fio 250endif 251 252all: $(PROGS) $(T_TEST_PROGS) $(SCRIPTS) FORCE 253 254.PHONY: all install clean 255.PHONY: FORCE cscope 256 257FIO-VERSION-FILE: FORCE 258 @$(SHELL) ./FIO-VERSION-GEN 259-include FIO-VERSION-FILE 260 261override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"' 262 263%.o : %.c 264 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< 265 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d 266 @mv -f $*.d $*.d.tmp 267 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d 268 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \ 269 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d 270 @rm -f $*.d.tmp 271 272ifdef CONFIG_ARITHMETIC 273lex.yy.c: exp/expression-parser.l 274 $(QUIET_LEX)$(LEX) exp/expression-parser.l 275 276lex.yy.o: lex.yy.c y.tab.h 277 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< 278 279y.tab.o: y.tab.c y.tab.h 280 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< 281 282y.tab.c: exp/expression-parser.y 283 $(QUIET_YACC)$(YACC) -l -d -b y exp/expression-parser.y 284 285y.tab.h: y.tab.c 286 287lexer.h: lex.yy.c 288 289exp/test-expression-parser.o: exp/test-expression-parser.c 290 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< 291exp/test-expression-parser: exp/test-expression-parser.o 292 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) $< y.tab.o lex.yy.o -o $@ $(LIBS) 293 294parse.o: lex.yy.o y.tab.o 295endif 296 297init.o: FIO-VERSION-FILE init.c 298 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c 299 300gcompat.o: gcompat.c gcompat.h 301 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c 302 303goptions.o: goptions.c goptions.h 304 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c 305 306ghelpers.o: ghelpers.c ghelpers.h 307 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c 308 309gerror.o: gerror.c gerror.h 310 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c 311 312gclient.o: gclient.c gclient.h 313 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c 314 315gfio.o: gfio.c ghelpers.c 316 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c 317 318graph.o: graph.c graph.h 319 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c 320 321cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h 322 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c 323 324printing.o: printing.c printing.h 325 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c 326 327t/stest: $(T_SMALLOC_OBJS) 328 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) 329 330t/ieee754: $(T_IEEE_OBJS) 331 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) 332 333fio: $(FIO_OBJS) 334 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(HDFSLIB) 335 336gfio: $(GFIO_OBJS) 337 $(QUIET_LINK)$(CC) $(filter-out -static, $(LDFLAGS)) -o gfio $(GFIO_OBJS) $(LIBS) $(GFIO_LIBS) $(GTK_LDFLAGS) $(HDFSLIB) 338 339t/fio-genzipf: $(T_ZIPF_OBJS) 340 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) 341 342t/axmap: $(T_AXMAP_OBJS) 343 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) 344 345t/lfsr-test: $(T_LFSR_TEST_OBJS) 346 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS) 347 348ifeq ($(CONFIG_TARGET_OS), Linux) 349t/fio-btrace2fio: $(T_BTRACE_FIO_OBJS) 350 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_BTRACE_FIO_OBJS) $(LIBS) 351endif 352 353t/fio-dedupe: $(T_DEDUPE_OBJS) 354 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_DEDUPE_OBJS) $(LIBS) 355 356clean: FORCE 357 @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 358 359distclean: clean FORCE 360 @rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf 361 362cscope: 363 @cscope -b -R 364 365tools/plot/fio2gnuplot.1: 366 @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot > tools/plot/fio2gnuplot.1 367 368doc: tools/plot/fio2gnuplot.1 369 @man -t ./fio.1 | ps2pdf - fio.pdf 370 @man -t tools/fio_generate_plots.1 | ps2pdf - fio_generate_plots.pdf 371 @man -t tools/plot/fio2gnuplot.1 | ps2pdf - fio2gnuplot.pdf 372 373install: $(PROGS) $(SCRIPTS) tools/plot/fio2gnuplot.1 FORCE 374 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir) 375 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir) 376 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1 377 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1 378 $(INSTALL) -m 644 tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1 379 $(INSTALL) -m 644 tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1 380 $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir) 381 $(INSTALL) -m 644 tools/plot/*gpm $(DESTDIR)$(sharedir)/ 382