1 DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
2 CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
4 OPTFLAGS= -O3 -g -ffast-math $(EXTFLAGS)
5 CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS)
8 SCRIPTS = fio_generate_plots
9 UNAME := $(shell uname)
11 ifneq ($(wildcard config-host.mak),)
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
19 @echo "Running configure for you..."
22 include config-host.mak
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 lib/flist_sort.c lib/hweight.c
34 ifdef CONFIG_64BIT_LLP64
35 CFLAGS += -DBITS_PER_LONG=32
38 CFLAGS += -DBITS_PER_LONG=64
41 CFLAGS += -DBITS_PER_LONG=32
44 CFLAGS += -DCONFIG_LIBAIO
45 SOURCE += engines/libaio.c
48 CFLAGS += -DCONFIG_RDMA
49 SOURCE += engines/rdma.c
52 CFLAGS += -DCONFIG_POSIXAIO
53 SOURCE += engines/posixaio.c
55 ifdef CONFIG_LINUX_FALLOCATE
56 SOURCE += engines/falloc.c
58 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
59 SOURCE += engines/e4defrag.c
61 ifdef CONFIG_LINUX_SPLICE
62 CFLAGS += -DCONFIG_LINUX_SPLICE
63 SOURCE += engines/splice.c
66 CFLAGS += -DCONFIG_GUASI
67 SOURCE += engines/guasi.c
69 ifdef CONFIG_FUSION_AW
70 CFLAGS += -DCONFIG_FUSION_AW
71 SOURCE += engines/fusion-aw.c
73 ifdef CONFIG_SOLARISAIO
74 CFLAGS += -DCONFIG_SOLARISAIO
75 SOURCE += engines/solarisaio.c
79 CFLAGS += -DCONFIG_STRSEP
80 SOURCE += lib/strsep.c
82 ifndef CONFIG_GETOPT_LONG_ONLY
83 CFLAGS += -DCONFIG_GETOPT_LONG_ONLY
84 SOURCE += lib/getopt_long.c
87 ifndef CONFIG_INET_ATON
88 CFLAGS += -DCONFIG_INET_ATON
89 SOURCE += lib/inet_aton.c
91 ifdef CONFIG_CLOCK_GETTIME
92 CFLAGS += -DCONFIG_CLOCK_GETTIME
94 ifdef CONFIG_POSIXAIO_FSYNC
95 CFLAGS += -DCONFIG_POSIXAIO_FSYNC
98 CFLAGS += -DCONFIG_FADVISE
100 ifdef CONFIG_CLOCK_MONOTONIC
101 CFLAGS += -DCONFIG_CLOCK_MONOTONIC
103 ifdef CONFIG_CLOCK_MONOTONIC_PRECISE
104 CFLAGS += -DCONFIG_CLOCK_MONOTONIC_PRECISE
106 ifdef CONFIG_GETTIMEOFDAY
107 CFLAGS += -DCONFIG_GETTIMEOFDAY
109 ifdef CONFIG_SOCKLEN_T
110 CFLAGS += -DCONFIG_SOCKLEN_T
113 CFLAGS += -DCONFIG_SFAA
115 ifdef CONFIG_FDATASYNC
116 CFLAGS += -DCONFIG_FDATASYNC
118 ifdef CONFIG_3ARG_AFFINITY
119 CFLAGS += -DCONFIG_3ARG_AFFINITY
121 ifdef CONFIG_2ARG_AFFINITY
122 CFLAGS += -DCONFIG_2ARG_AFFINITY
124 ifdef CONFIG_SYNC_FILE_RANGE
125 CFLAGS += -DCONFIG_SYNC_FILE_RANGE
128 CFLAGS += -DCONFIG_LIBNUMA
130 ifdef CONFIG_TLS_THREAD
131 CFLAGS += -DCONFIG_TLS_THREAD
133 ifdef CONFIG_POSIX_FALLOCATE
134 CFLAGS += -DCONFIG_POSIX_FALLOCATE
136 ifdef CONFIG_LINUX_FALLOCATE
137 CFLAGS += -DCONFIG_LINUX_FALLOCATE
140 ifeq ($(UNAME), Linux)
141 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
142 engines/binject.c profiles/tiobench.c
143 LIBS += -lpthread -ldl
146 ifeq ($(UNAME), Android)
147 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
150 CPPFLAGS += -DFIO_NO_HAVE_SHM_H
152 ifeq ($(UNAME), SunOS)
153 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
154 CPPFLAGS += -D__EXTENSIONS__
156 ifeq ($(UNAME), FreeBSD)
157 LIBS += -lpthread -lrt
160 ifeq ($(UNAME), NetBSD)
161 LIBS += -lpthread -lrt
165 LIBS += -lpthread -ldl -lrt
166 CPPFLAGS += -D_LARGE_FILES -D__ppc__
167 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
169 ifeq ($(UNAME), HP-UX)
170 LIBS += -lpthread -ldl -lrt
171 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
173 ifeq ($(UNAME), Darwin)
174 LIBS += -lpthread -ldl
176 ifneq (,$(findstring CYGWIN,$(UNAME)))
177 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
178 SOURCE += engines/windowsaio.c os/windows/posix.c
179 LIBS += -lpthread -lpsapi -lws2_32
180 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
183 OBJS = $(SOURCE:.c=.o)
185 T_SMALLOC_OBJS = t/stest.o
186 T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
187 T_SMALLOC_PROGS = t/stest
189 T_IEEE_OBJS = t/ieee754.o
190 T_IEEE_OBJS += lib/ieee754.o
191 T_IEEE_PROGS = t/ieee754
193 T_ZIPF_OBS = t/genzipf.o
194 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
195 T_ZIPF_PROGS = t/genzipf
197 T_AXMAP_OBJS = t/axmap.o
198 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
199 T_AXMAP_PROGS = t/axmap
201 T_OBJS = $(T_SMALLOC_OBJS)
202 T_OBJS += $(T_IEEE_OBJS)
203 T_OBJS += $(T_ZIPF_OBJS)
204 T_OBJS += $(T_AXMAP_OBJS)
206 T_PROGS = $(T_SMALLOC_PROGS)
207 T_PROGS += $(T_IEEE_PROGS)
208 T_PROGS += $(T_ZIPF_PROGS)
209 T_PROGS += $(T_AXMAP_PROGS)
211 ifneq ($(findstring $(MAKEFLAGS),s),s)
213 QUIET_CC = @echo ' ' CC $@;
214 QUIET_DEP = @echo ' ' DEP $@;
220 bindir = $(prefix)/bin
222 ifeq ($(UNAME), Darwin)
223 mandir = /usr/share/man
225 mandir = $(prefix)/man
228 all: .depend $(PROGS) $(SCRIPTS) FORCE
230 .PHONY: all install clean
233 FIO-VERSION-FILE: FORCE
234 @$(SHELL) ./FIO-VERSION-GEN
235 -include FIO-VERSION-FILE
237 CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
240 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
242 init.o: FIO-VERSION-FILE
243 $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
245 t/stest: $(T_SMALLOC_OBJS)
246 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
248 t/ieee754: $(T_IEEE_OBJS)
249 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
251 t/genzipf: $(T_ZIPF_OBJS)
252 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
254 t/axmap: $(T_AXMAP_OBJS)
255 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
258 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
261 $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
266 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak config-host.ld cscope.out
271 install: $(PROGS) $(SCRIPTS) FORCE
272 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
273 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
274 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
275 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
276 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
278 ifneq ($(wildcard .depend),)