Merge branch 'master' into gfio
[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 -lz $(EXTLIBS)
8PROGS = fio
9SCRIPTS = fio_generate_plots
10UNAME := $(shell uname)
11
12GTK_CFLAGS = `pkg-config --cflags gtk+-2.0 gthread-2.0`
13GTK_LDFLAGS = `pkg-config --libs gtk+-2.0 gthread-2.0`
14
15SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
16 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
17 lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
18 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
19 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
20 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
21 cconv.c lib/prio_tree.c json.c
22
23ifeq ($(UNAME), Linux)
24 SOURCE += diskutil.c fifo.c blktrace.c helpers.c cgroup.c trim.c \
25 engines/libaio.c engines/posixaio.c engines/sg.c \
26 engines/splice.c engines/syslet-rw.c engines/guasi.c \
27 engines/binject.c engines/rdma.c profiles/tiobench.c \
28 engines/fusion-aw.c engines/falloc.c engines/e4defrag.c
29 LIBS += -lpthread -ldl -lrt -laio
30 LDFLAGS += -rdynamic
31endif
32ifeq ($(UNAME), SunOS)
33 SOURCE += fifo.c lib/strsep.c helpers.c engines/posixaio.c \
34 engines/solarisaio.c
35 LIBS += -lpthread -ldl -laio -lrt -lnsl -lsocket
36 CPPFLAGS += -D__EXTENSIONS__
37endif
38ifeq ($(UNAME), FreeBSD)
39 SOURCE += helpers.c engines/posixaio.c
40 LIBS += -lpthread -lrt
41 LDFLAGS += -rdynamic
42endif
43ifeq ($(UNAME), NetBSD)
44 SOURCE += helpers.c engines/posixaio.c
45 LIBS += -lpthread -lrt
46 LDFLAGS += -rdynamic
47endif
48ifeq ($(UNAME), AIX)
49 SOURCE += fifo.c helpers.c lib/getopt_long.c engines/posixaio.c
50 LIBS += -lpthread -ldl -lrt
51 CPPFLAGS += -D_LARGE_FILES -D__ppc__
52 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
53endif
54ifeq ($(UNAME), HP-UX)
55 SOURCE += fifo.c helpers.c lib/getopt_long.c lib/strsep.c engines/posixaio.c
56 LIBS += -lpthread -ldl -lrt
57 CFLAGS += -D_LARGEFILE64_SOURCE
58endif
59ifeq ($(UNAME), Darwin)
60 SOURCE += helpers.c engines/posixaio.c
61 LIBS += -lpthread -ldl
62endif
63ifneq (,$(findstring CYGWIN,$(UNAME)))
64 SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
65 SOURCE += engines/windowsaio.c os/windows/posix.c
66 LIBS += -lpthread -lpsapi -lws2_32
67 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
68 CC = x86_64-w64-mingw32-gcc
69 #CC = i686-w64-mingw32-gcc
70endif
71
72OBJS = $(SOURCE:.c=.o)
73FIO_OBJS = $(OBJS) fio.o
74GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
75 gclient.o gcompat.o cairo_text_helpers.o printing.o
76
77T_SMALLOC_OBJS = t/stest.o
78T_SMALLOC_OBJS += mutex.o smalloc.o t/log.o gettime.o time.o
79T_SMALLOC_PROGS = t/stest
80
81T_IEEE_OBJS = t/ieee754.o
82T_IEEE_OBJS += lib/ieee754.o
83T_IEEE_PROGS = t/ieee754
84
85T_OBJS = $(T_SMALLOC_OBJS)
86T_OBJS += $(T_IEEE_OBJS)
87
88ifneq ($(findstring $(MAKEFLAGS),s),s)
89ifndef V
90 QUIET_CC = @echo ' ' CC $@;
91 QUIET_DEP = @echo ' ' DEP $@;
92endif
93endif
94
95INSTALL = install
96prefix = /usr/local
97bindir = $(prefix)/bin
98
99ifeq ($(UNAME), Darwin)
100mandir = /usr/share/man
101else
102mandir = $(prefix)/man
103endif
104
105all: .depend $(PROGS) $(SCRIPTS) FORCE
106
107.PHONY: all install clean
108.PHONY: FORCE cscope
109
110FIO-VERSION-FILE: FORCE
111 @$(SHELL) ./FIO-VERSION-GEN
112-include FIO-VERSION-FILE
113
114CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
115
116.c.o: .depend FORCE
117 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
118
119init.o: FIO-VERSION-FILE
120 $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
121
122gcompat.o: gcompat.c gcompat.h
123 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
124
125goptions.o: goptions.c goptions.h
126 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
127
128ghelpers.o: ghelpers.c ghelpers.h
129 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
130
131gerror.o: gerror.c gerror.h
132 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
133
134gclient.o: gclient.c gclient.h
135 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
136
137gfio.o: gfio.c ghelpers.c
138 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
139
140graph.o: graph.c graph.h
141 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
142
143cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
144 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c
145
146printing.o: printing.c printing.h
147 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
148
149t/stest: $(T_SMALLOC_OBJS)
150 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
151
152t/ieee754: $(T_IEEE_OBJS)
153 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
154
155fio: $(FIO_OBJS)
156 $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(LDFLAGS)
157
158gfio: $(GFIO_OBJS)
159 $(QUIET_CC)$(CC) $(LIBS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS)
160
161.depend: $(SOURCE)
162 $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
163
164$(PROGS): .depend
165
166clean: FORCE
167 -rm -f .depend $(GFIO_OBJS )$(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE
168
169cscope:
170 @cscope -b -R
171
172install: $(PROGS) $(SCRIPTS) FORCE
173 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
174 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
175 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
176 $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
177 $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
178
179ifneq ($(wildcard .depend),)
180include .depend
181endif
182
183