blob: ccfa802bfb9bfc74158b3fe5ffa4171ec1297e07 [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)
Yufei Renb6cf38f2011-08-02 12:15:30 +02007LIBS = -lm $(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
Bruce Cran93bcfd22012-02-20 20:18:19 +010012SOURCE := gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \
Bruce Crand015e392011-01-28 08:39:09 +010013 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
14 rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
Jens Axboec7c6cb42011-10-13 14:12:40 +020015 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
Jens Axboed48a9792011-07-09 08:54:26 +020016 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
Jens Axboe62cb17d2012-09-19 21:36:18 +020017 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
18 json.c
Bruce Crand015e392011-01-28 08:39:09 +010019
20ifeq ($(UNAME), Linux)
21 SOURCE += diskutil.c fifo.c blktrace.c helpers.c cgroup.c trim.c \
22 engines/libaio.c engines/posixaio.c engines/sg.c \
23 engines/splice.c engines/syslet-rw.c engines/guasi.c \
Santhosh Koundinya6ef63582012-09-18 23:20:21 +020024 engines/binject.c engines/rdma.c profiles/tiobench.c \
Dmitry Monakhov9c25d2e2012-09-19 23:22:56 +040025 engines/fusion-aw.c engines/falloc.c engines/e4defrag.c
Bruce Crand015e392011-01-28 08:39:09 +010026 LIBS += -lpthread -ldl -lrt -laio
Jens Axboe213a01b2011-10-07 13:24:16 +020027 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +010028endif
29ifeq ($(UNAME), SunOS)
Jens Axboe33c142b2011-04-25 20:49:45 +020030 SOURCE += fifo.c lib/strsep.c helpers.c engines/posixaio.c \
Jens Axboed48a9792011-07-09 08:54:26 +020031 engines/solarisaio.c
Bruce Crand015e392011-01-28 08:39:09 +010032 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
33 CPPFLAGS += -D__EXTENSIONS__
34endif
35ifeq ($(UNAME), FreeBSD)
Jens Axboed48a9792011-07-09 08:54:26 +020036 SOURCE += helpers.c engines/posixaio.c
Bruce Crand015e392011-01-28 08:39:09 +010037 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +020038 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +010039endif
40ifeq ($(UNAME), NetBSD)
Jens Axboed48a9792011-07-09 08:54:26 +020041 SOURCE += helpers.c engines/posixaio.c
Bruce Crand015e392011-01-28 08:39:09 +010042 LIBS += -lpthread -lrt
Jens Axboe213a01b2011-10-07 13:24:16 +020043 LDFLAGS += -rdynamic
Bruce Crand015e392011-01-28 08:39:09 +010044endif
45ifeq ($(UNAME), AIX)
Jens Axboed48a9792011-07-09 08:54:26 +020046 SOURCE += fifo.c helpers.c lib/getopt_long.c engines/posixaio.c
Bruce Crand015e392011-01-28 08:39:09 +010047 LIBS += -lpthread -ldl -lrt
Bruce Crand015e392011-01-28 08:39:09 +010048 CPPFLAGS += -D_LARGE_FILES -D__ppc__
Michael Perzl48b35be2011-07-13 20:28:07 +020049 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
Bruce Crand015e392011-01-28 08:39:09 +010050endif
Jens Axboec00a2282011-07-08 20:56:06 +020051ifeq ($(UNAME), HP-UX)
Jens Axboed48a9792011-07-09 08:54:26 +020052 SOURCE += fifo.c helpers.c lib/getopt_long.c lib/strsep.c engines/posixaio.c
Jens Axboeb5ffb752011-07-09 13:28:19 +020053 LIBS += -lpthread -ldl -lrt
Jens Axboed48a9792011-07-09 08:54:26 +020054 CFLAGS += -D_LARGEFILE64_SOURCE
Jens Axboec00a2282011-07-08 20:56:06 +020055endif
Bruce Crand015e392011-01-28 08:39:09 +010056ifeq ($(UNAME), Darwin)
Jens Axboed48a9792011-07-09 08:54:26 +020057 SOURCE += helpers.c engines/posixaio.c
Bruce Crand015e392011-01-28 08:39:09 +010058 LIBS += -lpthread -ldl
59endif
60ifneq (,$(findstring CYGWIN,$(UNAME)))
Bruce Cran93bcfd22012-02-20 20:18:19 +010061 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
62 SOURCE += engines/windowsaio.c os/windows/posix.c
63 LIBS += -lpthread -lpsapi -lws2_32
64 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
65 CC = x86_64-w64-mingw32-gcc
Bruce Crand3987942012-06-08 08:12:20 +020066 #CC = i686-w64-mingw32-gcc
Bruce Crand015e392011-01-28 08:39:09 +010067endif
68
Bruce Cran9b836562011-01-08 19:49:54 +010069OBJS = $(SOURCE:.c=.o)
Jens Axboe79d16312010-03-04 12:43:20 +010070
Jens Axboe61f78f32011-10-05 10:25:54 +020071T_SMALLOC_OBJS = t/stest.o
72T_SMALLOC_OBJS += mutex.o smalloc.o t/log.o
73T_SMALLOC_PROGS = t/stest
74
75T_IEEE_OBJS = t/ieee754.o
76T_IEEE_OBJS += ieee754.o
77T_IEEE_PROGS = t/ieee754
78
79T_OBJS = $(T_SMALLOC_OBJS)
80T_OBJS += $(T_IEEE_OBJS)
Jens Axboe34272072011-08-16 10:01:03 +020081
Jens Axboe4c3ecec2008-03-01 16:20:13 +010082ifneq ($(findstring $(MAKEFLAGS),s),s)
83ifndef V
84 QUIET_CC = @echo ' ' CC $@;
Jens Axboe0b2d6a72008-03-03 12:20:26 +010085 QUIET_DEP = @echo ' ' DEP $@;
Jens Axboe4c3ecec2008-03-01 16:20:13 +010086endif
87endif
88
Jens Axboec1d57252006-10-09 19:56:04 +020089INSTALL = install
90prefix = /usr/local
91bindir = $(prefix)/bin
Jens Axboebcdf7c52012-02-08 14:19:27 +010092
93ifeq ($(UNAME), Darwin)
94mandir = /usr/share/man
95else
Aaron Carrolld60e92d2007-09-17 10:32:59 +020096mandir = $(prefix)/man
Jens Axboebcdf7c52012-02-08 14:19:27 +010097endif
Jens Axboec1d57252006-10-09 19:56:04 +020098
Jens Axboe692a5d22012-04-11 22:07:07 +020099all: .depend $(PROGS) $(SCRIPTS) FORCE
Michael Zappef84622e2011-06-01 20:15:18 +0200100
Jens Axboe692a5d22012-04-11 22:07:07 +0200101.PHONY: all install clean
102.PHONY: FORCE cscope
103
104FIO-VERSION-FILE: FORCE
Bruce Cran84306c12012-04-16 19:33:03 +0200105 @$(SHELL) ./FIO-VERSION-GEN
Jens Axboe692a5d22012-04-11 22:07:07 +0200106-include FIO-VERSION-FILE
107
108CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
109
110.c.o: .depend FORCE
Bruce Cran9b836562011-01-08 19:49:54 +0100111 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
Diego Elio Pettenòe52947d2011-03-21 20:13:53 +0100112
Jens Axboea6204b62012-04-13 14:06:08 +0200113init.o: FIO-VERSION-FILE
114 $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
115
Jens Axboe61f78f32011-10-05 10:25:54 +0200116t/stest: $(T_SMALLOC_OBJS)
117 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
118
119t/ieee754: $(T_IEEE_OBJS)
120 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
Jens Axboefbc27922011-08-16 09:56:27 +0200121
Jens Axboe2f9ade32006-10-20 11:25:52 +0200122fio: $(OBJS)
Michael Perzl48b35be2011-07-13 20:28:07 +0200123 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
Jens Axboe4c3ecec2008-03-01 16:20:13 +0100124
Michael Zappef84622e2011-06-01 20:15:18 +0200125.depend: $(SOURCE)
Bruce Cran9b836562011-01-08 19:49:54 +0100126 $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
Jens Axboe0b2d6a72008-03-03 12:20:26 +0100127
Jens Axboe8541f322012-04-11 22:24:19 +0200128$(PROGS): .depend
Jens Axboeebac4652005-12-08 15:25:21 +0100129
Jens Axboe692a5d22012-04-11 22:07:07 +0200130clean: FORCE
131 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE
Jens Axboeebac4652005-12-08 15:25:21 +0100132
Jens Axboe592ef982006-06-06 20:58:57 +0200133cscope:
Jens Axboe366badd2010-07-19 16:18:35 -0600134 @cscope -b -R
Jens Axboe592ef982006-06-06 20:58:57 +0200135
Jens Axboe692a5d22012-04-11 22:07:07 +0200136install: $(PROGS) $(SCRIPTS) FORCE
Jens Axboe513ba3f2011-04-29 08:24:10 +0200137 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
Jens Axboeebac4652005-12-08 15:25:21 +0100138 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
Aaron Carrolld60e92d2007-09-17 10:32:59 +0200139 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
140 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
Jens Axboeccd4f412009-05-20 11:36:39 +0200141 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
Jens Axboeebac4652005-12-08 15:25:21 +0100142
Jens Axboe06fecb42008-03-03 12:22:19 +0100143ifneq ($(wildcard .depend),)
144include .depend
145endif