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