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