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
43 ifdef CONFIG_BIG_ENDIAN
44 CFLAGS += -DCONFIG_BIG_ENDIAN
46 ifdef CONFIG_LITTLE_ENDIAN
47 CFLAGS += -DCONFIG_LITTLE_ENDIAN
50 CFLAGS += -DCONFIG_LIBAIO
51 SOURCE += engines/libaio.c
54 CFLAGS += -DCONFIG_RDMA
55 SOURCE += engines/rdma.c
58 CFLAGS += -DCONFIG_POSIXAIO
59 SOURCE += engines/posixaio.c
61 ifdef CONFIG_LINUX_FALLOCATE
62 SOURCE += engines/falloc.c
64 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
65 SOURCE += engines/e4defrag.c
67 ifdef CONFIG_LINUX_SPLICE
68 CFLAGS += -DCONFIG_LINUX_SPLICE
69 SOURCE += engines/splice.c
72 CFLAGS += -DCONFIG_GUASI
73 SOURCE += engines/guasi.c
75 ifdef CONFIG_FUSION_AW
76 CFLAGS += -DCONFIG_FUSION_AW
77 SOURCE += engines/fusion-aw.c
79 ifdef CONFIG_SOLARISAIO
80 CFLAGS += -DCONFIG_SOLARISAIO
81 SOURCE += engines/solarisaio.c
85 CFLAGS += -DCONFIG_STRSEP
86 SOURCE += lib/strsep.c
88 ifndef CONFIG_GETOPT_LONG_ONLY
89 CFLAGS += -DCONFIG_GETOPT_LONG_ONLY
90 SOURCE += lib/getopt_long.c
93 ifndef CONFIG_INET_ATON
94 CFLAGS += -DCONFIG_INET_ATON
95 SOURCE += lib/inet_aton.c
97 ifdef CONFIG_CLOCK_GETTIME
98 CFLAGS += -DCONFIG_CLOCK_GETTIME
100 ifdef CONFIG_POSIXAIO_FSYNC
101 CFLAGS += -DCONFIG_POSIXAIO_FSYNC
104 CFLAGS += -DCONFIG_FADVISE
106 ifdef CONFIG_CLOCK_MONOTONIC
107 CFLAGS += -DCONFIG_CLOCK_MONOTONIC
109 ifdef CONFIG_CLOCK_MONOTONIC_PRECISE
110 CFLAGS += -DCONFIG_CLOCK_MONOTONIC_PRECISE
112 ifdef CONFIG_GETTIMEOFDAY
113 CFLAGS += -DCONFIG_GETTIMEOFDAY
115 ifdef CONFIG_SOCKLEN_T
116 CFLAGS += -DCONFIG_SOCKLEN_T
119 CFLAGS += -DCONFIG_SFAA
121 ifdef CONFIG_FDATASYNC
122 CFLAGS += -DCONFIG_FDATASYNC
124 ifdef CONFIG_3ARG_AFFINITY
125 CFLAGS += -DCONFIG_3ARG_AFFINITY
127 ifdef CONFIG_2ARG_AFFINITY
128 CFLAGS += -DCONFIG_2ARG_AFFINITY
130 ifdef CONFIG_SYNC_FILE_RANGE
131 CFLAGS += -DCONFIG_SYNC_FILE_RANGE
134 CFLAGS += -DCONFIG_LIBNUMA
136 ifdef CONFIG_TLS_THREAD
137 CFLAGS += -DCONFIG_TLS_THREAD
139 ifdef CONFIG_POSIX_FALLOCATE
140 CFLAGS += -DCONFIG_POSIX_FALLOCATE
142 ifdef CONFIG_LINUX_FALLOCATE
143 CFLAGS += -DCONFIG_LINUX_FALLOCATE
146 ifeq ($(UNAME), Linux)
147 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
148 engines/binject.c profiles/tiobench.c
149 LIBS += -lpthread -ldl
152 ifeq ($(UNAME), Android)
153 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
156 CPPFLAGS += -DFIO_NO_HAVE_SHM_H
158 ifeq ($(UNAME), SunOS)
159 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
160 CPPFLAGS += -D__EXTENSIONS__
162 ifeq ($(UNAME), FreeBSD)
163 LIBS += -lpthread -lrt
166 ifeq ($(UNAME), NetBSD)
167 LIBS += -lpthread -lrt
171 LIBS += -lpthread -ldl -lrt
172 CPPFLAGS += -D_LARGE_FILES -D__ppc__
173 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
175 ifeq ($(UNAME), HP-UX)
176 LIBS += -lpthread -ldl -lrt
177 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
179 ifeq ($(UNAME), Darwin)
180 LIBS += -lpthread -ldl
182 ifneq (,$(findstring CYGWIN,$(UNAME)))
183 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
184 SOURCE += engines/windowsaio.c os/windows/posix.c
185 LIBS += -lpthread -lpsapi -lws2_32
186 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
189 OBJS = $(SOURCE:.c=.o)
191 T_SMALLOC_OBJS = t/stest.o
192 T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
193 T_SMALLOC_PROGS = t/stest
195 T_IEEE_OBJS = t/ieee754.o
196 T_IEEE_OBJS += lib/ieee754.o
197 T_IEEE_PROGS = t/ieee754
199 T_ZIPF_OBS = t/genzipf.o
200 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
201 T_ZIPF_PROGS = t/genzipf
203 T_AXMAP_OBJS = t/axmap.o
204 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
205 T_AXMAP_PROGS = t/axmap
207 T_OBJS = $(T_SMALLOC_OBJS)
208 T_OBJS += $(T_IEEE_OBJS)
209 T_OBJS += $(T_ZIPF_OBJS)
210 T_OBJS += $(T_AXMAP_OBJS)
212 T_PROGS = $(T_SMALLOC_PROGS)
213 T_PROGS += $(T_IEEE_PROGS)
214 T_PROGS += $(T_ZIPF_PROGS)
215 T_PROGS += $(T_AXMAP_PROGS)
217 ifneq ($(findstring $(MAKEFLAGS),s),s)
219 QUIET_CC = @echo ' ' CC $@;
220 QUIET_DEP = @echo ' ' DEP $@;
226 bindir = $(prefix)/bin
228 ifeq ($(UNAME), Darwin)
229 mandir = /usr/share/man
231 mandir = $(prefix)/man
234 all: .depend $(PROGS) $(SCRIPTS) FORCE
236 .PHONY: all install clean
239 FIO-VERSION-FILE: FORCE
240 @$(SHELL) ./FIO-VERSION-GEN
241 -include FIO-VERSION-FILE
243 CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
246 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
248 init.o: FIO-VERSION-FILE
249 $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
251 t/stest: $(T_SMALLOC_OBJS)
252 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
254 t/ieee754: $(T_IEEE_OBJS)
255 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
257 t/genzipf: $(T_ZIPF_OBJS)
258 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
260 t/axmap: $(T_AXMAP_OBJS)
261 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
264 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
267 $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
272 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak config-host.ld cscope.out
277 install: $(PROGS) $(SCRIPTS) FORCE
278 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
279 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
280 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
281 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
282 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
284 ifneq ($(wildcard .depend),)