configure: enable --extra-cflags for Windows
[fio.git] / Makefile
CommitLineData
79e48f72 1DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
44404c5a 2CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(DEBUGFLAGS)
b14c9ed7 3OPTFLAGS= -O3 -g -ffast-math $(EXTFLAGS)
d015e398 4CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS)
b6cf38f0 5LIBS = -lm $(EXTLIBS)
ebac4655
JA
6PROGS = fio
7SCRIPTS = fio_generate_plots
d015e398
BC
8UNAME := $(shell uname)
9
67bf9823
JA
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
93bcfd20 24SOURCE := 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 \
44404c5a 31 helpers.c lib/flist_sort.c lib/hweight.c lib/getrusage.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
BC
81
82ifeq ($(UNAME), 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
ec5c6b12 88ifeq ($(UNAME), Android)
67bf9823 89 SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
ec5c6b12
AC
90 LIBS += -ldl
91 LDFLAGS += -rdynamic
92 CPPFLAGS += -DFIO_NO_HAVE_SHM_H
93endif
d015e398 94ifeq ($(UNAME), SunOS)
d015e398
BC
95 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
96 CPPFLAGS += -D__EXTENSIONS__
97endif
98ifeq ($(UNAME), FreeBSD)
d015e398 99 LIBS += -lpthread -lrt
213a01b0 100 LDFLAGS += -rdynamic
d015e398
BC
101endif
102ifeq ($(UNAME), NetBSD)
d015e398 103 LIBS += -lpthread -lrt
213a01b0 104 LDFLAGS += -rdynamic
d015e398
BC
105endif
106ifeq ($(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 110endif
c00a2289 111ifeq ($(UNAME), HP-UX)
b5ffb752 112 LIBS += -lpthread -ldl -lrt
67bf9823 113 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
c00a2289 114endif
d015e398 115ifeq ($(UNAME), Darwin)
d015e398
BC
116 LIBS += -lpthread -ldl
117endif
118ifneq (,$(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
123endif
124
9b836561 125OBJS = $(SOURCE:.c=.o)
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
61f78f3a
JA
143T_OBJS = $(T_SMALLOC_OBJS)
144T_OBJS += $(T_IEEE_OBJS)
6ff38856 145T_OBJS += $(T_ZIPF_OBJS)
ad1f90aa 146T_OBJS += $(T_AXMAP_OBJS)
6ff38856
JA
147
148T_PROGS = $(T_SMALLOC_PROGS)
149T_PROGS += $(T_IEEE_PROGS)
150T_PROGS += $(T_ZIPF_PROGS)
ad1f90aa 151T_PROGS += $(T_AXMAP_PROGS)
3427207d 152
4c3ecec4
JA
153ifneq ($(findstring $(MAKEFLAGS),s),s)
154ifndef V
155 QUIET_CC = @echo ' ' CC $@;
0b2d6a7a 156 QUIET_DEP = @echo ' ' DEP $@;
4c3ecec4
JA
157endif
158endif
159
c1d5725e
JA
160INSTALL = install
161prefix = /usr/local
162bindir = $(prefix)/bin
bcdf7c58
JA
163
164ifeq ($(UNAME), Darwin)
165mandir = /usr/share/man
166else
d60e92d1 167mandir = $(prefix)/man
bcdf7c58 168endif
c1d5725e 169
692a5d22 170all: .depend $(PROGS) $(SCRIPTS) FORCE
f84622e9 171
692a5d22
JA
172.PHONY: all install clean
173.PHONY: FORCE cscope
174
175FIO-VERSION-FILE: FORCE
84306c1d 176 @$(SHELL) ./FIO-VERSION-GEN
692a5d22
JA
177-include FIO-VERSION-FILE
178
179CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
180
181.c.o: .depend FORCE
4feafb1e 182 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
e52947d1 183
a6204b68 184init.o: FIO-VERSION-FILE
4feafb1e 185 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
a6204b68 186
61f78f3a
JA
187t/stest: $(T_SMALLOC_OBJS)
188 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
189
190t/ieee754: $(T_IEEE_OBJS)
191 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
fbc2792b 192
6ff38856
JA
193t/genzipf: $(T_ZIPF_OBJS)
194 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
195
ad1f90aa
JA
196t/axmap: $(T_AXMAP_OBJS)
197 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS) $(LDFLAGS)
198
2f9ade3c 199fio: $(OBJS)
48b35be0 200 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
4c3ecec4 201
f84622e9 202.depend: $(SOURCE)
9b836561 203 $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
0b2d6a7a 204
8541f32c 205$(PROGS): .depend
ebac4655 206
692a5d22 207clean: FORCE
68b739ad 208 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE config-host.mak cscope.out
ebac4655 209
592ef98a 210cscope:
366badd3 211 @cscope -b -R
592ef98a 212
692a5d22 213install: $(PROGS) $(SCRIPTS) FORCE
513ba3f7 214 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
ebac4655 215 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
d60e92d1
AC
216 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
217 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
ccd4f41b 218 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
ebac4655 219
06fecb4e
JA
220ifneq ($(wildcard .depend),)
221include .depend
222endif