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