blob: dab6e888546f2ced159a7edb2b66d30e3cf15878 [file] [log] [blame]
Jens Axboe79e48f72008-02-01 20:37:09 +01001DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
Jens Axboe44404c52013-01-24 14:20:09 -07002CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(DEBUGFLAGS)
Jens Axboeb14c9ed2013-01-08 13:41:35 +01003OPTFLAGS= -O3 -g -ffast-math $(EXTFLAGS)
Bruce Crand015e392011-01-28 08:39:09 +01004CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS)
Yufei Renb6cf38f2011-08-02 12:15:30 +02005LIBS = -lm $(EXTLIBS)
Jens Axboeebac4652005-12-08 15:25:21 +01006PROGS = fio
7SCRIPTS = fio_generate_plots
Bruce Crand015e392011-01-28 08:39:09 +01008UNAME := $(shell uname)
9
Jens Axboe67bf9822013-01-10 11:23:19 +010010ifneq ($(wildcard config-host.mak),)
11all:
12include config-host.mak
13config-host-mak: configure
14 @echo $@ is out-of-date, running configure
15 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
16else
17config-host.mak:
18 @echo "Running configure for you..."
19 @./configure
20all:
21include config-host.mak
22endif
23
Bruce Cran93bcfd22012-02-20 20:18:19 +010024SOURCE := gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \
Bruce Crand015e392011-01-28 08:39:09 +010025 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 \
Jens Axboec7c6cb42011-10-13 14:12:40 +020027 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
Jens Axboed48a9792011-07-09 08:54:26 +020028 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
Jens Axboe62cb17d2012-09-19 21:36:18 +020029 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
Jens Axboe67bf9822013-01-10 11:23:19 +010030 json.c lib/zipf.c lib/axmap.c lib/lfsr.c gettime-thread.c \
Jens Axboe44404c52013-01-24 14:20:09 -070031 helpers.c lib/flist_sort.c lib/hweight.c lib/getrusage.c
Jens Axboe67bf9822013-01-10 11:23:19 +010032
Bruce Cranc81f9342013-01-13 17:09:22 +000033ifdef CONFIG_64BIT_LLP64
34 CFLAGS += -DBITS_PER_LONG=32
35endif
Jens Axboe67bf9822013-01-10 11:23:19 +010036ifdef CONFIG_64BIT
37 CFLAGS += -DBITS_PER_LONG=64
38endif
39ifdef CONFIG_32BIT
40 CFLAGS += -DBITS_PER_LONG=32
41endif
Jens Axboe0dcebdf2013-01-23 15:42:16 -070042ifdef CONFIG_BIG_ENDIAN
43 CFLAGS += -DCONFIG_BIG_ENDIAN
44endif
45ifdef CONFIG_LITTLE_ENDIAN
46 CFLAGS += -DCONFIG_LITTLE_ENDIAN
47endif
Jens Axboe67bf9822013-01-10 11:23:19 +010048ifdef CONFIG_LIBAIO
49 CFLAGS += -DCONFIG_LIBAIO
50 SOURCE += engines/libaio.c
51endif
52ifdef CONFIG_RDMA
53 CFLAGS += -DCONFIG_RDMA
54 SOURCE += engines/rdma.c
55endif
56ifdef CONFIG_POSIXAIO
57 CFLAGS += -DCONFIG_POSIXAIO
58 SOURCE += engines/posixaio.c
59endif
60ifdef CONFIG_LINUX_FALLOCATE
61 SOURCE += engines/falloc.c
62endif
63ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
Jens Axboe997843c2013-01-24 15:27:40 -070064 CFLAGS += -DCONFIG_LINUX_EXT4_MOVE_EXTENT
Jens Axboe67bf9822013-01-10 11:23:19 +010065 SOURCE += engines/e4defrag.c
66endif
67ifdef CONFIG_LINUX_SPLICE
68 CFLAGS += -DCONFIG_LINUX_SPLICE
69 SOURCE += engines/splice.c
70endif
71ifdef CONFIG_GUASI
72 CFLAGS += -DCONFIG_GUASI
73 SOURCE += engines/guasi.c
74endif
75ifdef CONFIG_FUSION_AW
76 CFLAGS += -DCONFIG_FUSION_AW
77 SOURCE += engines/fusion-aw.c
78endif
79ifdef CONFIG_SOLARISAIO
80 CFLAGS += -DCONFIG_SOLARISAIO
81 SOURCE += engines/solarisaio.c
82endif
Jens Axboe4700b232013-01-24 15:33:33 -070083ifdef CONFIG_WINDOWSAIO
84 CFLAGS += -DCONFIG_WINDOWSAIO
85 SOURCE += engines/windowsaio.c
86endif
Jens Axboe67bf9822013-01-10 11:23:19 +010087
88ifndef CONFIG_STRSEP
89 CFLAGS += -DCONFIG_STRSEP
90 SOURCE += lib/strsep.c
91endif
92ifndef CONFIG_GETOPT_LONG_ONLY
93 CFLAGS += -DCONFIG_GETOPT_LONG_ONLY
94 SOURCE += lib/getopt_long.c
95endif
96
97ifndef CONFIG_INET_ATON
98 CFLAGS += -DCONFIG_INET_ATON
99 SOURCE += lib/inet_aton.c
100endif
101ifdef CONFIG_CLOCK_GETTIME
102 CFLAGS += -DCONFIG_CLOCK_GETTIME
103endif
104ifdef CONFIG_POSIXAIO_FSYNC
105 CFLAGS += -DCONFIG_POSIXAIO_FSYNC
106endif
107ifdef CONFIG_FADVISE
108 CFLAGS += -DCONFIG_FADVISE
109endif
110ifdef CONFIG_CLOCK_MONOTONIC
111 CFLAGS += -DCONFIG_CLOCK_MONOTONIC
112endif
113ifdef CONFIG_CLOCK_MONOTONIC_PRECISE
114 CFLAGS += -DCONFIG_CLOCK_MONOTONIC_PRECISE
115endif
116ifdef CONFIG_GETTIMEOFDAY
117 CFLAGS += -DCONFIG_GETTIMEOFDAY
118endif
119ifdef CONFIG_SOCKLEN_T
120 CFLAGS += -DCONFIG_SOCKLEN_T
121endif
122ifdef CONFIG_SFAA
123 CFLAGS += -DCONFIG_SFAA
124endif
125ifdef CONFIG_FDATASYNC
126 CFLAGS += -DCONFIG_FDATASYNC
127endif
128ifdef CONFIG_3ARG_AFFINITY
129 CFLAGS += -DCONFIG_3ARG_AFFINITY
130endif
131ifdef CONFIG_2ARG_AFFINITY
132 CFLAGS += -DCONFIG_2ARG_AFFINITY
133endif
134ifdef CONFIG_SYNC_FILE_RANGE
135 CFLAGS += -DCONFIG_SYNC_FILE_RANGE
136endif
137ifdef CONFIG_LIBNUMA
138 CFLAGS += -DCONFIG_LIBNUMA
139endif
140ifdef CONFIG_TLS_THREAD
141 CFLAGS += -DCONFIG_TLS_THREAD
142endif
Bruce Cranc81f9342013-01-13 17:09:22 +0000143ifdef CONFIG_POSIX_FALLOCATE
144 CFLAGS += -DCONFIG_POSIX_FALLOCATE
145endif
146ifdef CONFIG_LINUX_FALLOCATE
147 CFLAGS += -DCONFIG_LINUX_FALLOCATE
148endif
Jens Axboe44404c52013-01-24 14:20:09 -0700149ifdef CONFIG_RUSAGE_THREAD
150 CFLAGS += -DCONFIG_RUSAGE_THREAD
151endif
Bruce Crand015e392011-01-28 08:39:09 +0100152
153ifeq ($(UNAME), Linux)
Jens Axboe67bf9822013-01-10 11:23:19 +0100154 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
155 engines/binject.c profiles/tiobench.c
156 LIBS += -lpthread -ldl
Jens Axboe213a01b2011-10-07 13:24:16 +0200157 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +0100158endif
Aaron Carrollec5c6b12012-11-21 10:39:00 +0100159ifeq ($(UNAME), Android)
Jens Axboe67bf9822013-01-10 11:23:19 +0100160 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
Aaron Carrollec5c6b12012-11-21 10:39:00 +0100161 LIBS += -ldl
162 LDFLAGS += -rdynamic
163 CPPFLAGS += -DFIO_NO_HAVE_SHM_H
164endif
Bruce Crand015e392011-01-28 08:39:09 +0100165ifeq ($(UNAME), SunOS)
Bruce Crand015e392011-01-28 08:39:09 +0100166 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
167 CPPFLAGS += -D__EXTENSIONS__
168endif
169ifeq ($(UNAME), FreeBSD)
Bruce Crand015e392011-01-28 08:39:09 +0100170 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +0200171 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +0100172endif
173ifeq ($(UNAME), NetBSD)
Bruce Crand015e392011-01-28 08:39:09 +0100174 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +0200175 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +0100176endif
177ifeq ($(UNAME), AIX)
Bruce Crand015e392011-01-28 08:39:09 +0100178 LIBS += -lpthread -ldl -lrt
Bruce Crand015e392011-01-28 08:39:09 +0100179 CPPFLAGS += -D_LARGE_FILES -D__ppc__
Michael Perzl48b35be2011-07-13 20:28:07 +0200180 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
Bruce Crand015e392011-01-28 08:39:09 +0100181endif
Jens Axboec00a2282011-07-08 20:56:06 +0200182ifeq ($(UNAME), HP-UX)
Jens Axboeb5ffb752011-07-09 13:28:19 +0200183 LIBS += -lpthread -ldl -lrt
Jens Axboe67bf9822013-01-10 11:23:19 +0100184 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
Jens Axboec00a2282011-07-08 20:56:06 +0200185endif
Bruce Crand015e392011-01-28 08:39:09 +0100186ifeq ($(UNAME), Darwin)
Bruce Crand015e392011-01-28 08:39:09 +0100187 LIBS += -lpthread -ldl
188endif
189ifneq (,$(findstring CYGWIN,$(UNAME)))
Bruce Cran93bcfd22012-02-20 20:18:19 +0100190 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
Jens Axboe4700b232013-01-24 15:33:33 -0700191 SOURCE += os/windows/posix.c
Bruce Cran93bcfd22012-02-20 20:18:19 +0100192 LIBS += -lpthread -lpsapi -lws2_32
193 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
Bruce Crand015e392011-01-28 08:39:09 +0100194endif
195
Bruce Cran9b836562011-01-08 19:49:54 +0100196OBJS = $(SOURCE:.c=.o)
Jens Axboe79d16312010-03-04 12:43:20 +0100197
Jens Axboe61f78f32011-10-05 10:25:54 +0200198T_SMALLOC_OBJS = t/stest.o
Jens Axboe39ab7da2012-11-06 22:10:43 +0100199T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
Jens Axboe61f78f32011-10-05 10:25:54 +0200200T_SMALLOC_PROGS = t/stest
201
202T_IEEE_OBJS = t/ieee754.o
Jens Axboef98f3d02012-11-06 21:54:30 +0100203T_IEEE_OBJS += lib/ieee754.o
Jens Axboe61f78f32011-10-05 10:25:54 +0200204T_IEEE_PROGS = t/ieee754
205
Jens Axboe6ff38852012-11-06 16:09:14 +0100206T_ZIPF_OBS = t/genzipf.o
Jens Axboe24baa4c2012-11-12 20:54:12 -0700207T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
Jens Axboeeed3f512012-11-07 13:40:01 +0100208T_ZIPF_PROGS = t/genzipf
Jens Axboe6ff38852012-11-06 16:09:14 +0100209
Jens Axboead1f90a2012-11-28 21:29:14 +0100210T_AXMAP_OBJS = t/axmap.o
211T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
212T_AXMAP_PROGS = t/axmap
213
Jens Axboe61f78f32011-10-05 10:25:54 +0200214T_OBJS = $(T_SMALLOC_OBJS)
215T_OBJS += $(T_IEEE_OBJS)
Jens Axboe6ff38852012-11-06 16:09:14 +0100216T_OBJS += $(T_ZIPF_OBJS)
Jens Axboead1f90a2012-11-28 21:29:14 +0100217T_OBJS += $(T_AXMAP_OBJS)
Jens Axboe6ff38852012-11-06 16:09:14 +0100218
219T_PROGS = $(T_SMALLOC_PROGS)
220T_PROGS += $(T_IEEE_PROGS)
221T_PROGS += $(T_ZIPF_PROGS)
Jens Axboead1f90a2012-11-28 21:29:14 +0100222T_PROGS += $(T_AXMAP_PROGS)
Jens Axboe34272072011-08-16 10:01:03 +0200223
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100224ifneq ($(findstring $(MAKEFLAGS),s),s)
225ifndef V
226 QUIET_CC = @echo ' ' CC $@;
Jens Axboe0b2d6a72008-03-03 12:20:26 +0100227 QUIET_DEP = @echo ' ' DEP $@;
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100228endif
229endif
230
Jens Axboec1d57252006-10-09 19:56:04 +0200231INSTALL = install
232prefix = /usr/local
233bindir = $(prefix)/bin
Jens Axboebcdf7c52012-02-08 14:19:27 +0100234
235ifeq ($(UNAME), Darwin)
236mandir = /usr/share/man
237else
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200238mandir = $(prefix)/man
Jens Axboebcdf7c52012-02-08 14:19:27 +0100239endif
Jens Axboec1d57252006-10-09 19:56:04 +0200240
Jens Axboe692a5d22012-04-11 22:07:07 +0200241all: .depend $(PROGS) $(SCRIPTS) FORCE
Michael Zappef84622e2011-06-01 20:15:18 +0200242
Jens Axboe692a5d22012-04-11 22:07:07 +0200243.PHONY: all install clean
244.PHONY: FORCE cscope
245
246FIO-VERSION-FILE: FORCE
Bruce Cran84306c12012-04-16 19:33:03 +0200247 @$(SHELL) ./FIO-VERSION-GEN
Jens Axboe692a5d22012-04-11 22:07:07 +0200248-include FIO-VERSION-FILE
249
250CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
251
252.c.o: .depend FORCE
Bruce Cran9b836562011-01-08 19:49:54 +0100253 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
Diego Elio Pettenòe52947d2011-03-21 20:13:53 +0100254
Jens Axboea6204b62012-04-13 14:06:08 +0200255init.o: FIO-VERSION-FILE
256 $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
257
Jens Axboe61f78f32011-10-05 10:25:54 +0200258t/stest: $(T_SMALLOC_OBJS)
259 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
260
261t/ieee754: $(T_IEEE_OBJS)
262 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboefbc27922011-08-16 09:56:27 +0200263
Jens Axboe6ff38852012-11-06 16:09:14 +0100264t/genzipf: $(T_ZIPF_OBJS)
265 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
266
Jens Axboead1f90a2012-11-28 21:29:14 +0100267t/axmap: $(T_AXMAP_OBJS)
268 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
269
Jens Axboe2f9ade32006-10-20 11:25:52 +0200270fio: $(OBJS)
Michael Perzl48b35be2011-07-13 20:28:07 +0200271 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100272
Michael Zappef84622e2011-06-01 20:15:18 +0200273.depend: $(SOURCE)
Bruce Cran9b836562011-01-08 19:49:54 +0100274 $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
Jens Axboe0b2d6a72008-03-03 12:20:26 +0100275
Jens Axboe8541f322012-04-11 22:24:19 +0200276$(PROGS): .depend
Jens Axboeebac4652005-12-08 15:25:21 +0100277
Jens Axboe692a5d22012-04-11 22:07:07 +0200278clean: FORCE
Jens Axboe67bf9822013-01-10 11:23:19 +0100279 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak config-host.ld cscope.out
Jens Axboeebac4652005-12-08 15:25:21 +0100280
Jens Axboe592ef982006-06-06 20:58:57 +0200281cscope:
Jens Axboe366badd2010-07-19 16:18:35 -0600282 @cscope -b -R
Jens Axboe592ef982006-06-06 20:58:57 +0200283
Jens Axboe692a5d22012-04-11 22:07:07 +0200284install: $(PROGS) $(SCRIPTS) FORCE
Jens Axboe513ba3f2011-04-29 08:24:10 +0200285 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
Jens Axboeebac4652005-12-08 15:25:21 +0100286 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200287 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
288 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
Jens Axboeccd4f412009-05-20 11:36:39 +0200289 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
Jens Axboeebac4652005-12-08 15:25:21 +0100290
Jens Axboe06fecb42008-03-03 12:22:19 +0100291ifneq ($(wildcard .depend),)
292include .depend
293endif