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 
     40 ifdef CONFIG_64BIT_LLP64
     41   CFLAGS += -DBITS_PER_LONG=32
     42 endif
     43 ifdef CONFIG_64BIT
     44   CFLAGS += -DBITS_PER_LONG=64
     45 endif
     46 ifdef CONFIG_32BIT
     47   CFLAGS += -DBITS_PER_LONG=32
     48 endif
     49 ifdef CONFIG_LIBAIO
     50   SOURCE += engines/libaio.c
     51 endif
     52 ifdef CONFIG_RDMA
     53   SOURCE += engines/rdma.c
     54 endif
     55 ifdef CONFIG_POSIXAIO
     56   SOURCE += engines/posixaio.c
     57 endif
     58 ifdef CONFIG_LINUX_FALLOCATE
     59   SOURCE += engines/falloc.c
     60 endif
     61 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
     62   SOURCE += engines/e4defrag.c
     63 endif
     64 ifdef CONFIG_LINUX_SPLICE
     65   SOURCE += engines/splice.c
     66 endif
     67 ifdef CONFIG_GUASI
     68   SOURCE += engines/guasi.c
     69 endif
     70 ifdef CONFIG_FUSION_AW
     71   SOURCE += engines/fusion-aw.c
     72 endif
     73 ifdef CONFIG_SOLARISAIO
     74   SOURCE += engines/solarisaio.c
     75 endif
     76 ifdef CONFIG_WINDOWSAIO
     77   SOURCE += engines/windowsaio.c
     78 endif
     79 ifdef CONFIG_RBD
     80   SOURCE += engines/rbd.c
     81 endif
     82 ifndef CONFIG_STRSEP
     83   SOURCE += lib/strsep.c
     84 endif
     85 ifndef CONFIG_STRCASESTR
     86   SOURCE += lib/strcasestr.c
     87 endif
     88 ifndef CONFIG_GETOPT_LONG_ONLY
     89   SOURCE += lib/getopt_long.c
     90 endif
     91 ifndef CONFIG_INET_ATON
     92   SOURCE += lib/inet_aton.c
     93 endif
     94 
     95 ifeq ($(CONFIG_TARGET_OS), Linux)
     96   SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
     97 		engines/binject.c
     98   LIBS += -lpthread -ldl
     99   LDFLAGS += -rdynamic
    100 endif
    101 ifeq ($(CONFIG_TARGET_OS), Android)
    102   SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
    103   LIBS += -ldl
    104   LDFLAGS += -rdynamic
    105 endif
    106 ifeq ($(CONFIG_TARGET_OS), SunOS)
    107   LIBS	 += -lpthread -ldl
    108   CPPFLAGS += -D__EXTENSIONS__
    109 endif
    110 ifeq ($(CONFIG_TARGET_OS), FreeBSD)
    111   LIBS	 += -lpthread -lrt
    112   LDFLAGS += -rdynamic
    113 endif
    114 ifeq ($(CONFIG_TARGET_OS), OpenBSD)
    115   LIBS	 += -lpthread
    116   LDFLAGS += -rdynamic
    117 endif
    118 ifeq ($(CONFIG_TARGET_OS), NetBSD)
    119   LIBS	 += -lpthread -lrt
    120   LDFLAGS += -rdynamic
    121 endif
    122 ifeq ($(CONFIG_TARGET_OS), AIX)
    123   LIBS	 += -lpthread -ldl -lrt
    124   CPPFLAGS += -D_LARGE_FILES -D__ppc__
    125   LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
    126 endif
    127 ifeq ($(CONFIG_TARGET_OS), HP-UX)
    128   LIBS   += -lpthread -ldl -lrt
    129   CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
    130 endif
    131 ifeq ($(CONFIG_TARGET_OS), Darwin)
    132   LIBS	 += -lpthread -ldl
    133 endif
    134 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
    135   SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
    136   SOURCE += os/windows/posix.c
    137   LIBS	 += -lpthread -lpsapi -lws2_32
    138   CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format -static
    139 endif
    140 
    141 OBJS = $(SOURCE:.c=.o)
    142 
    143 FIO_OBJS = $(OBJS) fio.o
    144 GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
    145 			gclient.o gcompat.o cairo_text_helpers.o printing.o
    146 
    147 -include $(OBJS:.o=.d)
    148 
    149 T_SMALLOC_OBJS = t/stest.o
    150 T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
    151 T_SMALLOC_PROGS = t/stest
    152 
    153 T_IEEE_OBJS = t/ieee754.o
    154 T_IEEE_OBJS += lib/ieee754.o
    155 T_IEEE_PROGS = t/ieee754
    156 
    157 T_ZIPF_OBS = t/genzipf.o
    158 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
    159 T_ZIPF_PROGS = t/genzipf
    160 
    161 T_AXMAP_OBJS = t/axmap.o
    162 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
    163 T_AXMAP_PROGS = t/axmap
    164 
    165 T_LFSR_TEST_OBJS = t/lfsr-test.o
    166 T_LFSR_TEST_OBJS += lib/lfsr.o
    167 T_LFSR_TEST_PROGS = t/lfsr-test
    168 
    169 T_OBJS = $(T_SMALLOC_OBJS)
    170 T_OBJS += $(T_IEEE_OBJS)
    171 T_OBJS += $(T_ZIPF_OBJS)
    172 T_OBJS += $(T_AXMAP_OBJS)
    173 T_OBJS += $(T_LFSR_TEST_OBJS)
    174 
    175 T_PROGS = $(T_SMALLOC_PROGS)
    176 T_PROGS += $(T_IEEE_PROGS)
    177 T_PROGS += $(T_ZIPF_PROGS)
    178 T_PROGS += $(T_AXMAP_PROGS)
    179 T_PROGS += $(T_LFSR_TEST_PROGS)
    180 
    181 ifneq ($(findstring $(MAKEFLAGS),s),s)
    182 ifndef V
    183 	QUIET_CC	= @echo '   ' CC $@;
    184 	QUIET_LINK	= @echo '   ' LINK $@;
    185 	QUIET_DEP	= @echo '   ' DEP $@;
    186 endif
    187 endif
    188 
    189 ifeq ($(CONFIG_TARGET_OS), SunOS)
    190 	INSTALL = ginstall
    191 else
    192 	INSTALL = install
    193 endif
    194 prefix = /usr/local
    195 bindir = $(prefix)/bin
    196 
    197 ifeq ($(CONFIG_TARGET_OS), Darwin)
    198 mandir = /usr/share/man
    199 sharedir = /usr/share/fio
    200 else
    201 mandir = $(prefix)/man
    202 sharedir = $(prefix)/share/fio
    203 endif
    204 
    205 all: $(PROGS) $(SCRIPTS) FORCE
    206 
    207 .PHONY: all install clean
    208 .PHONY: FORCE cscope
    209 
    210 FIO-VERSION-FILE: FORCE
    211 	@$(SHELL) ./FIO-VERSION-GEN
    212 -include FIO-VERSION-FILE
    213 
    214 override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
    215 
    216 .c.o: FORCE FIO-VERSION-FILE
    217 	$(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
    218 	@$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
    219 	@mv -f $*.d $*.d.tmp
    220 	@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
    221 	@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
    222 		sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
    223 	@rm -f $*.d.tmp
    224 
    225 init.o: FIO-VERSION-FILE init.c
    226 	$(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
    227 
    228 gcompat.o: gcompat.c gcompat.h
    229 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
    230 
    231 goptions.o: goptions.c goptions.h
    232 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
    233 
    234 ghelpers.o: ghelpers.c ghelpers.h
    235 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
    236 
    237 gerror.o: gerror.c gerror.h
    238 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
    239 
    240 gclient.o: gclient.c gclient.h
    241 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
    242 
    243 gfio.o: gfio.c ghelpers.c
    244 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
    245 
    246 graph.o: graph.c graph.h
    247 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
    248 
    249 cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
    250 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c
    251 
    252 printing.o: printing.c printing.h
    253 	$(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
    254 
    255 t/stest: $(T_SMALLOC_OBJS)
    256 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
    257 
    258 t/ieee754: $(T_IEEE_OBJS)
    259 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
    260 
    261 fio: $(FIO_OBJS)
    262 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS)
    263 
    264 gfio: $(GFIO_OBJS)
    265 	$(QUIET_LINK)$(CC) $(LDFLAGS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS)
    266 
    267 t/genzipf: $(T_ZIPF_OBJS)
    268 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
    269 
    270 t/axmap: $(T_AXMAP_OBJS)
    271 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
    272 
    273 t/lfsr-test: $(T_LFSR_TEST_OBJS)
    274 	$(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
    275 
    276 clean: FORCE
    277 	-rm -f .depend $(FIO_OBJS) $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE *.d lib/*.d crc/*.d engines/*.d profiles/*.d t/*.d config-host.mak config-host.h
    278 
    279 distclean: clean FORCE
    280 	@rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf
    281 
    282 cscope:
    283 	@cscope -b -R
    284 
    285 tools/plot/fio2gnuplot.1:
    286 	@cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot >  tools/plot/fio2gnuplot.1
    287 
    288 doc: tools/plot/fio2gnuplot.1
    289 	@man -t ./fio.1 | ps2pdf - fio.pdf
    290 	@man -t tools/fio_generate_plots.1 | ps2pdf - fio_generate_plots.pdf
    291 	@man -t tools/plot/fio2gnuplot.1 | ps2pdf - fio2gnuplot.pdf
    292 
    293 install: $(PROGS) $(SCRIPTS) tools/plot/fio2gnuplot.1 FORCE
    294 	$(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
    295 	$(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
    296 	$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
    297 	$(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
    298 	$(INSTALL) -m 644 tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
    299 	$(INSTALL) -m 644 tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1
    300 	$(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
    301 	$(INSTALL) -m 644 tools/plot/*gpm $(DESTDIR)$(sharedir)/
    302