options: wire up e4defrag and falloc engines
[fio.git] / Makefile
... / ...
CommitLineData
1CC ?= gcc
2DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
3CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
4 $(DEBUGFLAGS)
5OPTFLAGS= -O3 -fno-omit-frame-pointer -g $(EXTFLAGS)
6CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS)
7LIBS = -lm $(EXTLIBS)
8PROGS = fio
9SCRIPTS = fio_generate_plots
10UNAME := $(shell uname)
11
12SOURCE := 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
20ifeq ($(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
28endif
29ifeq ($(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__
34endif
35ifeq ($(UNAME), FreeBSD)
36 SOURCE += helpers.c engines/posixaio.c
37 LIBS += -lpthread -lrt
38 LDFLAGS += -rdynamic
39endif
40ifeq ($(UNAME), NetBSD)
41 SOURCE += helpers.c engines/posixaio.c
42 LIBS += -lpthread -lrt
43 LDFLAGS += -rdynamic
44endif
45ifeq ($(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
50endif
51ifeq ($(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
55endif
56ifeq ($(UNAME), Darwin)
57 SOURCE += helpers.c engines/posixaio.c
58 LIBS += -lpthread -ldl
59endif
60ifneq (,$(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
67endif
68
69OBJS = $(SOURCE:.c=.o)
70
71T_SMALLOC_OBJS = t/stest.o
72T_SMALLOC_OBJS += mutex.o smalloc.o t/log.o
73T_SMALLOC_PROGS = t/stest
74
75T_IEEE_OBJS = t/ieee754.o
76T_IEEE_OBJS += ieee754.o
77T_IEEE_PROGS = t/ieee754
78
79T_OBJS = $(T_SMALLOC_OBJS)
80T_OBJS += $(T_IEEE_OBJS)
81
82ifneq ($(findstring $(MAKEFLAGS),s),s)
83ifndef V
84 QUIET_CC = @echo ' ' CC $@;
85 QUIET_DEP = @echo ' ' DEP $@;
86endif
87endif
88
89INSTALL = install
90prefix = /usr/local
91bindir = $(prefix)/bin
92
93ifeq ($(UNAME), Darwin)
94mandir = /usr/share/man
95else
96mandir = $(prefix)/man
97endif
98
99all: .depend $(PROGS) $(SCRIPTS) FORCE
100
101.PHONY: all install clean
102.PHONY: FORCE cscope
103
104FIO-VERSION-FILE: FORCE
105 @$(SHELL) ./FIO-VERSION-GEN
106-include FIO-VERSION-FILE
107
108CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
109
110.c.o: .depend FORCE
111 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
112
113init.o: FIO-VERSION-FILE
114 $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
115
116t/stest: $(T_SMALLOC_OBJS)
117 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
118
119t/ieee754: $(T_IEEE_OBJS)
120 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
121
122fio: $(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
130clean: FORCE
131 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE
132
133cscope:
134 @cscope -b -R
135
136install: $(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
143ifneq ($(wildcard .depend),)
144include .depend
145endif