blob: 04fbd732fb9494c4e4429c7cd5eb1b049b93733d [file] [log] [blame]
willy tarreaueedaa9f2005-12-17 14:08:03 +01001# This makefile supports different OS and CPU setups.
2# You should use it this way :
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +01003# make TARGET=os CPU=cpu REGEX=lib
willy tarreaueedaa9f2005-12-17 14:08:03 +01004
willy tarreaucee272f2006-03-19 21:16:26 +01005
willy tarreau750a4722005-12-17 13:21:24 +01006# Select target OS. TARGET must match a system for which COPTS and LIBS are
7# correctly defined below.
willy tarreau1c2ad212005-12-18 01:11:29 +01008#TARGET = linux26
willy tarreau750a4722005-12-17 13:21:24 +01009TARGET = linux24
willy tarreau64a3cc32005-12-18 01:13:11 +010010#TARGET = linux24e
willy tarreau750a4722005-12-17 13:21:24 +010011#TARGET = linux22
12#TARGET = solaris
willy tarreau750a4722005-12-17 13:21:24 +010013
Willy Tarreau4f60f162007-04-08 16:39:58 +020014USE_POLL = 1
15
16ifeq ($(TARGET),linux24e)
17USE_EPOLL = 1
Willy Tarreaude99e992007-04-16 00:53:59 +020018USE_SEPOLL = 1
Willy Tarreau4f60f162007-04-08 16:39:58 +020019endif
20
21ifeq ($(TARGET),linux26)
22USE_EPOLL = 1
Willy Tarreaude99e992007-04-16 00:53:59 +020023USE_SEPOLL = 1
Willy Tarreau4f60f162007-04-08 16:39:58 +020024endif
25
willy tarreaueedaa9f2005-12-17 14:08:03 +010026# pass CPU=<cpu_name> to make to optimize for a particular CPU
27CPU = generic
28#CPU = i586
29#CPU = i686
30#CPU = ultrasparc
willy tarreau0f7af912005-12-17 12:21:26 +010031
willy tarreau4373b962005-12-18 01:32:31 +010032# By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group
33# references seem broken using libc ! Use pcre instead.
willy tarreau036e1ce2005-12-17 13:46:33 +010034REGEX=libc
35#REGEX=pcre
willy tarreau4373b962005-12-18 01:32:31 +010036#REGEX=static-pcre
willy tarreau036e1ce2005-12-17 13:46:33 +010037
willy tarreaueedaa9f2005-12-17 14:08:03 +010038# tools options
39CC = gcc
40LD = gcc
41
willy tarreau036e1ce2005-12-17 13:46:33 +010042# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
willy tarreau2f6ba652005-12-17 13:57:42 +010043PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :)
willy tarreau036e1ce2005-12-17 13:46:33 +010044#PCREDIR=/usr/local
45
Willy Tarreau6d1a9882007-01-07 02:03:04 +010046# This is the directory hosting libtcpsplice.[ah] when USE_TCPSPLICE is set
47TCPSPLICEDIR :=
48
willy tarreau64a3cc32005-12-18 01:13:11 +010049# This is for standard Linux 2.6 with netfilter and epoll()
Willy Tarreau4f60f162007-04-08 16:39:58 +020050COPTS.linux26 = -DNETFILTER
willy tarreau1c2ad212005-12-18 01:11:29 +010051LIBS.linux26 =
52
willy tarreaub952e1d2005-12-18 01:31:20 +010053# This is for enhanced Linux 2.4 with netfilter and epoll() patch.
54# Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add
55# -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug.
Willy Tarreau4f60f162007-04-08 16:39:58 +020056#COPTS.linux24e = -DNETFILTER -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND
57COPTS.linux24e = -DNETFILTER -DUSE_MY_EPOLL
willy tarreau64a3cc32005-12-18 01:13:11 +010058LIBS.linux24e =
59
60# This is for standard Linux 2.4 with netfilter but without epoll()
Willy Tarreau4f60f162007-04-08 16:39:58 +020061COPTS.linux24 = -DNETFILTER
willy tarreau5cbea6f2005-12-17 12:48:26 +010062LIBS.linux24 =
willy tarreau0f7af912005-12-17 12:21:26 +010063
willy tarreau5cbea6f2005-12-17 12:48:26 +010064# This is for Linux 2.2
Willy Tarreau4f60f162007-04-08 16:39:58 +020065COPTS.linux22 = -DUSE_GETSOCKNAME
willy tarreau5cbea6f2005-12-17 12:48:26 +010066LIBS.linux22 =
67
68# This is for Solaris 8
Willy Tarreau4f60f162007-04-08 16:39:58 +020069COPTS.solaris = -fomit-frame-pointer -DFD_SETSIZE=65536
willy tarreau9da061b2005-12-17 12:29:56 +010070LIBS.solaris = -lnsl -lsocket
71
willy tarreaueedaa9f2005-12-17 14:08:03 +010072# CPU dependant optimizations
73COPTS.generic = -O2
Willy Tarreau390223b2006-10-15 23:43:42 +020074COPTS.i586 = -O2 -march=i586 -DCONFIG_HAP_USE_REGPARM
75COPTS.i686 = -O2 -march=i686 -DCONFIG_HAP_USE_REGPARM
willy tarreaueedaa9f2005-12-17 14:08:03 +010076COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
77
78# options for standard regex library
willy tarreau036e1ce2005-12-17 13:46:33 +010079COPTS.libc=
willy tarreaueedaa9f2005-12-17 14:08:03 +010080LIBS.libc=
willy tarreau036e1ce2005-12-17 13:46:33 +010081
willy tarreaueedaa9f2005-12-17 14:08:03 +010082# options for libpcre
willy tarreau036e1ce2005-12-17 13:46:33 +010083COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
84LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
85
willy tarreau4373b962005-12-18 01:32:31 +010086# options for static libpcre
87COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
88LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
89
willy tarreaueedaa9f2005-12-17 14:08:03 +010090# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
willy tarreaud38e72d2006-03-19 20:56:52 +010091#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
willy tarreau5cbea6f2005-12-17 12:48:26 +010092DEBUG = -g
willy tarreau9da061b2005-12-17 12:29:56 +010093
willy tarreau0174f312005-12-18 01:02:42 +010094# if small memory footprint is required, you can reduce the buffer size. There
95# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
willy tarreau64a3cc32005-12-18 01:13:11 +010096# with 1000 concurrent sessions. Putting it slightly lower than a page size
willy tarreaud38e72d2006-03-19 20:56:52 +010097# will avoid the additionnal paramters to overflow a page. 8030 bytes is
98# exactly 5.5 TCP segments of 1460 bytes.
99#SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
willy tarreau0174f312005-12-18 01:02:42 +0100100SMALL_OPTS =
101
willy tarreau1c2ad212005-12-18 01:11:29 +0100102# redefine this if you want to add some special PATH to include/libs
103ADDINC =
104ADDLIB =
105
106# set some defines when needed.
willy tarreaud38e72d2006-03-19 20:56:52 +0100107# - use -DTPROXY to compile with transparent proxy support.
Willy Tarreaubaaee002006-06-26 02:48:02 +0200108DEFINE = -DTPROXY
willy tarreau0174f312005-12-18 01:02:42 +0100109
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100110# Now let's determine the version, sub-version and release date.
111# If we're in the GIT tree, we can use the last commit's version and date.
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100112ifeq ($(IGNOREGIT),)
Willy Tarreaua1973c42007-04-09 22:07:11 +0200113VERSION := $(shell [ -d .git/. ] && ref=`git-describe --tags 2>/dev/null` && ref=$${ref%-g*} && echo "$${ref\#v}" )
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100114endif
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100115
116ifneq ($(VERSION),)
117# OK git is there and works.
Willy Tarreaua1973c42007-04-09 22:07:11 +0200118SUBVERS := $(shell comms=`git-log --no-merges v$(VERSION).. 2>/dev/null |grep -c ^commit `; [ $$comms -gt 0 ] && echo "-$$comms" )
119VERDATE := $(shell date +%Y/%m/%d -d "`git-log HEAD^.. 2>/dev/null | grep -m 1 ^Date: | cut -f2- -d: | cut -f1 -d+`" )
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100120else
121# Otherwise, use the hard-coded version of last tag, number of changes
122# since last tag, and release date.
Willy Tarreaua3503e02007-06-03 17:27:07 +0200123VERSION := 1.3.11.4
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100124SUBVERS :=
Willy Tarreaua3503e02007-06-03 17:27:07 +0200125VERDATE := 2007/06/03
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100126endif
Willy Tarreau77074d52006-11-12 23:57:19 +0100127
128#### build options
129
130# do not change this one, enable USE_* variables instead.
131OPTIONS =
Willy Tarreaub38651a2007-03-24 17:24:39 +0100132OPT_OBJS =
Willy Tarreau77074d52006-11-12 23:57:19 +0100133
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100134ifneq ($(USE_TCPSPLICE),)
135OPTIONS += -DCONFIG_HAP_TCPSPLICE
136endif
137
Willy Tarreaub38651a2007-03-24 17:24:39 +0100138# - set USE_CTTPROXY to enable full transparent proxy support
Willy Tarreau77074d52006-11-12 23:57:19 +0100139ifneq ($(USE_CTTPROXY),)
140OPTIONS += -DCONFIG_HAP_CTTPROXY
Willy Tarreaub38651a2007-03-24 17:24:39 +0100141OPT_OBJS += src/cttproxy.o
Willy Tarreau77074d52006-11-12 23:57:19 +0100142endif
143
144ifneq ($(USE_TPROXY),)
145OPTIONS += -DTPROXY
146endif
147
148ifneq ($(USE_POLL),)
149OPTIONS += -DENABLE_POLL
Willy Tarreau4f60f162007-04-08 16:39:58 +0200150OPT_OBJS += src/ev_poll.o
Willy Tarreau77074d52006-11-12 23:57:19 +0100151endif
152
153ifneq ($(USE_EPOLL),)
154OPTIONS += -DENABLE_EPOLL
Willy Tarreau4f60f162007-04-08 16:39:58 +0200155OPT_OBJS += src/ev_epoll.o
Willy Tarreau77074d52006-11-12 23:57:19 +0100156endif
157
Willy Tarreaude99e992007-04-16 00:53:59 +0200158ifneq ($(USE_SEPOLL),)
159OPTIONS += -DENABLE_SEPOLL
160OPT_OBJS += src/ev_sepoll.o
161endif
162
Willy Tarreau77074d52006-11-12 23:57:19 +0100163ifneq ($(USE_MY_EPOLL),)
164OPTIONS += -DUSE_MY_EPOLL
165endif
166
167ifneq ($(USE_NETFILTER),)
168OPTIONS += -DNETFILTER
169endif
170
171ifneq ($(USE_EPOLL_WORKAROUND),)
172OPTIONS += -DEPOLL_CTL_MOD_WORKAROUND
173endif
174
175ifneq ($(USE_GETSOCKNAME),)
176OPTIONS += -DUSE_GETSOCKNAME
177endif
178
179ifneq ($(USE_REGPARM),)
180OPTIONS += -DCONFIG_HAP_USE_REGPARM
181endif
182
Willy Tarreau79b34bf2006-12-22 15:28:43 +0100183ifneq ($(VERSION),)
184OPTIONS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
185endif
186
187ifneq ($(VERDATE),)
188OPTIONS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
189endif
190
Willy Tarreau77074d52006-11-12 23:57:19 +0100191#### end of build options
192
193
willy tarreaueedaa9f2005-12-17 14:08:03 +0100194# global options
195TARGET_OPTS=$(COPTS.$(TARGET))
196REGEX_OPTS=$(COPTS.$(REGEX))
197CPU_OPTS=$(COPTS.$(CPU))
198
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100199COPTS = -Iinclude $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) $(OPTIONS)
200LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX))
201
202ifneq ($(USE_TCPSPLICE),)
203COPTS += -I$(TCPSPLICEDIR)
204LIBS += -L$(TCPSPLICEDIR) -ltcpsplice
205endif
206
207COPTS += $(ADDINC)
208LIBS += $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +0100209
willy tarreaud38e72d2006-03-19 20:56:52 +0100210CFLAGS = -Wall $(COPTS) $(DEBUG)
willy tarreau0f7af912005-12-17 12:21:26 +0100211LDFLAGS = -g
212
213all: haproxy
214
Willy Tarreaubaaee002006-06-26 02:48:02 +0200215OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \
216 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
217 src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
Willy Tarreau086b3b42007-05-13 21:45:51 +0200218 src/checks.o src/queue.o src/client.o src/proxy.o \
Willy Tarreaubaaee002006-06-26 02:48:02 +0200219 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
Willy Tarreau50e608d2007-05-13 18:26:08 +0200220 src/session.o src/hdr_idx.o src/ev_select.o src/acl.o src/memory.o
Willy Tarreaubaaee002006-06-26 02:48:02 +0200221
Willy Tarreaub38651a2007-03-24 17:24:39 +0100222haproxy: $(OBJS) $(OPT_OBJS)
willy tarreau0f7af912005-12-17 12:21:26 +0100223 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
224
Willy Tarreaubaaee002006-06-26 02:48:02 +0200225objsize: haproxy
226 @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
227
willy tarreau0f7af912005-12-17 12:21:26 +0100228%.o: %.c
229 $(CC) $(CFLAGS) -c -o $@ $<
230
231clean:
Willy Tarreau1a587492006-10-15 23:40:58 +0200232 rm -f *.[oas] src/*.[oas] core haproxy test
233 for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100234 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz
235 rm -f haproxy-$(VERSION) nohup.out gmon.out
willy tarreauefae1842005-12-17 12:51:03 +0100236
willy tarreaue114bf92006-03-19 21:30:14 +0100237tar: clean
willy tarreaucee272f2006-03-19 21:16:26 +0100238 ln -s . haproxy-$(VERSION)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200239 tar --exclude=haproxy-$(VERSION)/.git \
240 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \
241 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \
242 -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz
willy tarreaucee272f2006-03-19 21:16:26 +0100243 rm -f haproxy-$(VERSION)
244
Willy Tarreau9f0a9012006-10-15 14:24:14 +0200245git-tar: clean
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100246 git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz