blob: 17d9dd1dd133cb2ecbf06d53ddd333f984844653 [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 Tarreauf2ef8c52007-07-11 09:19:31 +020022#
Willy Tarreau9f2b7302008-01-02 20:48:34 +010023# Options can be forced by specifying "USE_xxx=1" or can be disabled by using
24# "USE_xxx=" (empty string).
25#
26# Variables useful for packagers :
27# CC is set to "gcc" by default and is used for compilation only.
28# LD is set to "gcc" by default and is used for linking only.
29# CFLAGS is automatically set for the specified CPU and may be overridden.
30# LDFLAGS is automatically set to -g and may be overridden.
31# SMALL_OPTS may be used to specify some options to shrink memory usage.
32# DEBUG may be used to set some internal debugging options.
33# ADDINC may be used to complete the include path in the form -Ipath.
34# ADDLIB may be used to complete the library list in the form -Lpath -llib.
35# DEFINE may be used to specify any additional define, which will be reported
36# by "haproxy -vv" in CFLAGS.
37# SILENT_DEFINE may be used to specify other defines which will not be
38# reported by "haproxy -vv".
39#
40# Other variables :
41# DLMALLOC_SRC : build with dlmalloc, indicate the location of dlmalloc.c.
42# DLMALLOC_THRES : should match PAGE_SIZE on every platform (default: 4096).
43# PCREDIR : force the path to libpcre.
44# IGNOREGIT : ignore GIT commit versions if set.
45# VERSION : force haproxy version reporting.
46# SUBVERS : add a sub-version (eg: platform, model, ...).
47# VERDATE : force haproxy's release date.
Willy Tarreau4f60f162007-04-08 16:39:58 +020048
Willy Tarreau4f60f162007-04-08 16:39:58 +020049
Willy Tarreau9f2b7302008-01-02 20:48:34 +010050#### TARGET system
51# Use TARGET=<target_name> to optimize for a specifc target OS among the
52# following list (use the default "generic" if uncertain) :
53# generic, linux22, linux24, linux24e, linux24eold, linux26, solaris,
54# freebsd, openbsd, custom
55TARGET = generic
Willy Tarreau4f60f162007-04-08 16:39:58 +020056
Willy Tarreau9f2b7302008-01-02 20:48:34 +010057#### TARGET CPU
58# Use CPU=<cpu_name> to optimize for a particular CPU, among the following
59# list :
60# generic, i586, i686, ultrasparc, custom
willy tarreaueedaa9f2005-12-17 14:08:03 +010061CPU = generic
willy tarreau036e1ce2005-12-17 13:46:33 +010062
Willy Tarreau9f2b7302008-01-02 20:48:34 +010063#### Toolchain options.
64# GCC is normally used both for compiling and linking.
willy tarreaueedaa9f2005-12-17 14:08:03 +010065CC = gcc
66LD = gcc
67
Willy Tarreau9f2b7302008-01-02 20:48:34 +010068#### Debug flags (typically "-g").
69# Those flags only feed CFLAGS so it is not mandatory to use this form.
70DEBUG_CFLAGS = -g
willy tarreau036e1ce2005-12-17 13:46:33 +010071
Willy Tarreau9f2b7302008-01-02 20:48:34 +010072#### Memory usage tuning
73# If small memory footprint is required, you can reduce the buffer size. There
74# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
75# with 1000 concurrent sessions. Putting it slightly lower than a page size
76# will prevent the additional parameters to go beyond a page. 8030 bytes is
77# exactly 5.5 TCP segments of 1460 bytes and is generally good. Useful tuning
78# macros include :
79# SYSTEM_MAXCONN, BUFSIZE, MAXREWRITE, REQURI_LEN, CAPTURE_LEN.
80# Example: SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
81SMALL_OPTS =
Willy Tarreau6d1a9882007-01-07 02:03:04 +010082
Willy Tarreau9f2b7302008-01-02 20:48:34 +010083#### Debug settings
84# You can enable debugging on specific code parts by setting DEBUG=-DDEBUG_xxx.
85# Currently defined DEBUG macros include DEBUG_FULL, DEBUG_MEMORY, DEBUG_FSM,
86# DEBUG_HASH and DEBUG_PARSE_NO_SPEEDUP. Please consult sources for exact
87# meaning or do not use at all.
88DEBUG =
willy tarreau1c2ad212005-12-18 01:11:29 +010089
Willy Tarreau9f2b7302008-01-02 20:48:34 +010090#### Additional include and library dirs
91# Redefine this if you want to add some special PATH to include/libs
92ADDINC =
93ADDLIB =
willy tarreau64a3cc32005-12-18 01:13:11 +010094
Willy Tarreau9f2b7302008-01-02 20:48:34 +010095#### Specific macro definitions
96# Use DEFINE=-Dxxx to set any tunable macro. Anything declared here will appear
97# in the build options reported by "haproxy -vv". Use SILENT_DEFINE if you do
98# not want to pollute the report with complex defines.
99DEFINE =
100SILENT_DEFINE =
willy tarreau0f7af912005-12-17 12:21:26 +0100101
willy tarreau5cbea6f2005-12-17 12:48:26 +0100102
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100103#### CPU dependant optimizations
104# Some CFLAGS are set by default depending on the target CPU. Those flags only
105# feed CPU_CFLAGS, which in turn feed CFLAGS, so it is not mandatory to use
106# them. You should not have to change these options. Better use CPU_CFLAGS or
107# even CFLAGS instead.
108CPU_CFLAGS.generic = -O2
109CPU_CFLAGS.i586 = -O2 -march=i586
110CPU_CFLAGS.i686 = -O2 -march=i686
111CPU_CFLAGS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
112CPU_CFLAGS = $(CPU_CFLAGS.$(CPU))
willy tarreau9da061b2005-12-17 12:29:56 +0100113
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100114#### Common CFLAGS
115# These CFLAGS contain general optimization options, CPU-specific optimizations
116# and debug flags. They may be overridden by some distributions which prefer to
117# set all of them at once instead of playing with the CPU and DEBUG variables.
118CFLAGS = $(CPU_CFLAGS) $(DEBUG_CFLAGS)
willy tarreaueedaa9f2005-12-17 14:08:03 +0100119
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100120#### Common LDFLAGS
121# These LDFLAGS are used as the first "ld" options, regardless of any library
122# path or any other option. They may be changed to add any linker-specific
123# option at the beginning of the ld command line.
124LDFLAGS = -g
willy tarreau036e1ce2005-12-17 13:46:33 +0100125
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100126#### Target system options
127# Depending on the target platform, some options are set, as well as some
128# CFLAGS and LDFLAGS. The USE_* values are set to "implicit" so that they are
129# not reported in the build options string. You should not have to change
130# anything there.
131ifeq ($(TARGET),generic)
132 # generic system target has nothing specific
133 USE_POLL = implicit
134 USE_TPROXY = implicit
135else
136ifeq ($(TARGET),linux22)
137 # This is for Linux 2.2
138 USE_GETSOCKNAME = implicit
139 USE_POLL = implicit
140 USE_TPROXY = implicit
141else
142ifeq ($(TARGET),linux24)
143 # This is for standard Linux 2.4 with netfilter but without epoll()
144 USE_GETSOCKNAME = implicit
145 USE_NETFILTER = implicit
146 USE_POLL = implicit
147 USE_TPROXY = implicit
148else
149ifeq ($(TARGET),linux24e)
150 # This is for enhanced Linux 2.4 with netfilter and epoll() patch > 0.21
151 USE_GETSOCKNAME = implicit
152 USE_NETFILTER = implicit
153 USE_POLL = implicit
154 USE_EPOLL = implicit
155 USE_SEPOLL = implicit
156 USE_MY_EPOLL = implicit
157 USE_TPROXY = implicit
158else
159ifeq ($(TARGET),linux24eold)
160 # This is for enhanced Linux 2.4 with netfilter and epoll() patch <= 0.21,
161 # which needs a workaround for a very rare bug.
162 USE_GETSOCKNAME = implicit
163 USE_NETFILTER = implicit
164 USE_POLL = implicit
165 USE_EPOLL = implicit
166 USE_SEPOLL = implicit
167 USE_MY_EPOLL = implicit
168 USE_EPOLL_WORKAROUND = implicit
169 USE_TPROXY = implicit
170else
171ifeq ($(TARGET),linux26)
172 # This is for standard Linux 2.6 with netfilter and standard epoll()
173 USE_GETSOCKNAME = implicit
174 USE_NETFILTER = implicit
175 USE_POLL = implicit
176 USE_EPOLL = implicit
177 USE_SEPOLL = implicit
178 USE_TPROXY = implicit
179else
180ifeq ($(TARGET),solaris)
181 # This is for Solaris 8
182 USE_POLL = implicit
183 TARGET_CFLAGS = -fomit-frame-pointer -DFD_SETSIZE=65536 -D_REENTRANT
184 TARGET_LDFLAGS = -lnsl -lsocket
185 USE_TPROXY = implicit
186else
187ifeq ($(TARGET),freebsd)
188 # This is for FreeBSD
189 USE_POLL = implicit
190 USE_KQUEUE = implicit
191 USE_TPROXY = implicit
192else
193ifeq ($(TARGET),openbsd)
194 # This is for OpenBSD >= 3.0
195 USE_POLL = implicit
196 USE_KQUEUE = implicit
197 USE_TPROXY = implicit
198endif # openbsd
199endif # freebsd
200endif # solaris
201endif # linux26
202endif # linux24eold
203endif # linux24e
204endif # linux24
205endif # linux22
206endif # generic
willy tarreau036e1ce2005-12-17 13:46:33 +0100207
willy tarreau4373b962005-12-18 01:32:31 +0100208
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100209#### Old-style REGEX library settings for compatibility with previous setups.
210# It is still possible to use REGEX=<regex_lib> to select an alternative regex
211# library. By default, we use libc's regex. On Solaris 8/Sparc, grouping seems
212# to be broken using libc, so consider using pcre instead. Supported values are
213# "libc", "pcre", and "static-pcre". Use of this method is deprecated in favor
214# of "USE_PCRE" and "USE_STATIC_PCRE" (see build options below).
215REGEX = libc
willy tarreau9da061b2005-12-17 12:29:56 +0100216
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100217ifeq ($(REGEX),pcre)
218USE_PCRE = 1
219$(warning WARNING! use of "REGEX=pcre" is deprecated, consider using "USE_PCRE=1" instead.)
220endif
willy tarreau0174f312005-12-18 01:02:42 +0100221
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100222ifeq ($(REGEX),static-pcre)
223USE_STATIC_PCRE = 1
224$(warning WARNING! use of "REGEX=pcre-static" is deprecated, consider using "USE_STATIC_PCRE=1" instead.)
225endif
willy tarreau1c2ad212005-12-18 01:11:29 +0100226
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100227#### Old-style TPROXY settings
228ifneq ($(findstring -DTPROXY,$(DEFINE)),)
229USE_TPROXY = 1
230$(warning WARNING! use of "DEFINE=-DTPROXY" is deprecated, consider using "USE_TPROXY=1" instead.)
231endif
232
233
234#### Determine version, sub-version and release date.
235# If GIT is found, and IGNOREGIT is not set, VERSION, SUBVERS and VERDATE are
236# extracted from the last commit. Otherwise, use the contents of the files
237# holding the same names in the current directory.
willy tarreau0174f312005-12-18 01:02:42 +0100238
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100239ifeq ($(IGNOREGIT),)
Willy Tarreauec692562007-09-09 23:31:11 +0200240VERSION := $(shell [ -d .git/. ] && ref=`(git-describe --tags) 2>/dev/null` && ref=$${ref%-g*} && echo "$${ref\#v}")
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100241ifneq ($(VERSION),)
242# OK git is there and works.
Willy Tarreaua1973c42007-04-09 22:07:11 +0200243SUBVERS := $(shell comms=`git-log --no-merges v$(VERSION).. 2>/dev/null |grep -c ^commit `; [ $$comms -gt 0 ] && echo "-$$comms" )
244VERDATE := $(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 +0200245endif
246endif
247
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100248# Last commit version not found, take it from the files.
Willy Tarreauec692562007-09-09 23:31:11 +0200249ifeq ($(VERSION),)
250VERSION := $(shell cat VERSION 2>/dev/null || touch VERSION)
251endif
252ifeq ($(SUBVERS),)
253SUBVERS := $(shell cat SUBVERS 2>/dev/null || touch SUBVERS)
254endif
255ifeq ($(VERDATE),)
256VERDATE := $(shell cat VERDATE 2>/dev/null || touch VERDATE)
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100257endif
Willy Tarreau77074d52006-11-12 23:57:19 +0100258
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100259#### Build options
260# Do not change these ones, enable USE_* variables instead.
261OPTIONS_CFLAGS =
262OPTIONS_LDFLAGS =
263OPTIONS_OBJS =
Willy Tarreau77074d52006-11-12 23:57:19 +0100264
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100265# This variable collects all USE_* values except those set to "implicit". This
266# is used to report a list of all flags which were used to build this version.
267# Do not assign anything to it.
268BUILD_OPTIONS =
269
270# Return USE_xxx=$(USE_xxx) unless $(USE_xxx) = "implicit"
271# Usage:
272# BUILD_OPTIONS += $(call ignore_implicit,USE_xxx)
273ignore_implicit = $(patsubst %=implicit,,$(1)=$($(1)))
Willy Tarreau77074d52006-11-12 23:57:19 +0100274
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100275ifneq ($(USE_TCPSPLICE),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100276# This is the directory hosting libtcpsplice.[ah]
277TCPSPLICEDIR :=
278OPTIONS_CFLAGS += -DCONFIG_HAP_TCPSPLICE -I$(TCPSPLICEDIR)
279OPTIONS_LDFLAGS += -L$(TCPSPLICEDIR) -ltcpsplice
280BUILD_OPTIONS += $(call ignore_implicit,USE_TCPSPLICE)
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100281endif
282
Willy Tarreau77074d52006-11-12 23:57:19 +0100283ifneq ($(USE_CTTPROXY),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100284OPTIONS_CFLAGS += -DCONFIG_HAP_CTTPROXY
285OPTIONS_OBJS += src/cttproxy.o
286BUILD_OPTIONS += $(call ignore_implicit,USE_CTTPROXY)
Willy Tarreau77074d52006-11-12 23:57:19 +0100287endif
288
289ifneq ($(USE_TPROXY),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100290OPTIONS_CFLAGS += -DTPROXY
291BUILD_OPTIONS += $(call ignore_implicit,USE_TPROXY)
Willy Tarreau77074d52006-11-12 23:57:19 +0100292endif
293
294ifneq ($(USE_POLL),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100295OPTIONS_CFLAGS += -DENABLE_POLL
296OPTIONS_OBJS += src/ev_poll.o
297BUILD_OPTIONS += $(call ignore_implicit,USE_POLL)
Willy Tarreau77074d52006-11-12 23:57:19 +0100298endif
299
300ifneq ($(USE_EPOLL),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100301OPTIONS_CFLAGS += -DENABLE_EPOLL
302OPTIONS_OBJS += src/ev_epoll.o
303BUILD_OPTIONS += $(call ignore_implicit,USE_EPOLL)
Willy Tarreau77074d52006-11-12 23:57:19 +0100304endif
305
Willy Tarreaude99e992007-04-16 00:53:59 +0200306ifneq ($(USE_SEPOLL),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100307OPTIONS_CFLAGS += -DENABLE_SEPOLL
308OPTIONS_OBJS += src/ev_sepoll.o
309BUILD_OPTIONS += $(call ignore_implicit,USE_SEPOLL)
Willy Tarreaude99e992007-04-16 00:53:59 +0200310endif
311
Willy Tarreau77074d52006-11-12 23:57:19 +0100312ifneq ($(USE_MY_EPOLL),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100313OPTIONS_CFLAGS += -DUSE_MY_EPOLL
314BUILD_OPTIONS += $(call ignore_implicit,USE_MY_EPOLL)
315endif
316
317ifneq ($(USE_KQUEUE),)
318OPTIONS_CFLAGS += -DENABLE_KQUEUE
319OPTIONS_OBJS += src/ev_kqueue.o
320BUILD_OPTIONS += $(call ignore_implicit,USE_KQUEUE)
Willy Tarreau77074d52006-11-12 23:57:19 +0100321endif
322
323ifneq ($(USE_NETFILTER),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100324OPTIONS_CFLAGS += -DNETFILTER
325BUILD_OPTIONS += $(call ignore_implicit,USE_NETFILTER)
Willy Tarreau77074d52006-11-12 23:57:19 +0100326endif
327
328ifneq ($(USE_EPOLL_WORKAROUND),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100329OPTIONS_CFLAGS += -DEPOLL_CTL_MOD_WORKAROUND
330BUILD_OPTIONS += $(call ignore_implicit,USE_EPOLL_WORKAROUND)
Willy Tarreau77074d52006-11-12 23:57:19 +0100331endif
332
333ifneq ($(USE_GETSOCKNAME),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100334OPTIONS_CFLAGS += -DUSE_GETSOCKNAME
335BUILD_OPTIONS += $(call ignore_implicit,USE_GETSOCKNAME)
Willy Tarreau77074d52006-11-12 23:57:19 +0100336endif
337
338ifneq ($(USE_REGPARM),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100339OPTIONS_CFLAGS += -DCONFIG_HAP_USE_REGPARM
340BUILD_OPTIONS += $(call ignore_implicit,USE_REGPARM)
Willy Tarreau77074d52006-11-12 23:57:19 +0100341endif
342
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200343ifneq ($(DLMALLOC_SRC),)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100344# May be changed to match PAGE_SIZE on every platform
345DLMALLOC_THRES = 4096
346OPTIONS_OBJS += src/dlmalloc.o
347BUILD_OPTIONS += DLMALLOC_SRC=$(DLMALLOC_SRC)
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200348endif
349
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100350ifneq ($(USE_PCRE),)
351# PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is
352# automatically detected but can be forced if required.
353ifeq ($(PCREDIR),)
354PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local)
Willy Tarreau79b34bf2006-12-22 15:28:43 +0100355endif
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100356OPTIONS_CFLAGS += -DUSE_PCRE -I$(PCREDIR)/include
357OPTIONS_LDFLAGS += -L$(PCREDIR)/lib -lpcreposix -lpcre
358BUILD_OPTIONS += $(call ignore_implicit,USE_PCRE)
Willy Tarreau79b34bf2006-12-22 15:28:43 +0100359endif
360
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100361ifneq ($(USE_STATIC_PCRE),)
362# PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is
363# automatically detected but can be forced if required.
364ifeq ($(PCREDIR),)
365PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local)
366endif
367OPTIONS_CFLAGS += -DUSE_PCRE -I$(PCREDIR)/include
368OPTIONS_LDFLAGS += -L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
369BUILD_OPTIONS += $(call ignore_implicit,USE_STATIC_PCRE)
370endif
Willy Tarreau77074d52006-11-12 23:57:19 +0100371
372
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100373#### Global compile options
374VERBOSE_CFLAGS = $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE)
375COPTS = -Iinclude -Wall
376COPTS += $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE) $(SILENT_DEFINE)
377COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(ADDINC)
willy tarreaueedaa9f2005-12-17 14:08:03 +0100378
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100379ifneq ($(VERSION)$(SUBVERS),)
380COPTS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
381endif
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100382
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100383ifneq ($(VERDATE),)
384COPTS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100385endif
386
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100387#### Global link options
388# These options are added at the end of the "ld" command line. Use LDFLAGS to
389# add options at the beginning of the "ld" command line if needed.
390LDOPTS = $(TARGET_LDFLAGS) $(OPTIONS_LDFLAGS) $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +0100391
willy tarreau0f7af912005-12-17 12:21:26 +0100392
393all: haproxy
394
Willy Tarreaudd815982007-10-16 12:25:14 +0200395OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \
Willy Tarreaubaaee002006-06-26 02:48:02 +0200396 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
397 src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
Willy Tarreau92fb9832007-10-16 17:34:28 +0200398 src/checks.o src/queue.o src/client.o src/proxy.o src/proto_uxst.o \
Willy Tarreaubaaee002006-06-26 02:48:02 +0200399 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
Willy Tarreaue6b98942007-10-29 01:09:36 +0100400 src/senddata.o src/dumpstats.o src/proto_tcp.o \
Willy Tarreaue6d2e4d2007-11-15 23:56:17 +0100401 src/session.o src/hdr_idx.o src/ev_select.o \
402 src/acl.o src/memory.o \
403 src/ebtree.o src/eb32tree.o
Willy Tarreaubaaee002006-06-26 02:48:02 +0200404
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100405haproxy: $(OBJS) $(OPTIONS_OBJS)
406 $(LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
willy tarreau0f7af912005-12-17 12:21:26 +0100407
Willy Tarreaubaaee002006-06-26 02:48:02 +0200408objsize: haproxy
409 @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
410
willy tarreau0f7af912005-12-17 12:21:26 +0100411%.o: %.c
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100412 $(CC) $(COPTS) -c -o $@ $<
willy tarreau0f7af912005-12-17 12:21:26 +0100413
Willy Tarreau7b066db2007-12-02 11:28:59 +0100414src/haproxy.o: src/haproxy.c
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100415 $(CC) $(COPTS) \
416 -DBUILD_TARGET='"$(strip $(TARGET))"' \
417 -DBUILD_CPU='"$(strip $(CPU))"' \
418 -DBUILD_CC='"$(strip $(CC))"' \
419 -DBUILD_CFLAGS='"$(strip $(VERBOSE_CFLAGS))"' \
420 -DBUILD_OPTIONS='"$(strip $(BUILD_OPTIONS))"' \
421 -c -o $@ $<
Willy Tarreau7b066db2007-12-02 11:28:59 +0100422
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200423src/dlmalloc.o: $(DLMALLOC_SRC)
Willy Tarreau9f2b7302008-01-02 20:48:34 +0100424 $(CC) $(COPTS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200425
willy tarreau0f7af912005-12-17 12:21:26 +0100426clean:
Willy Tarreau1a587492006-10-15 23:40:58 +0200427 rm -f *.[oas] src/*.[oas] core haproxy test
428 for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100429 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz
430 rm -f haproxy-$(VERSION) nohup.out gmon.out
willy tarreauefae1842005-12-17 12:51:03 +0100431
willy tarreaue114bf92006-03-19 21:30:14 +0100432tar: clean
willy tarreaucee272f2006-03-19 21:16:26 +0100433 ln -s . haproxy-$(VERSION)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200434 tar --exclude=haproxy-$(VERSION)/.git \
435 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \
436 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \
437 -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz
willy tarreaucee272f2006-03-19 21:16:26 +0100438 rm -f haproxy-$(VERSION)
439
Willy Tarreau9f0a9012006-10-15 14:24:14 +0200440git-tar: clean
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100441 git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz
Willy Tarreauec692562007-09-09 23:31:11 +0200442
443version:
444 @echo "VERSION: $(VERSION)"
445 @echo "SUBVERS: $(SUBVERS)"
446 @echo "VERDATE: $(VERDATE)"
447
448# never use this one if you don't know what it is used for.
449update-version:
450 @echo "Ready to update the following versions :"
451 @echo "VERSION: $(VERSION)"
452 @echo "SUBVERS: $(SUBVERS)"
453 @echo "VERDATE: $(VERDATE)"
454 @echo "Press [ENTER] to continue or Ctrl-C to abort now.";read
455 echo "$(VERSION)" > VERSION
456 echo "$(SUBVERS)" > SUBVERS
457 echo "$(VERDATE)" > VERDATE