blob: a2d671d6fda8b484a1b8471c77f0890eb3a7eb24 [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 \
Huadong Liuf2a2ce02013-01-30 13:22:24 +010031 helpers.c lib/flist_sort.c lib/hweight.c lib/getrusage.c \
32 idletime.c
Jens Axboe67bf9822013-01-10 11:23:19 +010033
Bruce Cranc81f9342013-01-13 17:09:22 +000034ifdef CONFIG_64BIT_LLP64
35 CFLAGS += -DBITS_PER_LONG=32
36endif
Jens Axboe67bf9822013-01-10 11:23:19 +010037ifdef CONFIG_64BIT
38 CFLAGS += -DBITS_PER_LONG=64
39endif
40ifdef CONFIG_32BIT
41 CFLAGS += -DBITS_PER_LONG=32
42endif
Jens Axboe67bf9822013-01-10 11:23:19 +010043ifdef CONFIG_LIBAIO
Jens Axboe67bf9822013-01-10 11:23:19 +010044 SOURCE += engines/libaio.c
45endif
46ifdef CONFIG_RDMA
Jens Axboe67bf9822013-01-10 11:23:19 +010047 SOURCE += engines/rdma.c
48endif
49ifdef CONFIG_POSIXAIO
Jens Axboe67bf9822013-01-10 11:23:19 +010050 SOURCE += engines/posixaio.c
51endif
52ifdef CONFIG_LINUX_FALLOCATE
53 SOURCE += engines/falloc.c
54endif
55ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
56 SOURCE += engines/e4defrag.c
57endif
58ifdef CONFIG_LINUX_SPLICE
Jens Axboe67bf9822013-01-10 11:23:19 +010059 SOURCE += engines/splice.c
60endif
61ifdef CONFIG_GUASI
Jens Axboe67bf9822013-01-10 11:23:19 +010062 SOURCE += engines/guasi.c
63endif
64ifdef CONFIG_FUSION_AW
Jens Axboe67bf9822013-01-10 11:23:19 +010065 SOURCE += engines/fusion-aw.c
66endif
67ifdef CONFIG_SOLARISAIO
Jens Axboe67bf9822013-01-10 11:23:19 +010068 SOURCE += engines/solarisaio.c
69endif
Jens Axboe4700b232013-01-24 15:33:33 -070070ifdef CONFIG_WINDOWSAIO
Jens Axboe4700b232013-01-24 15:33:33 -070071 SOURCE += engines/windowsaio.c
72endif
Jens Axboe67bf9822013-01-10 11:23:19 +010073ifndef CONFIG_STRSEP
Jens Axboe67bf9822013-01-10 11:23:19 +010074 SOURCE += lib/strsep.c
75endif
76ifndef CONFIG_GETOPT_LONG_ONLY
Jens Axboe67bf9822013-01-10 11:23:19 +010077 SOURCE += lib/getopt_long.c
78endif
Jens Axboe67bf9822013-01-10 11:23:19 +010079ifndef CONFIG_INET_ATON
Jens Axboe67bf9822013-01-10 11:23:19 +010080 SOURCE += lib/inet_aton.c
81endif
Bruce Crand015e392011-01-28 08:39:09 +010082
83ifeq ($(UNAME), Linux)
Jens Axboe67bf9822013-01-10 11:23:19 +010084 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
85 engines/binject.c profiles/tiobench.c
86 LIBS += -lpthread -ldl
Jens Axboe213a01b2011-10-07 13:24:16 +020087 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +010088endif
Aaron Carrollec5c6b12012-11-21 10:39:00 +010089ifeq ($(UNAME), Android)
Jens Axboe67bf9822013-01-10 11:23:19 +010090 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
Aaron Carrollec5c6b12012-11-21 10:39:00 +010091 LIBS += -ldl
92 LDFLAGS += -rdynamic
93 CPPFLAGS += -DFIO_NO_HAVE_SHM_H
94endif
Bruce Crand015e392011-01-28 08:39:09 +010095ifeq ($(UNAME), SunOS)
Bruce Crand015e392011-01-28 08:39:09 +010096 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
97 CPPFLAGS += -D__EXTENSIONS__
98endif
99ifeq ($(UNAME), FreeBSD)
Bruce Crand015e392011-01-28 08:39:09 +0100100 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +0200101 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +0100102endif
103ifeq ($(UNAME), NetBSD)
Bruce Crand015e392011-01-28 08:39:09 +0100104 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +0200105 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +0100106endif
107ifeq ($(UNAME), AIX)
Bruce Crand015e392011-01-28 08:39:09 +0100108 LIBS += -lpthread -ldl -lrt
Bruce Crand015e392011-01-28 08:39:09 +0100109 CPPFLAGS += -D_LARGE_FILES -D__ppc__
Michael Perzl48b35be2011-07-13 20:28:07 +0200110 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
Bruce Crand015e392011-01-28 08:39:09 +0100111endif
Jens Axboec00a2282011-07-08 20:56:06 +0200112ifeq ($(UNAME), HP-UX)
Jens Axboeb5ffb752011-07-09 13:28:19 +0200113 LIBS += -lpthread -ldl -lrt
Jens Axboe67bf9822013-01-10 11:23:19 +0100114 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
Jens Axboec00a2282011-07-08 20:56:06 +0200115endif
Bruce Crand015e392011-01-28 08:39:09 +0100116ifeq ($(UNAME), Darwin)
Bruce Crand015e392011-01-28 08:39:09 +0100117 LIBS += -lpthread -ldl
118endif
119ifneq (,$(findstring CYGWIN,$(UNAME)))
Bruce Cran93bcfd22012-02-20 20:18:19 +0100120 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
Jens Axboe4700b232013-01-24 15:33:33 -0700121 SOURCE += os/windows/posix.c
Bruce Cran93bcfd22012-02-20 20:18:19 +0100122 LIBS += -lpthread -lpsapi -lws2_32
123 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
Bruce Crand015e392011-01-28 08:39:09 +0100124endif
125
Bruce Cran9b836562011-01-08 19:49:54 +0100126OBJS = $(SOURCE:.c=.o)
Jens Axboef67d6ee2013-02-01 15:51:23 +0100127-include $(OBJS:.o=.d)
Jens Axboe79d16312010-03-04 12:43:20 +0100128
Jens Axboe61f78f32011-10-05 10:25:54 +0200129T_SMALLOC_OBJS = t/stest.o
Jens Axboe39ab7da2012-11-06 22:10:43 +0100130T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
Jens Axboe61f78f32011-10-05 10:25:54 +0200131T_SMALLOC_PROGS = t/stest
132
133T_IEEE_OBJS = t/ieee754.o
Jens Axboef98f3d02012-11-06 21:54:30 +0100134T_IEEE_OBJS += lib/ieee754.o
Jens Axboe61f78f32011-10-05 10:25:54 +0200135T_IEEE_PROGS = t/ieee754
136
Jens Axboe6ff38852012-11-06 16:09:14 +0100137T_ZIPF_OBS = t/genzipf.o
Jens Axboe24baa4c2012-11-12 20:54:12 -0700138T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
Jens Axboeeed3f512012-11-07 13:40:01 +0100139T_ZIPF_PROGS = t/genzipf
Jens Axboe6ff38852012-11-06 16:09:14 +0100140
Jens Axboead1f90a2012-11-28 21:29:14 +0100141T_AXMAP_OBJS = t/axmap.o
142T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
143T_AXMAP_PROGS = t/axmap
144
Jens Axboe61f78f32011-10-05 10:25:54 +0200145T_OBJS = $(T_SMALLOC_OBJS)
146T_OBJS += $(T_IEEE_OBJS)
Jens Axboe6ff38852012-11-06 16:09:14 +0100147T_OBJS += $(T_ZIPF_OBJS)
Jens Axboead1f90a2012-11-28 21:29:14 +0100148T_OBJS += $(T_AXMAP_OBJS)
Jens Axboe6ff38852012-11-06 16:09:14 +0100149
150T_PROGS = $(T_SMALLOC_PROGS)
151T_PROGS += $(T_IEEE_PROGS)
152T_PROGS += $(T_ZIPF_PROGS)
Jens Axboead1f90a2012-11-28 21:29:14 +0100153T_PROGS += $(T_AXMAP_PROGS)
Jens Axboe34272072011-08-16 10:01:03 +0200154
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100155ifneq ($(findstring $(MAKEFLAGS),s),s)
156ifndef V
157 QUIET_CC = @echo ' ' CC $@;
Jens Axboe0b2d6a72008-03-03 12:20:26 +0100158 QUIET_DEP = @echo ' ' DEP $@;
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100159endif
160endif
161
Jens Axboec1d57252006-10-09 19:56:04 +0200162INSTALL = install
163prefix = /usr/local
164bindir = $(prefix)/bin
Jens Axboebcdf7c52012-02-08 14:19:27 +0100165
166ifeq ($(UNAME), Darwin)
167mandir = /usr/share/man
168else
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200169mandir = $(prefix)/man
Jens Axboebcdf7c52012-02-08 14:19:27 +0100170endif
Jens Axboec1d57252006-10-09 19:56:04 +0200171
Jens Axboef67d6ee2013-02-01 15:51:23 +0100172all: $(PROGS) $(SCRIPTS) FORCE
Michael Zappef84622e2011-06-01 20:15:18 +0200173
Jens Axboe692a5d22012-04-11 22:07:07 +0200174.PHONY: all install clean
175.PHONY: FORCE cscope
176
177FIO-VERSION-FILE: FORCE
Bruce Cran84306c12012-04-16 19:33:03 +0200178 @$(SHELL) ./FIO-VERSION-GEN
Jens Axboe692a5d22012-04-11 22:07:07 +0200179-include FIO-VERSION-FILE
180
David M. Lee7496ea32013-01-31 18:37:41 +0100181override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
Jens Axboe692a5d22012-04-11 22:07:07 +0200182
Jens Axboef67d6ee2013-02-01 15:51:23 +0100183.c.o: FORCE
Jens Axboe4feafb12013-01-24 23:07:55 -0700184 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
Jens Axboef67d6ee2013-02-01 15:51:23 +0100185 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
186 @mv -f $*.d $*.d.tmp
187 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
188 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
189 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
190 @rm -f $*.d.tmp
Diego Elio Pettenòe52947d2011-03-21 20:13:53 +0100191
Jens Axboea6204b62012-04-13 14:06:08 +0200192init.o: FIO-VERSION-FILE
Jens Axboe4feafb12013-01-24 23:07:55 -0700193 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
Jens Axboea6204b62012-04-13 14:06:08 +0200194
Jens Axboe61f78f32011-10-05 10:25:54 +0200195t/stest: $(T_SMALLOC_OBJS)
196 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
197
198t/ieee754: $(T_IEEE_OBJS)
199 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboefbc27922011-08-16 09:56:27 +0200200
Jens Axboe6ff38852012-11-06 16:09:14 +0100201t/genzipf: $(T_ZIPF_OBJS)
202 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
203
Jens Axboead1f90a2012-11-28 21:29:14 +0100204t/axmap: $(T_AXMAP_OBJS)
205 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
206
Jens Axboe2f9ade32006-10-20 11:25:52 +0200207fio: $(OBJS)
Michael Perzl48b35be2011-07-13 20:28:07 +0200208 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100209
Jens Axboe692a5d22012-04-11 22:07:07 +0200210clean: FORCE
Jens Axboef67d6ee2013-02-01 15:51:23 +0100211 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak cscope.out *.d
Jens Axboeebac4652005-12-08 15:25:21 +0100212
Jens Axboe592ef982006-06-06 20:58:57 +0200213cscope:
Jens Axboe366badd2010-07-19 16:18:35 -0600214 @cscope -b -R
Jens Axboe592ef982006-06-06 20:58:57 +0200215
Jens Axboe692a5d22012-04-11 22:07:07 +0200216install: $(PROGS) $(SCRIPTS) FORCE
Jens Axboe513ba3f2011-04-29 08:24:10 +0200217 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
Jens Axboeebac4652005-12-08 15:25:21 +0100218 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200219 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
220 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
Jens Axboeccd4f412009-05-20 11:36:39 +0200221 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1