1 ifneq ($(wildcard config-host.mak),)
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
9 ifneq ($(MAKECMDGOALS),clean)
10 @echo "Running configure for you..."
14 include config-host.mak
17 DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
18 CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(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)
23 SCRIPTS = tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio
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
40 ifdef CONFIG_64BIT_LLP64
41 CFLAGS += -DBITS_PER_LONG=32
44 CFLAGS += -DBITS_PER_LONG=64
47 CFLAGS += -DBITS_PER_LONG=32
50 SOURCE += engines/libaio.c
53 SOURCE += engines/rdma.c
56 SOURCE += engines/posixaio.c
58 ifdef CONFIG_LINUX_FALLOCATE
59 SOURCE += engines/falloc.c
61 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
62 SOURCE += engines/e4defrag.c
64 ifdef CONFIG_LINUX_SPLICE
65 SOURCE += engines/splice.c
68 SOURCE += engines/guasi.c
70 ifdef CONFIG_FUSION_AW
71 SOURCE += engines/fusion-aw.c
73 ifdef CONFIG_SOLARISAIO
74 SOURCE += engines/solarisaio.c
76 ifdef CONFIG_WINDOWSAIO
77 SOURCE += engines/windowsaio.c
80 SOURCE += lib/strsep.c
82 ifndef CONFIG_STRCASESTR
83 SOURCE += lib/strcasestr.c
85 ifndef CONFIG_GETOPT_LONG_ONLY
86 SOURCE += lib/getopt_long.c
88 ifndef CONFIG_INET_ATON
89 SOURCE += lib/inet_aton.c
92 ifeq ($(CONFIG_TARGET_OS), Linux)
93 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
95 LIBS += -lpthread -ldl
98 ifeq ($(CONFIG_TARGET_OS), Android)
99 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
103 ifeq ($(CONFIG_TARGET_OS), SunOS)
104 LIBS += -lpthread -ldl
105 CPPFLAGS += -D__EXTENSIONS__
107 ifeq ($(CONFIG_TARGET_OS), FreeBSD)
108 LIBS += -lpthread -lrt
111 ifeq ($(CONFIG_TARGET_OS), OpenBSD)
115 ifeq ($(CONFIG_TARGET_OS), NetBSD)
116 LIBS += -lpthread -lrt
119 ifeq ($(CONFIG_TARGET_OS), AIX)
120 LIBS += -lpthread -ldl -lrt
121 CPPFLAGS += -D_LARGE_FILES -D__ppc__
122 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
124 ifeq ($(CONFIG_TARGET_OS), HP-UX)
125 LIBS += -lpthread -ldl -lrt
126 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
128 ifeq ($(CONFIG_TARGET_OS), Darwin)
129 LIBS += -lpthread -ldl
131 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
132 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
133 SOURCE += os/windows/posix.c
134 LIBS += -lpthread -lpsapi -lws2_32
135 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format -static
138 OBJS = $(SOURCE:.c=.o)
140 FIO_OBJS = $(OBJS) fio.o
141 GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
142 gclient.o gcompat.o cairo_text_helpers.o printing.o
144 -include $(OBJS:.o=.d)
146 T_SMALLOC_OBJS = t/stest.o
147 T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
148 T_SMALLOC_PROGS = t/stest
150 T_IEEE_OBJS = t/ieee754.o
151 T_IEEE_OBJS += lib/ieee754.o
152 T_IEEE_PROGS = t/ieee754
154 T_ZIPF_OBS = t/genzipf.o
155 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
156 T_ZIPF_PROGS = t/genzipf
158 T_AXMAP_OBJS = t/axmap.o
159 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
160 T_AXMAP_PROGS = t/axmap
162 T_LFSR_TEST_OBJS = t/lfsr-test.o
163 T_LFSR_TEST_OBJS += lib/lfsr.o
164 T_LFSR_TEST_PROGS = t/lfsr-test
166 T_OBJS = $(T_SMALLOC_OBJS)
167 T_OBJS += $(T_IEEE_OBJS)
168 T_OBJS += $(T_ZIPF_OBJS)
169 T_OBJS += $(T_AXMAP_OBJS)
170 T_OBJS += $(T_LFSR_TEST_OBJS)
172 T_PROGS = $(T_SMALLOC_PROGS)
173 T_PROGS += $(T_IEEE_PROGS)
174 T_PROGS += $(T_ZIPF_PROGS)
175 T_PROGS += $(T_AXMAP_PROGS)
176 T_PROGS += $(T_LFSR_TEST_PROGS)
178 ifneq ($(findstring $(MAKEFLAGS),s),s)
180 QUIET_CC = @echo ' ' CC $@;
181 QUIET_LINK = @echo ' ' LINK $@;
182 QUIET_DEP = @echo ' ' DEP $@;
186 ifeq ($(CONFIG_TARGET_OS), SunOS)
192 bindir = $(prefix)/bin
194 ifeq ($(CONFIG_TARGET_OS), Darwin)
195 mandir = /usr/share/man
196 sharedir = /usr/share/fio
198 mandir = $(prefix)/man
199 sharedir = $(prefix)/share/fio
202 all: $(PROGS) $(SCRIPTS) FORCE
204 .PHONY: all install clean
207 FIO-VERSION-FILE: FORCE
208 @$(SHELL) ./FIO-VERSION-GEN
209 -include FIO-VERSION-FILE
211 override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
213 .c.o: FORCE FIO-VERSION-FILE
214 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
215 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
217 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
218 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
219 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
222 init.o: FIO-VERSION-FILE init.c
223 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
225 gcompat.o: gcompat.c gcompat.h
226 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
228 goptions.o: goptions.c goptions.h
229 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
231 ghelpers.o: ghelpers.c ghelpers.h
232 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
234 gerror.o: gerror.c gerror.h
235 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
237 gclient.o: gclient.c gclient.h
238 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
240 gfio.o: gfio.c ghelpers.c
241 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
243 graph.o: graph.c graph.h
244 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
246 cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
247 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c
249 printing.o: printing.c printing.h
250 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
252 t/stest: $(T_SMALLOC_OBJS)
253 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
255 t/ieee754: $(T_IEEE_OBJS)
256 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
259 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS)
262 $(QUIET_LINK)$(CC) $(LDFLAGS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS)
264 t/genzipf: $(T_ZIPF_OBJS)
265 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
267 t/axmap: $(T_AXMAP_OBJS)
268 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
270 t/lfsr-test: $(T_LFSR_TEST_OBJS)
271 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
274 -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
276 distclean: clean FORCE
282 tools/plot/fio2gnuplot.1:
283 @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot > tools/plot/fio2gnuplot.1
285 install: $(PROGS) $(SCRIPTS) tools/plot/fio2gnuplot.1 FORCE
286 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
287 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
288 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
289 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
290 $(INSTALL) -m 644 tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
291 $(INSTALL) -m 644 tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1
292 $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
293 $(INSTALL) -m 644 tools/plot/*gpm $(DESTDIR)$(sharedir)/