Makefile: fix gfio link for CONFIG_ARITHMETIC
[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 17DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
9195552e 18CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INTERNAL $(DEBUGFLAGS)
af4862b3 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 \
aee2ab67 38 profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \
f83ffd02 39 lib/tp.c lib/bloom.c
67bf9823 40
1b10477b
MM
41ifdef CONFIG_LIBHDFS
42 HDFSFLAGS= -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux -I $(FIO_LIBHDFS_INCLUDE)
43 HDFSLIB= $(JAVA_HOME)/jre/lib/amd64/server/libjvm.so $(FIO_LIBHDFS_LIB)/liblibhdfs.a
44 CFLAGS += $(HDFSFLAGS)
45 SOURCE += engines/libhdfs.c
46endif
47
c81f9347
BC
48ifdef CONFIG_64BIT_LLP64
49 CFLAGS += -DBITS_PER_LONG=32
50endif
67bf9823
JA
51ifdef CONFIG_64BIT
52 CFLAGS += -DBITS_PER_LONG=64
53endif
54ifdef CONFIG_32BIT
55 CFLAGS += -DBITS_PER_LONG=32
56endif
67bf9823 57ifdef CONFIG_LIBAIO
67bf9823
JA
58 SOURCE += engines/libaio.c
59endif
60ifdef CONFIG_RDMA
67bf9823
JA
61 SOURCE += engines/rdma.c
62endif
63ifdef CONFIG_POSIXAIO
67bf9823
JA
64 SOURCE += engines/posixaio.c
65endif
66ifdef CONFIG_LINUX_FALLOCATE
67 SOURCE += engines/falloc.c
68endif
69ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
70 SOURCE += engines/e4defrag.c
71endif
72ifdef CONFIG_LINUX_SPLICE
67bf9823
JA
73 SOURCE += engines/splice.c
74endif
75ifdef CONFIG_GUASI
67bf9823
JA
76 SOURCE += engines/guasi.c
77endif
78ifdef CONFIG_FUSION_AW
67bf9823
JA
79 SOURCE += engines/fusion-aw.c
80endif
81ifdef CONFIG_SOLARISAIO
67bf9823
JA
82 SOURCE += engines/solarisaio.c
83endif
4700b234 84ifdef CONFIG_WINDOWSAIO
4700b234
JA
85 SOURCE += engines/windowsaio.c
86endif
fc5c0345
DG
87ifdef CONFIG_RBD
88 SOURCE += engines/rbd.c
89endif
67bf9823 90ifndef CONFIG_STRSEP
67bf9823
JA
91 SOURCE += lib/strsep.c
92endif
9ad8da82
JA
93ifndef CONFIG_STRCASESTR
94 SOURCE += lib/strcasestr.c
95endif
67bf9823 96ifndef CONFIG_GETOPT_LONG_ONLY
67bf9823
JA
97 SOURCE += lib/getopt_long.c
98endif
67bf9823 99ifndef CONFIG_INET_ATON
67bf9823
JA
100 SOURCE += lib/inet_aton.c
101endif
6e7d7dfb 102ifdef CONFIG_GFAPI
103 SOURCE += engines/glusterfs.c
cc47f094 104 SOURCE += engines/glusterfs_sync.c
105 SOURCE += engines/glusterfs_async.c
6fa14b99 106 ifdef CONFIG_GF_FADVISE
107 CFLAGS += "-DGFAPI_USE_FADVISE"
108 endif
6e7d7dfb 109endif
d015e398 110
53cd4eee 111ifeq ($(CONFIG_TARGET_OS), Linux)
67bf9823 112 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
40bafa33 113 engines/binject.c lib/linux-dev-lookup.c
67bf9823 114 LIBS += -lpthread -ldl
213a01b0 115 LDFLAGS += -rdynamic
d015e398 116endif
53cd4eee 117ifeq ($(CONFIG_TARGET_OS), Android)
40bafa33
JA
118 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c \
119 lib/linux-dev-lookup.c
ec5c6b12
AC
120 LIBS += -ldl
121 LDFLAGS += -rdynamic
ec5c6b12 122endif
53cd4eee 123ifeq ($(CONFIG_TARGET_OS), SunOS)
7366ad05 124 LIBS += -lpthread -ldl
d015e398
BC
125 CPPFLAGS += -D__EXTENSIONS__
126endif
53cd4eee 127ifeq ($(CONFIG_TARGET_OS), FreeBSD)
d015e398 128 LIBS += -lpthread -lrt
213a01b0 129 LDFLAGS += -rdynamic
d015e398 130endif
3cd4c66f
J
131ifeq ($(CONFIG_TARGET_OS), OpenBSD)
132 LIBS += -lpthread
133 LDFLAGS += -rdynamic
134endif
53cd4eee 135ifeq ($(CONFIG_TARGET_OS), NetBSD)
d015e398 136 LIBS += -lpthread -lrt
213a01b0 137 LDFLAGS += -rdynamic
d015e398 138endif
53cd4eee 139ifeq ($(CONFIG_TARGET_OS), AIX)
d015e398 140 LIBS += -lpthread -ldl -lrt
d015e398 141 CPPFLAGS += -D_LARGE_FILES -D__ppc__
48b35be0 142 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
d015e398 143endif
53cd4eee 144ifeq ($(CONFIG_TARGET_OS), HP-UX)
b5ffb752 145 LIBS += -lpthread -ldl -lrt
67bf9823 146 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
c00a2289 147endif
53cd4eee 148ifeq ($(CONFIG_TARGET_OS), Darwin)
d015e398
BC
149 LIBS += -lpthread -ldl
150endif
53cd4eee 151ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
93bcfd20 152 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
4700b234 153 SOURCE += os/windows/posix.c
93bcfd20 154 LIBS += -lpthread -lpsapi -lws2_32
9aa5fe32 155 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format -static
d015e398
BC
156endif
157
9b836561 158OBJS = $(SOURCE:.c=.o)
90b7a96d 159
8232e285 160FIO_OBJS = $(OBJS) fio.o
b470a02c 161
7efff409
JA
162GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
163 gclient.o gcompat.o cairo_text_helpers.o printing.o
164
b470a02c
SC
165ifdef CONFIG_ARITHMETIC
166FIO_OBJS += lex.yy.o y.tab.o
7efff409 167GFIO_OBJS += lex.yy.o y.tab.o
b470a02c
SC
168endif
169
f67d6ee2 170-include $(OBJS:.o=.d)
79d16311 171
61f78f3a 172T_SMALLOC_OBJS = t/stest.o
9077ee4a 173T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o t/debug.o
61f78f3a
JA
174T_SMALLOC_PROGS = t/stest
175
176T_IEEE_OBJS = t/ieee754.o
84f43c6f 177T_IEEE_OBJS += lib/ieee754.o
61f78f3a
JA
178T_IEEE_PROGS = t/ieee754
179
6ff38856 180T_ZIPF_OBS = t/genzipf.o
24baa4c7 181T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
eed3f518 182T_ZIPF_PROGS = t/genzipf
6ff38856 183
ad1f90aa
JA
184T_AXMAP_OBJS = t/axmap.o
185T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
186T_AXMAP_PROGS = t/axmap
187
7a887ffe 188T_LFSR_TEST_OBJS = t/lfsr-test.o
9077ee4a 189T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o t/log.o t/debug.o
7a887ffe
AP
190T_LFSR_TEST_PROGS = t/lfsr-test
191
40bafa33
JA
192ifeq ($(CONFIG_TARGET_OS), Linux)
193T_BTRACE_FIO_OBJS = t/btrace2fio.o
194T_BTRACE_FIO_OBJS += fifo.o lib/flist_sort.o t/log.o lib/linux-dev-lookup.o
195T_BTRACE_FIO_PROGS = t/btrace2fio
196endif
197
bf481692
JA
198T_DEDUPE_OBJS = t/dedupe.o
199T_DEDUPE_OBJS += lib/rbtree.o t/log.o mutex.o smalloc.o gettime.o crc/md5.o \
78583f91
JA
200 memalign.o lib/bloom.o t/debug.o crc/xxhash.o crc/murmur3.o \
201 crc/crc32c.o crc/crc32c-intel.o crc/fnv.o
bf481692
JA
202T_DEDUPE_PROGS = t/dedupe
203
61f78f3a
JA
204T_OBJS = $(T_SMALLOC_OBJS)
205T_OBJS += $(T_IEEE_OBJS)
6ff38856 206T_OBJS += $(T_ZIPF_OBJS)
ad1f90aa 207T_OBJS += $(T_AXMAP_OBJS)
7a887ffe 208T_OBJS += $(T_LFSR_TEST_OBJS)
40bafa33 209T_OBJS += $(T_BTRACE_FIO_OBJS)
e5bf5a88 210T_OBJS += $(T_DEDUPE_OBJS)
6ff38856
JA
211
212T_PROGS = $(T_SMALLOC_PROGS)
213T_PROGS += $(T_IEEE_PROGS)
214T_PROGS += $(T_ZIPF_PROGS)
ad1f90aa 215T_PROGS += $(T_AXMAP_PROGS)
7a887ffe 216T_PROGS += $(T_LFSR_TEST_PROGS)
40bafa33 217T_PROGS += $(T_BTRACE_FIO_PROGS)
e5bf5a88
JA
218T_PROGS += $(T_DEDUPE_PROGS)
219
220PROGS += $(T_PROGS)
3427207d 221
4c3ecec4
JA
222ifneq ($(findstring $(MAKEFLAGS),s),s)
223ifndef V
224 QUIET_CC = @echo ' ' CC $@;
79816cf7
JA
225 QUIET_LINK = @echo ' ' LINK $@;
226 QUIET_DEP = @echo ' ' DEP $@;
227 QUIET_YACC = @echo ' ' YACC $@;
228 QUIET_LEX = @echo ' ' LEX $@;
4c3ecec4
JA
229endif
230endif
231
a8168a22
JA
232ifeq ($(CONFIG_TARGET_OS), SunOS)
233 INSTALL = ginstall
234else
235 INSTALL = install
236endif
c1d5725e
JA
237prefix = /usr/local
238bindir = $(prefix)/bin
bcdf7c58 239
53cd4eee 240ifeq ($(CONFIG_TARGET_OS), Darwin)
bcdf7c58 241mandir = /usr/share/man
eab4af4e 242sharedir = /usr/share/fio
bcdf7c58 243else
d60e92d1 244mandir = $(prefix)/man
eab4af4e 245sharedir = $(prefix)/share/fio
bcdf7c58 246endif
c1d5725e 247
f67d6ee2 248all: $(PROGS) $(SCRIPTS) FORCE
f84622e9 249
3d43382c
JA
250.PHONY: all install clean
251.PHONY: FORCE cscope
252
253FIO-VERSION-FILE: FORCE
84306c1d 254 @$(SHELL) ./FIO-VERSION-GEN
3d43382c
JA
255-include FIO-VERSION-FILE
256
7496ea3e 257override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
3d43382c 258
9e85c34e 259%.o : %.c
4feafb1e 260 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
f67d6ee2
JA
261 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
262 @mv -f $*.d $*.d.tmp
263 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
264 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
265 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
266 @rm -f $*.d.tmp
e52947d1 267
b470a02c 268ifdef CONFIG_ARITHMETIC
79816cf7 269lex.yy.c: exp/expression-parser.l
c9fa1c8d 270 $(QUIET_LEX)$(LEX) --header-file=lexer.h exp/expression-parser.l
79816cf7 271
b470a02c
SC
272lex.yy.o: lex.yy.c y.tab.h
273 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
274
275y.tab.o: y.tab.c y.tab.h
276 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
277
278y.tab.c: exp/expression-parser.y
7e0049e9 279 $(QUIET_YACC)$(YACC) --no-lines -d -b y exp/expression-parser.y
b470a02c 280
dc68fd2c 281y.tab.h: y.tab.c
b470a02c 282
c9fa1c8d
SC
283lexer.h: lex.yy.c
284
c879ba67
JA
285exp/test-expression-parser.o: exp/test-expression-parser.c
286 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
287exp/test-expression-parser: exp/test-expression-parser.o
288 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) $< y.tab.o lex.yy.o -o $@ $(LIBS)
289
b470a02c
SC
290parse.o: lex.yy.o y.tab.o
291endif
292
cb340b15 293init.o: FIO-VERSION-FILE init.c
4feafb1e 294 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
32d4cc61 295
f762cef9
JA
296gcompat.o: gcompat.c gcompat.h
297 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
298
9af4a244
JA
299goptions.o: goptions.c goptions.h
300 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
301
53e0e85d
JA
302ghelpers.o: ghelpers.c ghelpers.h
303 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
304
41666588
JA
305gerror.o: gerror.c gerror.h
306 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
307
1252d8f2
JA
308gclient.o: gclient.c gclient.h
309 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
310
53e0e85d 311gfio.o: gfio.c ghelpers.c
70d07ce1
JA
312 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
313
53e0e85d 314graph.o: graph.c graph.h
af58ef32
SC
315 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
316
ee2f55b2
SC
317cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
318 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c
319
bf3f7027
SC
320printing.o: printing.c printing.h
321 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
322
61f78f3a 323t/stest: $(T_SMALLOC_OBJS)
a3c86fc4 324 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
61f78f3a
JA
325
326t/ieee754: $(T_IEEE_OBJS)
a3c86fc4 327 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
fbc2792b 328
33765372 329fio: $(FIO_OBJS)
b492fa32 330 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(HDFSLIB)
4c3ecec4 331
70d07ce1 332gfio: $(GFIO_OBJS)
b492fa32 333 $(QUIET_LINK)$(CC) $(LDFLAGS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS)
70d07ce1 334
6ff38856 335t/genzipf: $(T_ZIPF_OBJS)
a3c86fc4 336 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
6ff38856 337
ad1f90aa 338t/axmap: $(T_AXMAP_OBJS)
a3c86fc4 339 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
ad1f90aa 340
7a887ffe 341t/lfsr-test: $(T_LFSR_TEST_OBJS)
a3c86fc4 342 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
7a887ffe 343
40bafa33
JA
344ifeq ($(CONFIG_TARGET_OS), Linux)
345t/btrace2fio: $(T_BTRACE_FIO_OBJS)
346 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_BTRACE_FIO_OBJS) $(LIBS)
347endif
348
bf481692
JA
349t/dedupe: $(T_DEDUPE_OBJS)
350 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_DEDUPE_OBJS) $(LIBS)
351
3d43382c 352clean: FORCE
d3955c8e 353 @rm -f .depend $(FIO_OBJS) $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE *.d lib/*.d crc/*.d engines/*.d profiles/*.d t/*.d config-host.mak config-host.h y.tab.[ch] lex.yy.c exp/*.[do] lexer.h
45f944b9
JA
354
355distclean: clean FORCE
7788b76f 356 @rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf
ebac4655 357
592ef98a 358cscope:
366badd3 359 @cscope -b -R
592ef98a 360
1378cc68
EV
361tools/plot/fio2gnuplot.1:
362 @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot > tools/plot/fio2gnuplot.1
363
7788b76f
JA
364doc: tools/plot/fio2gnuplot.1
365 @man -t ./fio.1 | ps2pdf - fio.pdf
366 @man -t tools/fio_generate_plots.1 | ps2pdf - fio_generate_plots.pdf
367 @man -t tools/plot/fio2gnuplot.1 | ps2pdf - fio2gnuplot.pdf
368
1378cc68 369install: $(PROGS) $(SCRIPTS) tools/plot/fio2gnuplot.1 FORCE
513ba3f7 370 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
ebac4655 371 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
d60e92d1
AC
372 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
373 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
0460eb92 374 $(INSTALL) -m 644 tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
1378cc68 375 $(INSTALL) -m 644 tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1
eab4af4e
EV
376 $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
377 $(INSTALL) -m 644 tools/plot/*gpm $(DESTDIR)$(sharedir)/