~ubuntu-branches/ubuntu/intrepid/haproxy/intrepid

« back to all changes in this revision

Viewing changes to Makefile

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Cornet
  • Date: 2008-03-09 21:30:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080309213029-8oupnrc607mg5uqw
Tags: 1.3.14.3-1
* New Upstream Version
* Add status argument support to init-script to conform to LSB.
* Cleanup pidfile after stop in init script. Init script return code fixups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This makefile supports different OS and CPU setups.
 
1
# This GNU Makefile supports different OS and CPU combinations.
 
2
#
2
3
# You should use it this way :
3
 
#   make TARGET=os CPU=cpu REGEX=lib
4
 
 
5
 
 
6
 
# Select target OS. TARGET must match a system for which COPTS and LIBS are
7
 
# correctly defined below.
8
 
#TARGET = linux26
9
 
TARGET = linux24
10
 
#TARGET = linux24e
11
 
#TARGET = linux22
12
 
#TARGET = solaris
13
 
 
14
 
USE_POLL = 1
15
 
 
16
 
ifeq ($(TARGET),linux24e)
17
 
USE_EPOLL = 1
18
 
USE_SEPOLL = 1
19
 
endif
20
 
 
21
 
ifeq ($(TARGET),linux26)
22
 
USE_EPOLL = 1
23
 
USE_SEPOLL = 1
24
 
endif
25
 
 
26
 
# pass CPU=<cpu_name> to make to optimize for a particular CPU
 
4
#   [g]make TARGET=os CPU=cpu USE_xxx=1 ...
 
5
#
 
6
# Valid USE_* options are the following. Most of them are automatically set by
 
7
# the TARGET, others have to be explictly specified :
 
8
#   USE_CTTPROXY         : enable CTTPROXY on Linux (needs kernel patch).
 
9
#   USE_DLMALLOC         : enable use of dlmalloc (see DLMALLOC_SRC)
 
10
#   USE_EPOLL            : enable epoll() on Linux 2.6. Automatic.
 
11
#   USE_EPOLL_WORKAROUND : enable epoll() bug workaround. Automatic.
 
12
#   USE_GETSOCKNAME      : enable getsockname() on Linux 2.2. Automatic.
 
13
#   USE_KQUEUE           : enable kqueue() on BSD. Automatic.
 
14
#   USE_MY_EPOLL         : redefine epoll_* syscalls. Automatic.
 
15
#   USE_NETFILTER        : enable netfilter on Linux. Automatic.
 
16
#   USE_PCRE             : enable use of libpcre for regex. Recommended.
 
17
#   USE_POLL             : enable poll(). Automatic.
 
18
#   USE_REGPARM          : enable regparm optimization. Recommended on x86.
 
19
#   USE_SEPOLL           : enable speculative epoll(). Automatic.
 
20
#   USE_STATIC_PCRE      : enable static libpcre. Recommended.
 
21
#   USE_TCPSPLICE        : enable tcp_splice() on Linux (needs kernel patch).
 
22
#   USE_TPROXY           : enable transparent proxy. Automatic.
 
23
#
 
24
# Options can be forced by specifying "USE_xxx=1" or can be disabled by using
 
25
# "USE_xxx=" (empty string).
 
26
#
 
27
# Variables useful for packagers :
 
28
#   CC is set to "gcc" by default and is used for compilation only.
 
29
#   LD is set to "gcc" by default and is used for linking only.
 
30
#   CFLAGS is automatically set for the specified CPU and may be overridden.
 
31
#   LDFLAGS is automatically set to -g and may be overridden.
 
32
#   SMALL_OPTS may be used to specify some options to shrink memory usage.
 
33
#   DEBUG may be used to set some internal debugging options.
 
34
#   ADDINC may be used to complete the include path in the form -Ipath.
 
35
#   ADDLIB may be used to complete the library list in the form -Lpath -llib.
 
36
#   DEFINE may be used to specify any additional define, which will be reported
 
37
#          by "haproxy -vv" in CFLAGS.
 
38
#   SILENT_DEFINE may be used to specify other defines which will not be
 
39
#     reported by "haproxy -vv".
 
40
#
 
41
# Other variables :
 
42
#   DLMALLOC_SRC   : build with dlmalloc, indicate the location of dlmalloc.c.
 
43
#   DLMALLOC_THRES : should match PAGE_SIZE on every platform (default: 4096).
 
44
#   PCREDIR        : force the path to libpcre.
 
45
#   IGNOREGIT      : ignore GIT commit versions if set.
 
46
#   VERSION        : force haproxy version reporting.
 
47
#   SUBVERS        : add a sub-version (eg: platform, model, ...).
 
48
#   VERDATE        : force haproxy's release date.
 
49
 
 
50
 
 
51
#### TARGET system
 
52
# Use TARGET=<target_name> to optimize for a specifc target OS among the
 
53
# following list (use the default "generic" if uncertain) :
 
54
#    generic, linux22, linux24, linux24e, linux24eold, linux26, solaris,
 
55
#    freebsd, openbsd, custom
 
56
TARGET = generic
 
57
 
 
58
#### TARGET CPU
 
59
# Use CPU=<cpu_name> to optimize for a particular CPU, among the following
 
60
# list :
 
61
#    generic, i586, i686, ultrasparc, custom
27
62
CPU = generic
28
 
#CPU = i586
29
 
#CPU = i686
30
 
#CPU = ultrasparc
31
 
 
32
 
# By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group
33
 
# references seem broken using libc ! Use pcre instead.
34
 
REGEX=libc
35
 
#REGEX=pcre
36
 
#REGEX=static-pcre
37
 
 
38
 
# tools options
 
63
 
 
64
#### Toolchain options.
 
65
# GCC is normally used both for compiling and linking.
39
66
CC = gcc
40
67
LD = gcc
41
68
 
42
 
# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
43
 
PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :)
44
 
#PCREDIR=/usr/local
45
 
 
46
 
# This is the directory hosting libtcpsplice.[ah] when USE_TCPSPLICE is set
47
 
TCPSPLICEDIR :=
48
 
 
49
 
# This is for standard Linux 2.6 with netfilter and epoll()
50
 
COPTS.linux26 = -DNETFILTER
51
 
LIBS.linux26 =
52
 
 
53
 
# This is for enhanced Linux 2.4 with netfilter and epoll() patch.
54
 
# Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add
55
 
# -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug.
56
 
#COPTS.linux24e = -DNETFILTER -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND
57
 
COPTS.linux24e = -DNETFILTER -DUSE_MY_EPOLL
58
 
LIBS.linux24e =
59
 
 
60
 
# This is for standard Linux 2.4 with netfilter but without epoll()
61
 
COPTS.linux24 = -DNETFILTER
62
 
LIBS.linux24 =
63
 
 
64
 
# This is for Linux 2.2
65
 
COPTS.linux22 = -DUSE_GETSOCKNAME
66
 
LIBS.linux22 =
67
 
 
68
 
# This is for Solaris 8
69
 
COPTS.solaris = -fomit-frame-pointer -DFD_SETSIZE=65536
70
 
LIBS.solaris = -lnsl -lsocket
71
 
 
72
 
# CPU dependant optimizations
73
 
COPTS.generic = -O2
74
 
COPTS.i586 = -O2 -march=i586 -DCONFIG_HAP_USE_REGPARM
75
 
COPTS.i686 = -O2 -march=i686 -DCONFIG_HAP_USE_REGPARM
76
 
COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
77
 
 
78
 
# options for standard regex library
79
 
COPTS.libc=
80
 
LIBS.libc=
81
 
 
82
 
# options for libpcre
83
 
COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
84
 
LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
85
 
 
86
 
# options for static libpcre
87
 
COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
88
 
LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
89
 
 
90
 
# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
91
 
#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
92
 
DEBUG = -g
93
 
 
94
 
# if small memory footprint is required, you can reduce the buffer size. There
 
69
#### Debug flags (typically "-g").
 
70
# Those flags only feed CFLAGS so it is not mandatory to use this form.
 
71
DEBUG_CFLAGS = -g
 
72
 
 
73
#### Memory usage tuning
 
74
# If small memory footprint is required, you can reduce the buffer size. There
95
75
# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
96
76
# with 1000 concurrent sessions. Putting it slightly lower than a page size
97
 
# will avoid the additionnal paramters to overflow a page. 8030 bytes is
98
 
# exactly 5.5 TCP segments of 1460 bytes.
99
 
#SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
 
77
# will prevent the additional parameters to go beyond a page. 8030 bytes is
 
78
# exactly 5.5 TCP segments of 1460 bytes and is generally good. Useful tuning
 
79
# macros include :
 
80
#    SYSTEM_MAXCONN, BUFSIZE, MAXREWRITE, REQURI_LEN, CAPTURE_LEN.
 
81
# Example: SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
100
82
SMALL_OPTS =
101
83
 
102
 
# redefine this if you want to add some special PATH to include/libs
 
84
#### Debug settings
 
85
# You can enable debugging on specific code parts by setting DEBUG=-DDEBUG_xxx.
 
86
# Currently defined DEBUG macros include DEBUG_FULL, DEBUG_MEMORY, DEBUG_FSM,
 
87
# DEBUG_HASH and DEBUG_PARSE_NO_SPEEDUP. Please consult sources for exact
 
88
# meaning or do not use at all.
 
89
DEBUG =
 
90
 
 
91
#### Additional include and library dirs
 
92
# Redefine this if you want to add some special PATH to include/libs
103
93
ADDINC =
104
94
ADDLIB =
105
95
 
106
 
# set some defines when needed.
107
 
# - use -DTPROXY to compile with transparent proxy support.
108
 
DEFINE = -DTPROXY
109
 
 
110
 
# Now let's determine the version, sub-version and release date.
111
 
# If we're in the GIT tree, we can use the last commit's version and date.
 
96
#### Specific macro definitions
 
97
# Use DEFINE=-Dxxx to set any tunable macro. Anything declared here will appear
 
98
# in the build options reported by "haproxy -vv". Use SILENT_DEFINE if you do
 
99
# not want to pollute the report with complex defines.
 
100
DEFINE =
 
101
SILENT_DEFINE =
 
102
 
 
103
 
 
104
#### CPU dependant optimizations
 
105
# Some CFLAGS are set by default depending on the target CPU. Those flags only
 
106
# feed CPU_CFLAGS, which in turn feed CFLAGS, so it is not mandatory to use
 
107
# them. You should not have to change these options. Better use CPU_CFLAGS or
 
108
# even CFLAGS instead.
 
109
CPU_CFLAGS.generic    = -O2
 
110
CPU_CFLAGS.i586       = -O2 -march=i586
 
111
CPU_CFLAGS.i686       = -O2 -march=i686
 
112
CPU_CFLAGS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
 
113
CPU_CFLAGS            = $(CPU_CFLAGS.$(CPU))
 
114
 
 
115
#### Common CFLAGS
 
116
# These CFLAGS contain general optimization options, CPU-specific optimizations
 
117
# and debug flags. They may be overridden by some distributions which prefer to
 
118
# set all of them at once instead of playing with the CPU and DEBUG variables.
 
119
CFLAGS = $(CPU_CFLAGS) $(DEBUG_CFLAGS)
 
120
 
 
121
#### Common LDFLAGS
 
122
# These LDFLAGS are used as the first "ld" options, regardless of any library
 
123
# path or any other option. They may be changed to add any linker-specific
 
124
# option at the beginning of the ld command line.
 
125
LDFLAGS = -g
 
126
 
 
127
#### Target system options
 
128
# Depending on the target platform, some options are set, as well as some
 
129
# CFLAGS and LDFLAGS. The USE_* values are set to "implicit" so that they are
 
130
# not reported in the build options string. You should not have to change
 
131
# anything there.
 
132
ifeq ($(TARGET),generic)
 
133
  # generic system target has nothing specific
 
134
  USE_POLL   = implicit
 
135
  USE_TPROXY = implicit
 
136
else
 
137
ifeq ($(TARGET),linux22)
 
138
  # This is for Linux 2.2
 
139
  USE_GETSOCKNAME = implicit
 
140
  USE_POLL        = implicit
 
141
  USE_TPROXY      = implicit
 
142
else
 
143
ifeq ($(TARGET),linux24)
 
144
  # This is for standard Linux 2.4 with netfilter but without epoll()
 
145
  USE_GETSOCKNAME = implicit
 
146
  USE_NETFILTER   = implicit
 
147
  USE_POLL        = implicit
 
148
  USE_TPROXY      = implicit
 
149
else
 
150
ifeq ($(TARGET),linux24e)
 
151
  # This is for enhanced Linux 2.4 with netfilter and epoll() patch > 0.21
 
152
  USE_GETSOCKNAME = implicit
 
153
  USE_NETFILTER   = implicit
 
154
  USE_POLL        = implicit
 
155
  USE_EPOLL       = implicit
 
156
  USE_SEPOLL      = implicit
 
157
  USE_MY_EPOLL    = implicit
 
158
  USE_TPROXY      = implicit
 
159
else
 
160
ifeq ($(TARGET),linux24eold)
 
161
  # This is for enhanced Linux 2.4 with netfilter and epoll() patch <= 0.21,
 
162
  # which needs a workaround for a very rare bug.
 
163
  USE_GETSOCKNAME      = implicit
 
164
  USE_NETFILTER        = implicit
 
165
  USE_POLL             = implicit
 
166
  USE_EPOLL            = implicit
 
167
  USE_SEPOLL           = implicit
 
168
  USE_MY_EPOLL         = implicit
 
169
  USE_EPOLL_WORKAROUND = implicit
 
170
  USE_TPROXY           = implicit
 
171
else
 
172
ifeq ($(TARGET),linux26)
 
173
  # This is for standard Linux 2.6 with netfilter and standard epoll()
 
174
  USE_GETSOCKNAME = implicit
 
175
  USE_NETFILTER   = implicit
 
176
  USE_POLL        = implicit
 
177
  USE_EPOLL       = implicit
 
178
  USE_SEPOLL      = implicit
 
179
  USE_TPROXY      = implicit
 
180
else
 
181
ifeq ($(TARGET),solaris)
 
182
  # This is for Solaris 8
 
183
  USE_POLL       = implicit
 
184
  TARGET_CFLAGS  = -fomit-frame-pointer -DFD_SETSIZE=65536 -D_REENTRANT
 
185
  TARGET_LDFLAGS = -lnsl -lsocket
 
186
  USE_TPROXY     = implicit
 
187
else
 
188
ifeq ($(TARGET),freebsd)
 
189
  # This is for FreeBSD
 
190
  USE_POLL       = implicit
 
191
  USE_KQUEUE     = implicit
 
192
  USE_TPROXY     = implicit
 
193
else
 
194
ifeq ($(TARGET),openbsd)
 
195
  # This is for OpenBSD >= 3.0
 
196
  USE_POLL       = implicit
 
197
  USE_KQUEUE     = implicit
 
198
  USE_TPROXY     = implicit
 
199
endif # openbsd
 
200
endif # freebsd
 
201
endif # solaris
 
202
endif # linux26
 
203
endif # linux24eold
 
204
endif # linux24e
 
205
endif # linux24
 
206
endif # linux22
 
207
endif # generic
 
208
 
 
209
 
 
210
#### Old-style REGEX library settings for compatibility with previous setups.
 
211
# It is still possible to use REGEX=<regex_lib> to select an alternative regex
 
212
# library. By default, we use libc's regex. On Solaris 8/Sparc, grouping seems
 
213
# to be broken using libc, so consider using pcre instead. Supported values are
 
214
# "libc", "pcre", and "static-pcre". Use of this method is deprecated in favor
 
215
# of "USE_PCRE" and "USE_STATIC_PCRE" (see build options below).
 
216
REGEX = libc
 
217
 
 
218
ifeq ($(REGEX),pcre)
 
219
USE_PCRE = 1
 
220
$(warning WARNING! use of "REGEX=pcre" is deprecated, consider using "USE_PCRE=1" instead.)
 
221
endif
 
222
 
 
223
ifeq ($(REGEX),static-pcre)
 
224
USE_STATIC_PCRE = 1
 
225
$(warning WARNING! use of "REGEX=pcre-static" is deprecated, consider using "USE_STATIC_PCRE=1" instead.)
 
226
endif
 
227
 
 
228
#### Old-style TPROXY settings
 
229
ifneq ($(findstring -DTPROXY,$(DEFINE)),)
 
230
USE_TPROXY = 1
 
231
$(warning WARNING! use of "DEFINE=-DTPROXY" is deprecated, consider using "USE_TPROXY=1" instead.)
 
232
endif
 
233
 
 
234
 
 
235
#### Determine version, sub-version and release date.
 
236
# If GIT is found, and IGNOREGIT is not set, VERSION, SUBVERS and VERDATE are
 
237
# extracted from the last commit. Otherwise, use the contents of the files
 
238
# holding the same names in the current directory.
 
239
 
112
240
ifeq ($(IGNOREGIT),)
113
 
VERSION := $(shell [ -d .git/. ] && ref=`git-describe --tags 2>/dev/null` && ref=$${ref%-g*} && echo "$${ref\#v}" )
114
 
endif
115
 
 
 
241
VERSION := $(shell [ -d .git/. ] && ref=`(git-describe --tags) 2>/dev/null` && ref=$${ref%-g*} && echo "$${ref\#v}")
116
242
ifneq ($(VERSION),)
117
243
# OK git is there and works.
118
244
SUBVERS := $(shell comms=`git-log --no-merges v$(VERSION).. 2>/dev/null |grep -c ^commit `; [ $$comms -gt 0 ] && echo "-$$comms" )
119
245
VERDATE := $(shell date +%Y/%m/%d -d "`git-log HEAD^.. 2>/dev/null | grep -m 1 ^Date: | cut -f2- -d: | cut -f1 -d+`" )
120
 
else
121
 
# Otherwise, use the hard-coded version of last tag, number of changes
122
 
# since last tag, and release date.
123
 
VERSION := 1.3.12
124
 
SUBVERS := 
125
 
VERDATE := 2007/06/17
126
 
endif
127
 
 
128
 
#### build options
129
 
 
130
 
# do not change this one, enable USE_* variables instead.
131
 
OPTIONS =
132
 
OPT_OBJS =
 
246
endif
 
247
endif
 
248
 
 
249
# Last commit version not found, take it from the files.
 
250
ifeq ($(VERSION),)
 
251
VERSION := $(shell cat VERSION 2>/dev/null || touch VERSION)
 
252
endif
 
253
ifeq ($(SUBVERS),)
 
254
SUBVERS := $(shell cat SUBVERS 2>/dev/null || touch SUBVERS)
 
255
endif
 
256
ifeq ($(VERDATE),)
 
257
VERDATE := $(shell cat VERDATE 2>/dev/null || touch VERDATE)
 
258
endif
 
259
 
 
260
#### Build options
 
261
# Do not change these ones, enable USE_* variables instead.
 
262
OPTIONS_CFLAGS  =
 
263
OPTIONS_LDFLAGS =
 
264
OPTIONS_OBJS    =
 
265
 
 
266
# This variable collects all USE_* values except those set to "implicit". This
 
267
# is used to report a list of all flags which were used to build this version.
 
268
# Do not assign anything to it.
 
269
BUILD_OPTIONS =
 
270
 
 
271
# Return USE_xxx=$(USE_xxx) unless $(USE_xxx) = "implicit"
 
272
# Usage: 
 
273
#   BUILD_OPTIONS += $(call ignore_implicit,USE_xxx)
 
274
ignore_implicit = $(patsubst %=implicit,,$(1)=$($(1)))
133
275
 
134
276
ifneq ($(USE_TCPSPLICE),)
135
 
OPTIONS += -DCONFIG_HAP_TCPSPLICE
 
277
# This is the directory hosting libtcpsplice.[ah]
 
278
TCPSPLICEDIR    :=
 
279
OPTIONS_CFLAGS  += -DCONFIG_HAP_TCPSPLICE -I$(TCPSPLICEDIR)
 
280
OPTIONS_LDFLAGS += -L$(TCPSPLICEDIR) -ltcpsplice
 
281
BUILD_OPTIONS   += $(call ignore_implicit,USE_TCPSPLICE)
136
282
endif
137
283
 
138
 
# - set USE_CTTPROXY to enable full transparent proxy support
139
284
ifneq ($(USE_CTTPROXY),)
140
 
OPTIONS += -DCONFIG_HAP_CTTPROXY
141
 
OPT_OBJS += src/cttproxy.o
 
285
OPTIONS_CFLAGS += -DCONFIG_HAP_CTTPROXY
 
286
OPTIONS_OBJS   += src/cttproxy.o
 
287
BUILD_OPTIONS  += $(call ignore_implicit,USE_CTTPROXY)
142
288
endif
143
289
 
144
290
ifneq ($(USE_TPROXY),)
145
 
OPTIONS += -DTPROXY
 
291
OPTIONS_CFLAGS += -DTPROXY
 
292
BUILD_OPTIONS  += $(call ignore_implicit,USE_TPROXY)
146
293
endif
147
294
 
148
295
ifneq ($(USE_POLL),)
149
 
OPTIONS += -DENABLE_POLL
150
 
OPT_OBJS += src/ev_poll.o
 
296
OPTIONS_CFLAGS += -DENABLE_POLL
 
297
OPTIONS_OBJS   += src/ev_poll.o
 
298
BUILD_OPTIONS  += $(call ignore_implicit,USE_POLL)
151
299
endif
152
300
 
153
301
ifneq ($(USE_EPOLL),)
154
 
OPTIONS += -DENABLE_EPOLL
155
 
OPT_OBJS += src/ev_epoll.o
 
302
OPTIONS_CFLAGS += -DENABLE_EPOLL
 
303
OPTIONS_OBJS   += src/ev_epoll.o
 
304
BUILD_OPTIONS  += $(call ignore_implicit,USE_EPOLL)
156
305
endif
157
306
 
158
307
ifneq ($(USE_SEPOLL),)
159
 
OPTIONS += -DENABLE_SEPOLL
160
 
OPT_OBJS += src/ev_sepoll.o
 
308
OPTIONS_CFLAGS += -DENABLE_SEPOLL
 
309
OPTIONS_OBJS   += src/ev_sepoll.o
 
310
BUILD_OPTIONS  += $(call ignore_implicit,USE_SEPOLL)
161
311
endif
162
312
 
163
313
ifneq ($(USE_MY_EPOLL),)
164
 
OPTIONS += -DUSE_MY_EPOLL
 
314
OPTIONS_CFLAGS += -DUSE_MY_EPOLL
 
315
BUILD_OPTIONS  += $(call ignore_implicit,USE_MY_EPOLL)
 
316
endif
 
317
 
 
318
ifneq ($(USE_KQUEUE),)
 
319
OPTIONS_CFLAGS += -DENABLE_KQUEUE
 
320
OPTIONS_OBJS   += src/ev_kqueue.o
 
321
BUILD_OPTIONS  += $(call ignore_implicit,USE_KQUEUE)
165
322
endif
166
323
 
167
324
ifneq ($(USE_NETFILTER),)
168
 
OPTIONS += -DNETFILTER
 
325
OPTIONS_CFLAGS += -DNETFILTER
 
326
BUILD_OPTIONS  += $(call ignore_implicit,USE_NETFILTER)
169
327
endif
170
328
 
171
329
ifneq ($(USE_EPOLL_WORKAROUND),)
172
 
OPTIONS += -DEPOLL_CTL_MOD_WORKAROUND
 
330
OPTIONS_CFLAGS += -DEPOLL_CTL_MOD_WORKAROUND
 
331
BUILD_OPTIONS  += $(call ignore_implicit,USE_EPOLL_WORKAROUND)
173
332
endif
174
333
 
175
334
ifneq ($(USE_GETSOCKNAME),)
176
 
OPTIONS += -DUSE_GETSOCKNAME
 
335
OPTIONS_CFLAGS += -DUSE_GETSOCKNAME
 
336
BUILD_OPTIONS  += $(call ignore_implicit,USE_GETSOCKNAME)
177
337
endif
178
338
 
179
339
ifneq ($(USE_REGPARM),)
180
 
OPTIONS += -DCONFIG_HAP_USE_REGPARM
181
 
endif
182
 
 
183
 
ifneq ($(VERSION),)
184
 
OPTIONS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
 
340
OPTIONS_CFLAGS += -DCONFIG_HAP_USE_REGPARM
 
341
BUILD_OPTIONS  += $(call ignore_implicit,USE_REGPARM)
 
342
endif
 
343
 
 
344
# report DLMALLOC_SRC only if explicitly specified
 
345
ifneq ($(DLMALLOC_SRC),)
 
346
BUILD_OPTIONS += DLMALLOC_SRC=$(DLMALLOC_SRC)
 
347
endif
 
348
 
 
349
ifneq ($(USE_DLMALLOC),)
 
350
BUILD_OPTIONS  += $(call ignore_implicit,USE_DLMALLOC)
 
351
ifeq ($(DLMALLOC_SRC),)
 
352
DLMALLOC_SRC=src/dlmalloc.c
 
353
endif
 
354
endif
 
355
 
 
356
ifneq ($(DLMALLOC_SRC),)
 
357
# DLMALLOC_THRES may be changed to match PAGE_SIZE on every platform
 
358
DLMALLOC_THRES = 4096
 
359
OPTIONS_OBJS  += src/dlmalloc.o
 
360
endif
 
361
 
 
362
ifneq ($(USE_PCRE),)
 
363
# PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is
 
364
# automatically detected but can be forced if required.
 
365
ifeq ($(PCREDIR),)
 
366
PCREDIR         := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local)
 
367
endif
 
368
OPTIONS_CFLAGS  += -DUSE_PCRE -I$(PCREDIR)/include
 
369
OPTIONS_LDFLAGS += -L$(PCREDIR)/lib -lpcreposix -lpcre
 
370
BUILD_OPTIONS   += $(call ignore_implicit,USE_PCRE)
 
371
endif
 
372
 
 
373
ifneq ($(USE_STATIC_PCRE),)
 
374
# PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is
 
375
# automatically detected but can be forced if required.
 
376
ifeq ($(PCREDIR),)
 
377
PCREDIR         := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local)
 
378
endif
 
379
OPTIONS_CFLAGS  += -DUSE_PCRE -I$(PCREDIR)/include
 
380
OPTIONS_LDFLAGS += -L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
 
381
BUILD_OPTIONS   += $(call ignore_implicit,USE_STATIC_PCRE)
 
382
endif
 
383
 
 
384
 
 
385
#### Global compile options
 
386
VERBOSE_CFLAGS = $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE)
 
387
COPTS  = -Iinclude -Wall
 
388
COPTS += $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE) $(SILENT_DEFINE)
 
389
COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(ADDINC)
 
390
 
 
391
ifneq ($(VERSION)$(SUBVERS),)
 
392
COPTS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
185
393
endif
186
394
 
187
395
ifneq ($(VERDATE),)
188
 
OPTIONS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
189
 
endif
190
 
 
191
 
#### end of build options
192
 
 
193
 
 
194
 
# global options
195
 
TARGET_OPTS=$(COPTS.$(TARGET))
196
 
REGEX_OPTS=$(COPTS.$(REGEX))
197
 
CPU_OPTS=$(COPTS.$(CPU))
198
 
 
199
 
COPTS = -Iinclude $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) $(OPTIONS)
200
 
LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX))
201
 
 
202
 
ifneq ($(USE_TCPSPLICE),)
203
 
COPTS += -I$(TCPSPLICEDIR)
204
 
LIBS  += -L$(TCPSPLICEDIR) -ltcpsplice
205
 
endif
206
 
 
207
 
COPTS += $(ADDINC)
208
 
LIBS += $(ADDLIB)
209
 
 
210
 
CFLAGS = -Wall $(COPTS) $(DEBUG)
211
 
LDFLAGS = -g
 
396
COPTS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
 
397
endif
 
398
 
 
399
#### Global link options
 
400
# These options are added at the end of the "ld" command line. Use LDFLAGS to
 
401
# add options at the beginning of the "ld" command line if needed.
 
402
LDOPTS = $(TARGET_LDFLAGS) $(OPTIONS_LDFLAGS) $(ADDLIB)
 
403
 
212
404
 
213
405
all: haproxy
214
406
 
215
 
OBJS = src/haproxy.o src/sessionhash.o src/base64.o \
 
407
OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \
216
408
       src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
217
409
       src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
218
 
       src/checks.o src/queue.o src/client.o src/proxy.o \
 
410
       src/checks.o src/queue.o src/client.o src/proxy.o src/proto_uxst.o \
219
411
       src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
220
 
       src/session.o src/hdr_idx.o src/ev_select.o src/acl.o src/memory.o
 
412
       src/senddata.o src/dumpstats.o src/proto_tcp.o \
 
413
       src/session.o src/hdr_idx.o src/ev_select.o \
 
414
       src/acl.o src/memory.o \
 
415
       src/ebtree.o src/eb32tree.o
221
416
 
222
 
haproxy: $(OBJS) $(OPT_OBJS)
223
 
        $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
 
417
haproxy: $(OBJS) $(OPTIONS_OBJS)
 
418
        $(LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
224
419
 
225
420
objsize: haproxy
226
421
        @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
227
422
 
228
423
%.o:    %.c
229
 
        $(CC) $(CFLAGS) -c -o $@ $<
 
424
        $(CC) $(COPTS) -c -o $@ $<
 
425
 
 
426
src/haproxy.o:  src/haproxy.c
 
427
        $(CC) $(COPTS) \
 
428
              -DBUILD_TARGET='"$(strip $(TARGET))"' \
 
429
              -DBUILD_CPU='"$(strip $(CPU))"' \
 
430
              -DBUILD_CC='"$(strip $(CC))"' \
 
431
              -DBUILD_CFLAGS='"$(strip $(VERBOSE_CFLAGS))"' \
 
432
              -DBUILD_OPTIONS='"$(strip $(BUILD_OPTIONS))"' \
 
433
               -c -o $@ $<
 
434
 
 
435
src/dlmalloc.o: $(DLMALLOC_SRC)
 
436
        $(CC) $(COPTS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
230
437
 
231
438
clean:
232
439
        rm -f *.[oas] src/*.[oas] core haproxy test
244
451
 
245
452
git-tar: clean
246
453
        git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz
 
454
 
 
455
version:
 
456
        @echo "VERSION: $(VERSION)"
 
457
        @echo "SUBVERS: $(SUBVERS)"
 
458
        @echo "VERDATE: $(VERDATE)"
 
459
 
 
460
# never use this one if you don't know what it is used for.
 
461
update-version:
 
462
        @echo "Ready to update the following versions :"
 
463
        @echo "VERSION: $(VERSION)"
 
464
        @echo "SUBVERS: $(SUBVERS)"
 
465
        @echo "VERDATE: $(VERDATE)"
 
466
        @echo "Press [ENTER] to continue or Ctrl-C to abort now.";read
 
467
        echo "$(VERSION)" > VERSION
 
468
        echo "$(SUBVERS)" > SUBVERS
 
469
        echo "$(VERDATE)" > VERDATE