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)
7 SCRIPTS = fio_generate_plots
8 UNAME := $(shell uname)
10 ifneq ($(wildcard config-host.mak),)
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
18 @echo "Running configure for you..."
21 include config-host.mak
24 SOURCE := gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \
25 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
26 rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
27 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
28 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
29 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
30 json.c lib/zipf.c lib/axmap.c lib/lfsr.c gettime-thread.c \
31 helpers.c lib/flist_sort.c lib/hweight.c lib/getrusage.c
33 ifdef CONFIG_64BIT_LLP64
34 CFLAGS += -DBITS_PER_LONG=32
37 CFLAGS += -DBITS_PER_LONG=64
40 CFLAGS += -DBITS_PER_LONG=32
42 ifdef CONFIG_BIG_ENDIAN
43 CFLAGS += -DCONFIG_BIG_ENDIAN
45 ifdef CONFIG_LITTLE_ENDIAN
46 CFLAGS += -DCONFIG_LITTLE_ENDIAN
49 CFLAGS += -DCONFIG_LIBAIO
50 SOURCE += engines/libaio.c
53 CFLAGS += -DCONFIG_RDMA
54 SOURCE += engines/rdma.c
57 CFLAGS += -DCONFIG_POSIXAIO
58 SOURCE += engines/posixaio.c
60 ifdef CONFIG_LINUX_FALLOCATE
61 SOURCE += engines/falloc.c
63 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
64 SOURCE += engines/e4defrag.c
66 ifdef CONFIG_LINUX_SPLICE
67 CFLAGS += -DCONFIG_LINUX_SPLICE
68 SOURCE += engines/splice.c
71 CFLAGS += -DCONFIG_GUASI
72 SOURCE += engines/guasi.c
74 ifdef CONFIG_FUSION_AW
75 CFLAGS += -DCONFIG_FUSION_AW
76 SOURCE += engines/fusion-aw.c
78 ifdef CONFIG_SOLARISAIO
79 CFLAGS += -DCONFIG_SOLARISAIO
80 SOURCE += engines/solarisaio.c
84 CFLAGS += -DCONFIG_STRSEP
85 SOURCE += lib/strsep.c
87 ifndef CONFIG_GETOPT_LONG_ONLY
88 CFLAGS += -DCONFIG_GETOPT_LONG_ONLY
89 SOURCE += lib/getopt_long.c
92 ifndef CONFIG_INET_ATON
93 CFLAGS += -DCONFIG_INET_ATON
94 SOURCE += lib/inet_aton.c
96 ifdef CONFIG_CLOCK_GETTIME
97 CFLAGS += -DCONFIG_CLOCK_GETTIME
99 ifdef CONFIG_POSIXAIO_FSYNC
100 CFLAGS += -DCONFIG_POSIXAIO_FSYNC
103 CFLAGS += -DCONFIG_FADVISE
105 ifdef CONFIG_CLOCK_MONOTONIC
106 CFLAGS += -DCONFIG_CLOCK_MONOTONIC
108 ifdef CONFIG_CLOCK_MONOTONIC_PRECISE
109 CFLAGS += -DCONFIG_CLOCK_MONOTONIC_PRECISE
111 ifdef CONFIG_GETTIMEOFDAY
112 CFLAGS += -DCONFIG_GETTIMEOFDAY
114 ifdef CONFIG_SOCKLEN_T
115 CFLAGS += -DCONFIG_SOCKLEN_T
118 CFLAGS += -DCONFIG_SFAA
120 ifdef CONFIG_FDATASYNC
121 CFLAGS += -DCONFIG_FDATASYNC
123 ifdef CONFIG_3ARG_AFFINITY
124 CFLAGS += -DCONFIG_3ARG_AFFINITY
126 ifdef CONFIG_2ARG_AFFINITY
127 CFLAGS += -DCONFIG_2ARG_AFFINITY
129 ifdef CONFIG_SYNC_FILE_RANGE
130 CFLAGS += -DCONFIG_SYNC_FILE_RANGE
133 CFLAGS += -DCONFIG_LIBNUMA
135 ifdef CONFIG_TLS_THREAD
136 CFLAGS += -DCONFIG_TLS_THREAD
138 ifdef CONFIG_POSIX_FALLOCATE
139 CFLAGS += -DCONFIG_POSIX_FALLOCATE
141 ifdef CONFIG_LINUX_FALLOCATE
142 CFLAGS += -DCONFIG_LINUX_FALLOCATE
144 ifdef CONFIG_RUSAGE_THREAD
145 CFLAGS += -DCONFIG_RUSAGE_THREAD
148 ifeq ($(UNAME), Linux)
149 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
150 engines/binject.c profiles/tiobench.c
151 LIBS += -lpthread -ldl
154 ifeq ($(UNAME), Android)
155 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
158 CPPFLAGS += -DFIO_NO_HAVE_SHM_H
160 ifeq ($(UNAME), SunOS)
161 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
162 CPPFLAGS += -D__EXTENSIONS__
164 ifeq ($(UNAME), FreeBSD)
165 LIBS += -lpthread -lrt
168 ifeq ($(UNAME), NetBSD)
169 LIBS += -lpthread -lrt
173 LIBS += -lpthread -ldl -lrt
174 CPPFLAGS += -D_LARGE_FILES -D__ppc__
175 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
177 ifeq ($(UNAME), HP-UX)
178 LIBS += -lpthread -ldl -lrt
179 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
181 ifeq ($(UNAME), Darwin)
182 LIBS += -lpthread -ldl
184 ifneq (,$(findstring CYGWIN,$(UNAME)))
185 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
186 SOURCE += engines/windowsaio.c os/windows/posix.c
187 LIBS += -lpthread -lpsapi -lws2_32
188 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
191 OBJS = $(SOURCE:.c=.o)
193 T_SMALLOC_OBJS = t/stest.o
194 T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
195 T_SMALLOC_PROGS = t/stest
197 T_IEEE_OBJS = t/ieee754.o
198 T_IEEE_OBJS += lib/ieee754.o
199 T_IEEE_PROGS = t/ieee754
201 T_ZIPF_OBS = t/genzipf.o
202 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
203 T_ZIPF_PROGS = t/genzipf
205 T_AXMAP_OBJS = t/axmap.o
206 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
207 T_AXMAP_PROGS = t/axmap
209 T_OBJS = $(T_SMALLOC_OBJS)
210 T_OBJS += $(T_IEEE_OBJS)
211 T_OBJS += $(T_ZIPF_OBJS)
212 T_OBJS += $(T_AXMAP_OBJS)
214 T_PROGS = $(T_SMALLOC_PROGS)
215 T_PROGS += $(T_IEEE_PROGS)
216 T_PROGS += $(T_ZIPF_PROGS)
217 T_PROGS += $(T_AXMAP_PROGS)
219 ifneq ($(findstring $(MAKEFLAGS),s),s)
221 QUIET_CC = @echo ' ' CC $@;
222 QUIET_DEP = @echo ' ' DEP $@;
228 bindir = $(prefix)/bin
230 ifeq ($(UNAME), Darwin)
231 mandir = /usr/share/man
233 mandir = $(prefix)/man
236 all: .depend $(PROGS) $(SCRIPTS) FORCE
238 .PHONY: all install clean
241 FIO-VERSION-FILE: FORCE
242 @$(SHELL) ./FIO-VERSION-GEN
243 -include FIO-VERSION-FILE
245 CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
248 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
250 init.o: FIO-VERSION-FILE
251 $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
253 t/stest: $(T_SMALLOC_OBJS)
254 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
256 t/ieee754: $(T_IEEE_OBJS)
257 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
259 t/genzipf: $(T_ZIPF_OBJS)
260 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
262 t/axmap: $(T_AXMAP_OBJS)
263 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
266 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
269 $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
274 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak config-host.ld cscope.out
279 install: $(PROGS) $(SCRIPTS) FORCE
280 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
281 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
282 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
283 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
284 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
286 ifneq ($(wildcard .depend),)