Add OpenBSD support
[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
265a2027 23SCRIPTS = tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio
af4862b3 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
3cd4c66f
J
111ifeq ($(CONFIG_TARGET_OS), OpenBSD)
112 LIBS += -lpthread
113 LDFLAGS += -rdynamic
114endif
53cd4eee 115ifeq ($(CONFIG_TARGET_OS), NetBSD)
d015e398 116 LIBS += -lpthread -lrt
213a01b0 117 LDFLAGS += -rdynamic
d015e398 118endif
53cd4eee 119ifeq ($(CONFIG_TARGET_OS), AIX)
d015e398 120 LIBS += -lpthread -ldl -lrt
d015e398 121 CPPFLAGS += -D_LARGE_FILES -D__ppc__
48b35be0 122 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
d015e398 123endif
53cd4eee 124ifeq ($(CONFIG_TARGET_OS), HP-UX)
b5ffb752 125 LIBS += -lpthread -ldl -lrt
67bf9823 126 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
c00a2289 127endif
53cd4eee 128ifeq ($(CONFIG_TARGET_OS), Darwin)
d015e398
BC
129 LIBS += -lpthread -ldl
130endif
53cd4eee 131ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
93bcfd20 132 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
4700b234 133 SOURCE += os/windows/posix.c
93bcfd20
BC
134 LIBS += -lpthread -lpsapi -lws2_32
135 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
d015e398
BC
136endif
137
9b836561 138OBJS = $(SOURCE:.c=.o)
90b7a96d 139
8232e285 140FIO_OBJS = $(OBJS) fio.o
1252d8f2 141GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
bf3f7027 142 gclient.o gcompat.o cairo_text_helpers.o printing.o
79d16311 143
f67d6ee2 144-include $(OBJS:.o=.d)
79d16311 145
61f78f3a 146T_SMALLOC_OBJS = t/stest.o
39ab7da2 147T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
61f78f3a
JA
148T_SMALLOC_PROGS = t/stest
149
150T_IEEE_OBJS = t/ieee754.o
84f43c6f 151T_IEEE_OBJS += lib/ieee754.o
61f78f3a
JA
152T_IEEE_PROGS = t/ieee754
153
6ff38856 154T_ZIPF_OBS = t/genzipf.o
24baa4c7 155T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
eed3f518 156T_ZIPF_PROGS = t/genzipf
6ff38856 157
ad1f90aa
JA
158T_AXMAP_OBJS = t/axmap.o
159T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
160T_AXMAP_PROGS = t/axmap
161
7a887ffe
AP
162T_LFSR_TEST_OBJS = t/lfsr-test.o
163T_LFSR_TEST_OBJS += lib/lfsr.o
164T_LFSR_TEST_PROGS = t/lfsr-test
165
61f78f3a
JA
166T_OBJS = $(T_SMALLOC_OBJS)
167T_OBJS += $(T_IEEE_OBJS)
6ff38856 168T_OBJS += $(T_ZIPF_OBJS)
ad1f90aa 169T_OBJS += $(T_AXMAP_OBJS)
7a887ffe 170T_OBJS += $(T_LFSR_TEST_OBJS)
6ff38856
JA
171
172T_PROGS = $(T_SMALLOC_PROGS)
173T_PROGS += $(T_IEEE_PROGS)
174T_PROGS += $(T_ZIPF_PROGS)
ad1f90aa 175T_PROGS += $(T_AXMAP_PROGS)
7a887ffe 176T_PROGS += $(T_LFSR_TEST_PROGS)
3427207d 177
4c3ecec4
JA
178ifneq ($(findstring $(MAKEFLAGS),s),s)
179ifndef V
180 QUIET_CC = @echo ' ' CC $@;
6ce038de 181 QUIET_LINK = @echo ' ' LINK $@;
0b2d6a7a 182 QUIET_DEP = @echo ' ' DEP $@;
4c3ecec4
JA
183endif
184endif
185
a8168a22
JA
186ifeq ($(CONFIG_TARGET_OS), SunOS)
187 INSTALL = ginstall
188else
189 INSTALL = install
190endif
c1d5725e
JA
191prefix = /usr/local
192bindir = $(prefix)/bin
bcdf7c58 193
53cd4eee 194ifeq ($(CONFIG_TARGET_OS), Darwin)
bcdf7c58 195mandir = /usr/share/man
eab4af4e 196sharedir = /usr/share/fio
bcdf7c58 197else
d60e92d1 198mandir = $(prefix)/man
eab4af4e 199sharedir = $(prefix)/share/fio
bcdf7c58 200endif
c1d5725e 201
f67d6ee2 202all: $(PROGS) $(SCRIPTS) FORCE
f84622e9 203
3d43382c
JA
204.PHONY: all install clean
205.PHONY: FORCE cscope
206
207FIO-VERSION-FILE: FORCE
84306c1d 208 @$(SHELL) ./FIO-VERSION-GEN
3d43382c
JA
209-include FIO-VERSION-FILE
210
7496ea3e 211override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
3d43382c 212
cb340b15 213.c.o: FORCE FIO-VERSION-FILE
4feafb1e 214 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
f67d6ee2
JA
215 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
216 @mv -f $*.d $*.d.tmp
217 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
218 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
219 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
220 @rm -f $*.d.tmp
e52947d1 221
cb340b15 222init.o: FIO-VERSION-FILE init.c
4feafb1e 223 $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
32d4cc61 224
f762cef9
JA
225gcompat.o: gcompat.c gcompat.h
226 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
227
9af4a244
JA
228goptions.o: goptions.c goptions.h
229 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
230
53e0e85d
JA
231ghelpers.o: ghelpers.c ghelpers.h
232 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
233
41666588
JA
234gerror.o: gerror.c gerror.h
235 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
236
1252d8f2
JA
237gclient.o: gclient.c gclient.h
238 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
239
53e0e85d 240gfio.o: gfio.c ghelpers.c
70d07ce1
JA
241 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
242
53e0e85d 243graph.o: graph.c graph.h
af58ef32
SC
244 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
245
ee2f55b2
SC
246cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
247 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c
248
bf3f7027
SC
249printing.o: printing.c printing.h
250 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
251
61f78f3a 252t/stest: $(T_SMALLOC_OBJS)
a3c86fc4 253 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
61f78f3a
JA
254
255t/ieee754: $(T_IEEE_OBJS)
a3c86fc4 256 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
fbc2792b 257
33765372 258fio: $(FIO_OBJS)
a3c86fc4 259 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS)
4c3ecec4 260
70d07ce1 261gfio: $(GFIO_OBJS)
a3c86fc4 262 $(QUIET_LINK)$(CC) $(LDFLAGS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS)
70d07ce1 263
6ff38856 264t/genzipf: $(T_ZIPF_OBJS)
a3c86fc4 265 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
6ff38856 266
ad1f90aa 267t/axmap: $(T_AXMAP_OBJS)
a3c86fc4 268 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
ad1f90aa 269
7a887ffe 270t/lfsr-test: $(T_LFSR_TEST_OBJS)
a3c86fc4 271 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
7a887ffe 272
3d43382c 273clean: FORCE
45f944b9
JA
274 -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
275
276distclean: clean FORCE
277 @rm -f cscope.out
ebac4655 278
592ef98a 279cscope:
366badd3 280 @cscope -b -R
592ef98a 281
1378cc68
EV
282tools/plot/fio2gnuplot.1:
283 @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot > tools/plot/fio2gnuplot.1
284
285install: $(PROGS) $(SCRIPTS) tools/plot/fio2gnuplot.1 FORCE
513ba3f7 286 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
ebac4655 287 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
d60e92d1
AC
288 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
289 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
0460eb92 290 $(INSTALL) -m 644 tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
1378cc68 291 $(INSTALL) -m 644 tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1
eab4af4e
EV
292 $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
293 $(INSTALL) -m 644 tools/plot/*gpm $(DESTDIR)$(sharedir)/