2005-12-17 13:08:03 +00:00
|
|
|
# This makefile supports different OS and CPU setups.
|
|
|
|
# You should use it this way :
|
2006-12-23 10:12:04 +00:00
|
|
|
# make TARGET=os CPU=cpu REGEX=lib
|
2005-12-17 13:08:03 +00:00
|
|
|
|
2006-03-19 20:16:26 +00:00
|
|
|
|
2005-12-17 12:21:24 +00:00
|
|
|
# Select target OS. TARGET must match a system for which COPTS and LIBS are
|
|
|
|
# correctly defined below.
|
2005-12-18 00:11:29 +00:00
|
|
|
#TARGET = linux26
|
2005-12-17 12:21:24 +00:00
|
|
|
TARGET = linux24
|
2005-12-18 00:13:11 +00:00
|
|
|
#TARGET = linux24e
|
2005-12-17 12:21:24 +00:00
|
|
|
#TARGET = linux22
|
|
|
|
#TARGET = solaris
|
|
|
|
|
2007-04-08 14:39:58 +00:00
|
|
|
USE_POLL = 1
|
|
|
|
|
|
|
|
ifeq ($(TARGET),linux24e)
|
|
|
|
USE_EPOLL = 1
|
2007-04-15 22:53:59 +00:00
|
|
|
USE_SEPOLL = 1
|
2007-04-08 14:39:58 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(TARGET),linux26)
|
|
|
|
USE_EPOLL = 1
|
2007-04-15 22:53:59 +00:00
|
|
|
USE_SEPOLL = 1
|
2007-04-08 14:39:58 +00:00
|
|
|
endif
|
|
|
|
|
2005-12-17 13:08:03 +00:00
|
|
|
# pass CPU=<cpu_name> to make to optimize for a particular CPU
|
|
|
|
CPU = generic
|
|
|
|
#CPU = i586
|
|
|
|
#CPU = i686
|
|
|
|
#CPU = ultrasparc
|
2005-12-17 11:21:26 +00:00
|
|
|
|
2005-12-18 00:32:31 +00:00
|
|
|
# By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group
|
|
|
|
# references seem broken using libc ! Use pcre instead.
|
2005-12-17 12:46:33 +00:00
|
|
|
REGEX=libc
|
|
|
|
#REGEX=pcre
|
2005-12-18 00:32:31 +00:00
|
|
|
#REGEX=static-pcre
|
2005-12-17 12:46:33 +00:00
|
|
|
|
2005-12-17 13:08:03 +00:00
|
|
|
# tools options
|
|
|
|
CC = gcc
|
|
|
|
LD = gcc
|
|
|
|
|
2005-12-17 12:46:33 +00:00
|
|
|
# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
|
2005-12-17 12:57:42 +00:00
|
|
|
PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :)
|
2005-12-17 12:46:33 +00:00
|
|
|
#PCREDIR=/usr/local
|
|
|
|
|
2007-01-07 01:03:04 +00:00
|
|
|
# This is the directory hosting libtcpsplice.[ah] when USE_TCPSPLICE is set
|
|
|
|
TCPSPLICEDIR :=
|
|
|
|
|
2005-12-18 00:13:11 +00:00
|
|
|
# This is for standard Linux 2.6 with netfilter and epoll()
|
2007-04-08 14:39:58 +00:00
|
|
|
COPTS.linux26 = -DNETFILTER
|
2005-12-18 00:11:29 +00:00
|
|
|
LIBS.linux26 =
|
|
|
|
|
2005-12-18 00:31:20 +00:00
|
|
|
# This is for enhanced Linux 2.4 with netfilter and epoll() patch.
|
|
|
|
# Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add
|
|
|
|
# -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug.
|
2007-04-08 14:39:58 +00:00
|
|
|
#COPTS.linux24e = -DNETFILTER -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND
|
|
|
|
COPTS.linux24e = -DNETFILTER -DUSE_MY_EPOLL
|
2005-12-18 00:13:11 +00:00
|
|
|
LIBS.linux24e =
|
|
|
|
|
|
|
|
# This is for standard Linux 2.4 with netfilter but without epoll()
|
2007-04-08 14:39:58 +00:00
|
|
|
COPTS.linux24 = -DNETFILTER
|
2005-12-17 11:48:26 +00:00
|
|
|
LIBS.linux24 =
|
2005-12-17 11:21:26 +00:00
|
|
|
|
2005-12-17 11:48:26 +00:00
|
|
|
# This is for Linux 2.2
|
2007-04-08 14:39:58 +00:00
|
|
|
COPTS.linux22 = -DUSE_GETSOCKNAME
|
2005-12-17 11:48:26 +00:00
|
|
|
LIBS.linux22 =
|
|
|
|
|
|
|
|
# This is for Solaris 8
|
2007-04-08 14:39:58 +00:00
|
|
|
COPTS.solaris = -fomit-frame-pointer -DFD_SETSIZE=65536
|
2005-12-17 11:29:56 +00:00
|
|
|
LIBS.solaris = -lnsl -lsocket
|
2005-12-17 11:21:26 +00:00
|
|
|
|
2005-12-17 13:08:03 +00:00
|
|
|
# CPU dependant optimizations
|
|
|
|
COPTS.generic = -O2
|
2006-10-15 21:43:42 +00:00
|
|
|
COPTS.i586 = -O2 -march=i586 -DCONFIG_HAP_USE_REGPARM
|
|
|
|
COPTS.i686 = -O2 -march=i686 -DCONFIG_HAP_USE_REGPARM
|
2005-12-17 13:08:03 +00:00
|
|
|
COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
|
|
|
|
|
|
|
|
# options for standard regex library
|
2005-12-17 12:46:33 +00:00
|
|
|
COPTS.libc=
|
2005-12-17 13:08:03 +00:00
|
|
|
LIBS.libc=
|
2005-12-17 12:46:33 +00:00
|
|
|
|
2005-12-17 13:08:03 +00:00
|
|
|
# options for libpcre
|
2005-12-17 12:46:33 +00:00
|
|
|
COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
|
|
|
|
LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
|
|
|
|
|
2005-12-18 00:32:31 +00:00
|
|
|
# options for static libpcre
|
|
|
|
COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
|
|
|
|
LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
|
|
|
|
|
2005-12-17 13:08:03 +00:00
|
|
|
# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
|
2006-03-19 19:56:52 +00:00
|
|
|
#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
|
2005-12-17 11:48:26 +00:00
|
|
|
DEBUG = -g
|
2005-12-17 11:29:56 +00:00
|
|
|
|
2005-12-18 00:02:42 +00:00
|
|
|
# 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
|
2005-12-18 00:13:11 +00:00
|
|
|
# with 1000 concurrent sessions. Putting it slightly lower than a page size
|
2006-03-19 19:56:52 +00:00
|
|
|
# will avoid the additionnal paramters to overflow a page. 8030 bytes is
|
|
|
|
# exactly 5.5 TCP segments of 1460 bytes.
|
|
|
|
#SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
|
2005-12-18 00:02:42 +00:00
|
|
|
SMALL_OPTS =
|
|
|
|
|
2005-12-18 00:11:29 +00:00
|
|
|
# redefine this if you want to add some special PATH to include/libs
|
|
|
|
ADDINC =
|
|
|
|
ADDLIB =
|
|
|
|
|
|
|
|
# set some defines when needed.
|
2006-03-19 19:56:52 +00:00
|
|
|
# - use -DTPROXY to compile with transparent proxy support.
|
2006-06-26 00:48:02 +00:00
|
|
|
DEFINE = -DTPROXY
|
2005-12-18 00:02:42 +00:00
|
|
|
|
2006-12-23 10:12:04 +00:00
|
|
|
# Now let's determine the version, sub-version and release date.
|
|
|
|
# If we're in the GIT tree, we can use the last commit's version and date.
|
2007-01-01 23:44:53 +00:00
|
|
|
ifeq ($(IGNOREGIT),)
|
2007-04-09 20:07:11 +00:00
|
|
|
VERSION := $(shell [ -d .git/. ] && ref=`git-describe --tags 2>/dev/null` && ref=$${ref%-g*} && echo "$${ref\#v}" )
|
2007-01-01 23:44:53 +00:00
|
|
|
endif
|
2006-12-23 10:12:04 +00:00
|
|
|
|
|
|
|
ifneq ($(VERSION),)
|
|
|
|
# OK git is there and works.
|
2007-04-09 20:07:11 +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 HEAD^.. 2>/dev/null | grep -m 1 ^Date: | cut -f2- -d: | cut -f1 -d+`" )
|
2006-12-23 10:12:04 +00:00
|
|
|
else
|
|
|
|
# Otherwise, use the hard-coded version of last tag, number of changes
|
|
|
|
# since last tag, and release date.
|
2007-06-17 21:41:40 +00:00
|
|
|
VERSION := 1.3.12
|
2007-01-01 23:44:53 +00:00
|
|
|
SUBVERS :=
|
2007-06-17 21:41:40 +00:00
|
|
|
VERDATE := 2007/06/17
|
2006-12-23 10:12:04 +00:00
|
|
|
endif
|
2006-11-12 22:57:19 +00:00
|
|
|
|
|
|
|
#### build options
|
|
|
|
|
|
|
|
# do not change this one, enable USE_* variables instead.
|
|
|
|
OPTIONS =
|
2007-03-24 16:24:39 +00:00
|
|
|
OPT_OBJS =
|
2006-11-12 22:57:19 +00:00
|
|
|
|
2007-01-07 01:03:04 +00:00
|
|
|
ifneq ($(USE_TCPSPLICE),)
|
|
|
|
OPTIONS += -DCONFIG_HAP_TCPSPLICE
|
|
|
|
endif
|
|
|
|
|
2007-03-24 16:24:39 +00:00
|
|
|
# - set USE_CTTPROXY to enable full transparent proxy support
|
2006-11-12 22:57:19 +00:00
|
|
|
ifneq ($(USE_CTTPROXY),)
|
|
|
|
OPTIONS += -DCONFIG_HAP_CTTPROXY
|
2007-03-24 16:24:39 +00:00
|
|
|
OPT_OBJS += src/cttproxy.o
|
2006-11-12 22:57:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_TPROXY),)
|
|
|
|
OPTIONS += -DTPROXY
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_POLL),)
|
|
|
|
OPTIONS += -DENABLE_POLL
|
2007-04-08 14:39:58 +00:00
|
|
|
OPT_OBJS += src/ev_poll.o
|
2006-11-12 22:57:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_EPOLL),)
|
|
|
|
OPTIONS += -DENABLE_EPOLL
|
2007-04-08 14:39:58 +00:00
|
|
|
OPT_OBJS += src/ev_epoll.o
|
2006-11-12 22:57:19 +00:00
|
|
|
endif
|
|
|
|
|
2007-04-15 22:53:59 +00:00
|
|
|
ifneq ($(USE_SEPOLL),)
|
|
|
|
OPTIONS += -DENABLE_SEPOLL
|
|
|
|
OPT_OBJS += src/ev_sepoll.o
|
|
|
|
endif
|
|
|
|
|
2006-11-12 22:57:19 +00:00
|
|
|
ifneq ($(USE_MY_EPOLL),)
|
|
|
|
OPTIONS += -DUSE_MY_EPOLL
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_NETFILTER),)
|
|
|
|
OPTIONS += -DNETFILTER
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_EPOLL_WORKAROUND),)
|
|
|
|
OPTIONS += -DEPOLL_CTL_MOD_WORKAROUND
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_GETSOCKNAME),)
|
|
|
|
OPTIONS += -DUSE_GETSOCKNAME
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(USE_REGPARM),)
|
|
|
|
OPTIONS += -DCONFIG_HAP_USE_REGPARM
|
|
|
|
endif
|
|
|
|
|
2006-12-22 14:28:43 +00:00
|
|
|
ifneq ($(VERSION),)
|
|
|
|
OPTIONS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(VERDATE),)
|
|
|
|
OPTIONS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
|
|
|
|
endif
|
|
|
|
|
2006-11-12 22:57:19 +00:00
|
|
|
#### end of build options
|
|
|
|
|
|
|
|
|
2005-12-17 13:08:03 +00:00
|
|
|
# global options
|
|
|
|
TARGET_OPTS=$(COPTS.$(TARGET))
|
|
|
|
REGEX_OPTS=$(COPTS.$(REGEX))
|
|
|
|
CPU_OPTS=$(COPTS.$(CPU))
|
|
|
|
|
2007-01-07 01:03:04 +00:00
|
|
|
COPTS = -Iinclude $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) $(OPTIONS)
|
|
|
|
LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX))
|
|
|
|
|
|
|
|
ifneq ($(USE_TCPSPLICE),)
|
|
|
|
COPTS += -I$(TCPSPLICEDIR)
|
|
|
|
LIBS += -L$(TCPSPLICEDIR) -ltcpsplice
|
|
|
|
endif
|
|
|
|
|
|
|
|
COPTS += $(ADDINC)
|
|
|
|
LIBS += $(ADDLIB)
|
2005-12-17 11:29:56 +00:00
|
|
|
|
2006-03-19 19:56:52 +00:00
|
|
|
CFLAGS = -Wall $(COPTS) $(DEBUG)
|
2005-12-17 11:21:26 +00:00
|
|
|
LDFLAGS = -g
|
|
|
|
|
|
|
|
all: haproxy
|
|
|
|
|
2006-06-26 00:48:02 +00:00
|
|
|
OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \
|
|
|
|
src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
|
|
|
|
src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
|
2007-05-13 19:45:51 +00:00
|
|
|
src/checks.o src/queue.o src/client.o src/proxy.o \
|
2006-06-26 00:48:02 +00:00
|
|
|
src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
|
2007-05-13 16:26:08 +00:00
|
|
|
src/session.o src/hdr_idx.o src/ev_select.o src/acl.o src/memory.o
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2007-03-24 16:24:39 +00:00
|
|
|
haproxy: $(OBJS) $(OPT_OBJS)
|
2005-12-17 11:21:26 +00:00
|
|
|
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
|
|
|
|
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
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
|
|
|
|
clean:
|
2006-10-15 21:40:58 +00:00
|
|
|
rm -f *.[oas] src/*.[oas] core haproxy test
|
|
|
|
for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;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
|
|
|
|
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
|
2006-12-23 10:12:04 +00:00
|
|
|
git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz
|