ioengine: Add fallocate ioengine
[fio.git] / Makefile
1 CC      ?= gcc
2 DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
3 CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
4         $(DEBUGFLAGS)
5 OPTFLAGS= -O3 -fno-omit-frame-pointer -g $(EXTFLAGS)
6 CFLAGS  = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS)
7 LIBS    = -lm $(EXTLIBS)
8 PROGS   = fio
9 SCRIPTS = fio_generate_plots
10 UNAME  := $(shell uname)
11
12 SOURCE := gettime.c fio.c ioengines.c init.c stat.c log.c time.c filesetup.c \
13                 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
14                 rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
15                 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
16                 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
17                 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c json.c
18
19 ifeq ($(UNAME), Linux)
20   SOURCE += diskutil.c fifo.c blktrace.c helpers.c cgroup.c trim.c \
21                 engines/libaio.c engines/posixaio.c engines/sg.c \
22                 engines/splice.c engines/syslet-rw.c engines/guasi.c \
23                 engines/binject.c engines/rdma.c profiles/tiobench.c \
24                 engines/fusion-aw.c engines/falloc.c
25   LIBS += -lpthread -ldl -lrt -laio
26   LDFLAGS += -rdynamic
27 endif
28 ifeq ($(UNAME), SunOS)
29   SOURCE += fifo.c lib/strsep.c helpers.c engines/posixaio.c \
30                 engines/solarisaio.c
31   LIBS   += -lpthread -ldl -laio -lrt -lnsl -lsocket
32   CPPFLAGS += -D__EXTENSIONS__
33 endif
34 ifeq ($(UNAME), FreeBSD)
35   SOURCE += helpers.c engines/posixaio.c
36   LIBS   += -lpthread -lrt
37   LDFLAGS += -rdynamic
38 endif
39 ifeq ($(UNAME), NetBSD)
40   SOURCE += helpers.c engines/posixaio.c
41   LIBS   += -lpthread -lrt
42   LDFLAGS += -rdynamic
43 endif
44 ifeq ($(UNAME), AIX)
45   SOURCE += fifo.c helpers.c lib/getopt_long.c engines/posixaio.c
46   LIBS   += -lpthread -ldl -lrt
47   CPPFLAGS += -D_LARGE_FILES -D__ppc__
48   LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
49 endif
50 ifeq ($(UNAME), HP-UX)
51   SOURCE += fifo.c helpers.c lib/getopt_long.c lib/strsep.c engines/posixaio.c
52   LIBS   += -lpthread -ldl -lrt
53   CFLAGS += -D_LARGEFILE64_SOURCE
54 endif
55 ifeq ($(UNAME), Darwin)
56   SOURCE += helpers.c engines/posixaio.c
57   LIBS   += -lpthread -ldl
58 endif
59 ifneq (,$(findstring CYGWIN,$(UNAME)))
60   SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
61   SOURCE += engines/windowsaio.c os/windows/posix.c
62   LIBS   += -lpthread -lpsapi -lws2_32
63   CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
64   CC      = x86_64-w64-mingw32-gcc
65   #CC     = i686-w64-mingw32-gcc
66 endif
67
68 OBJS = $(SOURCE:.c=.o)
69
70 T_SMALLOC_OBJS = t/stest.o
71 T_SMALLOC_OBJS += mutex.o smalloc.o t/log.o
72 T_SMALLOC_PROGS = t/stest
73
74 T_IEEE_OBJS = t/ieee754.o
75 T_IEEE_OBJS += ieee754.o
76 T_IEEE_PROGS = t/ieee754
77
78 T_OBJS = $(T_SMALLOC_OBJS)
79 T_OBJS += $(T_IEEE_OBJS)
80
81 ifneq ($(findstring $(MAKEFLAGS),s),s)
82 ifndef V
83         QUIET_CC        = @echo '   ' CC $@;
84         QUIET_DEP       = @echo '   ' DEP $@;
85 endif
86 endif
87
88 INSTALL = install
89 prefix = /usr/local
90 bindir = $(prefix)/bin
91
92 ifeq ($(UNAME), Darwin)
93 mandir = /usr/share/man
94 else
95 mandir = $(prefix)/man
96 endif
97
98 all: .depend $(PROGS) $(SCRIPTS) FORCE
99
100 .PHONY: all install clean
101 .PHONY: FORCE cscope
102
103 FIO-VERSION-FILE: FORCE
104         @$(SHELL) ./FIO-VERSION-GEN
105 -include FIO-VERSION-FILE
106
107 CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
108
109 .c.o: .depend FORCE
110         $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
111
112 init.o: FIO-VERSION-FILE
113         $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
114
115 t/stest: $(T_SMALLOC_OBJS)
116         $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
117
118 t/ieee754: $(T_IEEE_OBJS)
119         $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
120
121 fio: $(OBJS)
122         $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
123
124 .depend: $(SOURCE)
125         $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
126
127 $(PROGS): .depend
128
129 clean: FORCE
130         -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE
131
132 cscope:
133         @cscope -b -R
134
135 install: $(PROGS) $(SCRIPTS) FORCE
136         $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
137         $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
138         $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
139         $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
140         $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
141
142 ifneq ($(wildcard .depend),)
143 include .depend
144 endif