goptions: ensure that gopt_str_multi options get freed
[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 GTK_CFLAGS += -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED
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
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   LIBS += -lpthread -ldl -lrt -laio
31   LDFLAGS += -rdynamic
32 endif
33 ifeq ($(UNAME), SunOS)
34   SOURCE += fifo.c lib/strsep.c helpers.c engines/posixaio.c \
35                 engines/solarisaio.c
36   LIBS   += -lpthread -ldl -laio -lrt -lnsl -lsocket
37   CPPFLAGS += -D__EXTENSIONS__
38 endif
39 ifeq ($(UNAME), FreeBSD)
40   SOURCE += helpers.c engines/posixaio.c
41   LIBS   += -lpthread -lrt
42   LDFLAGS += -rdynamic
43 endif
44 ifeq ($(UNAME), NetBSD)
45   SOURCE += helpers.c engines/posixaio.c
46   LIBS   += -lpthread -lrt
47   LDFLAGS += -rdynamic
48 endif
49 ifeq ($(UNAME), AIX)
50   SOURCE += fifo.c helpers.c lib/getopt_long.c engines/posixaio.c
51   LIBS   += -lpthread -ldl -lrt
52   CPPFLAGS += -D_LARGE_FILES -D__ppc__
53   LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
54 endif
55 ifeq ($(UNAME), HP-UX)
56   SOURCE += fifo.c helpers.c lib/getopt_long.c lib/strsep.c engines/posixaio.c
57   LIBS   += -lpthread -ldl -lrt
58   CFLAGS += -D_LARGEFILE64_SOURCE
59 endif
60 ifeq ($(UNAME), Darwin)
61   SOURCE += helpers.c engines/posixaio.c
62   LIBS   += -lpthread -ldl
63 endif
64 ifneq (,$(findstring CYGWIN,$(UNAME)))
65   SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
66   SOURCE += engines/windowsaio.c os/windows/posix.c
67   LIBS   += -lpthread -lpsapi -lws2_32
68   CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
69   CC      = x86_64-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
76
77 T_SMALLOC_OBJS = t/stest.o
78 T_SMALLOC_OBJS += mutex.o smalloc.o t/log.o
79 T_SMALLOC_PROGS = t/stest
80
81 T_IEEE_OBJS = t/ieee754.o
82 T_IEEE_OBJS += 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_PATH) ./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 gcompat.o: gcompat.c gcompat.h
120         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
121
122 goptions.o: goptions.c goptions.h
123         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
124
125 ghelpers.o: ghelpers.c ghelpers.h
126         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
127
128 gerror.o: gerror.c gerror.h
129         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
130
131 gclient.o: gclient.c gclient.h
132         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
133
134 gfio.o: gfio.c ghelpers.c
135         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
136
137 graph.o: graph.c graph.h
138         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
139
140 t/stest: $(T_SMALLOC_OBJS)
141         $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS) $(LDFLAGS)
142
143 t/ieee754: $(T_IEEE_OBJS)
144         $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS) $(LDFLAGS)
145
146 fio: $(FIO_OBJS) FORCE
147         $(QUIET_CC)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(LDFLAGS)
148
149 gfio: $(GFIO_OBJS)
150         $(QUIET_CC)$(CC) $(LIBS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS)
151
152 .depend: $(SOURCE)
153         $(QUIET_DEP)$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SOURCE) 1> .depend
154
155 $(PROGS): .depend FORCE
156
157 clean: FORCE
158         -rm -f .depend $(GFIO_OBJS) $(FIO_OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE
159
160 cscope:
161         @cscope -b -R
162
163 install: $(PROGS) $(SCRIPTS) FORCE
164         $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
165         $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
166         $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
167         $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
168         $(INSTALL) -m 644 fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
169
170 ifneq ($(wildcard .depend),)
171 include .depend
172 endif
173
174