blob: f8285d0d45ae740fe1400d37abe5d5d8fa1a74d3 [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 Tarreau77074d52006-11-12 23:57:19 +010097# - use -DCONFIG_HAP_CTTPROXY to enable full transparent proxy support
Willy Tarreaubaaee002006-06-26 02:48:02 +020098DEFINE = -DTPROXY
willy tarreau0174f312005-12-18 01:02:42 +010099
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100100# Now let's determine the version, sub-version and release date.
101# If we're in the GIT tree, we can use the last commit's version and date.
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100102ifeq ($(IGNOREGIT),)
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100103VERSION := $(shell [ -d .git/. ] && ref=$$(git-describe --tags 2>/dev/null) && ref=$${ref%-g*} && echo "$${ref\#v}" )
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100104endif
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100105
106ifneq ($(VERSION),)
107# OK git is there and works.
108SUBVERS := $(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 +0100109VERDATE := $(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 +0100110else
111# Otherwise, use the hard-coded version of last tag, number of changes
112# since last tag, and release date.
Willy Tarreau5871f8e2007-01-07 02:47:01 +0100113VERSION := 1.3.5
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100114SUBVERS :=
Willy Tarreau5871f8e2007-01-07 02:47:01 +0100115VERDATE := 2007/01/07
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100116endif
Willy Tarreau77074d52006-11-12 23:57:19 +0100117
118#### build options
119
120# do not change this one, enable USE_* variables instead.
121OPTIONS =
122
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100123ifneq ($(USE_TCPSPLICE),)
124OPTIONS += -DCONFIG_HAP_TCPSPLICE
125endif
126
Willy Tarreau77074d52006-11-12 23:57:19 +0100127ifneq ($(USE_CTTPROXY),)
128OPTIONS += -DCONFIG_HAP_CTTPROXY
129endif
130
131ifneq ($(USE_TPROXY),)
132OPTIONS += -DTPROXY
133endif
134
135ifneq ($(USE_POLL),)
136OPTIONS += -DENABLE_POLL
137endif
138
139ifneq ($(USE_EPOLL),)
140OPTIONS += -DENABLE_EPOLL
141endif
142
143ifneq ($(USE_MY_EPOLL),)
144OPTIONS += -DUSE_MY_EPOLL
145endif
146
147ifneq ($(USE_NETFILTER),)
148OPTIONS += -DNETFILTER
149endif
150
151ifneq ($(USE_EPOLL_WORKAROUND),)
152OPTIONS += -DEPOLL_CTL_MOD_WORKAROUND
153endif
154
155ifneq ($(USE_GETSOCKNAME),)
156OPTIONS += -DUSE_GETSOCKNAME
157endif
158
159ifneq ($(USE_REGPARM),)
160OPTIONS += -DCONFIG_HAP_USE_REGPARM
161endif
162
Willy Tarreau79b34bf2006-12-22 15:28:43 +0100163ifneq ($(VERSION),)
164OPTIONS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
165endif
166
167ifneq ($(VERDATE),)
168OPTIONS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
169endif
170
Willy Tarreau77074d52006-11-12 23:57:19 +0100171#### end of build options
172
173
willy tarreaueedaa9f2005-12-17 14:08:03 +0100174# global options
175TARGET_OPTS=$(COPTS.$(TARGET))
176REGEX_OPTS=$(COPTS.$(REGEX))
177CPU_OPTS=$(COPTS.$(CPU))
178
Willy Tarreau6d1a9882007-01-07 02:03:04 +0100179COPTS = -Iinclude $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) $(OPTIONS)
180LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX))
181
182ifneq ($(USE_TCPSPLICE),)
183COPTS += -I$(TCPSPLICEDIR)
184LIBS += -L$(TCPSPLICEDIR) -ltcpsplice
185endif
186
187COPTS += $(ADDINC)
188LIBS += $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +0100189
willy tarreaud38e72d2006-03-19 20:56:52 +0100190CFLAGS = -Wall $(COPTS) $(DEBUG)
willy tarreau0f7af912005-12-17 12:21:26 +0100191LDFLAGS = -g
192
193all: haproxy
194
Willy Tarreaubaaee002006-06-26 02:48:02 +0200195OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \
196 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
197 src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
198 src/checks.o src/queue.o src/capture.o src/client.o src/proxy.o \
199 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
Willy Tarreau964c9362007-01-07 00:38:00 +0100200 src/session.o src/hdr_idx.o src/rbtree.o
Willy Tarreaubaaee002006-06-26 02:48:02 +0200201
202haproxy: $(OBJS)
willy tarreau0f7af912005-12-17 12:21:26 +0100203 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
204
Willy Tarreaubaaee002006-06-26 02:48:02 +0200205objsize: haproxy
206 @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
207
willy tarreau0f7af912005-12-17 12:21:26 +0100208%.o: %.c
209 $(CC) $(CFLAGS) -c -o $@ $<
210
211clean:
Willy Tarreau1a587492006-10-15 23:40:58 +0200212 rm -f *.[oas] src/*.[oas] core haproxy test
213 for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100214 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz
215 rm -f haproxy-$(VERSION) nohup.out gmon.out
willy tarreauefae1842005-12-17 12:51:03 +0100216
willy tarreaue114bf92006-03-19 21:30:14 +0100217tar: clean
willy tarreaucee272f2006-03-19 21:16:26 +0100218 ln -s . haproxy-$(VERSION)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200219 tar --exclude=haproxy-$(VERSION)/.git \
220 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \
221 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \
222 -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz
willy tarreaucee272f2006-03-19 21:16:26 +0100223 rm -f haproxy-$(VERSION)
224
Willy Tarreau9f0a9012006-10-15 14:24:14 +0200225git-tar: clean
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100226 git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz