Fio 2.1.3
[fio.git] / Makefile
CommitLineData
67bf9823
JA
1ifneq ($(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:
d443abcf 9ifneq ($(MAKECMDGOALS),clean)
67bf9823
JA
10 @echo "Running configure for you..."
11 @./configure
d443abcf 12endif
67bf9823
JA
13all:
14include config-host.mak
15endif
16
af4862b3
JA
17DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
18CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(DEBUGFLAGS)
19OPTFLAGS= -O3 -g -ffast-math
eb19930c 20CFLAGS = -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS)
af4862b3
JA
21LIBS += -lm $(EXTLIBS)
22PROGS = fio
265a2027 23SCRIPTS = tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio
af4862b3 24
91f94d5b
JA
25ifdef CONFIG_GFIO
26 PROGS += gfio
27endif
28
ea783f87 29SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
d015e398 30 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
05775438 31 lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
c7c6cb4c 32 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
d48a9799 33 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
2dc1cbb5 34 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
9a0db1e2 35 cconv.c lib/prio_tree.c json.c lib/zipf.c lib/axmap.c \
836fcc0f 36 lib/lfsr.c gettime-thread.c helpers.c lib/flist_sort.c \
d4afedfd 37 lib/hweight.c lib/getrusage.c idletime.c td_error.c \
2ae0b204 38 profiles/tiobench.c profiles/act.c io_u_queue.c
67bf9823 39
c81f9347
BC
40ifdef CONFIG_64BIT_LLP64
41 CFLAGS += -DBITS_PER_LONG=32
42endif
67bf9823
JA
43ifdef CONFIG_64BIT
44 CFLAGS += -DBITS_PER_LONG=64
45endif
46ifdef CONFIG_32BIT
47 CFLAGS += -DBITS_PER_LONG=32
48endif
67bf9823 49ifdef CONFIG_LIBAIO
67bf9823
JA
50 SOURCE += engines/libaio.c
51endif
52ifdef CONFIG_RDMA
67bf9823
JA
53 SOURCE += engines/rdma.c
54endif
55ifdef CONFIG_POSIXAIO
67bf9823
JA
56 SOURCE += engines/posixaio.c
57endif
58ifdef CONFIG_LINUX_FALLOCATE
59 SOURCE += engines/falloc.c
60endif
61ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
62 SOURCE += engines/e4defrag.c
63endif
64ifdef CONFIG_LINUX_SPLICE
67bf9823
JA
65 SOURCE += engines/splice.c
66endif
67ifdef CONFIG_GUASI
67bf9823
JA
68 SOURCE += engines/guasi.c
69endif
70ifdef CONFIG_FUSION_AW
67bf9823
JA
71 SOURCE += engines/fusion-aw.c
72endif
73ifdef CONFIG_SOLARISAIO
67bf9823
JA
74 SOURCE += engines/solarisaio.c
75endif
4700b234 76ifdef CONFIG_WINDOWSAIO
4700b234
JA
77 SOURCE += engines/windowsaio.c
78endif
67bf9823 79ifndef CONFIG_STRSEP
67bf9823
JA
80 SOURCE += lib/strsep.c
81endif
9ad8da82
JA
82ifndef CONFIG_STRCASESTR
83 SOURCE += lib/strcasestr.c
84endif
67bf9823 85ifndef CONFIG_GETOPT_LONG_ONLY
67bf9823
JA
86 SOURCE += lib/getopt_long.c
87endif
67bf9823 88ifndef CONFIG_INET_ATON
67bf9823
JA
89 SOURCE += lib/inet_aton.c
90endif
d015e398 91
53cd4eee 92ifeq ($(CONFIG_TARGET_OS), Linux)
67bf9823 93 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
d4afedfd 94 engines/binject.c
67bf9823 95 LIBS += -lpthread -ldl
213a01b0 96 LDFLAGS += -rdynamic
d015e398 97endif
53cd4eee 98ifeq ($(CONFIG_TARGET_OS), Android)
67bf9823 99 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
ec5c6b12
AC
100 LIBS += -ldl
101 LDFLAGS += -rdynamic
ec5c6b12 102endif
53cd4eee 103ifeq ($(CONFIG_TARGET_OS), SunOS)
7366ad05 104 LIBS += -lpthread -ldl
d015e398
BC
105 CPPFLAGS += -D__EXTENSIONS__
106endif
53cd4eee 107ifeq ($(CONFIG_TARGET_OS), FreeBSD)
d015e398 108 LIBS += -lpthread -lrt
213a01b0 109 LDFLAGS += -rdynamic
d015e398 110endif
53cd4eee 111ifeq ($(CONFIG_TARGET_OS), NetBSD)
d015e398 112 LIBS += -lpthread -lrt
213a01b0 113 LDFLAGS += -rdynamic
d015e398 114endif
53cd4eee 115ifeq ($(CONFIG_TARGET_OS), AIX)
d015e398 116 LIBS += -lpthread -ldl -lrt
d015e398 117 CPPFLAGS += -D_LARGE_FILES -D__ppc__
48b35be0 118 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
d015e398 119endif
53cd4eee 120ifeq ($(CONFIG_TARGET_OS), HP-UX)
b5ffb752 121 LIBS += -lpthread -ldl -lrt
67bf9823 122 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
c00a2289 123endif
53cd4eee 124ifeq ($(CONFIG_TARGET_OS), Darwin)
d015e398
BC
125 LIBS += -lpthread -ldl
126endif
53cd4eee 127ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
93bcfd20 128 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
4700b234 129 SOURCE += os/windows/posix.c
93bcfd20
BC
130 LIBS += -lpthread -lpsapi -lws2_32
131 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
d015e398
BC
132endif
133
9b836561 134OBJS = $(SOURCE:.c=.o)
90b7a96d 135
8232e285 136FIO_OBJS = $(OBJS) fio.o
1252d8f2 137GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
bf3f7027 138 gclient.o gcompat.o cairo_text_helpers.o printing.o
79d16311 139
f67d6ee2 140-include $(OBJS:.o=.d)
79d16311 141
61f78f3a 142T_SMALLOC_OBJS = t/stest.o
39ab7da2 143T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
61f78f3a
JA
144T_SMALLOC_PROGS = t/stest
145
146T_IEEE_OBJS = t/ieee754.o
84f43c6f 147T_IEEE_OBJS += lib/ieee754.o
61f78f3a
JA
148T_IEEE_PROGS = t/ieee754
149
6ff38856 150T_ZIPF_OBS = t/genzipf.o
24baa4c7 151T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
eed3f518 152T_ZIPF_PROGS = t/genzipf
6ff38856 153
ad1f90aa
JA
154T_AXMAP_OBJS = t/axmap.o
155T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
156T_AXMAP_PROGS = t/axmap
157
7a887ffe
AP
158T_LFSR_TEST_OBJS = t/lfsr-test.o
159T_LFSR_TEST_OBJS += lib/lfsr.o
160T_LFSR_TEST_PROGS = t/lfsr-test
161
61f78f3a
JA
162T_OBJS = $(T_SMALLOC_OBJS)
163T_OBJS += $(T_IEEE_OBJS)
6ff38856 164T_OBJS += $(T_ZIPF_OBJS)
ad1f90aa 165T_OBJS += $(T_AXMAP_OBJS)
7a887ffe 166T_OBJS += $(T_LFSR_TEST_OBJS)
6ff38856
JA
167
168T_PROGS = $(T_SMALLOC_PROGS)
169T_PROGS += $(T_IEEE_PROGS)
170T_PROGS += $(T_ZIPF_PROGS)
ad1f90aa 171T_PROGS += $(T_AXMAP_PROGS)
7a887ffe 172T_PROGS += $(T_LFSR_TEST_PROGS)
3427207d 173
4c3ecec4
JA
174ifneq ($(findstring $(MAKEFLAGS),s),s)
175ifndef V
176 QUIET_CC = @echo ' ' CC $@;
6ce038de 177 QUIET_LINK = @echo ' ' LINK $@;
0b2d6a7a 178 QUIET_DEP = @echo ' ' DEP $@;
4c3ecec4
JA
179endif
180endif
181
a8168a22
JA
182ifeq ($(CONFIG_TARGET_OS), SunOS)
183 INSTALL = ginstall
184else
185 INSTALL = install
186endif
c1d5725e
JA
187prefix = /usr/local
188bindir = $(prefix)/bin
bcdf7c58 189
53cd4eee 190ifeq ($(CONFIG_TARGET_OS), Darwin)
bcdf7c58 191mandir = /usr/share/man
eab4af4e 192sharedir = /usr/share/fio
bcdf7c58 193else
d60e92d1 194mandir = $(prefix)/man
eab4af4e 195sharedir = $(prefix)/share/fio
bcdf7c58 196endif
c1d5725e 197
f67d6ee2 198all: $(PROGS) $(SCRIPTS) FORCE
f84622e9 199
3d43382c
JA
200.PHONY: all install clean
201.PHONY: FORCE cscope
202
203FIO-VERSION-FILE: FORCE
84306c1d 204 @$(SHELL) ./FIO-VERSION-GEN
3d43382c
JA
205-include FIO-VERSION-FILE
206
7496ea3e 207override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
3d43382c 208
cb340b15 209.c.o: FORCE FIO-VERSION-FILE
4feafb1e 210 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
f67d6ee2
JA
211 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
212 @mv -f $*.d $*.d.tmp
213 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
214 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
215 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
216 @rm -f $*.d.tmp
e52947d1 217
cb340b15 218init.o: FIO-VERSION-FILE init.c
4feafb1e 219 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
32d4cc61 220
f762cef9
JA
221gcompat.o: gcompat.c gcompat.h
222 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
223
9af4a244
JA
224goptions.o: goptions.c goptions.h
225 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
226
53e0e85d
JA
227ghelpers.o: ghelpers.c ghelpers.h
228 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
229
41666588
JA
230gerror.o: gerror.c gerror.h
231 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
232
1252d8f2
JA
233gclient.o: gclient.c gclient.h
234 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
235
53e0e85d 236gfio.o: gfio.c ghelpers.c
70d07ce1
JA
237 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
238
53e0e85d 239graph.o: graph.c graph.h
af58ef32
SC
240 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
241
ee2f55b2
SC
242cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
243 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c
244
bf3f7027
SC
245printing.o: printing.c printing.h
246 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
247
61f78f3a 248t/stest: $(T_SMALLOC_OBJS)
a3c86fc4 249 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
61f78f3a
JA
250
251t/ieee754: $(T_IEEE_OBJS)
a3c86fc4 252 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
fbc2792b 253
33765372 254fio: $(FIO_OBJS)
a3c86fc4 255 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS)
4c3ecec4 256
70d07ce1 257gfio: $(GFIO_OBJS)
a3c86fc4 258 $(QUIET_LINK)$(CC) $(LDFLAGS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS)
70d07ce1 259
6ff38856 260t/genzipf: $(T_ZIPF_OBJS)
a3c86fc4 261 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
6ff38856 262
ad1f90aa 263t/axmap: $(T_AXMAP_OBJS)
a3c86fc4 264 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
ad1f90aa 265
7a887ffe 266t/lfsr-test: $(T_LFSR_TEST_OBJS)
a3c86fc4 267 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
7a887ffe 268
3d43382c 269clean: FORCE
45f944b9
JA
270 -rm -f .depend $(FIO_OBJS) $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE *.d config-host.mak config-host.h
271
272distclean: clean FORCE
273 @rm -f cscope.out
ebac4655 274
592ef98a 275cscope:
366badd3 276 @cscope -b -R
592ef98a 277
1378cc68
EV
278tools/plot/fio2gnuplot.1:
279 @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot > tools/plot/fio2gnuplot.1
280
281install: $(PROGS) $(SCRIPTS) tools/plot/fio2gnuplot.1 FORCE
513ba3f7 282 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
ebac4655 283 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
d60e92d1
AC
284 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
285 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
0460eb92 286 $(INSTALL) -m 644 tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
1378cc68 287 $(INSTALL) -m 644 tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1
eab4af4e
EV
288 $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
289 $(INSTALL) -m 644 tools/plot/*gpm $(DESTDIR)$(sharedir)/