blob: 0215a6dbc64516cc90ac0d95c787470f977f8a97 [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 tarreau64a3cc32005-12-18 01:13:11 +010034# This is for standard Linux 2.6 with netfilter and epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010035COPTS.linux26 = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL
36LIBS.linux26 =
37
willy tarreaub952e1d2005-12-18 01:31:20 +010038# This is for enhanced Linux 2.4 with netfilter and epoll() patch.
39# Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add
40# -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug.
41#COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND
willy tarreau64a3cc32005-12-18 01:13:11 +010042COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL
43LIBS.linux24e =
44
45# This is for standard Linux 2.4 with netfilter but without epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010046COPTS.linux24 = -DNETFILTER -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010047LIBS.linux24 =
willy tarreau0f7af912005-12-17 12:21:26 +010048
willy tarreau5cbea6f2005-12-17 12:48:26 +010049# This is for Linux 2.2
willy tarreau1c2ad212005-12-18 01:11:29 +010050COPTS.linux22 = -DUSE_GETSOCKNAME -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010051LIBS.linux22 =
52
53# This is for Solaris 8
willy tarreau64a3cc32005-12-18 01:13:11 +010054COPTS.solaris = -fomit-frame-pointer -DENABLE_POLL -DFD_SETSIZE=65536
willy tarreau9da061b2005-12-17 12:29:56 +010055LIBS.solaris = -lnsl -lsocket
56
willy tarreaueedaa9f2005-12-17 14:08:03 +010057# CPU dependant optimizations
58COPTS.generic = -O2
Willy Tarreau390223b2006-10-15 23:43:42 +020059COPTS.i586 = -O2 -march=i586 -DCONFIG_HAP_USE_REGPARM
60COPTS.i686 = -O2 -march=i686 -DCONFIG_HAP_USE_REGPARM
willy tarreaueedaa9f2005-12-17 14:08:03 +010061COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
62
63# options for standard regex library
willy tarreau036e1ce2005-12-17 13:46:33 +010064COPTS.libc=
willy tarreaueedaa9f2005-12-17 14:08:03 +010065LIBS.libc=
willy tarreau036e1ce2005-12-17 13:46:33 +010066
willy tarreaueedaa9f2005-12-17 14:08:03 +010067# options for libpcre
willy tarreau036e1ce2005-12-17 13:46:33 +010068COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
69LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
70
willy tarreau4373b962005-12-18 01:32:31 +010071# options for static libpcre
72COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
73LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
74
willy tarreaueedaa9f2005-12-17 14:08:03 +010075# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
willy tarreaud38e72d2006-03-19 20:56:52 +010076#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
willy tarreau5cbea6f2005-12-17 12:48:26 +010077DEBUG = -g
willy tarreau9da061b2005-12-17 12:29:56 +010078
willy tarreau0174f312005-12-18 01:02:42 +010079# if small memory footprint is required, you can reduce the buffer size. There
80# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
willy tarreau64a3cc32005-12-18 01:13:11 +010081# with 1000 concurrent sessions. Putting it slightly lower than a page size
willy tarreaud38e72d2006-03-19 20:56:52 +010082# will avoid the additionnal paramters to overflow a page. 8030 bytes is
83# exactly 5.5 TCP segments of 1460 bytes.
84#SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
willy tarreau0174f312005-12-18 01:02:42 +010085SMALL_OPTS =
86
willy tarreau1c2ad212005-12-18 01:11:29 +010087# redefine this if you want to add some special PATH to include/libs
88ADDINC =
89ADDLIB =
90
91# set some defines when needed.
92# Known ones are -DENABLE_POLL, -DENABLE_EPOLL, and -DUSE_MY_EPOLL
willy tarreaud38e72d2006-03-19 20:56:52 +010093# - use -DTPROXY to compile with transparent proxy support.
Willy Tarreau77074d52006-11-12 23:57:19 +010094# - use -DCONFIG_HAP_CTTPROXY to enable full transparent proxy support
Willy Tarreaubaaee002006-06-26 02:48:02 +020095DEFINE = -DTPROXY
willy tarreau0174f312005-12-18 01:02:42 +010096
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +010097# Now let's determine the version, sub-version and release date.
98# If we're in the GIT tree, we can use the last commit's version and date.
99VERSION := $(shell [ -d .git/. ] && ref=$$(git-describe --tags 2>/dev/null) && ref=$${ref%-g*} && echo "$${ref\#v}" )
100
101ifneq ($(VERSION),)
102# OK git is there and works.
103SUBVERS := $(shell comms=$$(git-log --no-merges v$(VERSION).. 2>/dev/null |grep -c ^commit ); [ $$comms -gt 0 ] && echo "-$$comms" )
104VERDATE := $(shell date +%Y/%m/%d -d "$$(git-log HEAD^.. 2>/dev/null | grep ^Date: | cut -f2- -d: | cut -f1 -d+)" )
105else
106# Otherwise, use the hard-coded version of last tag, number of changes
107# since last tag, and release date.
108VERSION := 1.3.3
109SUBVERS := -36
110VERDATE := 2006/12/23
111endif
Willy Tarreau77074d52006-11-12 23:57:19 +0100112
113#### build options
114
115# do not change this one, enable USE_* variables instead.
116OPTIONS =
117
118ifneq ($(USE_CTTPROXY),)
119OPTIONS += -DCONFIG_HAP_CTTPROXY
120endif
121
122ifneq ($(USE_TPROXY),)
123OPTIONS += -DTPROXY
124endif
125
126ifneq ($(USE_POLL),)
127OPTIONS += -DENABLE_POLL
128endif
129
130ifneq ($(USE_EPOLL),)
131OPTIONS += -DENABLE_EPOLL
132endif
133
134ifneq ($(USE_MY_EPOLL),)
135OPTIONS += -DUSE_MY_EPOLL
136endif
137
138ifneq ($(USE_NETFILTER),)
139OPTIONS += -DNETFILTER
140endif
141
142ifneq ($(USE_EPOLL_WORKAROUND),)
143OPTIONS += -DEPOLL_CTL_MOD_WORKAROUND
144endif
145
146ifneq ($(USE_GETSOCKNAME),)
147OPTIONS += -DUSE_GETSOCKNAME
148endif
149
150ifneq ($(USE_REGPARM),)
151OPTIONS += -DCONFIG_HAP_USE_REGPARM
152endif
153
Willy Tarreau79b34bf2006-12-22 15:28:43 +0100154ifneq ($(VERSION),)
155OPTIONS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
156endif
157
158ifneq ($(VERDATE),)
159OPTIONS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
160endif
161
Willy Tarreau77074d52006-11-12 23:57:19 +0100162#### end of build options
163
164
willy tarreaueedaa9f2005-12-17 14:08:03 +0100165# global options
166TARGET_OPTS=$(COPTS.$(TARGET))
167REGEX_OPTS=$(COPTS.$(REGEX))
168CPU_OPTS=$(COPTS.$(CPU))
169
Willy Tarreau77074d52006-11-12 23:57:19 +0100170COPTS=-Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) $(OPTIONS)
willy tarreauad90a0c2005-12-18 01:09:15 +0100171LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +0100172
willy tarreaud38e72d2006-03-19 20:56:52 +0100173CFLAGS = -Wall $(COPTS) $(DEBUG)
willy tarreau0f7af912005-12-17 12:21:26 +0100174LDFLAGS = -g
175
176all: haproxy
177
Willy Tarreaubaaee002006-06-26 02:48:02 +0200178OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \
179 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
180 src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
181 src/checks.o src/queue.o src/capture.o src/client.o src/proxy.o \
182 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
Willy Tarreaue5f20dc2006-12-03 15:21:35 +0100183 src/session.o src/hdr_idx.o
Willy Tarreaubaaee002006-06-26 02:48:02 +0200184
185haproxy: $(OBJS)
willy tarreau0f7af912005-12-17 12:21:26 +0100186 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
187
Willy Tarreaubaaee002006-06-26 02:48:02 +0200188objsize: haproxy
189 @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
190
willy tarreau0f7af912005-12-17 12:21:26 +0100191%.o: %.c
192 $(CC) $(CFLAGS) -c -o $@ $<
193
194clean:
Willy Tarreau1a587492006-10-15 23:40:58 +0200195 rm -f *.[oas] src/*.[oas] core haproxy test
196 for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100197 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz
198 rm -f haproxy-$(VERSION) nohup.out gmon.out
willy tarreauefae1842005-12-17 12:51:03 +0100199
willy tarreaue114bf92006-03-19 21:30:14 +0100200tar: clean
willy tarreaucee272f2006-03-19 21:16:26 +0100201 ln -s . haproxy-$(VERSION)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200202 tar --exclude=haproxy-$(VERSION)/.git \
203 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \
204 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \
205 -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz
willy tarreaucee272f2006-03-19 21:16:26 +0100206 rm -f haproxy-$(VERSION)
207
Willy Tarreau9f0a9012006-10-15 14:24:14 +0200208git-tar: clean
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100209 git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz