blob: d851640ac38eda2c39da25b9528fbab02268b06f [file] [log] [blame]
Jens Axboe31dc09d2012-08-14 14:34:32 +02001CC ?= gcc
Jens Axboe79e48f72008-02-01 20:37:09 +01002DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
Bruce Cran9b836562011-01-08 19:49:54 +01003CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
4 $(DEBUGFLAGS)
Jens Axboeb7eec502011-10-07 13:31:23 +02005OPTFLAGS= -O3 -fno-omit-frame-pointer -g $(EXTFLAGS)
Bruce Crand015e392011-01-28 08:39:09 +01006CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS)
Jens Axboe1b427252012-03-14 15:03:03 +01007LIBS = -lm -lz $(EXTLIBS)
Jens Axboeebac4652005-12-08 15:25:21 +01008PROGS = fio
9SCRIPTS = fio_generate_plots
Bruce Crand015e392011-01-28 08:39:09 +010010UNAME := $(shell uname)
11
Jens Axboe70d07ce2012-02-24 13:11:35 +010012GTK_CFLAGS = `pkg-config --cflags gtk+-2.0 gthread-2.0`
13GTK_LDFLAGS = `pkg-config --libs gtk+-2.0 gthread-2.0`
Stephen M. Cameronff1f3282012-02-24 08:17:30 +010014
Stephen M. Cameron8232e282012-02-24 08:17:31 +010015SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
Bruce Crand015e392011-01-28 08:39:09 +010016 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
Jens Axboe05775432012-03-21 14:07:11 +010017 lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
Jens Axboec7c6cb42011-10-13 14:12:40 +020018 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
Jens Axboed48a9792011-07-09 08:54:26 +020019 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
Jens Axboe2dc1cbb2012-03-08 14:52:25 +010020 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
Jens Axboed79db122012-09-24 08:51:24 +020021 cconv.c lib/prio_tree.c json.c
Bruce Crand015e392011-01-28 08:39:09 +010022
23ifeq ($(UNAME), Linux)
24 SOURCE += diskutil.c fifo.c blktrace.c helpers.c cgroup.c trim.c \
25 engines/libaio.c engines/posixaio.c engines/sg.c \
26 engines/splice.c engines/syslet-rw.c engines/guasi.c \
Santhosh Koundinya6ef63582012-09-18 23:20:21 +020027 engines/binject.c engines/rdma.c profiles/tiobench.c \
Dmitry Monakhov9c25d2e2012-09-19 23:22:56 +040028 engines/fusion-aw.c engines/falloc.c engines/e4defrag.c
Bruce Crand015e392011-01-28 08:39:09 +010029 LIBS += -lpthread -ldl -lrt -laio
Jens Axboe213a01b2011-10-07 13:24:16 +020030 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +010031endif
32ifeq ($(UNAME), SunOS)
Jens Axboe33c142b2011-04-25 20:49:45 +020033 SOURCE += fifo.c lib/strsep.c helpers.c engines/posixaio.c \
Jens Axboed48a9792011-07-09 08:54:26 +020034 engines/solarisaio.c
Bruce Crand015e392011-01-28 08:39:09 +010035 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
36 CPPFLAGS += -D__EXTENSIONS__
37endif
38ifeq ($(UNAME), FreeBSD)
Jens Axboed48a9792011-07-09 08:54:26 +020039 SOURCE += helpers.c engines/posixaio.c
Bruce Crand015e392011-01-28 08:39:09 +010040 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +020041 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +010042endif
43ifeq ($(UNAME), NetBSD)
Jens Axboed48a9792011-07-09 08:54:26 +020044 SOURCE += helpers.c engines/posixaio.c
Bruce Crand015e392011-01-28 08:39:09 +010045 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +020046 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +010047endif
48ifeq ($(UNAME), AIX)
Jens Axboed48a9792011-07-09 08:54:26 +020049 SOURCE += fifo.c helpers.c lib/getopt_long.c engines/posixaio.c
Bruce Crand015e392011-01-28 08:39:09 +010050 LIBS += -lpthread -ldl -lrt
Bruce Crand015e392011-01-28 08:39:09 +010051 CPPFLAGS += -D_LARGE_FILES -D__ppc__
Michael Perzl48b35be2011-07-13 20:28:07 +020052 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
Bruce Crand015e392011-01-28 08:39:09 +010053endif
Jens Axboec00a2282011-07-08 20:56:06 +020054ifeq ($(UNAME), HP-UX)
Jens Axboed48a9792011-07-09 08:54:26 +020055 SOURCE += fifo.c helpers.c lib/getopt_long.c lib/strsep.c engines/posixaio.c
Jens Axboeb5ffb752011-07-09 13:28:19 +020056 LIBS += -lpthread -ldl -lrt
Jens Axboed48a9792011-07-09 08:54:26 +020057 CFLAGS += -D_LARGEFILE64_SOURCE
Jens Axboec00a2282011-07-08 20:56:06 +020058endif
Bruce Crand015e392011-01-28 08:39:09 +010059ifeq ($(UNAME), Darwin)
Jens Axboed48a9792011-07-09 08:54:26 +020060 SOURCE += helpers.c engines/posixaio.c
Bruce Crand015e392011-01-28 08:39:09 +010061 LIBS += -lpthread -ldl
62endif
63ifneq (,$(findstring CYGWIN,$(UNAME)))
Bruce Cran93bcfd22012-02-20 20:18:19 +010064 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
65 SOURCE += engines/windowsaio.c os/windows/posix.c
66 LIBS += -lpthread -lpsapi -lws2_32
67 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
68 CC = x86_64-w64-mingw32-gcc
Bruce Crand3987942012-06-08 08:12:20 +020069 #CC = i686-w64-mingw32-gcc
Bruce Crand015e392011-01-28 08:39:09 +010070endif
71
Bruce Cran9b836562011-01-08 19:49:54 +010072OBJS = $(SOURCE:.c=.o)
Stephen M. Cameron8232e282012-02-24 08:17:31 +010073FIO_OBJS = $(OBJS) fio.o
Jens Axboe1252d8f2012-03-21 11:13:31 +010074GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
Stephen M. Cameronbf3f7022012-03-27 08:14:48 +020075 gclient.o gcompat.o cairo_text_helpers.o printing.o
Jens Axboe79d16312010-03-04 12:43:20 +010076
Jens Axboe61f78f32011-10-05 10:25:54 +020077T_SMALLOC_OBJS = t/stest.o
Jens Axboe84f43c62012-03-31 16:02:08 -070078T_SMALLOC_OBJS += mutex.o smalloc.o t/log.o gettime.o time.o
Jens Axboe61f78f32011-10-05 10:25:54 +020079T_SMALLOC_PROGS = t/stest
80
81T_IEEE_OBJS = t/ieee754.o
Jens Axboe84f43c62012-03-31 16:02:08 -070082T_IEEE_OBJS += lib/ieee754.o
Jens Axboe61f78f32011-10-05 10:25:54 +020083T_IEEE_PROGS = t/ieee754
84
85T_OBJS = $(T_SMALLOC_OBJS)
86T_OBJS += $(T_IEEE_OBJS)
Jens Axboe34272072011-08-16 10:01:03 +020087
Jens Axboe4c3ecec2008-03-01 16:20:13 +010088ifneq ($(findstring $(MAKEFLAGS),s),s)
89ifndef V
90 QUIET_CC = @echo ' ' CC $@;
Jens Axboe0b2d6a72008-03-03 12:20:26 +010091 QUIET_DEP = @echo ' ' DEP $@;
Jens Axboe4c3ecec2008-03-01 16:20:13 +010092endif
93endif
94
Jens Axboec1d57252006-10-09 19:56:04 +020095INSTALL = install
96prefix = /usr/local
97bindir = $(prefix)/bin
Jens Axboebcdf7c52012-02-08 14:19:27 +010098
99ifeq ($(UNAME), Darwin)
100mandir = /usr/share/man
101else
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200102mandir = $(prefix)/man
Jens Axboebcdf7c52012-02-08 14:19:27 +0100103endif
Jens Axboec1d57252006-10-09 19:56:04 +0200104
Jens Axboe3d433822012-03-21 22:25:22 +0100105all: .depend $(PROGS) $(SCRIPTS) FORCE
Michael Zappef84622e2011-06-01 20:15:18 +0200106
Jens Axboe3d433822012-03-21 22:25:22 +0100107.PHONY: all install clean
108.PHONY: FORCE cscope
109
110FIO-VERSION-FILE: FORCE
Bruce Cran84306c12012-04-16 19:33:03 +0200111 @$(SHELL) ./FIO-VERSION-GEN
Jens Axboe3d433822012-03-21 22:25:22 +0100112-include FIO-VERSION-FILE
113
114CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
115
116.c.o: .depend FORCE
Bruce Cran9b836562011-01-08 19:49:54 +0100117 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
Diego Elio Pettenòe52947d2011-03-21 20:13:53 +0100118
Jens Axboe32d4cc62012-04-13 14:06:08 +0200119init.o: FIO-VERSION-FILE
120 $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
121
Jens Axboef762cef2012-03-26 13:51:11 +0200122gcompat.o: gcompat.c gcompat.h
123 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
124
Jens Axboe9af4a242012-03-16 10:13:49 +0100125goptions.o: goptions.c goptions.h
126 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
127
Jens Axboe53e0e852012-03-15 19:38:01 +0100128ghelpers.o: ghelpers.c ghelpers.h
129 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
130
Jens Axboe41666582012-03-21 10:25:29 +0100131gerror.o: gerror.c gerror.h
132 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
133
Jens Axboe1252d8f2012-03-21 11:13:31 +0100134gclient.o: gclient.c gclient.h
135 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
136
Jens Axboe53e0e852012-03-15 19:38:01 +0100137gfio.o: gfio.c ghelpers.c
Jens Axboe70d07ce2012-02-24 13:11:35 +0100138 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
139
Jens Axboe53e0e852012-03-15 19:38:01 +0100140graph.o: graph.c graph.h
Stephen M. Cameronaf58ef32012-03-07 07:56:16 +0100141 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
142
Stephen M. Cameronee2f55b2012-03-27 08:14:09 +0200143cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
144 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c
145
Stephen M. Cameronbf3f7022012-03-27 08:14:48 +0200146printing.o: printing.c printing.h
147 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
148
Jens Axboe61f78f32011-10-05 10:25:54 +0200149t/stest: $(T_SMALLOC_OBJS)
150 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
151
152t/ieee754: $(T_IEEE_OBJS)
153 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboefbc27922011-08-16 09:56:27 +0200154
Jens Axboe33765372012-04-11 22:25:26 +0200155fio: $(FIO_OBJS)
Stephen M. Cameron8232e282012-02-24 08:17:31 +0100156 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100157
Jens Axboe70d07ce2012-02-24 13:11:35 +0100158gfio: $(GFIO_OBJS)
159 $(QUIET_CC)$(CC) $(LIBS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS)
160
Michael Zappef84622e2011-06-01 20:15:18 +0200161.depend: $(SOURCE)
Bruce Cran9b836562011-01-08 19:49:54 +0100162 $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
Jens Axboe0b2d6a72008-03-03 12:20:26 +0100163
Jens Axboe33765372012-04-11 22:25:26 +0200164$(PROGS): .depend
Jens Axboeebac4652005-12-08 15:25:21 +0100165
Jens Axboe3d433822012-03-21 22:25:22 +0100166clean: FORCE
Jens Axboefb390e22012-05-07 09:54:41 +0200167 -rm -f .depend $(GFIO_OBJS )$(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE
Jens Axboeebac4652005-12-08 15:25:21 +0100168
Jens Axboe592ef982006-06-06 20:58:57 +0200169cscope:
Jens Axboe366badd2010-07-19 16:18:35 -0600170 @cscope -b -R
Jens Axboe592ef982006-06-06 20:58:57 +0200171
Jens Axboe3d433822012-03-21 22:25:22 +0100172install: $(PROGS) $(SCRIPTS) FORCE
Jens Axboe513ba3f2011-04-29 08:24:10 +0200173 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
Jens Axboeebac4652005-12-08 15:25:21 +0100174 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200175 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
176 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
Jens Axboeccd4f412009-05-20 11:36:39 +0200177 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
Jens Axboeebac4652005-12-08 15:25:21 +0100178
Jens Axboe06fecb42008-03-03 12:22:19 +0100179ifneq ($(wildcard .depend),)
180include .depend
181endif
Stephen M. Cameronff1f3282012-02-24 08:17:30 +0100182
Stephen M. Cameronff1f3282012-02-24 08:17:30 +0100183