blob: 27e82c660a665b4d18ca2949e8c639ab5f5c9001 [file] [log] [blame]
Jens Axboe67bf9822013-01-10 11:23:19 +01001ifneq ($(wildcard config-host.mak),)
2all:
3include config-host.mak
4config-host-mak: configure
5 @echo $@ is out-of-date, running configure
6 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
7else
8config-host.mak:
9 @echo "Running configure for you..."
10 @./configure
11all:
12include config-host.mak
13endif
14
Jens Axboeaf4862b2013-03-29 08:55:32 -060015DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
16CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(DEBUGFLAGS)
17OPTFLAGS= -O3 -g -ffast-math
18CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS)
19LIBS += -lm $(EXTLIBS)
20PROGS = fio
21SCRIPTS = fio_generate_plots
22
Bruce Cran93bcfd22012-02-20 20:18:19 +010023SOURCE := gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \
Bruce Crand015e392011-01-28 08:39:09 +010024 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
25 rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
Jens Axboec7c6cb42011-10-13 14:12:40 +020026 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
Jens Axboed48a9792011-07-09 08:54:26 +020027 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
Jens Axboe62cb17d2012-09-19 21:36:18 +020028 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
Jens Axboe67bf9822013-01-10 11:23:19 +010029 json.c lib/zipf.c lib/axmap.c lib/lfsr.c gettime-thread.c \
Huadong Liuf2a2ce02013-01-30 13:22:24 +010030 helpers.c lib/flist_sort.c lib/hweight.c lib/getrusage.c \
31 idletime.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
Aaron Carroll53cd4ee2013-03-14 16:57:38 +110082ifeq ($(CONFIG_TARGET_OS), 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 Carroll53cd4ee2013-03-14 16:57:38 +110088ifeq ($(CONFIG_TARGET_OS), 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
Aaron Carrollec5c6b12012-11-21 10:39:00 +010092endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +110093ifeq ($(CONFIG_TARGET_OS), SunOS)
Jens Axboe7366ad02013-02-28 20:34:31 +010094 LIBS += -lpthread -ldl
Bruce Crand015e392011-01-28 08:39:09 +010095 CPPFLAGS += -D__EXTENSIONS__
96endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +110097ifeq ($(CONFIG_TARGET_OS), FreeBSD)
Bruce Crand015e392011-01-28 08:39:09 +010098 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +020099 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +0100100endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100101ifeq ($(CONFIG_TARGET_OS), NetBSD)
Bruce Crand015e392011-01-28 08:39:09 +0100102 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +0200103 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +0100104endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100105ifeq ($(CONFIG_TARGET_OS), AIX)
Bruce Crand015e392011-01-28 08:39:09 +0100106 LIBS += -lpthread -ldl -lrt
Bruce Crand015e392011-01-28 08:39:09 +0100107 CPPFLAGS += -D_LARGE_FILES -D__ppc__
Michael Perzl48b35be2011-07-13 20:28:07 +0200108 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
Bruce Crand015e392011-01-28 08:39:09 +0100109endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100110ifeq ($(CONFIG_TARGET_OS), HP-UX)
Jens Axboeb5ffb752011-07-09 13:28:19 +0200111 LIBS += -lpthread -ldl -lrt
Jens Axboe67bf9822013-01-10 11:23:19 +0100112 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
Jens Axboec00a2282011-07-08 20:56:06 +0200113endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100114ifeq ($(CONFIG_TARGET_OS), Darwin)
Bruce Crand015e392011-01-28 08:39:09 +0100115 LIBS += -lpthread -ldl
116endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100117ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
Bruce Cran93bcfd22012-02-20 20:18:19 +0100118 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
Jens Axboe4700b232013-01-24 15:33:33 -0700119 SOURCE += os/windows/posix.c
Bruce Cran93bcfd22012-02-20 20:18:19 +0100120 LIBS += -lpthread -lpsapi -lws2_32
121 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
Bruce Crand015e392011-01-28 08:39:09 +0100122endif
123
Bruce Cran9b836562011-01-08 19:49:54 +0100124OBJS = $(SOURCE:.c=.o)
Jens Axboef67d6ee2013-02-01 15:51:23 +0100125-include $(OBJS:.o=.d)
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
Alex Pyrgiotis7a887ff2013-03-08 14:37:04 +0200143T_LFSR_TEST_OBJS = t/lfsr-test.o
144T_LFSR_TEST_OBJS += lib/lfsr.o
145T_LFSR_TEST_PROGS = t/lfsr-test
146
Jens Axboe61f78f32011-10-05 10:25:54 +0200147T_OBJS = $(T_SMALLOC_OBJS)
148T_OBJS += $(T_IEEE_OBJS)
Jens Axboe6ff38852012-11-06 16:09:14 +0100149T_OBJS += $(T_ZIPF_OBJS)
Jens Axboead1f90a2012-11-28 21:29:14 +0100150T_OBJS += $(T_AXMAP_OBJS)
Alex Pyrgiotis7a887ff2013-03-08 14:37:04 +0200151T_OBJS += $(T_LFSR_TEST_OBJS)
Jens Axboe6ff38852012-11-06 16:09:14 +0100152
153T_PROGS = $(T_SMALLOC_PROGS)
154T_PROGS += $(T_IEEE_PROGS)
155T_PROGS += $(T_ZIPF_PROGS)
Jens Axboead1f90a2012-11-28 21:29:14 +0100156T_PROGS += $(T_AXMAP_PROGS)
Alex Pyrgiotis7a887ff2013-03-08 14:37:04 +0200157T_PROGS += $(T_LFSR_TEST_PROGS)
Jens Axboe34272072011-08-16 10:01:03 +0200158
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100159ifneq ($(findstring $(MAKEFLAGS),s),s)
160ifndef V
161 QUIET_CC = @echo ' ' CC $@;
Jens Axboe6ce038d2013-02-07 15:40:37 +0100162 QUIET_LINK = @echo ' ' LINK $@;
Jens Axboe0b2d6a72008-03-03 12:20:26 +0100163 QUIET_DEP = @echo ' ' DEP $@;
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100164endif
165endif
166
Jens Axboec1d57252006-10-09 19:56:04 +0200167INSTALL = install
168prefix = /usr/local
169bindir = $(prefix)/bin
Jens Axboebcdf7c52012-02-08 14:19:27 +0100170
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100171ifeq ($(CONFIG_TARGET_OS), Darwin)
Jens Axboebcdf7c52012-02-08 14:19:27 +0100172mandir = /usr/share/man
173else
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200174mandir = $(prefix)/man
Jens Axboebcdf7c52012-02-08 14:19:27 +0100175endif
Jens Axboec1d57252006-10-09 19:56:04 +0200176
Jens Axboef67d6ee2013-02-01 15:51:23 +0100177all: $(PROGS) $(SCRIPTS) FORCE
Michael Zappef84622e2011-06-01 20:15:18 +0200178
Jens Axboe692a5d22012-04-11 22:07:07 +0200179.PHONY: all install clean
180.PHONY: FORCE cscope
181
182FIO-VERSION-FILE: FORCE
Bruce Cran84306c12012-04-16 19:33:03 +0200183 @$(SHELL) ./FIO-VERSION-GEN
Jens Axboe692a5d22012-04-11 22:07:07 +0200184-include FIO-VERSION-FILE
185
David M. Lee7496ea32013-01-31 18:37:41 +0100186override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
Jens Axboe692a5d22012-04-11 22:07:07 +0200187
Jens Axboecb340b12013-02-05 11:03:12 +0100188.c.o: FORCE FIO-VERSION-FILE
Jens Axboe4feafb12013-01-24 23:07:55 -0700189 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
Jens Axboef67d6ee2013-02-01 15:51:23 +0100190 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
191 @mv -f $*.d $*.d.tmp
192 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
193 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
194 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
195 @rm -f $*.d.tmp
Diego Elio Pettenòe52947d2011-03-21 20:13:53 +0100196
Jens Axboecb340b12013-02-05 11:03:12 +0100197init.o: FIO-VERSION-FILE init.c
Jens Axboe4feafb12013-01-24 23:07:55 -0700198 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
Jens Axboea6204b62012-04-13 14:06:08 +0200199
Jens Axboe61f78f32011-10-05 10:25:54 +0200200t/stest: $(T_SMALLOC_OBJS)
Jens Axboe6ce038d2013-02-07 15:40:37 +0100201 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboe61f78f32011-10-05 10:25:54 +0200202
203t/ieee754: $(T_IEEE_OBJS)
Jens Axboe6ce038d2013-02-07 15:40:37 +0100204 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboefbc27922011-08-16 09:56:27 +0200205
Jens Axboe6ff38852012-11-06 16:09:14 +0100206t/genzipf: $(T_ZIPF_OBJS)
Jens Axboe6ce038d2013-02-07 15:40:37 +0100207 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboe6ff38852012-11-06 16:09:14 +0100208
Jens Axboead1f90a2012-11-28 21:29:14 +0100209t/axmap: $(T_AXMAP_OBJS)
Jens Axboe6ce038d2013-02-07 15:40:37 +0100210 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboead1f90a2012-11-28 21:29:14 +0100211
Alex Pyrgiotis7a887ff2013-03-08 14:37:04 +0200212t/lfsr-test: $(T_LFSR_TEST_OBJS)
213 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS) $(LDFLAGS)
214
Jens Axboe2f9ade32006-10-20 11:25:52 +0200215fio: $(OBJS)
Jens Axboe6ce038d2013-02-07 15:40:37 +0100216 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100217
Jens Axboe692a5d22012-04-11 22:07:07 +0200218clean: FORCE
Oleg Matcovschiff01f0f2013-03-12 00:04:16 -0700219 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak config-host.h cscope.out *.d
Jens Axboeebac4652005-12-08 15:25:21 +0100220
Jens Axboe592ef982006-06-06 20:58:57 +0200221cscope:
Jens Axboe366badd2010-07-19 16:18:35 -0600222 @cscope -b -R
Jens Axboe592ef982006-06-06 20:58:57 +0200223
Jens Axboe692a5d22012-04-11 22:07:07 +0200224install: $(PROGS) $(SCRIPTS) FORCE
Jens Axboe513ba3f2011-04-29 08:24:10 +0200225 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
Jens Axboeebac4652005-12-08 15:25:21 +0100226 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200227 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
228 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
Jens Axboeccd4f412009-05-20 11:36:39 +0200229 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1