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