blob: 30a7f2e8320caaf91493f72b10775468e9bf8fc0 [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 Axboe67bf9822013-01-10 11:23:19 +010042ifdef CONFIG_LIBAIO
Jens Axboe67bf9822013-01-10 11:23:19 +010043 SOURCE += engines/libaio.c
44endif
45ifdef CONFIG_RDMA
Jens Axboe67bf9822013-01-10 11:23:19 +010046 SOURCE += engines/rdma.c
47endif
48ifdef CONFIG_POSIXAIO
Jens Axboe67bf9822013-01-10 11:23:19 +010049 SOURCE += engines/posixaio.c
50endif
51ifdef CONFIG_LINUX_FALLOCATE
52 SOURCE += engines/falloc.c
53endif
54ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
55 SOURCE += engines/e4defrag.c
56endif
57ifdef CONFIG_LINUX_SPLICE
Jens Axboe67bf9822013-01-10 11:23:19 +010058 SOURCE += engines/splice.c
59endif
60ifdef CONFIG_GUASI
Jens Axboe67bf9822013-01-10 11:23:19 +010061 SOURCE += engines/guasi.c
62endif
63ifdef CONFIG_FUSION_AW
Jens Axboe67bf9822013-01-10 11:23:19 +010064 SOURCE += engines/fusion-aw.c
65endif
66ifdef CONFIG_SOLARISAIO
Jens Axboe67bf9822013-01-10 11:23:19 +010067 SOURCE += engines/solarisaio.c
68endif
Jens Axboe4700b232013-01-24 15:33:33 -070069ifdef CONFIG_WINDOWSAIO
Jens Axboe4700b232013-01-24 15:33:33 -070070 SOURCE += engines/windowsaio.c
71endif
Jens Axboe67bf9822013-01-10 11:23:19 +010072ifndef CONFIG_STRSEP
Jens Axboe67bf9822013-01-10 11:23:19 +010073 SOURCE += lib/strsep.c
74endif
75ifndef CONFIG_GETOPT_LONG_ONLY
Jens Axboe67bf9822013-01-10 11:23:19 +010076 SOURCE += lib/getopt_long.c
77endif
Jens Axboe67bf9822013-01-10 11:23:19 +010078ifndef CONFIG_INET_ATON
Jens Axboe67bf9822013-01-10 11:23:19 +010079 SOURCE += lib/inet_aton.c
80endif
Bruce Crand015e392011-01-28 08:39:09 +010081
82ifeq ($(UNAME), Linux)
Jens Axboe67bf9822013-01-10 11:23:19 +010083 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
84 engines/binject.c profiles/tiobench.c
85 LIBS += -lpthread -ldl
Jens Axboe213a01b2011-10-07 13:24:16 +020086 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +010087endif
Aaron Carrollec5c6b12012-11-21 10:39:00 +010088ifeq ($(UNAME), Android)
Jens Axboe67bf9822013-01-10 11:23:19 +010089 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
Aaron Carrollec5c6b12012-11-21 10:39:00 +010090 LIBS += -ldl
91 LDFLAGS += -rdynamic
92 CPPFLAGS += -DFIO_NO_HAVE_SHM_H
93endif
Bruce Crand015e392011-01-28 08:39:09 +010094ifeq ($(UNAME), SunOS)
Bruce Crand015e392011-01-28 08:39:09 +010095 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
96 CPPFLAGS += -D__EXTENSIONS__
97endif
98ifeq ($(UNAME), FreeBSD)
Bruce Crand015e392011-01-28 08:39:09 +010099 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +0200100 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +0100101endif
102ifeq ($(UNAME), NetBSD)
Bruce Crand015e392011-01-28 08:39:09 +0100103 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +0200104 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +0100105endif
106ifeq ($(UNAME), AIX)
Bruce Crand015e392011-01-28 08:39:09 +0100107 LIBS += -lpthread -ldl -lrt
Bruce Crand015e392011-01-28 08:39:09 +0100108 CPPFLAGS += -D_LARGE_FILES -D__ppc__
Michael Perzl48b35be2011-07-13 20:28:07 +0200109 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
Bruce Crand015e392011-01-28 08:39:09 +0100110endif
Jens Axboec00a2282011-07-08 20:56:06 +0200111ifeq ($(UNAME), HP-UX)
Jens Axboeb5ffb752011-07-09 13:28:19 +0200112 LIBS += -lpthread -ldl -lrt
Jens Axboe67bf9822013-01-10 11:23:19 +0100113 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
Jens Axboec00a2282011-07-08 20:56:06 +0200114endif
Bruce Crand015e392011-01-28 08:39:09 +0100115ifeq ($(UNAME), Darwin)
Bruce Crand015e392011-01-28 08:39:09 +0100116 LIBS += -lpthread -ldl
117endif
118ifneq (,$(findstring CYGWIN,$(UNAME)))
Bruce Cran93bcfd22012-02-20 20:18:19 +0100119 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
Jens Axboe4700b232013-01-24 15:33:33 -0700120 SOURCE += os/windows/posix.c
Bruce Cran93bcfd22012-02-20 20:18:19 +0100121 LIBS += -lpthread -lpsapi -lws2_32
122 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
Bruce Crand015e392011-01-28 08:39:09 +0100123endif
124
Bruce Cran9b836562011-01-08 19:49:54 +0100125OBJS = $(SOURCE:.c=.o)
Jens Axboe79d16312010-03-04 12:43:20 +0100126
Jens Axboe61f78f32011-10-05 10:25:54 +0200127T_SMALLOC_OBJS = t/stest.o
Jens Axboe39ab7da2012-11-06 22:10:43 +0100128T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
Jens Axboe61f78f32011-10-05 10:25:54 +0200129T_SMALLOC_PROGS = t/stest
130
131T_IEEE_OBJS = t/ieee754.o
Jens Axboef98f3d02012-11-06 21:54:30 +0100132T_IEEE_OBJS += lib/ieee754.o
Jens Axboe61f78f32011-10-05 10:25:54 +0200133T_IEEE_PROGS = t/ieee754
134
Jens Axboe6ff38852012-11-06 16:09:14 +0100135T_ZIPF_OBS = t/genzipf.o
Jens Axboe24baa4c2012-11-12 20:54:12 -0700136T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
Jens Axboeeed3f512012-11-07 13:40:01 +0100137T_ZIPF_PROGS = t/genzipf
Jens Axboe6ff38852012-11-06 16:09:14 +0100138
Jens Axboead1f90a2012-11-28 21:29:14 +0100139T_AXMAP_OBJS = t/axmap.o
140T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
141T_AXMAP_PROGS = t/axmap
142
Jens Axboe61f78f32011-10-05 10:25:54 +0200143T_OBJS = $(T_SMALLOC_OBJS)
144T_OBJS += $(T_IEEE_OBJS)
Jens Axboe6ff38852012-11-06 16:09:14 +0100145T_OBJS += $(T_ZIPF_OBJS)
Jens Axboead1f90a2012-11-28 21:29:14 +0100146T_OBJS += $(T_AXMAP_OBJS)
Jens Axboe6ff38852012-11-06 16:09:14 +0100147
148T_PROGS = $(T_SMALLOC_PROGS)
149T_PROGS += $(T_IEEE_PROGS)
150T_PROGS += $(T_ZIPF_PROGS)
Jens Axboead1f90a2012-11-28 21:29:14 +0100151T_PROGS += $(T_AXMAP_PROGS)
Jens Axboe34272072011-08-16 10:01:03 +0200152
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100153ifneq ($(findstring $(MAKEFLAGS),s),s)
154ifndef V
155 QUIET_CC = @echo ' ' CC $@;
Jens Axboe0b2d6a72008-03-03 12:20:26 +0100156 QUIET_DEP = @echo ' ' DEP $@;
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100157endif
158endif
159
Jens Axboec1d57252006-10-09 19:56:04 +0200160INSTALL = install
161prefix = /usr/local
162bindir = $(prefix)/bin
Jens Axboebcdf7c52012-02-08 14:19:27 +0100163
164ifeq ($(UNAME), Darwin)
165mandir = /usr/share/man
166else
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200167mandir = $(prefix)/man
Jens Axboebcdf7c52012-02-08 14:19:27 +0100168endif
Jens Axboec1d57252006-10-09 19:56:04 +0200169
Jens Axboe692a5d22012-04-11 22:07:07 +0200170all: .depend $(PROGS) $(SCRIPTS) FORCE
Michael Zappef84622e2011-06-01 20:15:18 +0200171
Jens Axboe692a5d22012-04-11 22:07:07 +0200172.PHONY: all install clean
173.PHONY: FORCE cscope
174
175FIO-VERSION-FILE: FORCE
Bruce Cran84306c12012-04-16 19:33:03 +0200176 @$(SHELL) ./FIO-VERSION-GEN
Jens Axboe692a5d22012-04-11 22:07:07 +0200177-include FIO-VERSION-FILE
178
179CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
180
181.c.o: .depend FORCE
Jens Axboe4feafb12013-01-24 23:07:55 -0700182 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
Diego Elio Pettenòe52947d2011-03-21 20:13:53 +0100183
Jens Axboea6204b62012-04-13 14:06:08 +0200184init.o: FIO-VERSION-FILE
Jens Axboe4feafb12013-01-24 23:07:55 -0700185 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
Jens Axboea6204b62012-04-13 14:06:08 +0200186
Jens Axboe61f78f32011-10-05 10:25:54 +0200187t/stest: $(T_SMALLOC_OBJS)
188 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
189
190t/ieee754: $(T_IEEE_OBJS)
191 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboefbc27922011-08-16 09:56:27 +0200192
Jens Axboe6ff38852012-11-06 16:09:14 +0100193t/genzipf: $(T_ZIPF_OBJS)
194 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
195
Jens Axboead1f90a2012-11-28 21:29:14 +0100196t/axmap: $(T_AXMAP_OBJS)
197 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
198
Jens Axboe2f9ade32006-10-20 11:25:52 +0200199fio: $(OBJS)
Michael Perzl48b35be2011-07-13 20:28:07 +0200200 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100201
Michael Zappef84622e2011-06-01 20:15:18 +0200202.depend: $(SOURCE)
Bruce Cran9b836562011-01-08 19:49:54 +0100203 $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
Jens Axboe0b2d6a72008-03-03 12:20:26 +0100204
Jens Axboe8541f322012-04-11 22:24:19 +0200205$(PROGS): .depend
Jens Axboeebac4652005-12-08 15:25:21 +0100206
Jens Axboe692a5d22012-04-11 22:07:07 +0200207clean: FORCE
Jens Axboe67bf9822013-01-10 11:23:19 +0100208 -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 +0100209
Jens Axboe592ef982006-06-06 20:58:57 +0200210cscope:
Jens Axboe366badd2010-07-19 16:18:35 -0600211 @cscope -b -R
Jens Axboe592ef982006-06-06 20:58:57 +0200212
Jens Axboe692a5d22012-04-11 22:07:07 +0200213install: $(PROGS) $(SCRIPTS) FORCE
Jens Axboe513ba3f2011-04-29 08:24:10 +0200214 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
Jens Axboeebac4652005-12-08 15:25:21 +0100215 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200216 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
217 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
Jens Axboeccd4f412009-05-20 11:36:39 +0200218 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
Jens Axboeebac4652005-12-08 15:25:21 +0100219
Jens Axboe06fecb42008-03-03 12:22:19 +0100220ifneq ($(wildcard .depend),)
221include .depend
222endif