| 1 | DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG |
| 2 | CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(DEBUGFLAGS) |
| 3 | OPTFLAGS= -O3 -g -ffast-math $(EXTFLAGS) |
| 4 | CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS) |
| 5 | LIBS = -lm -lz $(EXTLIBS) |
| 6 | PROGS = fio |
| 7 | SCRIPTS = fio_generate_plots |
| 8 | UNAME := $(shell uname) |
| 9 | |
| 10 | ifneq ($(wildcard config-host.mak),) |
| 11 | all: |
| 12 | include config-host.mak |
| 13 | config-host-mak: configure |
| 14 | @echo $@ is out-of-date, running configure |
| 15 | @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh |
| 16 | else |
| 17 | config-host.mak: |
| 18 | @echo "Running configure for you..." |
| 19 | @./configure |
| 20 | all: |
| 21 | include config-host.mak |
| 22 | endif |
| 23 | |
| 24 | ifdef CONFIG_GFIO |
| 25 | PROGS += gfio |
| 26 | endif |
| 27 | |
| 28 | SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \ |
| 29 | eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \ |
| 30 | lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \ |
| 31 | lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \ |
| 32 | engines/mmap.c engines/sync.c engines/null.c engines/net.c \ |
| 33 | memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \ |
| 34 | cconv.c lib/prio_tree.c json.c lib/zipf.c lib/axmap.c \ |
| 35 | lib/lfsr.c gettime-thread.c helpers.c lib/flist_sort.c \ |
| 36 | lib/hweight.c lib/getrusage.c idletime.c |
| 37 | |
| 38 | ifdef CONFIG_64BIT_LLP64 |
| 39 | CFLAGS += -DBITS_PER_LONG=32 |
| 40 | endif |
| 41 | ifdef CONFIG_64BIT |
| 42 | CFLAGS += -DBITS_PER_LONG=64 |
| 43 | endif |
| 44 | ifdef CONFIG_32BIT |
| 45 | CFLAGS += -DBITS_PER_LONG=32 |
| 46 | endif |
| 47 | ifdef CONFIG_LIBAIO |
| 48 | SOURCE += engines/libaio.c |
| 49 | endif |
| 50 | ifdef CONFIG_RDMA |
| 51 | SOURCE += engines/rdma.c |
| 52 | endif |
| 53 | ifdef CONFIG_POSIXAIO |
| 54 | SOURCE += engines/posixaio.c |
| 55 | endif |
| 56 | ifdef CONFIG_LINUX_FALLOCATE |
| 57 | SOURCE += engines/falloc.c |
| 58 | endif |
| 59 | ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT |
| 60 | SOURCE += engines/e4defrag.c |
| 61 | endif |
| 62 | ifdef CONFIG_LINUX_SPLICE |
| 63 | SOURCE += engines/splice.c |
| 64 | endif |
| 65 | ifdef CONFIG_GUASI |
| 66 | SOURCE += engines/guasi.c |
| 67 | endif |
| 68 | ifdef CONFIG_FUSION_AW |
| 69 | SOURCE += engines/fusion-aw.c |
| 70 | endif |
| 71 | ifdef CONFIG_SOLARISAIO |
| 72 | SOURCE += engines/solarisaio.c |
| 73 | endif |
| 74 | ifdef CONFIG_WINDOWSAIO |
| 75 | SOURCE += engines/windowsaio.c |
| 76 | endif |
| 77 | ifndef CONFIG_STRSEP |
| 78 | SOURCE += lib/strsep.c |
| 79 | endif |
| 80 | ifndef CONFIG_GETOPT_LONG_ONLY |
| 81 | SOURCE += lib/getopt_long.c |
| 82 | endif |
| 83 | ifndef CONFIG_INET_ATON |
| 84 | SOURCE += lib/inet_aton.c |
| 85 | endif |
| 86 | |
| 87 | ifeq ($(UNAME), Linux) |
| 88 | SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \ |
| 89 | engines/binject.c profiles/tiobench.c |
| 90 | LIBS += -lpthread -ldl |
| 91 | LDFLAGS += -rdynamic |
| 92 | endif |
| 93 | ifeq ($(UNAME), Android) |
| 94 | SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c |
| 95 | LIBS += -ldl |
| 96 | LDFLAGS += -rdynamic |
| 97 | endif |
| 98 | ifeq ($(UNAME), SunOS) |
| 99 | LIBS += -lpthread -ldl |
| 100 | CPPFLAGS += -D__EXTENSIONS__ |
| 101 | endif |
| 102 | ifeq ($(UNAME), FreeBSD) |
| 103 | LIBS += -lpthread -lrt |
| 104 | LDFLAGS += -rdynamic |
| 105 | endif |
| 106 | ifeq ($(UNAME), NetBSD) |
| 107 | LIBS += -lpthread -lrt |
| 108 | LDFLAGS += -rdynamic |
| 109 | endif |
| 110 | ifeq ($(UNAME), AIX) |
| 111 | LIBS += -lpthread -ldl -lrt |
| 112 | CPPFLAGS += -D_LARGE_FILES -D__ppc__ |
| 113 | LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000 |
| 114 | endif |
| 115 | ifeq ($(UNAME), HP-UX) |
| 116 | LIBS += -lpthread -ldl -lrt |
| 117 | CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED |
| 118 | endif |
| 119 | ifeq ($(UNAME), Darwin) |
| 120 | LIBS += -lpthread -ldl |
| 121 | endif |
| 122 | ifneq (,$(findstring CYGWIN,$(UNAME))) |
| 123 | SOURCE := $(filter-out engines/mmap.c,$(SOURCE)) |
| 124 | SOURCE += os/windows/posix.c |
| 125 | LIBS += -lpthread -lpsapi -lws2_32 |
| 126 | CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format |
| 127 | endif |
| 128 | |
| 129 | OBJS = $(SOURCE:.c=.o) |
| 130 | |
| 131 | FIO_OBJS = $(OBJS) fio.o |
| 132 | GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \ |
| 133 | gclient.o gcompat.o cairo_text_helpers.o printing.o |
| 134 | |
| 135 | -include $(OBJS:.o=.d) |
| 136 | |
| 137 | T_SMALLOC_OBJS = t/stest.o |
| 138 | T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o |
| 139 | T_SMALLOC_PROGS = t/stest |
| 140 | |
| 141 | T_IEEE_OBJS = t/ieee754.o |
| 142 | T_IEEE_OBJS += lib/ieee754.o |
| 143 | T_IEEE_PROGS = t/ieee754 |
| 144 | |
| 145 | T_ZIPF_OBS = t/genzipf.o |
| 146 | T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o |
| 147 | T_ZIPF_PROGS = t/genzipf |
| 148 | |
| 149 | T_AXMAP_OBJS = t/axmap.o |
| 150 | T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o |
| 151 | T_AXMAP_PROGS = t/axmap |
| 152 | |
| 153 | T_OBJS = $(T_SMALLOC_OBJS) |
| 154 | T_OBJS += $(T_IEEE_OBJS) |
| 155 | T_OBJS += $(T_ZIPF_OBJS) |
| 156 | T_OBJS += $(T_AXMAP_OBJS) |
| 157 | |
| 158 | T_PROGS = $(T_SMALLOC_PROGS) |
| 159 | T_PROGS += $(T_IEEE_PROGS) |
| 160 | T_PROGS += $(T_ZIPF_PROGS) |
| 161 | T_PROGS += $(T_AXMAP_PROGS) |
| 162 | |
| 163 | ifneq ($(findstring $(MAKEFLAGS),s),s) |
| 164 | ifndef V |
| 165 | QUIET_CC = @echo ' ' CC $@; |
| 166 | QUIET_LINK = @echo ' ' LINK $@; |
| 167 | QUIET_DEP = @echo ' ' DEP $@; |
| 168 | endif |
| 169 | endif |
| 170 | |
| 171 | INSTALL = install |
| 172 | prefix = /usr/local |
| 173 | bindir = $(prefix)/bin |
| 174 | |
| 175 | ifeq ($(UNAME), Darwin) |
| 176 | mandir = /usr/share/man |
| 177 | else |
| 178 | mandir = $(prefix)/man |
| 179 | endif |
| 180 | |
| 181 | all: $(PROGS) $(SCRIPTS) FORCE |
| 182 | |
| 183 | .PHONY: all install clean |
| 184 | .PHONY: FORCE cscope |
| 185 | |
| 186 | FIO-VERSION-FILE: FORCE |
| 187 | @$(SHELL) ./FIO-VERSION-GEN |
| 188 | -include FIO-VERSION-FILE |
| 189 | |
| 190 | override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"' |
| 191 | |
| 192 | .c.o: FORCE FIO-VERSION-FILE |
| 193 | $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< |
| 194 | @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d |
| 195 | @mv -f $*.d $*.d.tmp |
| 196 | @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d |
| 197 | @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \ |
| 198 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d |
| 199 | @rm -f $*.d.tmp |
| 200 | |
| 201 | init.o: FIO-VERSION-FILE init.c |
| 202 | $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c |
| 203 | |
| 204 | gcompat.o: gcompat.c gcompat.h |
| 205 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c |
| 206 | |
| 207 | goptions.o: goptions.c goptions.h |
| 208 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c |
| 209 | |
| 210 | ghelpers.o: ghelpers.c ghelpers.h |
| 211 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c |
| 212 | |
| 213 | gerror.o: gerror.c gerror.h |
| 214 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c |
| 215 | |
| 216 | gclient.o: gclient.c gclient.h |
| 217 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c |
| 218 | |
| 219 | gfio.o: gfio.c ghelpers.c |
| 220 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c |
| 221 | |
| 222 | graph.o: graph.c graph.h |
| 223 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c |
| 224 | |
| 225 | cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h |
| 226 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c |
| 227 | |
| 228 | printing.o: printing.c printing.h |
| 229 | $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c |
| 230 | |
| 231 | t/stest: $(T_SMALLOC_OBJS) |
| 232 | $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS) |
| 233 | |
| 234 | t/ieee754: $(T_IEEE_OBJS) |
| 235 | $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS) |
| 236 | |
| 237 | fio: $(FIO_OBJS) |
| 238 | $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(LDFLAGS) |
| 239 | |
| 240 | gfio: $(GFIO_OBJS) |
| 241 | $(QUIET_LINK)$(CC) $(LIBS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS) |
| 242 | |
| 243 | t/genzipf: $(T_ZIPF_OBJS) |
| 244 | $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS) |
| 245 | |
| 246 | t/axmap: $(T_AXMAP_OBJS) |
| 247 | $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS) |
| 248 | |
| 249 | clean: FORCE |
| 250 | -rm -f .depend $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE config-host.mak cscope.out *.d |
| 251 | |
| 252 | cscope: |
| 253 | @cscope -b -R |
| 254 | |
| 255 | install: $(PROGS) $(SCRIPTS) FORCE |
| 256 | $(INSTALL) -m 755 -d $(DESTDIR)$(bindir) |
| 257 | $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir) |
| 258 | $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1 |
| 259 | $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1 |
| 260 | $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1 |