Home | History | Annotate | Download | only in fio
      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
     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 
    111 ifeq ($(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
    116 endif
    117 ifeq ($(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
    122 endif
    123 ifeq ($(CONFIG_TARGET_OS), SunOS)
    124   LIBS	 += -lpthread -ldl
    125   CPPFLAGS += -D__EXTENSIONS__
    126 endif
    127 ifeq ($(CONFIG_TARGET_OS), FreeBSD)
    128   LIBS	 += -lpthread -lrt
    129   LDFLAGS += -rdynamic
    130 endif
    131 ifeq ($(CONFIG_TARGET_OS), OpenBSD)
    132   LIBS	 += -lpthread
    133   LDFLAGS += -rdynamic
    134 endif
    135 ifeq ($(CONFIG_TARGET_OS), NetBSD)
    136   LIBS	 += -lpthread -lrt
    137   LDFLAGS += -rdynamic
    138 endif
    139 ifeq ($(CONFIG_TARGET_OS), DragonFly)
    140   LIBS	 += -lpthread -lrt
    141   LDFLAGS += -rdynamic
    142 endif
    143 ifeq ($(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
    147 endif
    148 ifeq ($(CONFIG_TARGET_OS), HP-UX)
    149   LIBS   += -lpthread -ldl -lrt
    150   CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
    151 endif
    152 ifeq ($(CONFIG_TARGET_OS), Darwin)
    153   LIBS	 += -lpthread -ldl
    154 endif
    155 ifneq (,$(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
    160 endif
    161 
    162 OBJS = $(SOURCE:.c=.o)
    163 
    164 FIO_OBJS = $(OBJS) fio.o
    165 
    166 GFIO_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 
    169 ifdef CONFIG_ARITHMETIC
    170 FIO_OBJS += lex.yy.o y.tab.o
    171 GFIO_OBJS += lex.yy.o y.tab.o
    172 endif
    173 
    174 -include $(OBJS:.o=.d)
    175 
    176 T_SMALLOC_OBJS = t/stest.o
    177 T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o t/debug.o
    178 T_SMALLOC_PROGS = t/stest
    179 
    180 T_IEEE_OBJS = t/ieee754.o
    181 T_IEEE_OBJS += lib/ieee754.o
    182 T_IEEE_PROGS = t/ieee754
    183 
    184 T_ZIPF_OBS = t/genzipf.o
    185 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
    186 T_ZIPF_PROGS = t/fio-genzipf
    187 
    188 T_AXMAP_OBJS = t/axmap.o
    189 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
    190 T_AXMAP_PROGS = t/axmap
    191 
    192 T_LFSR_TEST_OBJS = t/lfsr-test.o
    193 T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o t/log.o t/debug.o
    194 T_LFSR_TEST_PROGS = t/lfsr-test
    195 
    196 ifeq ($(CONFIG_TARGET_OS), Linux)
    197 T_BTRACE_FIO_OBJS = t/btrace2fio.o
    198 T_BTRACE_FIO_OBJS += fifo.o lib/flist_sort.o t/log.o lib/linux-dev-lookup.o
    199 T_BTRACE_FIO_PROGS = t/fio-btrace2fio
    200 endif
    201 
    202 T_DEDUPE_OBJS = t/dedupe.o
    203 T_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
    206 T_DEDUPE_PROGS = t/fio-dedupe
    207 
    208 T_OBJS = $(T_SMALLOC_OBJS)
    209 T_OBJS += $(T_IEEE_OBJS)
    210 T_OBJS += $(T_ZIPF_OBJS)
    211 T_OBJS += $(T_AXMAP_OBJS)
    212 T_OBJS += $(T_LFSR_TEST_OBJS)
    213 T_OBJS += $(T_BTRACE_FIO_OBJS)
    214 T_OBJS += $(T_DEDUPE_OBJS)
    215 
    216 T_TEST_PROGS = $(T_SMALLOC_PROGS)
    217 T_TEST_PROGS += $(T_IEEE_PROGS)
    218 T_PROGS += $(T_ZIPF_PROGS)
    219 T_TEST_PROGS += $(T_AXMAP_PROGS)
    220 T_TEST_PROGS += $(T_LFSR_TEST_PROGS)
    221 T_PROGS += $(T_BTRACE_FIO_PROGS)
    222 T_PROGS += $(T_DEDUPE_PROGS)
    223 
    224 PROGS += $(T_PROGS)
    225 
    226 ifneq ($(findstring $(MAKEFLAGS),s),s)
    227 ifndef 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 $@;
    233 endif
    234 endif
    235 
    236 ifeq ($(CONFIG_TARGET_OS), SunOS)
    237 	INSTALL = ginstall
    238 else
    239 	INSTALL = install
    240 endif
    241 prefix = /usr/local
    242 bindir = $(prefix)/bin
    243 
    244 ifeq ($(CONFIG_TARGET_OS), Darwin)
    245 mandir = /usr/share/man
    246 sharedir = /usr/share/fio
    247 else
    248 mandir = $(prefix)/man
    249 sharedir = $(prefix)/share/fio
    250 endif
    251 
    252 all: $(PROGS) $(T_TEST_PROGS) $(SCRIPTS) FORCE
    253 
    254 .PHONY: all install clean
    255 .PHONY: FORCE cscope
    256 
    257 FIO-VERSION-FILE: FORCE
    258 	@$(SHELL) ./FIO-VERSION-GEN
    259 -include FIO-VERSION-FILE
    260 
    261 override 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 
    272 ifdef CONFIG_ARITHMETIC
    273 lex.yy.c: exp/expression-parser.l
    274 	$(QUIET_LEX)$(LEX) exp/expression-parser.l
    275 
    276 lex.yy.o: lex.yy.c y.tab.h
    277 	$(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
    278 
    279 y.tab.o: y.tab.c y.tab.h
    280 	$(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
    281 
    282 y.tab.c: exp/expression-parser.y
    283 	$(QUIET_YACC)$(YACC) -l -d -b y exp/expression-parser.y
    284 
    285 y.tab.h: y.tab.c
    286 
    287 lexer.h: lex.yy.c
    288 
    289 exp/test-expression-parser.o: exp/test-expression-parser.c
    290 	$(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
    291 exp/test-expression-parser: exp/test-expression-parser.o
    292 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) $< y.tab.o lex.yy.o -o $@ $(LIBS)
    293 
    294 parse.o: lex.yy.o y.tab.o
    295 endif
    296 
    297 init.o: FIO-VERSION-FILE init.c
    298 	$(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
    299 
    300 gcompat.o: gcompat.c gcompat.h
    301 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
    302 
    303 goptions.o: goptions.c goptions.h
    304 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
    305 
    306 ghelpers.o: ghelpers.c ghelpers.h
    307 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
    308 
    309 gerror.o: gerror.c gerror.h
    310 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
    311 
    312 gclient.o: gclient.c gclient.h
    313 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
    314 
    315 gfio.o: gfio.c ghelpers.c
    316 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
    317 
    318 graph.o: graph.c graph.h
    319 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
    320 
    321 cairo_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 
    324 printing.o: printing.c printing.h
    325 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
    326 
    327 t/stest: $(T_SMALLOC_OBJS)
    328 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
    329 
    330 t/ieee754: $(T_IEEE_OBJS)
    331 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
    332 
    333 fio: $(FIO_OBJS)
    334 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(HDFSLIB)
    335 
    336 gfio: $(GFIO_OBJS)
    337 	$(QUIET_LINK)$(CC) $(filter-out -static, $(LDFLAGS)) -o gfio $(GFIO_OBJS) $(LIBS) $(GFIO_LIBS) $(GTK_LDFLAGS) $(HDFSLIB)
    338 
    339 t/fio-genzipf: $(T_ZIPF_OBJS)
    340 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
    341 
    342 t/axmap: $(T_AXMAP_OBJS)
    343 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
    344 
    345 t/lfsr-test: $(T_LFSR_TEST_OBJS)
    346 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
    347 
    348 ifeq ($(CONFIG_TARGET_OS), Linux)
    349 t/fio-btrace2fio: $(T_BTRACE_FIO_OBJS)
    350 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_BTRACE_FIO_OBJS) $(LIBS)
    351 endif
    352 
    353 t/fio-dedupe: $(T_DEDUPE_OBJS)
    354 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_DEDUPE_OBJS) $(LIBS)
    355 
    356 clean: 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 
    359 distclean: clean FORCE
    360 	@rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf
    361 
    362 cscope:
    363 	@cscope -b -R
    364 
    365 tools/plot/fio2gnuplot.1:
    366 	@cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot >  tools/plot/fio2gnuplot.1
    367 
    368 doc: 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 
    373 install: $(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