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