blob: 43c05fd8ba0b853d66ff9c45571eb517d5140552 [file] [log] [blame]
Willy Tarreau9f2b7302008-01-02 20:48:34 +01001# This GNU Makefile supports different OS and CPU combinations.
2#
willy tarreaueedaa9f2005-12-17 14:08:03 +01003# You should use it this way :
Willy Tarreau9f2b7302008-01-02 20:48:34 +01004# [g]make TARGET=os CPU=cpu USE_xxx=1 ...
Willy Tarreauf2ef8c52007-07-11 09:19:31 +02005#
Willy Tarreau9f2b7302008-01-02 20:48:34 +01006# 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_EPOLL : enable epoll() on Linux 2.6. Automatic.
10# USE_EPOLL_WORKAROUND : enable epoll() bug workaround. Automatic.
11# USE_GETSOCKNAME : enable getsockname() on Linux 2.2. Automatic.
12# USE_KQUEUE : enable kqueue() on BSD. Automatic.
13# USE_MY_EPOLL : redefine epoll_* syscalls. Automatic.
14# USE_NETFILTER : enable netfilter on Linux. Automatic.
15# USE_PCRE : enable use of libpcre for regex. Recommended.
16# USE_POLL : enable poll(). Automatic.
17# USE_REGPARM : enable regparm optimization. Recommended on x86.
18# USE_SEPOLL : enable speculative epoll(). Automatic.
19# USE_STATIC_PCRE : enable static libpcre. Recommended.
20# USE_TCPSPLICE : enable tcp_splice() on Linux (needs kernel patch).
21# USE_TPROXY : enable transparent proxy. Automatic.
Willy Tarreaub1e52e82008-01-13 14:49:51 +010022# USE_LINUX_TPROXY : enable full transparent proxy (need kernel patch).
Willy Tarreauf2ef8c52007-07-11 09:19:31 +020023#
Willy Tarreau9f2b7302008-01-02 20:48:34 +010024# 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.
Willy Tarreau4f60f162007-04-08 16:39:58 +020049
Willy Tarreau4f60f162007-04-08 16:39:58 +020050
Willy Tarreau9f2b7302008-01-02 20:48:34 +010051#### 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
56TARGET = generic
Willy Tarreau4f60f162007-04-08 16:39:58 +020057
Willy Tarreau9f2b7302008-01-02 20:48:34 +010058#### TARGET CPU
59# Use CPU=<cpu_name> to optimize for a particular CPU, among the following
60# list :
61# generic, i586, i686, ultrasparc, custom
willy tarreaueedaa9f2005-12-17 14:08:03 +010062CPU = generic
willy tarreau036e1ce2005-12-17 13:46:33 +010063
Willy Tarreau9f2b7302008-01-02 20:48:34 +010064#### Toolchain options.
65# GCC is normally used both for compiling and linking.
willy tarreaueedaa9f2005-12-17 14:08:03 +010066CC = gcc
67LD = gcc
68
Willy Tarreau9f2b7302008-01-02 20:48:34 +010069#### Debug flags (typically "-g").
70# Those flags only feed CFLAGS so it is not mandatory to use this form.
71DEBUG_CFLAGS = -g
willy tarreau036e1ce2005-12-17 13:46:33 +010072
Willy Tarreau9f2b7302008-01-02 20:48:34 +010073#### Memory usage tuning
74# If small memory footprint is required, you can reduce the buffer size. There
75# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
76# with 1000 concurrent sessions. Putting it slightly lower than a page size
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
82SMALL_OPTS =
Willy Tarreau6d1a9882007-01-07 02:03:04 +010083
Willy Tarreau9f2b7302008-01-02 20:48:34 +010084#### 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.
89DEBUG =
willy tarreau1c2ad212005-12-18 01:11:29 +010090
Willy Tarreau9f2b7302008-01-02 20:48:34 +010091#### Additional include and library dirs
92# Redefine this if you want to add some special PATH to include/libs
93ADDINC =
94ADDLIB =
willy tarreau64a3cc32005-12-18 01:13:11 +010095
Willy Tarreau9f2b7302008-01-02 20:48:34 +010096#### 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.
100DEFINE =
101SILENT_DEFINE =
willy tarreau0f7af912005-12-17 12:21:26 +0100102
willy tarreau5cbea6f2005-12-17 12:48:26 +0100103
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100104#### 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.
109CPU_CFLAGS.generic = -O2
110CPU_CFLAGS.i586 = -O2 -march=i586
111CPU_CFLAGS.i686 = -O2 -march=i686
112CPU_CFLAGS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
113CPU_CFLAGS = $(CPU_CFLAGS.$(CPU))
willy tarreau9da061b2005-12-17 12:29:56 +0100114
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100115#### 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.
119CFLAGS = $(CPU_CFLAGS) $(DEBUG_CFLAGS)
willy tarreaueedaa9f2005-12-17 14:08:03 +0100120
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100121#### 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.
125LDFLAGS = -g
willy tarreau036e1ce2005-12-17 13:46:33 +0100126
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100127#### 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.
132ifeq ($(TARGET),generic)
133 # generic system target has nothing specific
134 USE_POLL = implicit
135 USE_TPROXY = implicit
136else
137ifeq ($(TARGET),linux22)
138 # This is for Linux 2.2
139 USE_GETSOCKNAME = implicit
140 USE_POLL = implicit
141 USE_TPROXY = implicit
142else
143ifeq ($(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
149else
150ifeq ($(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
159else
160ifeq ($(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
171else
172ifeq ($(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
180else
181ifeq ($(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
187else
188ifeq ($(TARGET),freebsd)
189 # This is for FreeBSD
190 USE_POLL = implicit
191 USE_KQUEUE = implicit
192 USE_TPROXY = implicit
193else
194ifeq ($(TARGET),openbsd)
195 # This is for OpenBSD >= 3.0
196 USE_POLL = implicit
197 USE_KQUEUE = implicit
198 USE_TPROXY = implicit
199endif # openbsd
200endif # freebsd
201endif # solaris
202endif # linux26
203endif # linux24eold
204endif # linux24e
205endif # linux24
206endif # linux22
207endif # generic
willy tarreau036e1ce2005-12-17 13:46:33 +0100208
willy tarreau4373b962005-12-18 01:32:31 +0100209
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100210#### 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).
216REGEX = libc
willy tarreau9da061b2005-12-17 12:29:56 +0100217
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100218ifeq ($(REGEX),pcre)
219USE_PCRE = 1
220$(warning WARNING! use of "REGEX=pcre" is deprecated, consider using "USE_PCRE=1" instead.)
221endif
willy tarreau0174f312005-12-18 01:02:42 +0100222
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100223ifeq ($(REGEX),static-pcre)
224USE_STATIC_PCRE = 1
225$(warning WARNING! use of "REGEX=pcre-static" is deprecated, consider using "USE_STATIC_PCRE=1" instead.)
226endif
willy tarreau1c2ad212005-12-18 01:11:29 +0100227
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100228#### Old-style TPROXY settings
229ifneq ($(findstring -DTPROXY,$(DEFINE)),)
230USE_TPROXY = 1
231$(warning WARNING! use of "DEFINE=-DTPROXY" is deprecated, consider using "USE_TPROXY=1" instead.)
232endif
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.
willy tarreau0174f312005-12-18 01:02:42 +0100239
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100240ifeq ($(IGNOREGIT),)
Willy Tarreauec692562007-09-09 23:31:11 +0200241VERSION := $(shell [ -d .git/. ] && ref=`(git-describe --tags) 2>/dev/null` && ref=$${ref%-g*} && echo "$${ref\#v}")
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100242ifneq ($(VERSION),)
243# OK git is there and works.
Willy Tarreaua1973c42007-04-09 22:07:11 +0200244SUBVERS := $(shell comms=`git-log --no-merges v$(VERSION).. 2>/dev/null |grep -c ^commit `; [ $$comms -gt 0 ] && echo "-$$comms" )
245VERDATE := $(shell date +%Y/%m/%d -d "`git-log HEAD^.. 2>/dev/null | grep -m 1 ^Date: | cut -f2- -d: | cut -f1 -d+`" )
Willy Tarreauec692562007-09-09 23:31:11 +0200246endif
247endif
248
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100249# Last commit version not found, take it from the files.
Willy Tarreauec692562007-09-09 23:31:11 +0200250ifeq ($(VERSION),)
251VERSION := $(shell cat VERSION 2>/dev/null || touch VERSION)
252endif
253ifeq ($(SUBVERS),)
254SUBVERS := $(shell cat SUBVERS 2>/dev/null || touch SUBVERS)
255endif
256ifeq ($(VERDATE),)
257VERDATE := $(shell cat VERDATE 2>/dev/null || touch VERDATE)
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100258endif
Willy Tarreau77074d52006-11-12 23:57:19 +0100259
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100260#### Build options
261# Do not change these ones, enable USE_* variables instead.
262OPTIONS_CFLAGS =
263OPTIONS_LDFLAGS =
264OPTIONS_OBJS =
Willy Tarreau77074d52006-11-12 23:57:19 +0100265
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100266# 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.
269BUILD_OPTIONS =
270
271# Return USE_xxx=$(USE_xxx) unless $(USE_xxx) = "implicit"
272# Usage:
273# BUILD_OPTIONS += $(call ignore_implicit,USE_xxx)
274ignore_implicit = $(patsubst %=implicit,,$(1)=$($(1)))
Willy Tarreau77074d52006-11-12 23:57:19 +0100275
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100276ifneq ($(USE_TCPSPLICE),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100277# This is the directory hosting libtcpsplice.[ah]
278TCPSPLICEDIR :=
279OPTIONS_CFLAGS += -DCONFIG_HAP_TCPSPLICE -I$(TCPSPLICEDIR)
280OPTIONS_LDFLAGS += -L$(TCPSPLICEDIR) -ltcpsplice
281BUILD_OPTIONS += $(call ignore_implicit,USE_TCPSPLICE)
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100282endif
283
Willy Tarreau77074d52006-11-12 23:57:19 +0100284ifneq ($(USE_CTTPROXY),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100285OPTIONS_CFLAGS += -DCONFIG_HAP_CTTPROXY
286OPTIONS_OBJS += src/cttproxy.o
287BUILD_OPTIONS += $(call ignore_implicit,USE_CTTPROXY)
Willy Tarreau77074d52006-11-12 23:57:19 +0100288endif
289
290ifneq ($(USE_TPROXY),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100291OPTIONS_CFLAGS += -DTPROXY
292BUILD_OPTIONS += $(call ignore_implicit,USE_TPROXY)
Willy Tarreau77074d52006-11-12 23:57:19 +0100293endif
294
Willy Tarreaub1e52e82008-01-13 14:49:51 +0100295ifneq ($(USE_LINUX_TPROXY),)
296OPTIONS_CFLAGS += -DCONFIG_HAP_LINUX_TPROXY
297BUILD_OPTIONS += $(call ignore_implicit,USE_LINUX_TPROXY)
298endif
299
Willy Tarreau77074d52006-11-12 23:57:19 +0100300ifneq ($(USE_POLL),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100301OPTIONS_CFLAGS += -DENABLE_POLL
302OPTIONS_OBJS += src/ev_poll.o
303BUILD_OPTIONS += $(call ignore_implicit,USE_POLL)
Willy Tarreau77074d52006-11-12 23:57:19 +0100304endif
305
306ifneq ($(USE_EPOLL),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100307OPTIONS_CFLAGS += -DENABLE_EPOLL
308OPTIONS_OBJS += src/ev_epoll.o
309BUILD_OPTIONS += $(call ignore_implicit,USE_EPOLL)
Willy Tarreau77074d52006-11-12 23:57:19 +0100310endif
311
Willy Tarreaude99e992007-04-16 00:53:59 +0200312ifneq ($(USE_SEPOLL),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100313OPTIONS_CFLAGS += -DENABLE_SEPOLL
314OPTIONS_OBJS += src/ev_sepoll.o
315BUILD_OPTIONS += $(call ignore_implicit,USE_SEPOLL)
Willy Tarreaude99e992007-04-16 00:53:59 +0200316endif
317
Willy Tarreau77074d52006-11-12 23:57:19 +0100318ifneq ($(USE_MY_EPOLL),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100319OPTIONS_CFLAGS += -DUSE_MY_EPOLL
320BUILD_OPTIONS += $(call ignore_implicit,USE_MY_EPOLL)
321endif
322
323ifneq ($(USE_KQUEUE),)
324OPTIONS_CFLAGS += -DENABLE_KQUEUE
325OPTIONS_OBJS += src/ev_kqueue.o
326BUILD_OPTIONS += $(call ignore_implicit,USE_KQUEUE)
Willy Tarreau77074d52006-11-12 23:57:19 +0100327endif
328
329ifneq ($(USE_NETFILTER),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100330OPTIONS_CFLAGS += -DNETFILTER
331BUILD_OPTIONS += $(call ignore_implicit,USE_NETFILTER)
Willy Tarreau77074d52006-11-12 23:57:19 +0100332endif
333
334ifneq ($(USE_EPOLL_WORKAROUND),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100335OPTIONS_CFLAGS += -DEPOLL_CTL_MOD_WORKAROUND
336BUILD_OPTIONS += $(call ignore_implicit,USE_EPOLL_WORKAROUND)
Willy Tarreau77074d52006-11-12 23:57:19 +0100337endif
338
339ifneq ($(USE_GETSOCKNAME),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100340OPTIONS_CFLAGS += -DUSE_GETSOCKNAME
341BUILD_OPTIONS += $(call ignore_implicit,USE_GETSOCKNAME)
Willy Tarreau77074d52006-11-12 23:57:19 +0100342endif
343
344ifneq ($(USE_REGPARM),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100345OPTIONS_CFLAGS += -DCONFIG_HAP_USE_REGPARM
346BUILD_OPTIONS += $(call ignore_implicit,USE_REGPARM)
Willy Tarreau77074d52006-11-12 23:57:19 +0100347endif
348
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200349ifneq ($(DLMALLOC_SRC),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100350# May be changed to match PAGE_SIZE on every platform
351DLMALLOC_THRES = 4096
352OPTIONS_OBJS += src/dlmalloc.o
353BUILD_OPTIONS += DLMALLOC_SRC=$(DLMALLOC_SRC)
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200354endif
355
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100356ifneq ($(USE_PCRE),)
357# PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is
358# automatically detected but can be forced if required.
359ifeq ($(PCREDIR),)
360PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local)
Willy Tarreau79b34bf2006-12-22 15:28:43 +0100361endif
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100362OPTIONS_CFLAGS += -DUSE_PCRE -I$(PCREDIR)/include
363OPTIONS_LDFLAGS += -L$(PCREDIR)/lib -lpcreposix -lpcre
364BUILD_OPTIONS += $(call ignore_implicit,USE_PCRE)
Willy Tarreau79b34bf2006-12-22 15:28:43 +0100365endif
366
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100367ifneq ($(USE_STATIC_PCRE),)
368# PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is
369# automatically detected but can be forced if required.
370ifeq ($(PCREDIR),)
371PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local)
372endif
373OPTIONS_CFLAGS += -DUSE_PCRE -I$(PCREDIR)/include
374OPTIONS_LDFLAGS += -L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
375BUILD_OPTIONS += $(call ignore_implicit,USE_STATIC_PCRE)
376endif
Willy Tarreau77074d52006-11-12 23:57:19 +0100377
378
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100379#### Global compile options
380VERBOSE_CFLAGS = $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE)
381COPTS = -Iinclude -Wall
382COPTS += $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE) $(SILENT_DEFINE)
383COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(ADDINC)
willy tarreaueedaa9f2005-12-17 14:08:03 +0100384
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100385ifneq ($(VERSION)$(SUBVERS),)
386COPTS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
387endif
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100388
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100389ifneq ($(VERDATE),)
390COPTS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100391endif
392
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100393#### Global link options
394# These options are added at the end of the "ld" command line. Use LDFLAGS to
395# add options at the beginning of the "ld" command line if needed.
396LDOPTS = $(TARGET_LDFLAGS) $(OPTIONS_LDFLAGS) $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +0100397
willy tarreau0f7af912005-12-17 12:21:26 +0100398
399all: haproxy
400
Willy Tarreaudd815982007-10-16 12:25:14 +0200401OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \
Willy Tarreaubaaee002006-06-26 02:48:02 +0200402 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
403 src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
Willy Tarreau92fb9832007-10-16 17:34:28 +0200404 src/checks.o src/queue.o src/client.o src/proxy.o src/proto_uxst.o \
Willy Tarreaubaaee002006-06-26 02:48:02 +0200405 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
Willy Tarreaue6b98942007-10-29 01:09:36 +0100406 src/senddata.o src/dumpstats.o src/proto_tcp.o \
Willy Tarreaue6d2e4d2007-11-15 23:56:17 +0100407 src/session.o src/hdr_idx.o src/ev_select.o \
408 src/acl.o src/memory.o \
409 src/ebtree.o src/eb32tree.o
Willy Tarreaubaaee002006-06-26 02:48:02 +0200410
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100411haproxy: $(OBJS) $(OPTIONS_OBJS)
412 $(LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
willy tarreau0f7af912005-12-17 12:21:26 +0100413
Willy Tarreaubaaee002006-06-26 02:48:02 +0200414objsize: haproxy
415 @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
416
willy tarreau0f7af912005-12-17 12:21:26 +0100417%.o: %.c
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100418 $(CC) $(COPTS) -c -o $@ $<
willy tarreau0f7af912005-12-17 12:21:26 +0100419
Willy Tarreau7b066db2007-12-02 11:28:59 +0100420src/haproxy.o: src/haproxy.c
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100421 $(CC) $(COPTS) \
422 -DBUILD_TARGET='"$(strip $(TARGET))"' \
423 -DBUILD_CPU='"$(strip $(CPU))"' \
424 -DBUILD_CC='"$(strip $(CC))"' \
425 -DBUILD_CFLAGS='"$(strip $(VERBOSE_CFLAGS))"' \
426 -DBUILD_OPTIONS='"$(strip $(BUILD_OPTIONS))"' \
427 -c -o $@ $<
Willy Tarreau7b066db2007-12-02 11:28:59 +0100428
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200429src/dlmalloc.o: $(DLMALLOC_SRC)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100430 $(CC) $(COPTS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200431
willy tarreau0f7af912005-12-17 12:21:26 +0100432clean:
Willy Tarreau1a587492006-10-15 23:40:58 +0200433 rm -f *.[oas] src/*.[oas] core haproxy test
434 for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100435 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz
436 rm -f haproxy-$(VERSION) nohup.out gmon.out
willy tarreauefae1842005-12-17 12:51:03 +0100437
willy tarreaue114bf92006-03-19 21:30:14 +0100438tar: clean
willy tarreaucee272f2006-03-19 21:16:26 +0100439 ln -s . haproxy-$(VERSION)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200440 tar --exclude=haproxy-$(VERSION)/.git \
441 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \
442 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \
443 -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz
willy tarreaucee272f2006-03-19 21:16:26 +0100444 rm -f haproxy-$(VERSION)
445
Willy Tarreau9f0a9012006-10-15 14:24:14 +0200446git-tar: clean
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100447 git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz
Willy Tarreauec692562007-09-09 23:31:11 +0200448
449version:
450 @echo "VERSION: $(VERSION)"
451 @echo "SUBVERS: $(SUBVERS)"
452 @echo "VERDATE: $(VERDATE)"
453
454# never use this one if you don't know what it is used for.
455update-version:
456 @echo "Ready to update the following versions :"
457 @echo "VERSION: $(VERSION)"
458 @echo "SUBVERS: $(SUBVERS)"
459 @echo "VERDATE: $(VERDATE)"
460 @echo "Press [ENTER] to continue or Ctrl-C to abort now.";read
461 echo "$(VERSION)" > VERSION
462 echo "$(SUBVERS)" > SUBVERS
463 echo "$(VERDATE)" > VERDATE