Fixup json bandwidth output
[fio.git] / Makefile
CommitLineData
67bf9823
JA
1ifneq ($(wildcard config-host.mak),)
2all:
3include config-host.mak
4config-host-mak: configure
5 @echo $@ is out-of-date, running configure
6 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
7else
8config-host.mak:
9 @echo "Running configure for you..."
10 @./configure
11all:
12include config-host.mak
13endif
14
af4862b3
JA
15DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
16CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(DEBUGFLAGS)
17OPTFLAGS= -O3 -g -ffast-math
18CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS)
19LIBS += -lm $(EXTLIBS)
20PROGS = fio
21SCRIPTS = fio_generate_plots
22
93bcfd20 23SOURCE := gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \
d015e398
BC
24 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
25 rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
c7c6cb4c 26 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
d48a9799 27 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
62cb17de 28 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
67bf9823 29 json.c lib/zipf.c lib/axmap.c lib/lfsr.c gettime-thread.c \
f2a2ce0e
HL
30 helpers.c lib/flist_sort.c lib/hweight.c lib/getrusage.c \
31 idletime.c
67bf9823 32
c81f9347
BC
33ifdef CONFIG_64BIT_LLP64
34 CFLAGS += -DBITS_PER_LONG=32
35endif
67bf9823
JA
36ifdef CONFIG_64BIT
37 CFLAGS += -DBITS_PER_LONG=64
38endif
39ifdef CONFIG_32BIT
40 CFLAGS += -DBITS_PER_LONG=32
41endif
67bf9823 42ifdef CONFIG_LIBAIO
67bf9823
JA
43 SOURCE += engines/libaio.c
44endif
45ifdef CONFIG_RDMA
67bf9823
JA
46 SOURCE += engines/rdma.c
47endif
48ifdef CONFIG_POSIXAIO
67bf9823
JA
49 SOURCE += engines/posixaio.c
50endif
51ifdef CONFIG_LINUX_FALLOCATE
52 SOURCE += engines/falloc.c
53endif
54ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
55 SOURCE += engines/e4defrag.c
56endif
57ifdef CONFIG_LINUX_SPLICE
67bf9823
JA
58 SOURCE += engines/splice.c
59endif
60ifdef CONFIG_GUASI
67bf9823
JA
61 SOURCE += engines/guasi.c
62endif
63ifdef CONFIG_FUSION_AW
67bf9823
JA
64 SOURCE += engines/fusion-aw.c
65endif
66ifdef CONFIG_SOLARISAIO
67bf9823
JA
67 SOURCE += engines/solarisaio.c
68endif
4700b234 69ifdef CONFIG_WINDOWSAIO
4700b234
JA
70 SOURCE += engines/windowsaio.c
71endif
67bf9823 72ifndef CONFIG_STRSEP
67bf9823
JA
73 SOURCE += lib/strsep.c
74endif
75ifndef CONFIG_GETOPT_LONG_ONLY
67bf9823
JA
76 SOURCE += lib/getopt_long.c
77endif
67bf9823 78ifndef CONFIG_INET_ATON
67bf9823
JA
79 SOURCE += lib/inet_aton.c
80endif
d015e398 81
53cd4eee 82ifeq ($(CONFIG_TARGET_OS), Linux)
67bf9823
JA
83 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
84 engines/binject.c profiles/tiobench.c
85 LIBS += -lpthread -ldl
213a01b0 86 LDFLAGS += -rdynamic
d015e398 87endif
53cd4eee 88ifeq ($(CONFIG_TARGET_OS), Android)
67bf9823 89 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
ec5c6b12
AC
90 LIBS += -ldl
91 LDFLAGS += -rdynamic
ec5c6b12 92endif
53cd4eee 93ifeq ($(CONFIG_TARGET_OS), SunOS)
7366ad05 94 LIBS += -lpthread -ldl
d015e398
BC
95 CPPFLAGS += -D__EXTENSIONS__
96endif
53cd4eee 97ifeq ($(CONFIG_TARGET_OS), FreeBSD)
d015e398 98 LIBS += -lpthread -lrt
213a01b0 99 LDFLAGS += -rdynamic
d015e398 100endif
53cd4eee 101ifeq ($(CONFIG_TARGET_OS), NetBSD)
d015e398 102 LIBS += -lpthread -lrt
213a01b0 103 LDFLAGS += -rdynamic
d015e398 104endif
53cd4eee 105ifeq ($(CONFIG_TARGET_OS), AIX)
d015e398 106 LIBS += -lpthread -ldl -lrt
d015e398 107 CPPFLAGS += -D_LARGE_FILES -D__ppc__
48b35be0 108 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
d015e398 109endif
53cd4eee 110ifeq ($(CONFIG_TARGET_OS), HP-UX)
b5ffb752 111 LIBS += -lpthread -ldl -lrt
67bf9823 112 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
c00a2289 113endif
53cd4eee 114ifeq ($(CONFIG_TARGET_OS), Darwin)
d015e398
BC
115 LIBS += -lpthread -ldl
116endif
53cd4eee 117ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
93bcfd20 118 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
4700b234 119 SOURCE += os/windows/posix.c
93bcfd20
BC
120 LIBS += -lpthread -lpsapi -lws2_32
121 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
d015e398
BC
122endif
123
9b836561 124OBJS = $(SOURCE:.c=.o)
f67d6ee2 125-include $(OBJS:.o=.d)
79d16311 126
61f78f3a 127T_SMALLOC_OBJS = t/stest.o
39ab7da2 128T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
61f78f3a
JA
129T_SMALLOC_PROGS = t/stest
130
131T_IEEE_OBJS = t/ieee754.o
f98f3d07 132T_IEEE_OBJS += lib/ieee754.o
61f78f3a
JA
133T_IEEE_PROGS = t/ieee754
134
6ff38856 135T_ZIPF_OBS = t/genzipf.o
24baa4c7 136T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
eed3f518 137T_ZIPF_PROGS = t/genzipf
6ff38856 138
ad1f90aa
JA
139T_AXMAP_OBJS = t/axmap.o
140T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
141T_AXMAP_PROGS = t/axmap
142
7a887ffe
AP
143T_LFSR_TEST_OBJS = t/lfsr-test.o
144T_LFSR_TEST_OBJS += lib/lfsr.o
145T_LFSR_TEST_PROGS = t/lfsr-test
146
61f78f3a
JA
147T_OBJS = $(T_SMALLOC_OBJS)
148T_OBJS += $(T_IEEE_OBJS)
6ff38856 149T_OBJS += $(T_ZIPF_OBJS)
ad1f90aa 150T_OBJS += $(T_AXMAP_OBJS)
7a887ffe 151T_OBJS += $(T_LFSR_TEST_OBJS)
6ff38856
JA
152
153T_PROGS = $(T_SMALLOC_PROGS)
154T_PROGS += $(T_IEEE_PROGS)
155T_PROGS += $(T_ZIPF_PROGS)
ad1f90aa 156T_PROGS += $(T_AXMAP_PROGS)
7a887ffe 157T_PROGS += $(T_LFSR_TEST_PROGS)
3427207d 158
4c3ecec4
JA
159ifneq ($(findstring $(MAKEFLAGS),s),s)
160ifndef V
161 QUIET_CC = @echo ' ' CC $@;
6ce038de 162 QUIET_LINK = @echo ' ' LINK $@;
0b2d6a7a 163 QUIET_DEP = @echo ' ' DEP $@;
4c3ecec4
JA
164endif
165endif
166
c1d5725e
JA
167INSTALL = install
168prefix = /usr/local
169bindir = $(prefix)/bin
bcdf7c58 170
53cd4eee 171ifeq ($(CONFIG_TARGET_OS), Darwin)
bcdf7c58
JA
172mandir = /usr/share/man
173else
d60e92d1 174mandir = $(prefix)/man
bcdf7c58 175endif
c1d5725e 176
f67d6ee2 177all: $(PROGS) $(SCRIPTS) FORCE
f84622e9 178
692a5d22
JA
179.PHONY: all install clean
180.PHONY: FORCE cscope
181
182FIO-VERSION-FILE: FORCE
84306c1d 183 @$(SHELL) ./FIO-VERSION-GEN
692a5d22
JA
184-include FIO-VERSION-FILE
185
7496ea3e 186override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
692a5d22 187
cb340b15 188.c.o: FORCE FIO-VERSION-FILE
4feafb1e 189 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
f67d6ee2
JA
190 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
191 @mv -f $*.d $*.d.tmp
192 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
193 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
194 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
195 @rm -f $*.d.tmp
e52947d1 196
cb340b15 197init.o: FIO-VERSION-FILE init.c
4feafb1e 198 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
a6204b68 199
61f78f3a 200t/stest: $(T_SMALLOC_OBJS)
6ce038de 201 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
61f78f3a
JA
202
203t/ieee754: $(T_IEEE_OBJS)
6ce038de 204 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
fbc2792b 205
6ff38856 206t/genzipf: $(T_ZIPF_OBJS)
6ce038de 207 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
6ff38856 208
ad1f90aa 209t/axmap: $(T_AXMAP_OBJS)
6ce038de 210 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
ad1f90aa 211
7a887ffe
AP
212t/lfsr-test: $(T_LFSR_TEST_OBJS)
213 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS) $(LDFLAGS)
214
2f9ade3c 215fio: $(OBJS)
6ce038de 216 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
4c3ecec4 217
692a5d22 218clean: FORCE
ff01f0f1 219 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak config-host.h cscope.out *.d
ebac4655 220
592ef98a 221cscope:
366badd3 222 @cscope -b -R
592ef98a 223
692a5d22 224install: $(PROGS) $(SCRIPTS) FORCE
513ba3f7 225 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
ebac4655 226 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
d60e92d1
AC
227 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
228 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
ccd4f41b 229 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1