Use RUSAGE_THREAD, if available
[fio.git] / Makefile
... / ...
CommitLineData
1DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
2CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
3 $(DEBUGFLAGS)
4OPTFLAGS= -O3 -g -ffast-math $(EXTFLAGS)
5CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS)
6LIBS = -lm $(EXTLIBS)
7PROGS = fio
8SCRIPTS = fio_generate_plots
9UNAME := $(shell uname)
10
11ifneq ($(wildcard config-host.mak),)
12all:
13include config-host.mak
14config-host-mak: configure
15 @echo $@ is out-of-date, running configure
16 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
17else
18config-host.mak:
19 @echo "Running configure for you..."
20 @./configure
21all:
22include config-host.mak
23endif
24
25SOURCE := gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \
26 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
27 rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
28 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
29 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
30 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
31 json.c lib/zipf.c lib/axmap.c lib/lfsr.c gettime-thread.c \
32 helpers.c lib/flist_sort.c lib/hweight.c
33
34ifdef CONFIG_64BIT_LLP64
35 CFLAGS += -DBITS_PER_LONG=32
36endif
37ifdef CONFIG_64BIT
38 CFLAGS += -DBITS_PER_LONG=64
39endif
40ifdef CONFIG_32BIT
41 CFLAGS += -DBITS_PER_LONG=32
42endif
43ifdef CONFIG_BIG_ENDIAN
44 CFLAGS += -DCONFIG_BIG_ENDIAN
45endif
46ifdef CONFIG_LITTLE_ENDIAN
47 CFLAGS += -DCONFIG_LITTLE_ENDIAN
48endif
49ifdef CONFIG_LIBAIO
50 CFLAGS += -DCONFIG_LIBAIO
51 SOURCE += engines/libaio.c
52endif
53ifdef CONFIG_RDMA
54 CFLAGS += -DCONFIG_RDMA
55 SOURCE += engines/rdma.c
56endif
57ifdef CONFIG_POSIXAIO
58 CFLAGS += -DCONFIG_POSIXAIO
59 SOURCE += engines/posixaio.c
60endif
61ifdef CONFIG_LINUX_FALLOCATE
62 SOURCE += engines/falloc.c
63endif
64ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
65 SOURCE += engines/e4defrag.c
66endif
67ifdef CONFIG_LINUX_SPLICE
68 CFLAGS += -DCONFIG_LINUX_SPLICE
69 SOURCE += engines/splice.c
70endif
71ifdef CONFIG_GUASI
72 CFLAGS += -DCONFIG_GUASI
73 SOURCE += engines/guasi.c
74endif
75ifdef CONFIG_FUSION_AW
76 CFLAGS += -DCONFIG_FUSION_AW
77 SOURCE += engines/fusion-aw.c
78endif
79ifdef CONFIG_SOLARISAIO
80 CFLAGS += -DCONFIG_SOLARISAIO
81 SOURCE += engines/solarisaio.c
82endif
83
84ifndef CONFIG_STRSEP
85 CFLAGS += -DCONFIG_STRSEP
86 SOURCE += lib/strsep.c
87endif
88ifndef CONFIG_GETOPT_LONG_ONLY
89 CFLAGS += -DCONFIG_GETOPT_LONG_ONLY
90 SOURCE += lib/getopt_long.c
91endif
92
93ifndef CONFIG_INET_ATON
94 CFLAGS += -DCONFIG_INET_ATON
95 SOURCE += lib/inet_aton.c
96endif
97ifdef CONFIG_CLOCK_GETTIME
98 CFLAGS += -DCONFIG_CLOCK_GETTIME
99endif
100ifdef CONFIG_POSIXAIO_FSYNC
101 CFLAGS += -DCONFIG_POSIXAIO_FSYNC
102endif
103ifdef CONFIG_FADVISE
104 CFLAGS += -DCONFIG_FADVISE
105endif
106ifdef CONFIG_CLOCK_MONOTONIC
107 CFLAGS += -DCONFIG_CLOCK_MONOTONIC
108endif
109ifdef CONFIG_CLOCK_MONOTONIC_PRECISE
110 CFLAGS += -DCONFIG_CLOCK_MONOTONIC_PRECISE
111endif
112ifdef CONFIG_GETTIMEOFDAY
113 CFLAGS += -DCONFIG_GETTIMEOFDAY
114endif
115ifdef CONFIG_SOCKLEN_T
116 CFLAGS += -DCONFIG_SOCKLEN_T
117endif
118ifdef CONFIG_SFAA
119 CFLAGS += -DCONFIG_SFAA
120endif
121ifdef CONFIG_FDATASYNC
122 CFLAGS += -DCONFIG_FDATASYNC
123endif
124ifdef CONFIG_3ARG_AFFINITY
125 CFLAGS += -DCONFIG_3ARG_AFFINITY
126endif
127ifdef CONFIG_2ARG_AFFINITY
128 CFLAGS += -DCONFIG_2ARG_AFFINITY
129endif
130ifdef CONFIG_SYNC_FILE_RANGE
131 CFLAGS += -DCONFIG_SYNC_FILE_RANGE
132endif
133ifdef CONFIG_LIBNUMA
134 CFLAGS += -DCONFIG_LIBNUMA
135endif
136ifdef CONFIG_TLS_THREAD
137 CFLAGS += -DCONFIG_TLS_THREAD
138endif
139ifdef CONFIG_POSIX_FALLOCATE
140 CFLAGS += -DCONFIG_POSIX_FALLOCATE
141endif
142ifdef CONFIG_LINUX_FALLOCATE
143 CFLAGS += -DCONFIG_LINUX_FALLOCATE
144endif
145
146ifeq ($(UNAME), Linux)
147 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
148 engines/binject.c profiles/tiobench.c
149 LIBS += -lpthread -ldl
150 LDFLAGS += -rdynamic
151endif
152ifeq ($(UNAME), Android)
153 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
154 LIBS += -ldl
155 LDFLAGS += -rdynamic
156 CPPFLAGS += -DFIO_NO_HAVE_SHM_H
157endif
158ifeq ($(UNAME), SunOS)
159 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
160 CPPFLAGS += -D__EXTENSIONS__
161endif
162ifeq ($(UNAME), FreeBSD)
163 LIBS += -lpthread -lrt
164 LDFLAGS += -rdynamic
165endif
166ifeq ($(UNAME), NetBSD)
167 LIBS += -lpthread -lrt
168 LDFLAGS += -rdynamic
169endif
170ifeq ($(UNAME), AIX)
171 LIBS += -lpthread -ldl -lrt
172 CPPFLAGS += -D_LARGE_FILES -D__ppc__
173 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
174endif
175ifeq ($(UNAME), HP-UX)
176 LIBS += -lpthread -ldl -lrt
177 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
178endif
179ifeq ($(UNAME), Darwin)
180 LIBS += -lpthread -ldl
181endif
182ifneq (,$(findstring CYGWIN,$(UNAME)))
183 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
184 SOURCE += engines/windowsaio.c os/windows/posix.c
185 LIBS += -lpthread -lpsapi -lws2_32
186 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
187endif
188
189OBJS = $(SOURCE:.c=.o)
190
191T_SMALLOC_OBJS = t/stest.o
192T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
193T_SMALLOC_PROGS = t/stest
194
195T_IEEE_OBJS = t/ieee754.o
196T_IEEE_OBJS += lib/ieee754.o
197T_IEEE_PROGS = t/ieee754
198
199T_ZIPF_OBS = t/genzipf.o
200T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
201T_ZIPF_PROGS = t/genzipf
202
203T_AXMAP_OBJS = t/axmap.o
204T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
205T_AXMAP_PROGS = t/axmap
206
207T_OBJS = $(T_SMALLOC_OBJS)
208T_OBJS += $(T_IEEE_OBJS)
209T_OBJS += $(T_ZIPF_OBJS)
210T_OBJS += $(T_AXMAP_OBJS)
211
212T_PROGS = $(T_SMALLOC_PROGS)
213T_PROGS += $(T_IEEE_PROGS)
214T_PROGS += $(T_ZIPF_PROGS)
215T_PROGS += $(T_AXMAP_PROGS)
216
217ifneq ($(findstring $(MAKEFLAGS),s),s)
218ifndef V
219 QUIET_CC = @echo ' ' CC $@;
220 QUIET_DEP = @echo ' ' DEP $@;
221endif
222endif
223
224INSTALL = install
225prefix = /usr/local
226bindir = $(prefix)/bin
227
228ifeq ($(UNAME), Darwin)
229mandir = /usr/share/man
230else
231mandir = $(prefix)/man
232endif
233
234all: .depend $(PROGS) $(SCRIPTS) FORCE
235
236.PHONY: all install clean
237.PHONY: FORCE cscope
238
239FIO-VERSION-FILE: FORCE
240 @$(SHELL) ./FIO-VERSION-GEN
241-include FIO-VERSION-FILE
242
243CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
244
245.c.o: .depend FORCE
246 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
247
248init.o: FIO-VERSION-FILE
249 $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
250
251t/stest: $(T_SMALLOC_OBJS)
252 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
253
254t/ieee754: $(T_IEEE_OBJS)
255 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
256
257t/genzipf: $(T_ZIPF_OBJS)
258 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
259
260t/axmap: $(T_AXMAP_OBJS)
261 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
262
263fio: $(OBJS)
264 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
265
266.depend: $(SOURCE)
267 $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
268
269$(PROGS): .depend
270
271clean: FORCE
272 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak config-host.ld cscope.out
273
274cscope:
275 @cscope -b -R
276
277install: $(PROGS) $(SCRIPTS) FORCE
278 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
279 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
280 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
281 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
282 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
283
284ifneq ($(wildcard .depend),)
285include .depend
286endif