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