Merge branch 'master' into gfio
[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 -lz $(EXTLIBS)
8 PROGS   = fio
9 SCRIPTS = fio_generate_plots
10 UNAME  := $(shell uname)
11
12 GTK_CFLAGS = `pkg-config --cflags gtk+-2.0 gthread-2.0`
13 GTK_LDFLAGS = `pkg-config --libs gtk+-2.0 gthread-2.0`
14
15 SOURCE := 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
23 ifeq ($(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
31 endif
32 ifeq ($(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__
37 endif
38 ifeq ($(UNAME), FreeBSD)
39   SOURCE += helpers.c engines/posixaio.c
40   LIBS   += -lpthread -lrt
41   LDFLAGS += -rdynamic
42 endif
43 ifeq ($(UNAME), NetBSD)
44   SOURCE += helpers.c engines/posixaio.c
45   LIBS   += -lpthread -lrt
46   LDFLAGS += -rdynamic
47 endif
48 ifeq ($(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
53 endif
54 ifeq ($(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
58 endif
59 ifeq ($(UNAME), Darwin)
60   SOURCE += helpers.c engines/posixaio.c
61   LIBS   += -lpthread -ldl
62 endif
63 ifneq (,$(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
70 endif
71
72 OBJS = $(SOURCE:.c=.o)
73 FIO_OBJS = $(OBJS) fio.o
74 GFIO_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
77 T_SMALLOC_OBJS = t/stest.o
78 T_SMALLOC_OBJS += mutex.o smalloc.o t/log.o gettime.o time.o
79 T_SMALLOC_PROGS = t/stest
80
81 T_IEEE_OBJS = t/ieee754.o
82 T_IEEE_OBJS += lib/ieee754.o
83 T_IEEE_PROGS = t/ieee754
84
85 T_OBJS = $(T_SMALLOC_OBJS)
86 T_OBJS += $(T_IEEE_OBJS)
87
88 ifneq ($(findstring $(MAKEFLAGS),s),s)
89 ifndef V
90         QUIET_CC        = @echo '   ' CC $@;
91         QUIET_DEP       = @echo '   ' DEP $@;
92 endif
93 endif
94
95 INSTALL = install
96 prefix = /usr/local
97 bindir = $(prefix)/bin
98
99 ifeq ($(UNAME), Darwin)
100 mandir = /usr/share/man
101 else
102 mandir = $(prefix)/man
103 endif
104
105 all: .depend $(PROGS) $(SCRIPTS) FORCE
106
107 .PHONY: all install clean
108 .PHONY: FORCE cscope
109
110 FIO-VERSION-FILE: FORCE
111         @$(SHELL) ./FIO-VERSION-GEN
112 -include FIO-VERSION-FILE
113
114 CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
115
116 .c.o: .depend FORCE
117         $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
118
119 init.o: FIO-VERSION-FILE
120         $(QUIET_CC)$(CC) -o init.o -c $(CFLAGS) $(CPPFLAGS) -c init.c
121
122 gcompat.o: gcompat.c gcompat.h
123         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
124
125 goptions.o: goptions.c goptions.h
126         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
127
128 ghelpers.o: ghelpers.c ghelpers.h
129         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
130
131 gerror.o: gerror.c gerror.h
132         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
133
134 gclient.o: gclient.c gclient.h
135         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
136
137 gfio.o: gfio.c ghelpers.c
138         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
139
140 graph.o: graph.c graph.h
141         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
142
143 cairo_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
146 printing.o: printing.c printing.h
147         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
148
149 t/stest: $(T_SMALLOC_OBJS)
150         $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
151
152 t/ieee754: $(T_IEEE_OBJS)
153         $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
154
155 fio: $(FIO_OBJS)
156         $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(LDFLAGS)
157
158 gfio: $(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
166 clean: FORCE
167         -rm -f .depend $(GFIO_OBJS )$(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE
168
169 cscope:
170         @cscope -b -R
171
172 install: $(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
179 ifneq ($(wildcard .depend),)
180 include .depend
181 endif
182
183