blob: faa37c05933e4dfc60ebecaacbcb3105312a0880 [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 tarreaueedaa9f2005-12-17 14:08:03 +010014# pass CPU=<cpu_name> to make to optimize for a particular CPU
15CPU = generic
16#CPU = i586
17#CPU = i686
18#CPU = ultrasparc
willy tarreau0f7af912005-12-17 12:21:26 +010019
willy tarreau4373b962005-12-18 01:32:31 +010020# By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group
21# references seem broken using libc ! Use pcre instead.
willy tarreau036e1ce2005-12-17 13:46:33 +010022REGEX=libc
23#REGEX=pcre
willy tarreau4373b962005-12-18 01:32:31 +010024#REGEX=static-pcre
willy tarreau036e1ce2005-12-17 13:46:33 +010025
willy tarreaueedaa9f2005-12-17 14:08:03 +010026# tools options
27CC = gcc
28LD = gcc
29
willy tarreau036e1ce2005-12-17 13:46:33 +010030# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
willy tarreau2f6ba652005-12-17 13:57:42 +010031PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :)
willy tarreau036e1ce2005-12-17 13:46:33 +010032#PCREDIR=/usr/local
33
Willy Tarreau6d1a9882007-01-07 02:03:04 +010034# This is the directory hosting libtcpsplice.[ah] when USE_TCPSPLICE is set
35TCPSPLICEDIR :=
36
willy tarreau64a3cc32005-12-18 01:13:11 +010037# This is for standard Linux 2.6 with netfilter and epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010038COPTS.linux26 = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL
39LIBS.linux26 =
40
willy tarreaub952e1d2005-12-18 01:31:20 +010041# This is for enhanced Linux 2.4 with netfilter and epoll() patch.
42# Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add
43# -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug.
44#COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND
willy tarreau64a3cc32005-12-18 01:13:11 +010045COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL
46LIBS.linux24e =
47
48# This is for standard Linux 2.4 with netfilter but without epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010049COPTS.linux24 = -DNETFILTER -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010050LIBS.linux24 =
willy tarreau0f7af912005-12-17 12:21:26 +010051
willy tarreau5cbea6f2005-12-17 12:48:26 +010052# This is for Linux 2.2
willy tarreau1c2ad212005-12-18 01:11:29 +010053COPTS.linux22 = -DUSE_GETSOCKNAME -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010054LIBS.linux22 =
55
56# This is for Solaris 8
willy tarreau64a3cc32005-12-18 01:13:11 +010057COPTS.solaris = -fomit-frame-pointer -DENABLE_POLL -DFD_SETSIZE=65536
willy tarreau9da061b2005-12-17 12:29:56 +010058LIBS.solaris = -lnsl -lsocket
59
willy tarreaueedaa9f2005-12-17 14:08:03 +010060# CPU dependant optimizations
61COPTS.generic = -O2
Willy Tarreau390223b2006-10-15 23:43:42 +020062COPTS.i586 = -O2 -march=i586 -DCONFIG_HAP_USE_REGPARM
63COPTS.i686 = -O2 -march=i686 -DCONFIG_HAP_USE_REGPARM
willy tarreaueedaa9f2005-12-17 14:08:03 +010064COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
65
66# options for standard regex library
willy tarreau036e1ce2005-12-17 13:46:33 +010067COPTS.libc=
willy tarreaueedaa9f2005-12-17 14:08:03 +010068LIBS.libc=
willy tarreau036e1ce2005-12-17 13:46:33 +010069
willy tarreaueedaa9f2005-12-17 14:08:03 +010070# options for libpcre
willy tarreau036e1ce2005-12-17 13:46:33 +010071COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
72LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
73
willy tarreau4373b962005-12-18 01:32:31 +010074# options for static libpcre
75COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
76LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
77
willy tarreaueedaa9f2005-12-17 14:08:03 +010078# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
willy tarreaud38e72d2006-03-19 20:56:52 +010079#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
willy tarreau5cbea6f2005-12-17 12:48:26 +010080DEBUG = -g
willy tarreau9da061b2005-12-17 12:29:56 +010081
willy tarreau0174f312005-12-18 01:02:42 +010082# if small memory footprint is required, you can reduce the buffer size. There
83# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
willy tarreau64a3cc32005-12-18 01:13:11 +010084# with 1000 concurrent sessions. Putting it slightly lower than a page size
willy tarreaud38e72d2006-03-19 20:56:52 +010085# will avoid the additionnal paramters to overflow a page. 8030 bytes is
86# exactly 5.5 TCP segments of 1460 bytes.
87#SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
willy tarreau0174f312005-12-18 01:02:42 +010088SMALL_OPTS =
89
willy tarreau1c2ad212005-12-18 01:11:29 +010090# redefine this if you want to add some special PATH to include/libs
91ADDINC =
92ADDLIB =
93
94# set some defines when needed.
95# Known ones are -DENABLE_POLL, -DENABLE_EPOLL, and -DUSE_MY_EPOLL
willy tarreaud38e72d2006-03-19 20:56:52 +010096# - use -DTPROXY to compile with transparent proxy support.
Willy Tarreaubaaee002006-06-26 02:48:02 +020097DEFINE = -DTPROXY
willy tarreau0174f312005-12-18 01:02:42 +010098
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +010099# Now let's determine the version, sub-version and release date.
100# If we're in the GIT tree, we can use the last commit's version and date.
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100101ifeq ($(IGNOREGIT),)
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100102VERSION := $(shell [ -d .git/. ] && ref=$$(git-describe --tags 2>/dev/null) && ref=$${ref%-g*} && echo "$${ref\#v}" )
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100103endif
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100104
105ifneq ($(VERSION),)
106# OK git is there and works.
107SUBVERS := $(shell comms=$$(git-log --no-merges v$(VERSION).. 2>/dev/null |grep -c ^commit ); [ $$comms -gt 0 ] && echo "-$$comms" )
Willy Tarreau42afc3b2007-01-07 00:43:29 +0100108VERDATE := $(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 +0100109else
110# Otherwise, use the hard-coded version of last tag, number of changes
111# since last tag, and release date.
Willy Tarreau42c76592007-04-03 20:30:13 +0200112VERSION := 1.3.8.2
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100113SUBVERS :=
Willy Tarreau42c76592007-04-03 20:30:13 +0200114VERDATE := 2007/04/03
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100115endif
Willy Tarreau77074d52006-11-12 23:57:19 +0100116
117#### build options
118
119# do not change this one, enable USE_* variables instead.
120OPTIONS =
Willy Tarreaub38651a2007-03-24 17:24:39 +0100121OPT_OBJS =
Willy Tarreau77074d52006-11-12 23:57:19 +0100122
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100123ifneq ($(USE_TCPSPLICE),)
124OPTIONS += -DCONFIG_HAP_TCPSPLICE
125endif
126
Willy Tarreaub38651a2007-03-24 17:24:39 +0100127# - set USE_CTTPROXY to enable full transparent proxy support
Willy Tarreau77074d52006-11-12 23:57:19 +0100128ifneq ($(USE_CTTPROXY),)
129OPTIONS += -DCONFIG_HAP_CTTPROXY
Willy Tarreaub38651a2007-03-24 17:24:39 +0100130OPT_OBJS += src/cttproxy.o
Willy Tarreau77074d52006-11-12 23:57:19 +0100131endif
132
133ifneq ($(USE_TPROXY),)
134OPTIONS += -DTPROXY
135endif
136
137ifneq ($(USE_POLL),)
138OPTIONS += -DENABLE_POLL
139endif
140
141ifneq ($(USE_EPOLL),)
142OPTIONS += -DENABLE_EPOLL
143endif
144
145ifneq ($(USE_MY_EPOLL),)
146OPTIONS += -DUSE_MY_EPOLL
147endif
148
149ifneq ($(USE_NETFILTER),)
150OPTIONS += -DNETFILTER
151endif
152
153ifneq ($(USE_EPOLL_WORKAROUND),)
154OPTIONS += -DEPOLL_CTL_MOD_WORKAROUND
155endif
156
157ifneq ($(USE_GETSOCKNAME),)
158OPTIONS += -DUSE_GETSOCKNAME
159endif
160
161ifneq ($(USE_REGPARM),)
162OPTIONS += -DCONFIG_HAP_USE_REGPARM
163endif
164
Willy Tarreau79b34bf2006-12-22 15:28:43 +0100165ifneq ($(VERSION),)
166OPTIONS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
167endif
168
169ifneq ($(VERDATE),)
170OPTIONS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
171endif
172
Willy Tarreau77074d52006-11-12 23:57:19 +0100173#### end of build options
174
175
willy tarreaueedaa9f2005-12-17 14:08:03 +0100176# global options
177TARGET_OPTS=$(COPTS.$(TARGET))
178REGEX_OPTS=$(COPTS.$(REGEX))
179CPU_OPTS=$(COPTS.$(CPU))
180
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100181COPTS = -Iinclude $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) $(OPTIONS)
182LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX))
183
184ifneq ($(USE_TCPSPLICE),)
185COPTS += -I$(TCPSPLICEDIR)
186LIBS += -L$(TCPSPLICEDIR) -ltcpsplice
187endif
188
189COPTS += $(ADDINC)
190LIBS += $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +0100191
willy tarreaud38e72d2006-03-19 20:56:52 +0100192CFLAGS = -Wall $(COPTS) $(DEBUG)
willy tarreau0f7af912005-12-17 12:21:26 +0100193LDFLAGS = -g
194
195all: haproxy
196
Willy Tarreaubaaee002006-06-26 02:48:02 +0200197OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \
198 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
199 src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
200 src/checks.o src/queue.o src/capture.o src/client.o src/proxy.o \
201 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
Willy Tarreau964c9362007-01-07 00:38:00 +0100202 src/session.o src/hdr_idx.o src/rbtree.o
Willy Tarreaubaaee002006-06-26 02:48:02 +0200203
Willy Tarreaub38651a2007-03-24 17:24:39 +0100204haproxy: $(OBJS) $(OPT_OBJS)
willy tarreau0f7af912005-12-17 12:21:26 +0100205 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
206
Willy Tarreaubaaee002006-06-26 02:48:02 +0200207objsize: haproxy
208 @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
209
willy tarreau0f7af912005-12-17 12:21:26 +0100210%.o: %.c
211 $(CC) $(CFLAGS) -c -o $@ $<
212
213clean:
Willy Tarreau1a587492006-10-15 23:40:58 +0200214 rm -f *.[oas] src/*.[oas] core haproxy test
215 for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100216 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz
217 rm -f haproxy-$(VERSION) nohup.out gmon.out
willy tarreauefae1842005-12-17 12:51:03 +0100218
willy tarreaue114bf92006-03-19 21:30:14 +0100219tar: clean
willy tarreaucee272f2006-03-19 21:16:26 +0100220 ln -s . haproxy-$(VERSION)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200221 tar --exclude=haproxy-$(VERSION)/.git \
222 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \
223 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \
224 -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz
willy tarreaucee272f2006-03-19 21:16:26 +0100225 rm -f haproxy-$(VERSION)
226
Willy Tarreau9f0a9012006-10-15 14:24:14 +0200227git-tar: clean
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100228 git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz