genfio: Splitting gen_template in 2 parts
[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:
d443abcf 9ifneq ($(MAKECMDGOALS),clean)
67bf9823
JA
10 @echo "Running configure for you..."
11 @./configure
d443abcf 12endif
67bf9823
JA
13all:
14include config-host.mak
15endif
16
af4862b3
JA
17DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
18CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(DEBUGFLAGS)
19OPTFLAGS= -O3 -g -ffast-math
eb19930c 20CFLAGS = -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS)
af4862b3
JA
21LIBS += -lm $(EXTLIBS)
22PROGS = fio
23SCRIPTS = fio_generate_plots
24
91f94d5b
JA
25ifdef CONFIG_GFIO
26 PROGS += gfio
27endif
28
ea783f87 29SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
d015e398 30 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
05775438 31 lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
c7c6cb4c 32 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
d48a9799 33 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
2dc1cbb5 34 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
9a0db1e2 35 cconv.c lib/prio_tree.c json.c lib/zipf.c lib/axmap.c \
836fcc0f 36 lib/lfsr.c gettime-thread.c helpers.c lib/flist_sort.c \
d4afedfd 37 lib/hweight.c lib/getrusage.c idletime.c td_error.c \
2ae0b204 38 profiles/tiobench.c profiles/act.c io_u_queue.c
67bf9823 39
c81f9347
BC
40ifdef CONFIG_64BIT_LLP64
41 CFLAGS += -DBITS_PER_LONG=32
42endif
67bf9823
JA
43ifdef CONFIG_64BIT
44 CFLAGS += -DBITS_PER_LONG=64
45endif
46ifdef CONFIG_32BIT
47 CFLAGS += -DBITS_PER_LONG=32
48endif
67bf9823 49ifdef CONFIG_LIBAIO
67bf9823
JA
50 SOURCE += engines/libaio.c
51endif
52ifdef CONFIG_RDMA
67bf9823
JA
53 SOURCE += engines/rdma.c
54endif
55ifdef CONFIG_POSIXAIO
67bf9823
JA
56 SOURCE += engines/posixaio.c
57endif
58ifdef CONFIG_LINUX_FALLOCATE
59 SOURCE += engines/falloc.c
60endif
61ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
62 SOURCE += engines/e4defrag.c
63endif
64ifdef CONFIG_LINUX_SPLICE
67bf9823
JA
65 SOURCE += engines/splice.c
66endif
67ifdef CONFIG_GUASI
67bf9823
JA
68 SOURCE += engines/guasi.c
69endif
70ifdef CONFIG_FUSION_AW
67bf9823
JA
71 SOURCE += engines/fusion-aw.c
72endif
73ifdef CONFIG_SOLARISAIO
67bf9823
JA
74 SOURCE += engines/solarisaio.c
75endif
4700b234 76ifdef CONFIG_WINDOWSAIO
4700b234
JA
77 SOURCE += engines/windowsaio.c
78endif
67bf9823 79ifndef CONFIG_STRSEP
67bf9823
JA
80 SOURCE += lib/strsep.c
81endif
9ad8da82
JA
82ifndef CONFIG_STRCASESTR
83 SOURCE += lib/strcasestr.c
84endif
67bf9823 85ifndef CONFIG_GETOPT_LONG_ONLY
67bf9823
JA
86 SOURCE += lib/getopt_long.c
87endif
67bf9823 88ifndef CONFIG_INET_ATON
67bf9823
JA
89 SOURCE += lib/inet_aton.c
90endif
d015e398 91
53cd4eee 92ifeq ($(CONFIG_TARGET_OS), Linux)
67bf9823 93 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
d4afedfd 94 engines/binject.c
67bf9823 95 LIBS += -lpthread -ldl
213a01b0 96 LDFLAGS += -rdynamic
d015e398 97endif
53cd4eee 98ifeq ($(CONFIG_TARGET_OS), Android)
67bf9823 99 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
ec5c6b12
AC
100 LIBS += -ldl
101 LDFLAGS += -rdynamic
ec5c6b12 102endif
53cd4eee 103ifeq ($(CONFIG_TARGET_OS), SunOS)
7366ad05 104 LIBS += -lpthread -ldl
d015e398
BC
105 CPPFLAGS += -D__EXTENSIONS__
106endif
53cd4eee 107ifeq ($(CONFIG_TARGET_OS), FreeBSD)
d015e398 108 LIBS += -lpthread -lrt
213a01b0 109 LDFLAGS += -rdynamic
d015e398 110endif
53cd4eee 111ifeq ($(CONFIG_TARGET_OS), NetBSD)
d015e398 112 LIBS += -lpthread -lrt
213a01b0 113 LDFLAGS += -rdynamic
d015e398 114endif
53cd4eee 115ifeq ($(CONFIG_TARGET_OS), AIX)
d015e398 116 LIBS += -lpthread -ldl -lrt
d015e398 117 CPPFLAGS += -D_LARGE_FILES -D__ppc__
48b35be0 118 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
d015e398 119endif
53cd4eee 120ifeq ($(CONFIG_TARGET_OS), HP-UX)
b5ffb752 121 LIBS += -lpthread -ldl -lrt
67bf9823 122 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
c00a2289 123endif
53cd4eee 124ifeq ($(CONFIG_TARGET_OS), Darwin)
d015e398
BC
125 LIBS += -lpthread -ldl
126endif
53cd4eee 127ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
93bcfd20 128 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
4700b234 129 SOURCE += os/windows/posix.c
93bcfd20
BC
130 LIBS += -lpthread -lpsapi -lws2_32
131 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
d015e398
BC
132endif
133
9b836561 134OBJS = $(SOURCE:.c=.o)
90b7a96d 135
8232e285 136FIO_OBJS = $(OBJS) fio.o
1252d8f2 137GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
bf3f7027 138 gclient.o gcompat.o cairo_text_helpers.o printing.o
79d16311 139
f67d6ee2 140-include $(OBJS:.o=.d)
79d16311 141
61f78f3a 142T_SMALLOC_OBJS = t/stest.o
39ab7da2 143T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
61f78f3a
JA
144T_SMALLOC_PROGS = t/stest
145
146T_IEEE_OBJS = t/ieee754.o
84f43c6f 147T_IEEE_OBJS += lib/ieee754.o
61f78f3a
JA
148T_IEEE_PROGS = t/ieee754
149
6ff38856 150T_ZIPF_OBS = t/genzipf.o
24baa4c7 151T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
eed3f518 152T_ZIPF_PROGS = t/genzipf
6ff38856 153
ad1f90aa
JA
154T_AXMAP_OBJS = t/axmap.o
155T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
156T_AXMAP_PROGS = t/axmap
157
7a887ffe
AP
158T_LFSR_TEST_OBJS = t/lfsr-test.o
159T_LFSR_TEST_OBJS += lib/lfsr.o
160T_LFSR_TEST_PROGS = t/lfsr-test
161
61f78f3a
JA
162T_OBJS = $(T_SMALLOC_OBJS)
163T_OBJS += $(T_IEEE_OBJS)
6ff38856 164T_OBJS += $(T_ZIPF_OBJS)
ad1f90aa 165T_OBJS += $(T_AXMAP_OBJS)
7a887ffe 166T_OBJS += $(T_LFSR_TEST_OBJS)
6ff38856
JA
167
168T_PROGS = $(T_SMALLOC_PROGS)
169T_PROGS += $(T_IEEE_PROGS)
170T_PROGS += $(T_ZIPF_PROGS)
ad1f90aa 171T_PROGS += $(T_AXMAP_PROGS)
7a887ffe 172T_PROGS += $(T_LFSR_TEST_PROGS)
3427207d 173
4c3ecec4
JA
174ifneq ($(findstring $(MAKEFLAGS),s),s)
175ifndef V
176 QUIET_CC = @echo ' ' CC $@;
6ce038de 177 QUIET_LINK = @echo ' ' LINK $@;
0b2d6a7a 178 QUIET_DEP = @echo ' ' DEP $@;
4c3ecec4
JA
179endif
180endif
181
a8168a22
JA
182ifeq ($(CONFIG_TARGET_OS), SunOS)
183 INSTALL = ginstall
184else
185 INSTALL = install
186endif
c1d5725e
JA
187prefix = /usr/local
188bindir = $(prefix)/bin
bcdf7c58 189
53cd4eee 190ifeq ($(CONFIG_TARGET_OS), Darwin)
bcdf7c58
JA
191mandir = /usr/share/man
192else
d60e92d1 193mandir = $(prefix)/man
bcdf7c58 194endif
c1d5725e 195
f67d6ee2 196all: $(PROGS) $(SCRIPTS) FORCE
f84622e9 197
3d43382c
JA
198.PHONY: all install clean
199.PHONY: FORCE cscope
200
201FIO-VERSION-FILE: FORCE
84306c1d 202 @$(SHELL) ./FIO-VERSION-GEN
3d43382c
JA
203-include FIO-VERSION-FILE
204
7496ea3e 205override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
3d43382c 206
cb340b15 207.c.o: FORCE FIO-VERSION-FILE
4feafb1e 208 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
f67d6ee2
JA
209 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
210 @mv -f $*.d $*.d.tmp
211 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
212 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
213 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
214 @rm -f $*.d.tmp
e52947d1 215
cb340b15 216init.o: FIO-VERSION-FILE init.c
4feafb1e 217 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
32d4cc61 218
f762cef9
JA
219gcompat.o: gcompat.c gcompat.h
220 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
221
9af4a244
JA
222goptions.o: goptions.c goptions.h
223 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
224
53e0e85d
JA
225ghelpers.o: ghelpers.c ghelpers.h
226 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
227
41666588
JA
228gerror.o: gerror.c gerror.h
229 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
230
1252d8f2
JA
231gclient.o: gclient.c gclient.h
232 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
233
53e0e85d 234gfio.o: gfio.c ghelpers.c
70d07ce1
JA
235 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
236
53e0e85d 237graph.o: graph.c graph.h
af58ef32
SC
238 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
239
ee2f55b2
SC
240cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
241 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c
242
bf3f7027
SC
243printing.o: printing.c printing.h
244 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
245
61f78f3a 246t/stest: $(T_SMALLOC_OBJS)
6ce038de 247 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
61f78f3a
JA
248
249t/ieee754: $(T_IEEE_OBJS)
6ce038de 250 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
fbc2792b 251
33765372 252fio: $(FIO_OBJS)
9db01ef9 253 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(LDFLAGS)
4c3ecec4 254
70d07ce1 255gfio: $(GFIO_OBJS)
9db01ef9 256 $(QUIET_LINK)$(CC) $(LIBS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS)
70d07ce1 257
6ff38856 258t/genzipf: $(T_ZIPF_OBJS)
6ce038de 259 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
6ff38856 260
ad1f90aa 261t/axmap: $(T_AXMAP_OBJS)
6ce038de 262 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
ad1f90aa 263
7a887ffe
AP
264t/lfsr-test: $(T_LFSR_TEST_OBJS)
265 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS) $(LDFLAGS)
266
3d43382c 267clean: FORCE
45f944b9
JA
268 -rm -f .depend $(FIO_OBJS) $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE *.d config-host.mak config-host.h
269
270distclean: clean FORCE
271 @rm -f cscope.out
ebac4655 272
592ef98a 273cscope:
366badd3 274 @cscope -b -R
592ef98a 275
3d43382c 276install: $(PROGS) $(SCRIPTS) FORCE
513ba3f7 277 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
ebac4655 278 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
d60e92d1
AC
279 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
280 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
ccd4f41b 281 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1