2 DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
3 CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
5 OPTFLAGS= -O3 -fno-omit-frame-pointer -g $(EXTFLAGS)
6 CFLAGS = -std=gnu99 -Wwrite-strings -Wall $(OPTFLAGS)
9 SCRIPTS = fio_generate_plots
10 UNAME := $(shell uname)
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 lib/zipf.c gettime-thread.c
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
29 ifeq ($(UNAME), SunOS)
30 SOURCE += fifo.c lib/strsep.c helpers.c engines/posixaio.c \
32 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
33 CPPFLAGS += -D__EXTENSIONS__
35 ifeq ($(UNAME), FreeBSD)
36 SOURCE += helpers.c engines/posixaio.c
37 LIBS += -lpthread -lrt
40 ifeq ($(UNAME), NetBSD)
41 SOURCE += helpers.c engines/posixaio.c
42 LIBS += -lpthread -lrt
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
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
56 ifeq ($(UNAME), Darwin)
57 SOURCE += helpers.c engines/posixaio.c
58 LIBS += -lpthread -ldl
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
69 OBJS = $(SOURCE:.c=.o)
71 T_SMALLOC_OBJS = t/stest.o
72 T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
73 T_SMALLOC_PROGS = t/stest
75 T_IEEE_OBJS = t/ieee754.o
76 T_IEEE_OBJS += lib/ieee754.o
77 T_IEEE_PROGS = t/ieee754
79 T_ZIPF_OBS = t/genzipf.o
80 T_ZIPF_OBJS += rbtree.o t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
81 T_ZIPF_PROGS = t/genzipf
83 T_OBJS = $(T_SMALLOC_OBJS)
84 T_OBJS += $(T_IEEE_OBJS)
85 T_OBJS += $(T_ZIPF_OBJS)
87 T_PROGS = $(T_SMALLOC_PROGS)
88 T_PROGS += $(T_IEEE_PROGS)
89 T_PROGS += $(T_ZIPF_PROGS)
91 ifneq ($(findstring $(MAKEFLAGS),s),s)
93 QUIET_CC = @echo ' ' CC $@;
94 QUIET_DEP = @echo ' ' DEP $@;
100 bindir = $(prefix)/bin
102 ifeq ($(UNAME), Darwin)
103 mandir = /usr/share/man
105 mandir = $(prefix)/man
108 all: .depend $(PROGS) $(SCRIPTS) FORCE
110 .PHONY: all install clean
113 FIO-VERSION-FILE: FORCE
114 @$(SHELL) ./FIO-VERSION-GEN
115 -include FIO-VERSION-FILE
117 CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
120 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
122 init.o: FIO-VERSION-FILE
123 $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
125 t/stest: $(T_SMALLOC_OBJS)
126 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
128 t/ieee754: $(T_IEEE_OBJS)
129 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
131 t/genzipf: $(T_ZIPF_OBJS)
132 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS) $(LDFLAGS)
135 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
138 $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
143 -rm -f .depend $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core FIO-VERSION-FILE
148 install: $(PROGS) $(SCRIPTS) FORCE
149 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
150 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
151 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
152 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
153 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
155 ifneq ($(wildcard .depend),)