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
94 ifeq ($(UNAME), SunOS)
95 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
96 CPPFLAGS += -D__EXTENSIONS__
98 ifeq ($(UNAME), FreeBSD)
99 LIBS += -lpthread -lrt
102 ifeq ($(UNAME), NetBSD)
103 LIBS += -lpthread -lrt
107 LIBS += -lpthread -ldl -lrt
108 CPPFLAGS += -D_LARGE_FILES -D__ppc__
109 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
111 ifeq ($(UNAME), HP-UX)
112 LIBS += -lpthread -ldl -lrt
113 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
115 ifeq ($(UNAME), Darwin)
116 LIBS += -lpthread -ldl
118 ifneq (,$(findstring CYGWIN,$(UNAME)))
119 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
120 SOURCE += os/windows/posix.c
121 LIBS += -lpthread -lpsapi -lws2_32
122 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
125 OBJS = $(SOURCE:.c=.o)
126 -include $(OBJS:.o=.d)
128 T_SMALLOC_OBJS = t/stest.o
129 T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
130 T_SMALLOC_PROGS = t/stest
132 T_IEEE_OBJS = t/ieee754.o
133 T_IEEE_OBJS += lib/ieee754.o
134 T_IEEE_PROGS = t/ieee754
136 T_ZIPF_OBS = t/genzipf.o
137 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
138 T_ZIPF_PROGS = t/genzipf
140 T_AXMAP_OBJS = t/axmap.o
141 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
142 T_AXMAP_PROGS = t/axmap
144 T_OBJS = $(T_SMALLOC_OBJS)
145 T_OBJS += $(T_IEEE_OBJS)
146 T_OBJS += $(T_ZIPF_OBJS)
147 T_OBJS += $(T_AXMAP_OBJS)
149 T_PROGS = $(T_SMALLOC_PROGS)
150 T_PROGS += $(T_IEEE_PROGS)
151 T_PROGS += $(T_ZIPF_PROGS)
152 T_PROGS += $(T_AXMAP_PROGS)
154 ifneq ($(findstring $(MAKEFLAGS),s),s)
156 QUIET_CC = @echo ' ' CC $@;
157 QUIET_LINK = @echo ' ' LINK $@;
158 QUIET_DEP = @echo ' ' DEP $@;
164 bindir = $(prefix)/bin
166 ifeq ($(UNAME), Darwin)
167 mandir = /usr/share/man
169 mandir = $(prefix)/man
172 all: $(PROGS) $(SCRIPTS) FORCE
174 .PHONY: all install clean
177 FIO-VERSION-FILE: FORCE
178 @$(SHELL) ./FIO-VERSION-GEN
179 -include FIO-VERSION-FILE
181 override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
183 .c.o: FORCE FIO-VERSION-FILE
184 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
185 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
187 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
188 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
189 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
192 init.o: FIO-VERSION-FILE init.c
193 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
195 t/stest: $(T_SMALLOC_OBJS)
196 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
198 t/ieee754: $(T_IEEE_OBJS)
199 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
201 t/genzipf: $(T_ZIPF_OBJS)
202 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
204 t/axmap: $(T_AXMAP_OBJS)
205 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
208 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
211 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak cscope.out *.d
216 install: $(PROGS) $(SCRIPTS) FORCE
217 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
218 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
219 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
220 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
221 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1