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