1 DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
2 CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(DEBUGFLAGS)
3 OPTFLAGS= -O3 -g -ffast-math $(EXTFLAGS)
4 CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS)
7 SCRIPTS = fio_generate_plots
8 UNAME := $(shell uname)
10 ifneq ($(wildcard config-host.mak),)
12 include config-host.mak
13 config-host-mak: configure
14 @echo $@ is out-of-date, running configure
15 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
18 @echo "Running configure for you..."
21 include config-host.mak
24 SOURCE := gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \
25 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
26 rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
27 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
28 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
29 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
30 json.c lib/zipf.c lib/axmap.c lib/lfsr.c gettime-thread.c \
31 helpers.c lib/flist_sort.c lib/hweight.c lib/getrusage.c \
34 ifdef CONFIG_64BIT_LLP64
35 CFLAGS += -DBITS_PER_LONG=32
38 CFLAGS += -DBITS_PER_LONG=64
41 CFLAGS += -DBITS_PER_LONG=32
44 SOURCE += engines/libaio.c
47 SOURCE += engines/rdma.c
50 SOURCE += engines/posixaio.c
52 ifdef CONFIG_LINUX_FALLOCATE
53 SOURCE += engines/falloc.c
55 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
56 SOURCE += engines/e4defrag.c
58 ifdef CONFIG_LINUX_SPLICE
59 SOURCE += engines/splice.c
62 SOURCE += engines/guasi.c
64 ifdef CONFIG_FUSION_AW
65 SOURCE += engines/fusion-aw.c
67 ifdef CONFIG_SOLARISAIO
68 SOURCE += engines/solarisaio.c
70 ifdef CONFIG_WINDOWSAIO
71 SOURCE += engines/windowsaio.c
74 SOURCE += lib/strsep.c
76 ifndef CONFIG_GETOPT_LONG_ONLY
77 SOURCE += lib/getopt_long.c
79 ifndef CONFIG_INET_ATON
80 SOURCE += lib/inet_aton.c
83 ifeq ($(UNAME), Linux)
84 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
85 engines/binject.c profiles/tiobench.c
86 LIBS += -lpthread -ldl
89 ifeq ($(UNAME), Android)
90 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
93 CPPFLAGS += -DFIO_NO_HAVE_SHM_H
95 ifeq ($(UNAME), SunOS)
96 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
97 CPPFLAGS += -D__EXTENSIONS__
99 ifeq ($(UNAME), FreeBSD)
100 LIBS += -lpthread -lrt
103 ifeq ($(UNAME), NetBSD)
104 LIBS += -lpthread -lrt
108 LIBS += -lpthread -ldl -lrt
109 CPPFLAGS += -D_LARGE_FILES -D__ppc__
110 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
112 ifeq ($(UNAME), HP-UX)
113 LIBS += -lpthread -ldl -lrt
114 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
116 ifeq ($(UNAME), Darwin)
117 LIBS += -lpthread -ldl
119 ifneq (,$(findstring CYGWIN,$(UNAME)))
120 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
121 SOURCE += os/windows/posix.c
122 LIBS += -lpthread -lpsapi -lws2_32
123 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
126 OBJS = $(SOURCE:.c=.o)
127 -include $(OBJS:.o=.d)
129 T_SMALLOC_OBJS = t/stest.o
130 T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
131 T_SMALLOC_PROGS = t/stest
133 T_IEEE_OBJS = t/ieee754.o
134 T_IEEE_OBJS += lib/ieee754.o
135 T_IEEE_PROGS = t/ieee754
137 T_ZIPF_OBS = t/genzipf.o
138 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
139 T_ZIPF_PROGS = t/genzipf
141 T_AXMAP_OBJS = t/axmap.o
142 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
143 T_AXMAP_PROGS = t/axmap
145 T_OBJS = $(T_SMALLOC_OBJS)
146 T_OBJS += $(T_IEEE_OBJS)
147 T_OBJS += $(T_ZIPF_OBJS)
148 T_OBJS += $(T_AXMAP_OBJS)
150 T_PROGS = $(T_SMALLOC_PROGS)
151 T_PROGS += $(T_IEEE_PROGS)
152 T_PROGS += $(T_ZIPF_PROGS)
153 T_PROGS += $(T_AXMAP_PROGS)
155 ifneq ($(findstring $(MAKEFLAGS),s),s)
157 QUIET_CC = @echo ' ' CC $@;
158 QUIET_LINK = @echo ' ' LINK $@;
159 QUIET_DEP = @echo ' ' DEP $@;
165 bindir = $(prefix)/bin
167 ifeq ($(UNAME), Darwin)
168 mandir = /usr/share/man
170 mandir = $(prefix)/man
173 all: $(PROGS) $(SCRIPTS) FORCE
175 .PHONY: all install clean
178 FIO-VERSION-FILE: FORCE
179 @$(SHELL) ./FIO-VERSION-GEN
180 -include FIO-VERSION-FILE
182 override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
184 .c.o: FORCE FIO-VERSION-FILE
185 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
186 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
188 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
189 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
190 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
193 init.o: FIO-VERSION-FILE init.c
194 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
196 t/stest: $(T_SMALLOC_OBJS)
197 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
199 t/ieee754: $(T_IEEE_OBJS)
200 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
202 t/genzipf: $(T_ZIPF_OBJS)
203 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
205 t/axmap: $(T_AXMAP_OBJS)
206 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
209 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
212 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak cscope.out *.d
217 install: $(PROGS) $(SCRIPTS) FORCE
218 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
219 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
220 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
221 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
222 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1