engine: fix error handling for e4defrag/falloc
[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 \
18                 json.c
19
20 ifeq ($(UNAME), Linux)
21   SOURCE += diskutil.c fifo.c blktrace.c helpers.c cgroup.c trim.c \
22                 engines/libaio.c engines/posixaio.c engines/sg.c \
23                 engines/splice.c engines/syslet-rw.c engines/guasi.c \
24                 engines/binject.c engines/rdma.c profiles/tiobench.c \
25                 engines/fusion-aw.c engines/falloc.c engines/e4defrag.c
26   LIBS += -lpthread -ldl -lrt -laio
27   LDFLAGS += -rdynamic
28 endif
29 ifeq ($(UNAME), SunOS)
30   SOURCE += fifo.c lib/strsep.c helpers.c engines/posixaio.c \
31                 engines/solarisaio.c
32   LIBS   += -lpthread -ldl -laio -lrt -lnsl -lsocket
33   CPPFLAGS += -D__EXTENSIONS__
34 endif
35 ifeq ($(UNAME), FreeBSD)
36   SOURCE += helpers.c engines/posixaio.c
37   LIBS   += -lpthread -lrt
38   LDFLAGS += -rdynamic
39 endif
40 ifeq ($(UNAME), NetBSD)
41   SOURCE += helpers.c engines/posixaio.c
42   LIBS   += -lpthread -lrt
43   LDFLAGS += -rdynamic
44 endif
45 ifeq ($(UNAME), AIX)
46   SOURCE += fifo.c helpers.c lib/getopt_long.c engines/posixaio.c
47   LIBS   += -lpthread -ldl -lrt
48   CPPFLAGS += -D_LARGE_FILES -D__ppc__
49   LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
50 endif
51 ifeq ($(UNAME), HP-UX)
52   SOURCE += fifo.c helpers.c lib/getopt_long.c lib/strsep.c engines/posixaio.c
53   LIBS   += -lpthread -ldl -lrt
54   CFLAGS += -D_LARGEFILE64_SOURCE
55 endif
56 ifeq ($(UNAME), Darwin)
57   SOURCE += helpers.c engines/posixaio.c
58   LIBS   += -lpthread -ldl
59 endif
60 ifneq (,$(findstring CYGWIN,$(UNAME)))
61   SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
62   SOURCE += engines/windowsaio.c os/windows/posix.c
63   LIBS   += -lpthread -lpsapi -lws2_32
64   CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
65   CC      = x86_64-w64-mingw32-gcc
66   #CC     = i686-w64-mingw32-gcc
67 endif
68
69 OBJS = $(SOURCE:.c=.o)
70
71 T_SMALLOC_OBJS = t/stest.o
72 T_SMALLOC_OBJS += mutex.o smalloc.o t/log.o
73 T_SMALLOC_PROGS = t/stest
74
75 T_IEEE_OBJS = t/ieee754.o
76 T_IEEE_OBJS += ieee754.o
77 T_IEEE_PROGS = t/ieee754
78
79 T_OBJS = $(T_SMALLOC_OBJS)
80 T_OBJS += $(T_IEEE_OBJS)
81
82 ifneq ($(findstring $(MAKEFLAGS),s),s)
83 ifndef V
84         QUIET_CC        = @echo '   ' CC $@;
85         QUIET_DEP       = @echo '   ' DEP $@;
86 endif
87 endif
88
89 INSTALL = install
90 prefix = /usr/local
91 bindir = $(prefix)/bin
92
93 ifeq ($(UNAME), Darwin)
94 mandir = /usr/share/man
95 else
96 mandir = $(prefix)/man
97 endif
98
99 all: .depend $(PROGS) $(SCRIPTS) FORCE
100
101 .PHONY: all install clean
102 .PHONY: FORCE cscope
103
104 FIO-VERSION-FILE: FORCE
105         @$(SHELL) ./FIO-VERSION-GEN
106 -include FIO-VERSION-FILE
107
108 CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
109
110 .c.o: .depend FORCE
111         $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
112
113 init.o: FIO-VERSION-FILE
114         $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
115
116 t/stest: $(T_SMALLOC_OBJS)
117         $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
118
119 t/ieee754: $(T_IEEE_OBJS)
120         $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
121
122 fio: $(OBJS)
123         $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
124
125 .depend: $(SOURCE)
126         $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
127
128 $(PROGS): .depend
129
130 clean: FORCE
131         -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE
132
133 cscope:
134         @cscope -b -R
135
136 install: $(PROGS) $(SCRIPTS) FORCE
137         $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
138         $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
139         $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
140         $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
141         $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
142
143 ifneq ($(wildcard .depend),)
144 include .depend
145 endif