Merge branch 'master' into gfio
[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 -lz $(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
24ifdef CONFIG_GFIO
25 PROGS += gfio
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 lib/getrusage.c idletime.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_LIBAIO
48 SOURCE += engines/libaio.c
49endif
50ifdef CONFIG_RDMA
51 SOURCE += engines/rdma.c
52endif
53ifdef CONFIG_POSIXAIO
54 SOURCE += engines/posixaio.c
55endif
56ifdef CONFIG_LINUX_FALLOCATE
57 SOURCE += engines/falloc.c
58endif
59ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
60 SOURCE += engines/e4defrag.c
61endif
62ifdef CONFIG_LINUX_SPLICE
63 SOURCE += engines/splice.c
64endif
65ifdef CONFIG_GUASI
66 SOURCE += engines/guasi.c
67endif
68ifdef CONFIG_FUSION_AW
69 SOURCE += engines/fusion-aw.c
70endif
71ifdef CONFIG_SOLARISAIO
72 SOURCE += engines/solarisaio.c
73endif
74ifdef CONFIG_WINDOWSAIO
75 SOURCE += engines/windowsaio.c
76endif
77ifndef CONFIG_STRSEP
78 SOURCE += lib/strsep.c
79endif
80ifndef CONFIG_GETOPT_LONG_ONLY
81 SOURCE += lib/getopt_long.c
82endif
83ifndef CONFIG_INET_ATON
84 SOURCE += lib/inet_aton.c
85endif
86
87ifeq ($(UNAME), Linux)
88 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
89 engines/binject.c profiles/tiobench.c
90 LIBS += -lpthread -ldl
91 LDFLAGS += -rdynamic
92endif
93ifeq ($(UNAME), Android)
94 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
95 LIBS += -ldl
96 LDFLAGS += -rdynamic
97endif
98ifeq ($(UNAME), SunOS)
99 LIBS += -lpthread -ldl
100 CPPFLAGS += -D__EXTENSIONS__
101endif
102ifeq ($(UNAME), FreeBSD)
103 LIBS += -lpthread -lrt
104 LDFLAGS += -rdynamic
105endif
106ifeq ($(UNAME), NetBSD)
107 LIBS += -lpthread -lrt
108 LDFLAGS += -rdynamic
109endif
110ifeq ($(UNAME), AIX)
111 LIBS += -lpthread -ldl -lrt
112 CPPFLAGS += -D_LARGE_FILES -D__ppc__
113 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
114endif
115ifeq ($(UNAME), HP-UX)
116 LIBS += -lpthread -ldl -lrt
117 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
118endif
119ifeq ($(UNAME), Darwin)
120 LIBS += -lpthread -ldl
121endif
122ifneq (,$(findstring CYGWIN,$(UNAME)))
123 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
124 SOURCE += os/windows/posix.c
125 LIBS += -lpthread -lpsapi -lws2_32
126 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
127endif
128
129OBJS = $(SOURCE:.c=.o)
130
131FIO_OBJS = $(OBJS) fio.o
132GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
133 gclient.o gcompat.o cairo_text_helpers.o printing.o
134
135-include $(OBJS:.o=.d)
136
137T_SMALLOC_OBJS = t/stest.o
138T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
139T_SMALLOC_PROGS = t/stest
140
141T_IEEE_OBJS = t/ieee754.o
142T_IEEE_OBJS += lib/ieee754.o
143T_IEEE_PROGS = t/ieee754
144
145T_ZIPF_OBS = t/genzipf.o
146T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
147T_ZIPF_PROGS = t/genzipf
148
149T_AXMAP_OBJS = t/axmap.o
150T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
151T_AXMAP_PROGS = t/axmap
152
153T_OBJS = $(T_SMALLOC_OBJS)
154T_OBJS += $(T_IEEE_OBJS)
155T_OBJS += $(T_ZIPF_OBJS)
156T_OBJS += $(T_AXMAP_OBJS)
157
158T_PROGS = $(T_SMALLOC_PROGS)
159T_PROGS += $(T_IEEE_PROGS)
160T_PROGS += $(T_ZIPF_PROGS)
161T_PROGS += $(T_AXMAP_PROGS)
162
163ifneq ($(findstring $(MAKEFLAGS),s),s)
164ifndef V
165 QUIET_CC = @echo ' ' CC $@;
166 QUIET_LINK = @echo ' ' LINK $@;
167 QUIET_DEP = @echo ' ' DEP $@;
168endif
169endif
170
171INSTALL = install
172prefix = /usr/local
173bindir = $(prefix)/bin
174
175ifeq ($(UNAME), Darwin)
176mandir = /usr/share/man
177else
178mandir = $(prefix)/man
179endif
180
181all: $(PROGS) $(SCRIPTS) FORCE
182
183.PHONY: all install clean
184.PHONY: FORCE cscope
185
186FIO-VERSION-FILE: FORCE
187 @$(SHELL) ./FIO-VERSION-GEN
188-include FIO-VERSION-FILE
189
190override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
191
192.c.o: FORCE FIO-VERSION-FILE
193 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
194 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
195 @mv -f $*.d $*.d.tmp
196 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
197 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
198 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
199 @rm -f $*.d.tmp
200
201init.o: FIO-VERSION-FILE init.c
202 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
203
204gcompat.o: gcompat.c gcompat.h
205 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
206
207goptions.o: goptions.c goptions.h
208 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
209
210ghelpers.o: ghelpers.c ghelpers.h
211 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
212
213gerror.o: gerror.c gerror.h
214 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
215
216gclient.o: gclient.c gclient.h
217 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
218
219gfio.o: gfio.c ghelpers.c
220 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
221
222graph.o: graph.c graph.h
223 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
224
225cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
226 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c
227
228printing.o: printing.c printing.h
229 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
230
231t/stest: $(T_SMALLOC_OBJS)
232 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
233
234t/ieee754: $(T_IEEE_OBJS)
235 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
236
237fio: $(FIO_OBJS)
238 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(LDFLAGS)
239
240gfio: $(GFIO_OBJS)
241 $(QUIET_LINK)$(CC) $(LIBS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS)
242
243t/genzipf: $(T_ZIPF_OBJS)
244 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
245
246t/axmap: $(T_AXMAP_OBJS)
247 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
248
249clean: FORCE
250 -rm -f .depend $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE config-host.mak cscope.out *.d
251
252cscope:
253 @cscope -b -R
254
255install: $(PROGS) $(SCRIPTS) FORCE
256 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
257 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
258 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
259 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
260 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1