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 \
35 CFLAGS += -DBITS_PER_LONG=64
38 CFLAGS += -DBITS_PER_LONG=32
42 CFLAGS += -DCONFIG_LIBAIO
43 SOURCE += engines/libaio.c
46 CFLAGS += -DCONFIG_RDMA
47 SOURCE += engines/rdma.c
50 CFLAGS += -DCONFIG_POSIXAIO
51 SOURCE += engines/posixaio.c
53 ifdef CONFIG_LINUX_FALLOCATE
54 SOURCE += engines/falloc.c
56 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
57 SOURCE += engines/e4defrag.c
59 ifdef CONFIG_LINUX_SPLICE
60 CFLAGS += -DCONFIG_LINUX_SPLICE
61 SOURCE += engines/splice.c
64 CFLAGS += -DCONFIG_GUASI
65 SOURCE += engines/guasi.c
67 ifdef CONFIG_FUSION_AW
68 CFLAGS += -DCONFIG_FUSION_AW
69 SOURCE += engines/fusion-aw.c
71 ifdef CONFIG_SOLARISAIO
72 CFLAGS += -DCONFIG_SOLARISAIO
73 SOURCE += engines/solarisaio.c
77 CFLAGS += -DCONFIG_STRSEP
78 SOURCE += lib/strsep.c
80 ifndef CONFIG_GETOPT_LONG_ONLY
81 CFLAGS += -DCONFIG_GETOPT_LONG_ONLY
82 SOURCE += lib/getopt_long.c
85 ifndef CONFIG_INET_ATON
86 CFLAGS += -DCONFIG_INET_ATON
87 SOURCE += lib/inet_aton.c
89 ifdef CONFIG_CLOCK_GETTIME
90 CFLAGS += -DCONFIG_CLOCK_GETTIME
92 ifdef CONFIG_POSIXAIO_FSYNC
93 CFLAGS += -DCONFIG_POSIXAIO_FSYNC
96 CFLAGS += -DCONFIG_FADVISE
98 ifdef CONFIG_CLOCK_MONOTONIC
99 CFLAGS += -DCONFIG_CLOCK_MONOTONIC
101 ifdef CONFIG_CLOCK_MONOTONIC_PRECISE
102 CFLAGS += -DCONFIG_CLOCK_MONOTONIC_PRECISE
104 ifdef CONFIG_GETTIMEOFDAY
105 CFLAGS += -DCONFIG_GETTIMEOFDAY
107 ifdef CONFIG_SOCKLEN_T
108 CFLAGS += -DCONFIG_SOCKLEN_T
111 CFLAGS += -DCONFIG_SFAA
113 ifdef CONFIG_FDATASYNC
114 CFLAGS += -DCONFIG_FDATASYNC
116 ifdef CONFIG_3ARG_AFFINITY
117 CFLAGS += -DCONFIG_3ARG_AFFINITY
119 ifdef CONFIG_2ARG_AFFINITY
120 CFLAGS += -DCONFIG_2ARG_AFFINITY
122 ifdef CONFIG_SYNC_FILE_RANGE
123 CFLAGS += -DCONFIG_SYNC_FILE_RANGE
126 CFLAGS += -DCONFIG_LIBNUMA
128 ifdef CONFIG_TLS_THREAD
129 CFLAGS += -DCONFIG_TLS_THREAD
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
138 ifeq ($(UNAME), Android)
139 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
142 CPPFLAGS += -DFIO_NO_HAVE_SHM_H
144 ifeq ($(UNAME), SunOS)
145 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
146 CPPFLAGS += -D__EXTENSIONS__
148 ifeq ($(UNAME), FreeBSD)
149 LIBS += -lpthread -lrt
152 ifeq ($(UNAME), NetBSD)
153 LIBS += -lpthread -lrt
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
161 ifeq ($(UNAME), HP-UX)
162 LIBS += -lpthread -ldl -lrt
163 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
165 ifeq ($(UNAME), Darwin)
166 LIBS += -lpthread -ldl
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
175 OBJS = $(SOURCE:.c=.o)
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
181 T_IEEE_OBJS = t/ieee754.o
182 T_IEEE_OBJS += lib/ieee754.o
183 T_IEEE_PROGS = t/ieee754
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
189 T_AXMAP_OBJS = t/axmap.o
190 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
191 T_AXMAP_PROGS = t/axmap
193 T_OBJS = $(T_SMALLOC_OBJS)
194 T_OBJS += $(T_IEEE_OBJS)
195 T_OBJS += $(T_ZIPF_OBJS)
196 T_OBJS += $(T_AXMAP_OBJS)
198 T_PROGS = $(T_SMALLOC_PROGS)
199 T_PROGS += $(T_IEEE_PROGS)
200 T_PROGS += $(T_ZIPF_PROGS)
201 T_PROGS += $(T_AXMAP_PROGS)
203 ifneq ($(findstring $(MAKEFLAGS),s),s)
205 QUIET_CC = @echo ' ' CC $@;
206 QUIET_DEP = @echo ' ' DEP $@;
212 bindir = $(prefix)/bin
214 ifeq ($(UNAME), Darwin)
215 mandir = /usr/share/man
217 mandir = $(prefix)/man
220 all: .depend $(PROGS) $(SCRIPTS) FORCE
222 .PHONY: all install clean
225 FIO-VERSION-FILE: FORCE
226 @$(SHELL) ./FIO-VERSION-GEN
227 -include FIO-VERSION-FILE
229 CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
232 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
234 init.o: FIO-VERSION-FILE
235 $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
237 t/stest: $(T_SMALLOC_OBJS)
238 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
240 t/ieee754: $(T_IEEE_OBJS)
241 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
243 t/genzipf: $(T_ZIPF_OBJS)
244 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
246 t/axmap: $(T_AXMAP_OBJS)
247 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
250 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
253 $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
258 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak config-host.ld cscope.out
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
270 ifneq ($(wildcard .depend),)