2006-03-19 19:56:52 +00:00
|
|
|
# This makefile is dedicated to OpenBSD (and possibly other BSDs)
|
2006-10-15 21:50:42 +00:00
|
|
|
# You should use it this way :
|
|
|
|
# make TARGET=os CPU=cpu
|
2007-07-11 07:19:31 +00:00
|
|
|
#
|
|
|
|
# Some optional components may be added, such as DLMALLOC :
|
|
|
|
#
|
|
|
|
# make TARGET=freebsd CPU=i686 DLMALLOC_SRC=/usr/local/src/dlmalloc.c \
|
|
|
|
# OPT_OBJS=src/dlmalloc.o
|
2006-10-15 21:50:42 +00:00
|
|
|
|
2006-03-19 19:56:52 +00:00
|
|
|
# Select target OS. TARGET must match a system for which COPTS and LIBS are
|
|
|
|
# correctly defined below.
|
|
|
|
TARGET = openbsd
|
|
|
|
|
|
|
|
# pass CPU=<cpu_name> to make to optimize for a particular CPU
|
|
|
|
CPU = generic
|
2010-11-28 06:41:00 +00:00
|
|
|
#CPU = native
|
2006-03-19 19:56:52 +00:00
|
|
|
#CPU = i586
|
|
|
|
#CPU = i686
|
|
|
|
#CPU = ultrasparc
|
|
|
|
|
|
|
|
# By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group
|
|
|
|
# references seem broken using libc ! Use pcre instead.
|
|
|
|
REGEX=libc
|
|
|
|
#REGEX=pcre
|
|
|
|
#REGEX=static-pcre
|
|
|
|
|
|
|
|
# tools options
|
|
|
|
CC = gcc
|
|
|
|
LD = gcc
|
|
|
|
|
2006-10-15 21:50:42 +00:00
|
|
|
# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
|
|
|
|
PCREDIR!= pcre-config --prefix 2>/dev/null || :
|
|
|
|
#PCREDIR=/usr/local
|
2006-03-19 19:56:52 +00:00
|
|
|
|
2006-10-15 21:50:42 +00:00
|
|
|
# This is for OpenBSD 3.0 and above
|
2007-04-09 10:03:06 +00:00
|
|
|
COPTS.openbsd = -DENABLE_POLL -DENABLE_KQUEUE
|
2006-03-19 19:56:52 +00:00
|
|
|
LIBS.openbsd =
|
|
|
|
|
|
|
|
# CPU dependant optimizations
|
|
|
|
COPTS.generic = -O2
|
2010-11-28 06:41:00 +00:00
|
|
|
COPTS.native = -O2 -march=native
|
2006-03-19 19:56:52 +00:00
|
|
|
COPTS.i586 = -O2 -march=i586
|
|
|
|
COPTS.i686 = -O2 -march=i686
|
|
|
|
COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
|
|
|
|
|
|
|
|
# options for standard regex library
|
|
|
|
COPTS.libc=
|
|
|
|
LIBS.libc=
|
|
|
|
|
|
|
|
# options for libpcre
|
|
|
|
COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
|
|
|
|
LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
|
|
|
|
|
|
|
|
# options for static libpcre
|
|
|
|
COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
|
|
|
|
LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
|
|
|
|
|
|
|
|
# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
|
|
|
|
#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
|
|
|
|
DEBUG = -g
|
|
|
|
|
|
|
|
# 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 avoid the additionnal paramters to overflow a page. 8030 bytes is
|
|
|
|
# exactly 5.5 TCP segments of 1460 bytes.
|
|
|
|
#SMALL_OPTS =
|
|
|
|
SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
|
|
|
|
|
|
|
|
# redefine this if you want to add some special PATH to include/libs
|
|
|
|
ADDINC =
|
|
|
|
ADDLIB =
|
|
|
|
|
2007-07-11 07:19:31 +00:00
|
|
|
# redefine this if you want to add some special .o files
|
|
|
|
OPT_OBJS =
|
|
|
|
|
2006-03-19 19:56:52 +00:00
|
|
|
# set some defines when needed.
|
2006-10-15 21:50:42 +00:00
|
|
|
# Known ones are -DENABLE_POLL
|
2006-03-19 19:56:52 +00:00
|
|
|
# - use -DTPROXY to compile with transparent proxy support.
|
2011-03-23 19:00:53 +00:00
|
|
|
# - use -DUSE_GETADDRINFO to use of getaddrinfo() to resolve IPv6 host names
|
2006-06-26 00:48:02 +00:00
|
|
|
DEFINE = -DTPROXY
|
2006-03-19 19:56:52 +00:00
|
|
|
|
2007-07-11 07:19:31 +00:00
|
|
|
# May be changed to patch PAGE_SIZE on every platform when using dlmalloc
|
|
|
|
DLMALLOC_THRES=4096
|
|
|
|
|
2006-03-19 19:56:52 +00:00
|
|
|
# global options
|
|
|
|
TARGET_OPTS=$(COPTS.$(TARGET))
|
|
|
|
REGEX_OPTS=$(COPTS.$(REGEX))
|
|
|
|
CPU_OPTS=$(COPTS.$(CPU))
|
2010-11-28 07:28:15 +00:00
|
|
|
SPEC_OPTS=-fno-strict-aliasing
|
2006-03-19 19:56:52 +00:00
|
|
|
|
2007-09-09 21:31:11 +00:00
|
|
|
VERSION != cat VERSION 2>/dev/null || touch VERSION
|
|
|
|
SUBVERS != cat SUBVERS 2>/dev/null || touch SUBVERS
|
|
|
|
VERDATE != cat VERDATE 2>/dev/null || touch VERDATE
|
|
|
|
|
|
|
|
VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \
|
|
|
|
-DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
|
2006-03-19 19:56:52 +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
|
|
|
|
|
|
|
|
COPTS = -Iinclude -I$(EBTREE_DIR) $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) \
|
2010-11-28 07:28:15 +00:00
|
|
|
$(SPEC_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(VER_OPTS) $(DEFINE)
|
2007-09-09 21:31:11 +00:00
|
|
|
LIBS = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
|
|
|
|
CFLAGS = -Wall $(COPTS) $(DEBUG)
|
2006-03-19 19:56:52 +00:00
|
|
|
LDFLAGS = -g
|
|
|
|
|
2007-10-16 10:25:14 +00:00
|
|
|
OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \
|
2006-10-15 21:50:42 +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/proto_uxst.o \
|
2006-10-15 21:50:42 +00:00
|
|
|
src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
|
2010-09-23 16:30:22 +00:00
|
|
|
src/peers.o 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 \
|
[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 \
|
2007-11-15 22:56:17 +00:00
|
|
|
src/ev_poll.o src/ev_kqueue.o \
|
2010-02-26 20:36:32 +00:00
|
|
|
src/acl.o src/memory.o src/freq_ctr.o \
|
|
|
|
src/auth.o src/stick_table.o src/pattern.o
|
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
|
2006-10-15 21:50:42 +00:00
|
|
|
|
2006-03-19 19:56:52 +00:00
|
|
|
all: haproxy
|
|
|
|
|
2009-10-26 20:10:04 +00:00
|
|
|
haproxy: $(OBJS) $(OPT_OBJS) $(EBTREE_OBJS)
|
2006-03-19 19:56:52 +00:00
|
|
|
$(LD) $(LDFLAGS) -o $@ $> $(LIBS)
|
|
|
|
|
2006-10-15 21:50:42 +00:00
|
|
|
.SUFFIXES: .c.o
|
2006-03-19 19:56:52 +00:00
|
|
|
|
2006-10-15 21:50:42 +00:00
|
|
|
.c.o:
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $>
|
2006-03-19 19:56:52 +00:00
|
|
|
|
2007-12-02 10:28:59 +00:00
|
|
|
src/haproxy.o: src/haproxy.c
|
|
|
|
$(CC) $(CFLAGS) -DBUILD_TARGET='"$(TARGET)"' -DBUILD_CC='"$(CC)"' \
|
|
|
|
-DBUILD_CPU='"$(CPU)"' -DBUILD_REGEX='"$(REGEX)"' \
|
|
|
|
-DBUILD_OPTS='"$(COPTS)"' -c -o $@ $>
|
|
|
|
|
2007-07-11 07:19:31 +00:00
|
|
|
src/dlmalloc.o: $(DLMALLOC_SRC)
|
|
|
|
$(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $>
|
|
|
|
|
2006-03-19 19:56:52 +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-10-15 21:50:42 +00:00
|
|
|
rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out
|
2007-09-09 21:31:11 +00:00
|
|
|
|
|
|
|
version:
|
|
|
|
@echo "VERSION: $(VERSION)"
|
|
|
|
@echo "SUBVERS: $(SUBVERS)"
|
|
|
|
@echo "VERDATE: $(VERDATE)"
|