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