blob: 21e6ad33dc5785665569abfa2c91ff66fc2dcf8e [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
Jens Axboe91f94d52013-01-24 10:25:42 -070023ifdef CONFIG_GFIO
24 PROGS += gfio
25endif
26
Jens Axboeea783f82013-04-05 12:54:03 +020027SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
Bruce Crand015e392011-01-28 08:39:09 +010028 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
Jens Axboe05775432012-03-21 14:07:11 +010029 lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
Jens Axboec7c6cb42011-10-13 14:12:40 +020030 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
Jens Axboed48a9792011-07-09 08:54:26 +020031 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
Jens Axboe2dc1cbb2012-03-08 14:52:25 +010032 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
Jens Axboe9a0db1e2012-12-03 14:38:08 +010033 cconv.c lib/prio_tree.c json.c lib/zipf.c lib/axmap.c \
Jens Axboe836fcc02013-01-24 09:08:45 -070034 lib/lfsr.c gettime-thread.c helpers.c lib/flist_sort.c \
Jens Axboe95820b62013-01-31 13:23:40 +010035 lib/hweight.c lib/getrusage.c idletime.c
Jens Axboe67bf9822013-01-10 11:23:19 +010036
Bruce Cranc81f9342013-01-13 17:09:22 +000037ifdef CONFIG_64BIT_LLP64
38 CFLAGS += -DBITS_PER_LONG=32
39endif
Jens Axboe67bf9822013-01-10 11:23:19 +010040ifdef CONFIG_64BIT
41 CFLAGS += -DBITS_PER_LONG=64
42endif
43ifdef CONFIG_32BIT
44 CFLAGS += -DBITS_PER_LONG=32
45endif
Jens Axboe67bf9822013-01-10 11:23:19 +010046ifdef CONFIG_LIBAIO
Jens Axboe67bf9822013-01-10 11:23:19 +010047 SOURCE += engines/libaio.c
48endif
49ifdef CONFIG_RDMA
Jens Axboe67bf9822013-01-10 11:23:19 +010050 SOURCE += engines/rdma.c
51endif
52ifdef CONFIG_POSIXAIO
Jens Axboe67bf9822013-01-10 11:23:19 +010053 SOURCE += engines/posixaio.c
54endif
55ifdef CONFIG_LINUX_FALLOCATE
56 SOURCE += engines/falloc.c
57endif
58ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
59 SOURCE += engines/e4defrag.c
60endif
61ifdef CONFIG_LINUX_SPLICE
Jens Axboe67bf9822013-01-10 11:23:19 +010062 SOURCE += engines/splice.c
63endif
64ifdef CONFIG_GUASI
Jens Axboe67bf9822013-01-10 11:23:19 +010065 SOURCE += engines/guasi.c
66endif
67ifdef CONFIG_FUSION_AW
Jens Axboe67bf9822013-01-10 11:23:19 +010068 SOURCE += engines/fusion-aw.c
69endif
70ifdef CONFIG_SOLARISAIO
Jens Axboe67bf9822013-01-10 11:23:19 +010071 SOURCE += engines/solarisaio.c
72endif
Jens Axboe4700b232013-01-24 15:33:33 -070073ifdef CONFIG_WINDOWSAIO
Jens Axboe4700b232013-01-24 15:33:33 -070074 SOURCE += engines/windowsaio.c
75endif
Jens Axboe67bf9822013-01-10 11:23:19 +010076ifndef CONFIG_STRSEP
Jens Axboe67bf9822013-01-10 11:23:19 +010077 SOURCE += lib/strsep.c
78endif
79ifndef CONFIG_GETOPT_LONG_ONLY
Jens Axboe67bf9822013-01-10 11:23:19 +010080 SOURCE += lib/getopt_long.c
81endif
Jens Axboe67bf9822013-01-10 11:23:19 +010082ifndef CONFIG_INET_ATON
Jens Axboe67bf9822013-01-10 11:23:19 +010083 SOURCE += lib/inet_aton.c
84endif
Bruce Crand015e392011-01-28 08:39:09 +010085
Aaron Carroll53cd4ee2013-03-14 16:57:38 +110086ifeq ($(CONFIG_TARGET_OS), Linux)
Jens Axboe67bf9822013-01-10 11:23:19 +010087 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
88 engines/binject.c profiles/tiobench.c
89 LIBS += -lpthread -ldl
Jens Axboe213a01b2011-10-07 13:24:16 +020090 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +010091endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +110092ifeq ($(CONFIG_TARGET_OS), Android)
Jens Axboe67bf9822013-01-10 11:23:19 +010093 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
Aaron Carrollec5c6b12012-11-21 10:39:00 +010094 LIBS += -ldl
95 LDFLAGS += -rdynamic
Aaron Carrollec5c6b12012-11-21 10:39:00 +010096endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +110097ifeq ($(CONFIG_TARGET_OS), SunOS)
Jens Axboe7366ad02013-02-28 20:34:31 +010098 LIBS += -lpthread -ldl
Bruce Crand015e392011-01-28 08:39:09 +010099 CPPFLAGS += -D__EXTENSIONS__
100endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100101ifeq ($(CONFIG_TARGET_OS), FreeBSD)
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), NetBSD)
Bruce Crand015e392011-01-28 08:39:09 +0100106 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +0200107 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +0100108endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100109ifeq ($(CONFIG_TARGET_OS), AIX)
Bruce Crand015e392011-01-28 08:39:09 +0100110 LIBS += -lpthread -ldl -lrt
Bruce Crand015e392011-01-28 08:39:09 +0100111 CPPFLAGS += -D_LARGE_FILES -D__ppc__
Michael Perzl48b35be2011-07-13 20:28:07 +0200112 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
Bruce Crand015e392011-01-28 08:39:09 +0100113endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100114ifeq ($(CONFIG_TARGET_OS), HP-UX)
Jens Axboeb5ffb752011-07-09 13:28:19 +0200115 LIBS += -lpthread -ldl -lrt
Jens Axboe67bf9822013-01-10 11:23:19 +0100116 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
Jens Axboec00a2282011-07-08 20:56:06 +0200117endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100118ifeq ($(CONFIG_TARGET_OS), Darwin)
Bruce Crand015e392011-01-28 08:39:09 +0100119 LIBS += -lpthread -ldl
120endif
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100121ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
Bruce Cran93bcfd22012-02-20 20:18:19 +0100122 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
Jens Axboe4700b232013-01-24 15:33:33 -0700123 SOURCE += os/windows/posix.c
Bruce Cran93bcfd22012-02-20 20:18:19 +0100124 LIBS += -lpthread -lpsapi -lws2_32
125 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
Bruce Crand015e392011-01-28 08:39:09 +0100126endif
127
Bruce Cran9b836562011-01-08 19:49:54 +0100128OBJS = $(SOURCE:.c=.o)
Jens Axboe90b7a962013-02-04 12:51:09 +0100129
Stephen M. Cameron8232e282012-02-24 08:17:31 +0100130FIO_OBJS = $(OBJS) fio.o
Jens Axboe1252d8f2012-03-21 11:13:31 +0100131GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
Stephen M. Cameronbf3f7022012-03-27 08:14:48 +0200132 gclient.o gcompat.o cairo_text_helpers.o printing.o
Jens Axboe79d16312010-03-04 12:43:20 +0100133
Jens Axboef67d6ee2013-02-01 15:51:23 +0100134-include $(OBJS:.o=.d)
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100135
Jens Axboe61f78f32011-10-05 10:25:54 +0200136T_SMALLOC_OBJS = t/stest.o
Jens Axboe39ab7da2012-11-06 22:10:43 +0100137T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
Jens Axboe61f78f32011-10-05 10:25:54 +0200138T_SMALLOC_PROGS = t/stest
139
140T_IEEE_OBJS = t/ieee754.o
Jens Axboe84f43c62012-03-31 16:02:08 -0700141T_IEEE_OBJS += lib/ieee754.o
Jens Axboe61f78f32011-10-05 10:25:54 +0200142T_IEEE_PROGS = t/ieee754
143
Jens Axboe6ff38852012-11-06 16:09:14 +0100144T_ZIPF_OBS = t/genzipf.o
Jens Axboe24baa4c2012-11-12 20:54:12 -0700145T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
Jens Axboeeed3f512012-11-07 13:40:01 +0100146T_ZIPF_PROGS = t/genzipf
Jens Axboe6ff38852012-11-06 16:09:14 +0100147
Jens Axboead1f90a2012-11-28 21:29:14 +0100148T_AXMAP_OBJS = t/axmap.o
149T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
150T_AXMAP_PROGS = t/axmap
151
Alex Pyrgiotis7a887ff2013-03-08 14:37:04 +0200152T_LFSR_TEST_OBJS = t/lfsr-test.o
153T_LFSR_TEST_OBJS += lib/lfsr.o
154T_LFSR_TEST_PROGS = t/lfsr-test
155
Jens Axboe61f78f32011-10-05 10:25:54 +0200156T_OBJS = $(T_SMALLOC_OBJS)
157T_OBJS += $(T_IEEE_OBJS)
Jens Axboe6ff38852012-11-06 16:09:14 +0100158T_OBJS += $(T_ZIPF_OBJS)
Jens Axboead1f90a2012-11-28 21:29:14 +0100159T_OBJS += $(T_AXMAP_OBJS)
Alex Pyrgiotis7a887ff2013-03-08 14:37:04 +0200160T_OBJS += $(T_LFSR_TEST_OBJS)
Jens Axboe6ff38852012-11-06 16:09:14 +0100161
162T_PROGS = $(T_SMALLOC_PROGS)
163T_PROGS += $(T_IEEE_PROGS)
164T_PROGS += $(T_ZIPF_PROGS)
Jens Axboead1f90a2012-11-28 21:29:14 +0100165T_PROGS += $(T_AXMAP_PROGS)
Alex Pyrgiotis7a887ff2013-03-08 14:37:04 +0200166T_PROGS += $(T_LFSR_TEST_PROGS)
Jens Axboe34272072011-08-16 10:01:03 +0200167
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100168ifneq ($(findstring $(MAKEFLAGS),s),s)
169ifndef V
170 QUIET_CC = @echo ' ' CC $@;
Jens Axboe6ce038d2013-02-07 15:40:37 +0100171 QUIET_LINK = @echo ' ' LINK $@;
Jens Axboe0b2d6a72008-03-03 12:20:26 +0100172 QUIET_DEP = @echo ' ' DEP $@;
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100173endif
174endif
175
Jens Axboec1d57252006-10-09 19:56:04 +0200176INSTALL = install
177prefix = /usr/local
178bindir = $(prefix)/bin
Jens Axboebcdf7c52012-02-08 14:19:27 +0100179
Aaron Carroll53cd4ee2013-03-14 16:57:38 +1100180ifeq ($(CONFIG_TARGET_OS), Darwin)
Jens Axboebcdf7c52012-02-08 14:19:27 +0100181mandir = /usr/share/man
182else
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200183mandir = $(prefix)/man
Jens Axboebcdf7c52012-02-08 14:19:27 +0100184endif
Jens Axboec1d57252006-10-09 19:56:04 +0200185
Jens Axboef67d6ee2013-02-01 15:51:23 +0100186all: $(PROGS) $(SCRIPTS) FORCE
Michael Zappef84622e2011-06-01 20:15:18 +0200187
Jens Axboe3d433822012-03-21 22:25:22 +0100188.PHONY: all install clean
189.PHONY: FORCE cscope
190
191FIO-VERSION-FILE: FORCE
Bruce Cran84306c12012-04-16 19:33:03 +0200192 @$(SHELL) ./FIO-VERSION-GEN
Jens Axboe3d433822012-03-21 22:25:22 +0100193-include FIO-VERSION-FILE
194
David M. Lee7496ea32013-01-31 18:37:41 +0100195override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
Jens Axboe3d433822012-03-21 22:25:22 +0100196
Jens Axboecb340b12013-02-05 11:03:12 +0100197.c.o: FORCE FIO-VERSION-FILE
Jens Axboe4feafb12013-01-24 23:07:55 -0700198 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
Jens Axboef67d6ee2013-02-01 15:51:23 +0100199 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
200 @mv -f $*.d $*.d.tmp
201 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
202 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
203 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
204 @rm -f $*.d.tmp
Diego Elio Pettenòe52947d2011-03-21 20:13:53 +0100205
Jens Axboecb340b12013-02-05 11:03:12 +0100206init.o: FIO-VERSION-FILE init.c
Jens Axboe4feafb12013-01-24 23:07:55 -0700207 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
Jens Axboe32d4cc62012-04-13 14:06:08 +0200208
Jens Axboef762cef2012-03-26 13:51:11 +0200209gcompat.o: gcompat.c gcompat.h
210 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
211
Jens Axboe9af4a242012-03-16 10:13:49 +0100212goptions.o: goptions.c goptions.h
213 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
214
Jens Axboe53e0e852012-03-15 19:38:01 +0100215ghelpers.o: ghelpers.c ghelpers.h
216 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
217
Jens Axboe41666582012-03-21 10:25:29 +0100218gerror.o: gerror.c gerror.h
219 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
220
Jens Axboe1252d8f2012-03-21 11:13:31 +0100221gclient.o: gclient.c gclient.h
222 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
223
Jens Axboe53e0e852012-03-15 19:38:01 +0100224gfio.o: gfio.c ghelpers.c
Jens Axboe70d07ce2012-02-24 13:11:35 +0100225 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
226
Jens Axboe53e0e852012-03-15 19:38:01 +0100227graph.o: graph.c graph.h
Stephen M. Cameronaf58ef32012-03-07 07:56:16 +0100228 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
229
Stephen M. Cameronee2f55b2012-03-27 08:14:09 +0200230cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
231 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c
232
Stephen M. Cameronbf3f7022012-03-27 08:14:48 +0200233printing.o: printing.c printing.h
234 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
235
Jens Axboe61f78f32011-10-05 10:25:54 +0200236t/stest: $(T_SMALLOC_OBJS)
Jens Axboe6ce038d2013-02-07 15:40:37 +0100237 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboe61f78f32011-10-05 10:25:54 +0200238
239t/ieee754: $(T_IEEE_OBJS)
Jens Axboe6ce038d2013-02-07 15:40:37 +0100240 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboefbc27922011-08-16 09:56:27 +0200241
Jens Axboe33765372012-04-11 22:25:26 +0200242fio: $(FIO_OBJS)
Jens Axboe9db01ef2013-02-07 15:45:39 +0100243 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100244
Jens Axboe70d07ce2012-02-24 13:11:35 +0100245gfio: $(GFIO_OBJS)
Jens Axboe9db01ef2013-02-07 15:45:39 +0100246 $(QUIET_LINK)$(CC) $(LIBS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS)
Jens Axboe70d07ce2012-02-24 13:11:35 +0100247
Jens Axboe6ff38852012-11-06 16:09:14 +0100248t/genzipf: $(T_ZIPF_OBJS)
Jens Axboe6ce038d2013-02-07 15:40:37 +0100249 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboe6ff38852012-11-06 16:09:14 +0100250
Jens Axboead1f90a2012-11-28 21:29:14 +0100251t/axmap: $(T_AXMAP_OBJS)
Jens Axboe6ce038d2013-02-07 15:40:37 +0100252 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboead1f90a2012-11-28 21:29:14 +0100253
Alex Pyrgiotis7a887ff2013-03-08 14:37:04 +0200254t/lfsr-test: $(T_LFSR_TEST_OBJS)
255 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS) $(LDFLAGS)
256
Jens Axboe3d433822012-03-21 22:25:22 +0100257clean: FORCE
Jens Axboed7213922013-03-21 06:45:27 -0600258 -rm -f .depend $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE config-host.mak config-host.h cscope.out *.d
Jens Axboeebac4652005-12-08 15:25:21 +0100259
Jens Axboe592ef982006-06-06 20:58:57 +0200260cscope:
Jens Axboe366badd2010-07-19 16:18:35 -0600261 @cscope -b -R
Jens Axboe592ef982006-06-06 20:58:57 +0200262
Jens Axboe3d433822012-03-21 22:25:22 +0100263install: $(PROGS) $(SCRIPTS) FORCE
Jens Axboe513ba3f2011-04-29 08:24:10 +0200264 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
Jens Axboeebac4652005-12-08 15:25:21 +0100265 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200266 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
267 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
Jens Axboeccd4f412009-05-20 11:36:39 +0200268 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1