| 1 | ifneq ($(wildcard config-host.mak),) |
| 2 | all: |
| 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 |
| 7 | else |
| 8 | config-host.mak: |
| 9 | ifneq ($(MAKECMDGOALS),clean) |
| 10 | @echo "Running configure for you..." |
| 11 | @./configure |
| 12 | endif |
| 13 | all: |
| 14 | include config-host.mak |
| 15 | endif |
| 16 | |
| 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) |
| 22 | PROGS = fio |
| 23 | SCRIPTS = tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio |
| 24 | |
| 25 | ifdef CONFIG_GFIO |
| 26 | PROGS += gfio |
| 27 | endif |
| 28 | |
| 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 |
| 40 | |
| 41 | ifdef 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 |
| 46 | endif |
| 47 | |
| 48 | ifdef CONFIG_64BIT_LLP64 |
| 49 | CFLAGS += -DBITS_PER_LONG=32 |
| 50 | endif |
| 51 | ifdef CONFIG_64BIT |
| 52 | CFLAGS += -DBITS_PER_LONG=64 |
| 53 | endif |
| 54 | ifdef CONFIG_32BIT |
| 55 | CFLAGS += -DBITS_PER_LONG=32 |
| 56 | endif |
| 57 | ifdef CONFIG_LIBAIO |
| 58 | SOURCE += engines/libaio.c |
| 59 | endif |
| 60 | ifdef CONFIG_RDMA |
| 61 | SOURCE += engines/rdma.c |
| 62 | endif |
| 63 | ifdef CONFIG_POSIXAIO |
| 64 | SOURCE += engines/posixaio.c |
| 65 | endif |
| 66 | ifdef CONFIG_LINUX_FALLOCATE |
| 67 | SOURCE += engines/falloc.c |
| 68 | endif |
| 69 | ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT |
| 70 | SOURCE += engines/e4defrag.c |
| 71 | endif |
| 72 | ifdef CONFIG_LINUX_SPLICE |
| 73 | SOURCE += engines/splice.c |
| 74 | endif |
| 75 | ifdef CONFIG_GUASI |
| 76 | SOURCE += engines/guasi.c |
| 77 | endif |
| 78 | ifdef CONFIG_FUSION_AW |
| 79 | SOURCE += engines/fusion-aw.c |
| 80 | endif |
| 81 | ifdef CONFIG_SOLARISAIO |
| 82 | SOURCE += engines/solarisaio.c |
| 83 | endif |
| 84 | ifdef CONFIG_WINDOWSAIO |
| 85 | SOURCE += engines/windowsaio.c |
| 86 | endif |
| 87 | ifdef CONFIG_RBD |
| 88 | SOURCE += engines/rbd.c |
| 89 | endif |
| 90 | ifndef CONFIG_STRSEP |
| 91 | SOURCE += lib/strsep.c |
| 92 | endif |
| 93 | ifndef CONFIG_STRCASESTR |
| 94 | SOURCE += lib/strcasestr.c |
| 95 | endif |
| 96 | ifndef CONFIG_GETOPT_LONG_ONLY |
| 97 | SOURCE += lib/getopt_long.c |
| 98 | endif |
| 99 | ifndef CONFIG_INET_ATON |
| 100 | SOURCE += lib/inet_aton.c |
| 101 | endif |
| 102 | ifdef 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 |
| 109 | endif |
| 110 | ifdef CONFIG_MTD |
| 111 | SOURCE += engines/mtd.c |
| 112 | SOURCE += lib/libmtd.c |
| 113 | SOURCE += lib/libmtd_legacy.c |
| 114 | endif |
| 115 | |
| 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 |
| 120 | LDFLAGS += -rdynamic |
| 121 | endif |
| 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 |
| 125 | LIBS += -ldl |
| 126 | LDFLAGS += -rdynamic |
| 127 | endif |
| 128 | ifeq ($(CONFIG_TARGET_OS), SunOS) |
| 129 | LIBS += -lpthread -ldl |
| 130 | CPPFLAGS += -D__EXTENSIONS__ |
| 131 | endif |
| 132 | ifeq ($(CONFIG_TARGET_OS), FreeBSD) |
| 133 | LIBS += -lpthread -lrt |
| 134 | LDFLAGS += -rdynamic |
| 135 | endif |
| 136 | ifeq ($(CONFIG_TARGET_OS), OpenBSD) |
| 137 | LIBS += -lpthread |
| 138 | LDFLAGS += -rdynamic |
| 139 | endif |
| 140 | ifeq ($(CONFIG_TARGET_OS), NetBSD) |
| 141 | LIBS += -lpthread -lrt |
| 142 | LDFLAGS += -rdynamic |
| 143 | endif |
| 144 | ifeq ($(CONFIG_TARGET_OS), DragonFly) |
| 145 | LIBS += -lpthread -lrt |
| 146 | LDFLAGS += -rdynamic |
| 147 | endif |
| 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 |
| 152 | endif |
| 153 | ifeq ($(CONFIG_TARGET_OS), HP-UX) |
| 154 | LIBS += -lpthread -ldl -lrt |
| 155 | CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED |
| 156 | endif |
| 157 | ifeq ($(CONFIG_TARGET_OS), Darwin) |
| 158 | LIBS += -lpthread -ldl |
| 159 | endif |
| 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 |
| 165 | endif |
| 166 | |
| 167 | OBJS = $(SOURCE:.c=.o) |
| 168 | |
| 169 | FIO_OBJS = $(OBJS) fio.o |
| 170 | |
| 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 |
| 173 | |
| 174 | ifdef CONFIG_ARITHMETIC |
| 175 | FIO_OBJS += lex.yy.o y.tab.o |
| 176 | GFIO_OBJS += lex.yy.o y.tab.o |
| 177 | endif |
| 178 | |
| 179 | -include $(OBJS:.o=.d) |
| 180 | |
| 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 |
| 184 | |
| 185 | T_IEEE_OBJS = t/ieee754.o |
| 186 | T_IEEE_OBJS += lib/ieee754.o |
| 187 | T_IEEE_PROGS = t/ieee754 |
| 188 | |
| 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 |
| 192 | |
| 193 | T_AXMAP_OBJS = t/axmap.o |
| 194 | T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o |
| 195 | T_AXMAP_PROGS = t/axmap |
| 196 | |
| 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 |
| 200 | |
| 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 |
| 205 | endif |
| 206 | |
| 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 |
| 212 | |
| 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) |
| 220 | |
| 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) |
| 228 | |
| 229 | PROGS += $(T_PROGS) |
| 230 | |
| 231 | ifneq ($(findstring $(MAKEFLAGS),s),s) |
| 232 | ifndef V |
| 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 $@; |
| 238 | endif |
| 239 | endif |
| 240 | |
| 241 | ifeq ($(CONFIG_TARGET_OS), SunOS) |
| 242 | INSTALL = ginstall |
| 243 | else |
| 244 | INSTALL = install |
| 245 | endif |
| 246 | prefix = /usr/local |
| 247 | bindir = $(prefix)/bin |
| 248 | |
| 249 | ifeq ($(CONFIG_TARGET_OS), Darwin) |
| 250 | mandir = /usr/share/man |
| 251 | sharedir = /usr/share/fio |
| 252 | else |
| 253 | mandir = $(prefix)/man |
| 254 | sharedir = $(prefix)/share/fio |
| 255 | endif |
| 256 | |
| 257 | all: $(PROGS) $(T_TEST_PROGS) $(SCRIPTS) FORCE |
| 258 | |
| 259 | .PHONY: all install clean |
| 260 | .PHONY: FORCE cscope |
| 261 | |
| 262 | FIO-VERSION-FILE: FORCE |
| 263 | @$(SHELL) ./FIO-VERSION-GEN |
| 264 | -include FIO-VERSION-FILE |
| 265 | |
| 266 | override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"' |
| 267 | |
| 268 | %.o : %.c |
| 269 | $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< |
| 270 | @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d |
| 271 | @mv -f $*.d $*.d.tmp |
| 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 |
| 275 | @rm -f $*.d.tmp |
| 276 | |
| 277 | ifdef CONFIG_ARITHMETIC |
| 278 | lex.yy.c: exp/expression-parser.l |
| 279 | $(QUIET_LEX)$(LEX) exp/expression-parser.l |
| 280 | |
| 281 | lex.yy.o: lex.yy.c y.tab.h |
| 282 | $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< |
| 283 | |
| 284 | y.tab.o: y.tab.c y.tab.h |
| 285 | $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< |
| 286 | |
| 287 | y.tab.c: exp/expression-parser.y |
| 288 | $(QUIET_YACC)$(YACC) -l -d -b y exp/expression-parser.y |
| 289 | |
| 290 | y.tab.h: y.tab.c |
| 291 | |
| 292 | lexer.h: lex.yy.c |
| 293 | |
| 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) |
| 298 | |
| 299 | parse.o: lex.yy.o y.tab.o |
| 300 | endif |
| 301 | |
| 302 | init.o: FIO-VERSION-FILE init.c |
| 303 | $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c |
| 304 | |
| 305 | gcompat.o: gcompat.c gcompat.h |
| 306 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c |
| 307 | |
| 308 | goptions.o: goptions.c goptions.h |
| 309 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c |
| 310 | |
| 311 | ghelpers.o: ghelpers.c ghelpers.h |
| 312 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c |
| 313 | |
| 314 | gerror.o: gerror.c gerror.h |
| 315 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c |
| 316 | |
| 317 | gclient.o: gclient.c gclient.h |
| 318 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c |
| 319 | |
| 320 | gfio.o: gfio.c ghelpers.c |
| 321 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c |
| 322 | |
| 323 | graph.o: graph.c graph.h |
| 324 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c |
| 325 | |
| 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 |
| 328 | |
| 329 | printing.o: printing.c printing.h |
| 330 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c |
| 331 | |
| 332 | t/stest: $(T_SMALLOC_OBJS) |
| 333 | $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) |
| 334 | |
| 335 | t/ieee754: $(T_IEEE_OBJS) |
| 336 | $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) |
| 337 | |
| 338 | fio: $(FIO_OBJS) |
| 339 | $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(HDFSLIB) |
| 340 | |
| 341 | gfio: $(GFIO_OBJS) |
| 342 | $(QUIET_LINK)$(CC) $(filter-out -static, $(LDFLAGS)) -o gfio $(GFIO_OBJS) $(LIBS) $(GFIO_LIBS) $(GTK_LDFLAGS) $(HDFSLIB) |
| 343 | |
| 344 | t/fio-genzipf: $(T_ZIPF_OBJS) |
| 345 | $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) |
| 346 | |
| 347 | t/axmap: $(T_AXMAP_OBJS) |
| 348 | $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) |
| 349 | |
| 350 | t/lfsr-test: $(T_LFSR_TEST_OBJS) |
| 351 | $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS) |
| 352 | |
| 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) |
| 356 | endif |
| 357 | |
| 358 | t/fio-dedupe: $(T_DEDUPE_OBJS) |
| 359 | $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_DEDUPE_OBJS) $(LIBS) |
| 360 | |
| 361 | clean: FORCE |
| 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 |
| 363 | |
| 364 | distclean: clean FORCE |
| 365 | @rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf |
| 366 | |
| 367 | cscope: |
| 368 | @cscope -b -R |
| 369 | |
| 370 | tools/plot/fio2gnuplot.1: |
| 371 | @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot > tools/plot/fio2gnuplot.1 |
| 372 | |
| 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 |
| 377 | |
| 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)/ |