2008-01-02 19:48:34 +00:00
|
|
|
# This GNU Makefile supports different OS and CPU combinations.
|
|
|
|
#
|
2005-12-17 13:08:03 +00:00
|
|
|
# You should use it this way :
|
2009-04-11 17:45:50 +00:00
|
|
|
# [g]make TARGET=os ARCH=arch CPU=cpu USE_xxx=1 ...
|
2007-07-11 07:19:31 +00:00
|
|
|
#
|
2008-01-02 19:48:34 +00:00
|
|
|
# Valid USE_* options are the following. Most of them are automatically set by
|
|
|
|
# the TARGET, others have to be explictly specified :
|
|
|
|
# USE_CTTPROXY : enable CTTPROXY on Linux (needs kernel patch).
|
2008-02-19 09:53:32 +00:00
|
|
|
# USE_DLMALLOC : enable use of dlmalloc (see DLMALLOC_SRC)
|
2008-01-02 19:48:34 +00:00
|
|
|
# USE_EPOLL : enable epoll() on Linux 2.6. Automatic.
|
|
|
|
# USE_GETSOCKNAME : enable getsockname() on Linux 2.2. Automatic.
|
|
|
|
# USE_KQUEUE : enable kqueue() on BSD. Automatic.
|
|
|
|
# USE_MY_EPOLL : redefine epoll_* syscalls. Automatic.
|
|
|
|
# USE_NETFILTER : enable netfilter on Linux. Automatic.
|
|
|
|
# USE_PCRE : enable use of libpcre for regex. Recommended.
|
|
|
|
# USE_POLL : enable poll(). Automatic.
|
|
|
|
# USE_REGPARM : enable regparm optimization. Recommended on x86.
|
|
|
|
# USE_SEPOLL : enable speculative epoll(). Automatic.
|
|
|
|
# USE_STATIC_PCRE : enable static libpcre. Recommended.
|
|
|
|
# USE_TPROXY : enable transparent proxy. Automatic.
|
2010-04-25 20:35:17 +00:00
|
|
|
# USE_LINUX_TPROXY : enable full transparent proxy (needs kernel 2.6.28).
|
2009-01-25 15:13:42 +00:00
|
|
|
# USE_LINUX_SPLICE : enable kernel 2.6 splicing (broken on old kernels)
|
[BUILD] fix platform-dependant build issues related to crypt()
Holger Just and Ross West reported build issues on FreeBSD and
Solaris that were initially caused by the definition of
_XOPEN_SOURCE at the top of auth.c, which was required on Linux
to avoid a build warning.
Krzysztof Oledzki found that using _GNU_SOURCE instead also worked
on Linux and did not cause any issue on several versions of FreeBSD.
Solaris still reported a warning this time, which was fixed by
including <crypt.h>, which itself is not present on FreeBSD nor on
all Linux toolchains.
So by adding a new build option (NEED_CRYPT_H), we can get Solaris
to get crypt() working and stop complaining at the same time, without
impacting other platforms.
This fix was tested at least on several linux toolchains (at least
uclibc, glibc 2.2.5, 2.3.6 and 2.7), on FreeBSD 4 to 8, Solaris 8
(which needs crypt.h), and AIX 5.3 (without crypt.h).
Every time it builds without a warning.
2010-03-04 18:10:14 +00:00
|
|
|
# USE_LIBCRYPT : enable crypted passwords using -lcrypt
|
|
|
|
# USE_CRYPT_H : set it if your system requires including crypt.h
|
2007-07-11 07:19:31 +00:00
|
|
|
#
|
2008-01-02 19:48:34 +00:00
|
|
|
# Options can be forced by specifying "USE_xxx=1" or can be disabled by using
|
|
|
|
# "USE_xxx=" (empty string).
|
|
|
|
#
|
|
|
|
# Variables useful for packagers :
|
|
|
|
# CC is set to "gcc" by default and is used for compilation only.
|
|
|
|
# LD is set to "gcc" by default and is used for linking only.
|
2009-04-11 17:45:50 +00:00
|
|
|
# ARCH may be useful to force build of 32-bit binary on 64-bit systems
|
2008-01-02 19:48:34 +00:00
|
|
|
# CFLAGS is automatically set for the specified CPU and may be overridden.
|
|
|
|
# LDFLAGS is automatically set to -g and may be overridden.
|
|
|
|
# SMALL_OPTS may be used to specify some options to shrink memory usage.
|
|
|
|
# DEBUG may be used to set some internal debugging options.
|
|
|
|
# ADDINC may be used to complete the include path in the form -Ipath.
|
|
|
|
# ADDLIB may be used to complete the library list in the form -Lpath -llib.
|
|
|
|
# DEFINE may be used to specify any additional define, which will be reported
|
|
|
|
# by "haproxy -vv" in CFLAGS.
|
|
|
|
# SILENT_DEFINE may be used to specify other defines which will not be
|
|
|
|
# reported by "haproxy -vv".
|
2008-03-12 13:25:35 +00:00
|
|
|
# DESTDIR is not set by default and is used for installation only.
|
|
|
|
# It might be useful to set DESTDIR if you want to install haproxy
|
|
|
|
# in a sandbox.
|
|
|
|
# PREFIX is set to "/usr/local" by default and is used for installation only.
|
|
|
|
# SBINDIR is set to "$(PREFIX)/sbin" by default and is used for installation
|
|
|
|
# only.
|
2008-03-12 13:57:54 +00:00
|
|
|
# MANDIR is set to "$(PREFIX)/share/man" by default and is used for
|
|
|
|
# installation only.
|
2008-03-12 15:24:49 +00:00
|
|
|
# DOCDIR is set to "$(PREFIX)/doc/haproxy" by default and is used for
|
|
|
|
# installation only.
|
2008-01-02 19:48:34 +00:00
|
|
|
#
|
|
|
|
# Other variables :
|
|
|
|
# DLMALLOC_SRC : build with dlmalloc, indicate the location of dlmalloc.c.
|
|
|
|
# DLMALLOC_THRES : should match PAGE_SIZE on every platform (default: 4096).
|
|
|
|
# PCREDIR : force the path to libpcre.
|
|
|
|
# IGNOREGIT : ignore GIT commit versions if set.
|
|
|
|
# VERSION : force haproxy version reporting.
|
|
|
|
# SUBVERS : add a sub-version (eg: platform, model, ...).
|
|
|
|
# VERDATE : force haproxy's release date.
|
|
|
|
|
2008-03-12 13:25:35 +00:00
|
|
|
#### Installation options.
|
|
|
|
DESTDIR =
|
|
|
|
PREFIX = /usr/local
|
|
|
|
SBINDIR = $(PREFIX)/sbin
|
2008-11-16 00:29:03 +00:00
|
|
|
MANDIR = $(PREFIX)/share/man
|
2008-03-12 15:24:49 +00:00
|
|
|
DOCDIR = $(PREFIX)/doc/haproxy
|
2008-01-02 19:48:34 +00:00
|
|
|
|
|
|
|
#### TARGET system
|
|
|
|
# Use TARGET=<target_name> to optimize for a specifc target OS among the
|
|
|
|
# following list (use the default "generic" if uncertain) :
|
2009-03-29 13:08:25 +00:00
|
|
|
# generic, linux22, linux24, linux24e, linux26, solaris,
|
2009-06-14 16:27:54 +00:00
|
|
|
# freebsd, openbsd, cygwin, custom
|
2008-03-11 05:37:39 +00:00
|
|
|
TARGET =
|
2008-01-02 19:48:34 +00:00
|
|
|
|
|
|
|
#### TARGET CPU
|
|
|
|
# Use CPU=<cpu_name> to optimize for a particular CPU, among the following
|
|
|
|
# list :
|
|
|
|
# generic, i586, i686, ultrasparc, custom
|
2005-12-17 13:08:03 +00:00
|
|
|
CPU = generic
|
2005-12-17 11:21:26 +00:00
|
|
|
|
2009-04-11 17:45:50 +00:00
|
|
|
#### Architecture, used when not building for native architecture
|
|
|
|
# Use ARCH=<arch_name> to force build for a specific architecture. Known
|
|
|
|
# architectures will lead to "-m32" or "-m64" being added to CFLAGS and
|
|
|
|
# LDFLAGS. This can be required to build 32-bit binaries on 64-bit targets.
|
|
|
|
# Currently, only x86_64, i386, i486, i586 and i686 are understood.
|
|
|
|
ARCH =
|
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Toolchain options.
|
|
|
|
# GCC is normally used both for compiling and linking.
|
2005-12-17 13:08:03 +00:00
|
|
|
CC = gcc
|
2008-03-17 17:23:12 +00:00
|
|
|
LD = $(CC)
|
2005-12-17 13:08:03 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Debug flags (typically "-g").
|
|
|
|
# Those flags only feed CFLAGS so it is not mandatory to use this form.
|
|
|
|
DEBUG_CFLAGS = -g
|
2005-12-17 11:48:26 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Memory usage tuning
|
|
|
|
# If small memory footprint is required, you can reduce the buffer size. There
|
|
|
|
# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
|
|
|
|
# with 1000 concurrent sessions. Putting it slightly lower than a page size
|
|
|
|
# will prevent the additional parameters to go beyond a page. 8030 bytes is
|
|
|
|
# exactly 5.5 TCP segments of 1460 bytes and is generally good. Useful tuning
|
|
|
|
# macros include :
|
|
|
|
# SYSTEM_MAXCONN, BUFSIZE, MAXREWRITE, REQURI_LEN, CAPTURE_LEN.
|
|
|
|
# Example: SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
|
|
|
|
SMALL_OPTS =
|
2005-12-17 11:21:26 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Debug settings
|
|
|
|
# You can enable debugging on specific code parts by setting DEBUG=-DDEBUG_xxx.
|
|
|
|
# Currently defined DEBUG macros include DEBUG_FULL, DEBUG_MEMORY, DEBUG_FSM,
|
2010-01-29 16:50:44 +00:00
|
|
|
# DEBUG_HASH and DEBUG_AUTH. Please check sources for exact meaning or do not
|
|
|
|
# use at all.
|
2008-01-02 19:48:34 +00:00
|
|
|
DEBUG =
|
2005-12-17 13:08:03 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Additional include and library dirs
|
|
|
|
# Redefine this if you want to add some special PATH to include/libs
|
|
|
|
ADDINC =
|
|
|
|
ADDLIB =
|
2005-12-17 12:46:33 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Specific macro definitions
|
|
|
|
# Use DEFINE=-Dxxx to set any tunable macro. Anything declared here will appear
|
|
|
|
# in the build options reported by "haproxy -vv". Use SILENT_DEFINE if you do
|
|
|
|
# not want to pollute the report with complex defines.
|
|
|
|
DEFINE =
|
|
|
|
SILENT_DEFINE =
|
|
|
|
|
|
|
|
|
|
|
|
#### CPU dependant optimizations
|
|
|
|
# Some CFLAGS are set by default depending on the target CPU. Those flags only
|
|
|
|
# feed CPU_CFLAGS, which in turn feed CFLAGS, so it is not mandatory to use
|
|
|
|
# them. You should not have to change these options. Better use CPU_CFLAGS or
|
|
|
|
# even CFLAGS instead.
|
|
|
|
CPU_CFLAGS.generic = -O2
|
|
|
|
CPU_CFLAGS.i586 = -O2 -march=i586
|
|
|
|
CPU_CFLAGS.i686 = -O2 -march=i686
|
|
|
|
CPU_CFLAGS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
|
|
|
|
CPU_CFLAGS = $(CPU_CFLAGS.$(CPU))
|
|
|
|
|
2009-04-11 17:45:50 +00:00
|
|
|
#### ARCH dependant flags, may be overriden by CPU flags
|
|
|
|
ARCH_FLAGS.i386 = -m32 -march=i386
|
|
|
|
ARCH_FLAGS.i486 = -m32 -march=i486
|
|
|
|
ARCH_FLAGS.i586 = -m32 -march=i586
|
|
|
|
ARCH_FLAGS.i686 = -m32 -march=i686
|
|
|
|
ARCH_FLAGS.x86_64 = -m64 -march=x86-64
|
|
|
|
ARCH_FLAGS = $(ARCH_FLAGS.$(ARCH))
|
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Common CFLAGS
|
|
|
|
# These CFLAGS contain general optimization options, CPU-specific optimizations
|
|
|
|
# and debug flags. They may be overridden by some distributions which prefer to
|
|
|
|
# set all of them at once instead of playing with the CPU and DEBUG variables.
|
2009-04-11 17:45:50 +00:00
|
|
|
CFLAGS = $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS)
|
2008-01-02 19:48:34 +00:00
|
|
|
|
|
|
|
#### Common LDFLAGS
|
|
|
|
# These LDFLAGS are used as the first "ld" options, regardless of any library
|
|
|
|
# path or any other option. They may be changed to add any linker-specific
|
|
|
|
# option at the beginning of the ld command line.
|
2009-04-11 17:45:50 +00:00
|
|
|
LDFLAGS = $(ARCH_FLAGS) -g
|
2005-12-17 12:46:33 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Target system options
|
|
|
|
# Depending on the target platform, some options are set, as well as some
|
|
|
|
# CFLAGS and LDFLAGS. The USE_* values are set to "implicit" so that they are
|
|
|
|
# not reported in the build options string. You should not have to change
|
|
|
|
# anything there.
|
|
|
|
ifeq ($(TARGET),generic)
|
|
|
|
# generic system target has nothing specific
|
|
|
|
USE_POLL = implicit
|
|
|
|
USE_TPROXY = implicit
|
|
|
|
else
|
|
|
|
ifeq ($(TARGET),linux22)
|
|
|
|
# This is for Linux 2.2
|
|
|
|
USE_GETSOCKNAME = implicit
|
|
|
|
USE_POLL = implicit
|
|
|
|
USE_TPROXY = implicit
|
2010-01-29 16:50:44 +00:00
|
|
|
USE_LIBCRYPT = implicit
|
2008-01-02 19:48:34 +00:00
|
|
|
else
|
|
|
|
ifeq ($(TARGET),linux24)
|
|
|
|
# This is for standard Linux 2.4 with netfilter but without epoll()
|
|
|
|
USE_GETSOCKNAME = implicit
|
|
|
|
USE_NETFILTER = implicit
|
|
|
|
USE_POLL = implicit
|
|
|
|
USE_TPROXY = implicit
|
2010-01-29 16:50:44 +00:00
|
|
|
USE_LIBCRYPT = implicit
|
2008-01-02 19:48:34 +00:00
|
|
|
else
|
|
|
|
ifeq ($(TARGET),linux24e)
|
|
|
|
# This is for enhanced Linux 2.4 with netfilter and epoll() patch > 0.21
|
|
|
|
USE_GETSOCKNAME = implicit
|
|
|
|
USE_NETFILTER = implicit
|
|
|
|
USE_POLL = implicit
|
|
|
|
USE_EPOLL = implicit
|
|
|
|
USE_SEPOLL = implicit
|
|
|
|
USE_MY_EPOLL = implicit
|
|
|
|
USE_TPROXY = implicit
|
2010-01-29 16:50:44 +00:00
|
|
|
USE_LIBCRYPT = implicit
|
2008-01-02 19:48:34 +00:00
|
|
|
else
|
|
|
|
ifeq ($(TARGET),linux26)
|
|
|
|
# This is for standard Linux 2.6 with netfilter and standard epoll()
|
|
|
|
USE_GETSOCKNAME = implicit
|
|
|
|
USE_NETFILTER = implicit
|
|
|
|
USE_POLL = implicit
|
|
|
|
USE_EPOLL = implicit
|
|
|
|
USE_SEPOLL = implicit
|
|
|
|
USE_TPROXY = implicit
|
2010-01-29 16:50:44 +00:00
|
|
|
USE_LIBCRYPT = implicit
|
2008-01-02 19:48:34 +00:00
|
|
|
else
|
|
|
|
ifeq ($(TARGET),solaris)
|
|
|
|
# This is for Solaris 8
|
|
|
|
USE_POLL = implicit
|
|
|
|
TARGET_CFLAGS = -fomit-frame-pointer -DFD_SETSIZE=65536 -D_REENTRANT
|
|
|
|
TARGET_LDFLAGS = -lnsl -lsocket
|
|
|
|
USE_TPROXY = implicit
|
[BUILD] fix platform-dependant build issues related to crypt()
Holger Just and Ross West reported build issues on FreeBSD and
Solaris that were initially caused by the definition of
_XOPEN_SOURCE at the top of auth.c, which was required on Linux
to avoid a build warning.
Krzysztof Oledzki found that using _GNU_SOURCE instead also worked
on Linux and did not cause any issue on several versions of FreeBSD.
Solaris still reported a warning this time, which was fixed by
including <crypt.h>, which itself is not present on FreeBSD nor on
all Linux toolchains.
So by adding a new build option (NEED_CRYPT_H), we can get Solaris
to get crypt() working and stop complaining at the same time, without
impacting other platforms.
This fix was tested at least on several linux toolchains (at least
uclibc, glibc 2.2.5, 2.3.6 and 2.7), on FreeBSD 4 to 8, Solaris 8
(which needs crypt.h), and AIX 5.3 (without crypt.h).
Every time it builds without a warning.
2010-03-04 18:10:14 +00:00
|
|
|
USE_LIBCRYPT = implicit
|
|
|
|
USE_CRYPT_H = implicit
|
2008-01-02 19:48:34 +00:00
|
|
|
else
|
|
|
|
ifeq ($(TARGET),freebsd)
|
|
|
|
# This is for FreeBSD
|
|
|
|
USE_POLL = implicit
|
|
|
|
USE_KQUEUE = implicit
|
|
|
|
USE_TPROXY = implicit
|
2010-01-29 16:50:44 +00:00
|
|
|
USE_LIBCRYPT = implicit
|
2008-01-02 19:48:34 +00:00
|
|
|
else
|
|
|
|
ifeq ($(TARGET),openbsd)
|
|
|
|
# This is for OpenBSD >= 3.0
|
|
|
|
USE_POLL = implicit
|
|
|
|
USE_KQUEUE = implicit
|
|
|
|
USE_TPROXY = implicit
|
2009-06-14 16:27:54 +00:00
|
|
|
else
|
|
|
|
ifeq ($(TARGET),cygwin)
|
|
|
|
# This is for Cygwin
|
|
|
|
# Cygwin adds IPv6 support only in version 1.7 (in beta right now).
|
|
|
|
USE_POLL = implicit
|
|
|
|
USE_TPROXY = implicit
|
|
|
|
TARGET_CFLAGS = $(if $(filter 1.5.%, $(shell uname -r)), -DUSE_IPV6 -DAF_INET6=23 -DINET6_ADDRSTRLEN=46, )
|
|
|
|
endif # cygwin
|
2008-01-02 19:48:34 +00:00
|
|
|
endif # openbsd
|
|
|
|
endif # freebsd
|
|
|
|
endif # solaris
|
|
|
|
endif # linux26
|
|
|
|
endif # linux24e
|
|
|
|
endif # linux24
|
|
|
|
endif # linux22
|
|
|
|
endif # generic
|
|
|
|
|
|
|
|
|
|
|
|
#### Old-style REGEX library settings for compatibility with previous setups.
|
|
|
|
# It is still possible to use REGEX=<regex_lib> to select an alternative regex
|
|
|
|
# library. By default, we use libc's regex. On Solaris 8/Sparc, grouping seems
|
|
|
|
# to be broken using libc, so consider using pcre instead. Supported values are
|
|
|
|
# "libc", "pcre", and "static-pcre". Use of this method is deprecated in favor
|
|
|
|
# of "USE_PCRE" and "USE_STATIC_PCRE" (see build options below).
|
|
|
|
REGEX = libc
|
|
|
|
|
|
|
|
ifeq ($(REGEX),pcre)
|
|
|
|
USE_PCRE = 1
|
|
|
|
$(warning WARNING! use of "REGEX=pcre" is deprecated, consider using "USE_PCRE=1" instead.)
|
|
|
|
endif
|
2005-12-18 00:32:31 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
ifeq ($(REGEX),static-pcre)
|
|
|
|
USE_STATIC_PCRE = 1
|
|
|
|
$(warning WARNING! use of "REGEX=pcre-static" is deprecated, consider using "USE_STATIC_PCRE=1" instead.)
|
|
|
|
endif
|
2005-12-17 11:29:56 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Old-style TPROXY settings
|
|
|
|
ifneq ($(findstring -DTPROXY,$(DEFINE)),)
|
|
|
|
USE_TPROXY = 1
|
|
|
|
$(warning WARNING! use of "DEFINE=-DTPROXY" is deprecated, consider using "USE_TPROXY=1" instead.)
|
|
|
|
endif
|
2005-12-18 00:02:42 +00:00
|
|
|
|
2005-12-18 00:11:29 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Determine version, sub-version and release date.
|
|
|
|
# If GIT is found, and IGNOREGIT is not set, VERSION, SUBVERS and VERDATE are
|
|
|
|
# extracted from the last commit. Otherwise, use the contents of the files
|
|
|
|
# holding the same names in the current directory.
|
2005-12-18 00:02:42 +00:00
|
|
|
|
2007-01-01 23:44:53 +00:00
|
|
|
ifeq ($(IGNOREGIT),)
|
2009-07-23 11:43:33 +00:00
|
|
|
VERSION := $(shell [ -d .git/. ] && ref=`(git describe --tags) 2>/dev/null` && ref=$${ref%-g*} && echo "$${ref\#v}")
|
2006-12-23 10:12:04 +00:00
|
|
|
ifneq ($(VERSION),)
|
|
|
|
# OK git is there and works.
|
2009-07-14 11:24:16 +00:00
|
|
|
SUBVERS := $(shell comms=`git log --no-merges v$(VERSION).. 2>/dev/null |grep -c ^commit `; [ $$comms -gt 0 ] && echo "-$$comms" )
|
|
|
|
VERDATE := $(shell date +%Y/%m/%d -d "`git log --pretty=fuller HEAD^.. 2>/dev/null | sed -ne '/^CommitDate:/{s/\(^[^ ]*:\)\|\( [-+].*\)//gp;q}'`" )
|
2007-09-09 21:31:11 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
# Last commit version not found, take it from the files.
|
2007-09-09 21:31:11 +00:00
|
|
|
ifeq ($(VERSION),)
|
|
|
|
VERSION := $(shell cat VERSION 2>/dev/null || touch VERSION)
|
|
|
|
endif
|
|
|
|
ifeq ($(SUBVERS),)
|
|
|
|
SUBVERS := $(shell cat SUBVERS 2>/dev/null || touch SUBVERS)
|
|
|
|
endif
|
|
|
|
ifeq ($(VERDATE),)
|
|
|
|
VERDATE := $(shell cat VERDATE 2>/dev/null || touch VERDATE)
|
2006-12-23 10:12:04 +00:00
|
|
|
endif
|
2006-11-12 22:57:19 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Build options
|
|
|
|
# Do not change these ones, enable USE_* variables instead.
|
|
|
|
OPTIONS_CFLAGS =
|
|
|
|
OPTIONS_LDFLAGS =
|
|
|
|
OPTIONS_OBJS =
|
|
|
|
|
|
|
|
# This variable collects all USE_* values except those set to "implicit". This
|
|
|
|
# is used to report a list of all flags which were used to build this version.
|
|
|
|
# Do not assign anything to it.
|
|
|
|
BUILD_OPTIONS =
|
2006-11-12 22:57:19 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
# Return USE_xxx=$(USE_xxx) unless $(USE_xxx) = "implicit"
|
|
|
|
# Usage:
|
|
|
|
# BUILD_OPTIONS += $(call ignore_implicit,USE_xxx)
|
|
|
|
ignore_implicit = $(patsubst %=implicit,,$(1)=$($(1)))
|
2006-11-12 22:57:19 +00:00
|
|
|
|
2007-01-07 01:03:04 +00:00
|
|
|
ifneq ($(USE_TCPSPLICE),)
|
2009-08-16 11:20:32 +00:00
|
|
|
$(error experimental option USE_TCPSPLICE has been removed, check USE_LINUX_SPLICE)
|
2007-01-07 01:03:04 +00:00
|
|
|
endif
|
|
|
|
|
2009-01-25 15:13:42 +00:00
|
|
|
ifneq ($(USE_LINUX_SPLICE),)
|
|
|
|
OPTIONS_CFLAGS += -DCONFIG_HAP_LINUX_SPLICE
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_LINUX_SPLICE)
|
|
|
|
endif
|
|
|
|
|
2006-11-12 22:57:19 +00:00
|
|
|
ifneq ($(USE_CTTPROXY),)
|
2008-01-02 19:48:34 +00:00
|
|
|
OPTIONS_CFLAGS += -DCONFIG_HAP_CTTPROXY
|
|
|
|
OPTIONS_OBJS += src/cttproxy.o
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_CTTPROXY)
|
2006-11-12 22:57:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_TPROXY),)
|
2008-01-02 19:48:34 +00:00
|
|
|
OPTIONS_CFLAGS += -DTPROXY
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_TPROXY)
|
2006-11-12 22:57:19 +00:00
|
|
|
endif
|
|
|
|
|
2008-01-13 13:49:51 +00:00
|
|
|
ifneq ($(USE_LINUX_TPROXY),)
|
|
|
|
OPTIONS_CFLAGS += -DCONFIG_HAP_LINUX_TPROXY
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_LINUX_TPROXY)
|
|
|
|
endif
|
|
|
|
|
2010-01-29 16:50:44 +00:00
|
|
|
ifneq ($(USE_LIBCRYPT),)
|
|
|
|
OPTIONS_CFLAGS += -DCONFIG_HAP_CRYPT
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_LIBCRYPT)
|
|
|
|
OPTIONS_LDFLAGS += -lcrypt
|
|
|
|
endif
|
|
|
|
|
[BUILD] fix platform-dependant build issues related to crypt()
Holger Just and Ross West reported build issues on FreeBSD and
Solaris that were initially caused by the definition of
_XOPEN_SOURCE at the top of auth.c, which was required on Linux
to avoid a build warning.
Krzysztof Oledzki found that using _GNU_SOURCE instead also worked
on Linux and did not cause any issue on several versions of FreeBSD.
Solaris still reported a warning this time, which was fixed by
including <crypt.h>, which itself is not present on FreeBSD nor on
all Linux toolchains.
So by adding a new build option (NEED_CRYPT_H), we can get Solaris
to get crypt() working and stop complaining at the same time, without
impacting other platforms.
This fix was tested at least on several linux toolchains (at least
uclibc, glibc 2.2.5, 2.3.6 and 2.7), on FreeBSD 4 to 8, Solaris 8
(which needs crypt.h), and AIX 5.3 (without crypt.h).
Every time it builds without a warning.
2010-03-04 18:10:14 +00:00
|
|
|
ifneq ($(USE_CRYPT_H),)
|
|
|
|
OPTIONS_CFLAGS += -DNEED_CRYPT_H
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_CRYPT_H)
|
|
|
|
endif
|
|
|
|
|
2006-11-12 22:57:19 +00:00
|
|
|
ifneq ($(USE_POLL),)
|
2008-01-02 19:48:34 +00:00
|
|
|
OPTIONS_CFLAGS += -DENABLE_POLL
|
|
|
|
OPTIONS_OBJS += src/ev_poll.o
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_POLL)
|
2006-11-12 22:57:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_EPOLL),)
|
2008-01-02 19:48:34 +00:00
|
|
|
OPTIONS_CFLAGS += -DENABLE_EPOLL
|
|
|
|
OPTIONS_OBJS += src/ev_epoll.o
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_EPOLL)
|
2006-11-12 22:57:19 +00:00
|
|
|
endif
|
|
|
|
|
2007-04-15 22:53:59 +00:00
|
|
|
ifneq ($(USE_SEPOLL),)
|
2008-01-02 19:48:34 +00:00
|
|
|
OPTIONS_CFLAGS += -DENABLE_SEPOLL
|
|
|
|
OPTIONS_OBJS += src/ev_sepoll.o
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_SEPOLL)
|
2007-04-15 22:53:59 +00:00
|
|
|
endif
|
|
|
|
|
2006-11-12 22:57:19 +00:00
|
|
|
ifneq ($(USE_MY_EPOLL),)
|
2008-01-02 19:48:34 +00:00
|
|
|
OPTIONS_CFLAGS += -DUSE_MY_EPOLL
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_MY_EPOLL)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_KQUEUE),)
|
|
|
|
OPTIONS_CFLAGS += -DENABLE_KQUEUE
|
|
|
|
OPTIONS_OBJS += src/ev_kqueue.o
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_KQUEUE)
|
2006-11-12 22:57:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_NETFILTER),)
|
2008-01-02 19:48:34 +00:00
|
|
|
OPTIONS_CFLAGS += -DNETFILTER
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_NETFILTER)
|
2006-11-12 22:57:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_GETSOCKNAME),)
|
2008-01-02 19:48:34 +00:00
|
|
|
OPTIONS_CFLAGS += -DUSE_GETSOCKNAME
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_GETSOCKNAME)
|
2006-11-12 22:57:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_REGPARM),)
|
2009-10-27 20:40:18 +00:00
|
|
|
OPTIONS_CFLAGS += -DCONFIG_REGPARM=3
|
2008-01-02 19:48:34 +00:00
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_REGPARM)
|
2006-11-12 22:57:19 +00:00
|
|
|
endif
|
|
|
|
|
2008-03-07 09:02:14 +00:00
|
|
|
# report DLMALLOC_SRC only if explicitly specified
|
|
|
|
ifneq ($(DLMALLOC_SRC),)
|
|
|
|
BUILD_OPTIONS += DLMALLOC_SRC=$(DLMALLOC_SRC)
|
|
|
|
endif
|
|
|
|
|
2008-02-19 09:53:32 +00:00
|
|
|
ifneq ($(USE_DLMALLOC),)
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_DLMALLOC)
|
|
|
|
ifeq ($(DLMALLOC_SRC),)
|
|
|
|
DLMALLOC_SRC=src/dlmalloc.c
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2007-07-11 07:19:31 +00:00
|
|
|
ifneq ($(DLMALLOC_SRC),)
|
2008-03-07 09:02:14 +00:00
|
|
|
# DLMALLOC_THRES may be changed to match PAGE_SIZE on every platform
|
2008-01-02 19:48:34 +00:00
|
|
|
DLMALLOC_THRES = 4096
|
|
|
|
OPTIONS_OBJS += src/dlmalloc.o
|
2007-07-11 07:19:31 +00:00
|
|
|
endif
|
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
ifneq ($(USE_PCRE),)
|
|
|
|
# PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is
|
|
|
|
# automatically detected but can be forced if required.
|
|
|
|
ifeq ($(PCREDIR),)
|
|
|
|
PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local)
|
2006-12-22 14:28:43 +00:00
|
|
|
endif
|
2008-11-20 13:47:04 +00:00
|
|
|
ifeq ($(USE_STATIC_PCRE),)
|
2008-01-02 19:48:34 +00:00
|
|
|
OPTIONS_CFLAGS += -DUSE_PCRE -I$(PCREDIR)/include
|
|
|
|
OPTIONS_LDFLAGS += -L$(PCREDIR)/lib -lpcreposix -lpcre
|
2008-11-20 13:47:04 +00:00
|
|
|
endif
|
2008-01-02 19:48:34 +00:00
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_PCRE)
|
2006-12-22 14:28:43 +00:00
|
|
|
endif
|
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
ifneq ($(USE_STATIC_PCRE),)
|
|
|
|
# PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is
|
|
|
|
# automatically detected but can be forced if required.
|
|
|
|
ifeq ($(PCREDIR),)
|
|
|
|
PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local)
|
|
|
|
endif
|
|
|
|
OPTIONS_CFLAGS += -DUSE_PCRE -I$(PCREDIR)/include
|
|
|
|
OPTIONS_LDFLAGS += -L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
|
|
|
|
BUILD_OPTIONS += $(call ignore_implicit,USE_STATIC_PCRE)
|
|
|
|
endif
|
2006-11-12 22:57:19 +00:00
|
|
|
|
2009-10-26 20:10:04 +00:00
|
|
|
# This one can be changed to look for ebtree files in an external directory
|
|
|
|
EBTREE_DIR := ebtree
|
2006-11-12 22:57:19 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Global compile options
|
|
|
|
VERBOSE_CFLAGS = $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE)
|
2009-10-26 20:10:04 +00:00
|
|
|
COPTS = -Iinclude -I$(EBTREE_DIR) -Wall
|
2008-01-02 19:48:34 +00:00
|
|
|
COPTS += $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE) $(SILENT_DEFINE)
|
|
|
|
COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(ADDINC)
|
2005-12-17 13:08:03 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
ifneq ($(VERSION)$(SUBVERS),)
|
|
|
|
COPTS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
|
|
|
|
endif
|
2007-01-07 01:03:04 +00:00
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
ifneq ($(VERDATE),)
|
|
|
|
COPTS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
|
2007-01-07 01:03:04 +00:00
|
|
|
endif
|
|
|
|
|
2008-01-02 19:48:34 +00:00
|
|
|
#### Global link options
|
|
|
|
# These options are added at the end of the "ld" command line. Use LDFLAGS to
|
|
|
|
# add options at the beginning of the "ld" command line if needed.
|
|
|
|
LDOPTS = $(TARGET_LDFLAGS) $(OPTIONS_LDFLAGS) $(ADDLIB)
|
2005-12-17 11:29:56 +00:00
|
|
|
|
2008-03-11 05:37:39 +00:00
|
|
|
ifeq ($(TARGET),)
|
|
|
|
all:
|
|
|
|
@echo
|
|
|
|
@echo "Due to too many reports of suboptimized setups, building without"
|
|
|
|
@echo "specifying the target is no longer supported. Please specify the"
|
|
|
|
@echo "target OS in the TARGET variable, in the following form:"
|
|
|
|
@echo
|
|
|
|
@echo " $ make TARGET=xxx"
|
|
|
|
@echo
|
|
|
|
@echo "Please choose the target among the following supported list :"
|
|
|
|
@echo
|
2009-03-29 13:08:25 +00:00
|
|
|
@echo " linux26, linux24, linux24e, linux22, solaris"
|
2009-06-14 16:27:54 +00:00
|
|
|
@echo " freebsd, openbsd, cygwin, custom, generic"
|
2008-03-11 05:37:39 +00:00
|
|
|
@echo
|
|
|
|
@echo "Use \"generic\" if you don't want any optimization, \"custom\" if you"
|
|
|
|
@echo "want to precisely tweak every option, or choose the target which"
|
|
|
|
@echo "matches your OS the most in order to gain the maximum performance"
|
|
|
|
@echo "out of it. Please check the Makefile in case of doubts."
|
|
|
|
@echo
|
|
|
|
@exit 1
|
|
|
|
else
|
2005-12-17 11:21:26 +00:00
|
|
|
all: haproxy
|
2008-03-11 05:37:39 +00:00
|
|
|
endif
|
2005-12-17 11:21:26 +00:00
|
|
|
|
2007-10-16 10:25:14 +00:00
|
|
|
OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \
|
2006-06-26 00:48:02 +00:00
|
|
|
src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
|
2009-01-25 12:49:53 +00:00
|
|
|
src/time.o src/fd.o src/pipe.o src/regex.o src/cfgparse.o src/server.o \
|
2010-05-24 19:02:37 +00:00
|
|
|
src/checks.o src/queue.o src/frontend.o src/proxy.o src/stick_table.o src/proto_uxst.o \
|
2006-06-26 00:48:02 +00:00
|
|
|
src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
|
[MEDIUM] backend: implement consistent hashing variation
Consistent hashing provides some interesting advantages over common
hashing. It avoids full redistribution in case of a server failure,
or when expanding the farm. This has a cost however, the hashing is
far from being perfect, as we associate a server to a request by
searching the server with the closest key in a tree. Since servers
appear multiple times based on their weights, it is recommended to
use weights larger than approximately 10-20 in order to smoothen
the distribution a bit.
In some cases, playing with weights will be the only solution to
make a server appear more often and increase chances of being picked,
so stats are very important with consistent hashing.
In order to indicate the type of hashing, use :
hash-type map-based (default, old one)
hash-type consistent (new one)
Consistent hashing can make sense in a cache farm, in order not
to redistribute everyone when a cache changes state. It could also
probably be used for long sessions such as terminal sessions, though
that has not be attempted yet.
More details on this method of hashing here :
http://www.spiteful.com/2008/03/17/programmers-toolbox-part-3-consistent-hashing/
2009-10-01 05:52:15 +00:00
|
|
|
src/lb_chash.o src/lb_fwlc.o src/lb_fwrr.o src/lb_map.o \
|
2008-11-30 18:48:07 +00:00
|
|
|
src/stream_interface.o src/dumpstats.o src/proto_tcp.o \
|
2009-05-10 07:00:20 +00:00
|
|
|
src/session.o src/hdr_idx.o src/ev_select.o src/signal.o \
|
2010-01-29 16:50:44 +00:00
|
|
|
src/acl.o src/pattern.o src/memory.o src/freq_ctr.o src/auth.o
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2009-10-26 20:10:04 +00:00
|
|
|
EBTREE_OBJS = $(EBTREE_DIR)/ebtree.o \
|
|
|
|
$(EBTREE_DIR)/eb32tree.o $(EBTREE_DIR)/eb64tree.o \
|
|
|
|
$(EBTREE_DIR)/ebmbtree.o $(EBTREE_DIR)/ebsttree.o \
|
|
|
|
$(EBTREE_DIR)/ebimtree.o $(EBTREE_DIR)/ebistree.o
|
|
|
|
|
|
|
|
# Not used right now
|
|
|
|
LIB_EBTREE = $(EBTREE_DIR)/libebtree.a
|
|
|
|
|
|
|
|
haproxy: $(OBJS) $(OPTIONS_OBJS) $(EBTREE_OBJS)
|
2008-01-02 19:48:34 +00:00
|
|
|
$(LD) $(LDFLAGS) -o $@ $^ $(LDOPTS)
|
2005-12-17 11:21:26 +00:00
|
|
|
|
2009-10-26 20:10:04 +00:00
|
|
|
$(LIB_EBTREE): $(EBTREE_OBJS)
|
|
|
|
$(AR) rv $@ $^
|
|
|
|
|
2006-06-26 00:48:02 +00:00
|
|
|
objsize: haproxy
|
|
|
|
@objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
|
|
|
|
|
2005-12-17 11:21:26 +00:00
|
|
|
%.o: %.c
|
2008-01-02 19:48:34 +00:00
|
|
|
$(CC) $(COPTS) -c -o $@ $<
|
2005-12-17 11:21:26 +00:00
|
|
|
|
2007-12-02 10:28:59 +00:00
|
|
|
src/haproxy.o: src/haproxy.c
|
2008-01-02 19:48:34 +00:00
|
|
|
$(CC) $(COPTS) \
|
|
|
|
-DBUILD_TARGET='"$(strip $(TARGET))"' \
|
2009-04-11 17:45:50 +00:00
|
|
|
-DBUILD_ARCH='"$(strip $(ARCH))"' \
|
2008-01-02 19:48:34 +00:00
|
|
|
-DBUILD_CPU='"$(strip $(CPU))"' \
|
|
|
|
-DBUILD_CC='"$(strip $(CC))"' \
|
|
|
|
-DBUILD_CFLAGS='"$(strip $(VERBOSE_CFLAGS))"' \
|
|
|
|
-DBUILD_OPTIONS='"$(strip $(BUILD_OPTIONS))"' \
|
|
|
|
-c -o $@ $<
|
2007-12-02 10:28:59 +00:00
|
|
|
|
2007-07-11 07:19:31 +00:00
|
|
|
src/dlmalloc.o: $(DLMALLOC_SRC)
|
2008-01-02 19:48:34 +00:00
|
|
|
$(CC) $(COPTS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
|
2007-07-11 07:19:31 +00:00
|
|
|
|
2008-03-12 13:57:54 +00:00
|
|
|
install-man:
|
2008-03-12 16:19:16 +00:00
|
|
|
install -d $(DESTDIR)$(MANDIR)/man1
|
|
|
|
install -m 644 doc/haproxy.1 $(DESTDIR)$(MANDIR)/man1
|
2008-03-12 13:57:54 +00:00
|
|
|
|
2008-03-12 15:24:49 +00:00
|
|
|
install-doc:
|
2008-03-12 16:19:16 +00:00
|
|
|
install -d $(DESTDIR)$(DOCDIR)
|
2008-03-12 15:24:49 +00:00
|
|
|
for x in configuration architecture haproxy-en haproxy-fr; do \
|
2008-03-12 16:19:16 +00:00
|
|
|
install -m 644 doc/$$x.txt $(DESTDIR)$(DOCDIR) ; \
|
2008-03-12 15:24:49 +00:00
|
|
|
done
|
|
|
|
|
2008-06-11 22:25:46 +00:00
|
|
|
install-bin: haproxy
|
2008-03-12 16:19:16 +00:00
|
|
|
install -d $(DESTDIR)$(SBINDIR)
|
|
|
|
install haproxy $(DESTDIR)$(SBINDIR)
|
2008-03-12 13:25:35 +00:00
|
|
|
|
2008-03-12 16:28:13 +00:00
|
|
|
install: install-bin install-man install-doc
|
2008-03-12 14:21:05 +00:00
|
|
|
|
2005-12-17 11:21:26 +00:00
|
|
|
clean:
|
2009-10-26 20:10:04 +00:00
|
|
|
rm -f *.[oas] src/*.[oas] ebtree/*.[oas] haproxy test
|
|
|
|
for dir in . src include/* doc ebtree; do rm -f $$dir/*~ $$dir/*.rej $$dir/core; done
|
2006-12-23 10:12:04 +00:00
|
|
|
rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz
|
|
|
|
rm -f haproxy-$(VERSION) nohup.out gmon.out
|
2005-12-17 11:51:03 +00:00
|
|
|
|
2009-10-10 20:20:44 +00:00
|
|
|
tags:
|
2010-03-29 07:35:20 +00:00
|
|
|
find src include \( -name '*.c' -o -name '*.h' \) -print0 | \
|
2009-10-10 20:20:44 +00:00
|
|
|
xargs -0 etags --declarations --members
|
|
|
|
|
2006-03-19 20:30:14 +00:00
|
|
|
tar: clean
|
2006-03-19 20:16:26 +00:00
|
|
|
ln -s . haproxy-$(VERSION)
|
2006-06-26 00:48:02 +00:00
|
|
|
tar --exclude=haproxy-$(VERSION)/.git \
|
|
|
|
--exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \
|
|
|
|
--exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \
|
|
|
|
-cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz
|
2006-03-19 20:16:26 +00:00
|
|
|
rm -f haproxy-$(VERSION)
|
|
|
|
|
2006-10-15 12:24:14 +00:00
|
|
|
git-tar: clean
|
2009-07-23 11:43:33 +00:00
|
|
|
git archive --format=tar --prefix="haproxy-$(VERSION)/" HEAD | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz
|
2007-09-09 21:31:11 +00:00
|
|
|
|
|
|
|
version:
|
|
|
|
@echo "VERSION: $(VERSION)"
|
|
|
|
@echo "SUBVERS: $(SUBVERS)"
|
|
|
|
@echo "VERDATE: $(VERDATE)"
|
|
|
|
|
|
|
|
# never use this one if you don't know what it is used for.
|
|
|
|
update-version:
|
|
|
|
@echo "Ready to update the following versions :"
|
|
|
|
@echo "VERSION: $(VERSION)"
|
|
|
|
@echo "SUBVERS: $(SUBVERS)"
|
|
|
|
@echo "VERDATE: $(VERDATE)"
|
|
|
|
@echo "Press [ENTER] to continue or Ctrl-C to abort now.";read
|
|
|
|
echo "$(VERSION)" > VERSION
|
|
|
|
echo "$(SUBVERS)" > SUBVERS
|
|
|
|
echo "$(VERDATE)" > VERDATE
|