blob: 906e8ee95dc8993a6de90ba4fbb86ba430a54cc5 [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.
Willy Tarreau6620dbb2007-01-02 00:44:53 +010099ifeq ($(IGNOREGIT),)
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100100VERSION := $(shell [ -d .git/. ] && ref=$$(git-describe --tags 2>/dev/null) && ref=$${ref%-g*} && echo "$${ref\#v}" )
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100101endif
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100102
103ifneq ($(VERSION),)
104# OK git is there and works.
105SUBVERS := $(shell comms=$$(git-log --no-merges v$(VERSION).. 2>/dev/null |grep -c ^commit ); [ $$comms -gt 0 ] && echo "-$$comms" )
106VERDATE := $(shell date +%Y/%m/%d -d "$$(git-log HEAD^.. 2>/dev/null | grep ^Date: | cut -f2- -d: | cut -f1 -d+)" )
107else
108# Otherwise, use the hard-coded version of last tag, number of changes
109# since last tag, and release date.
Willy Tarreau6620dbb2007-01-02 00:44:53 +0100110VERSION := 1.3.4
111SUBVERS :=
112VERDATE := 2007/01/02
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100113endif
Willy Tarreau77074d52006-11-12 23:57:19 +0100114
115#### build options
116
117# do not change this one, enable USE_* variables instead.
118OPTIONS =
119
120ifneq ($(USE_CTTPROXY),)
121OPTIONS += -DCONFIG_HAP_CTTPROXY
122endif
123
124ifneq ($(USE_TPROXY),)
125OPTIONS += -DTPROXY
126endif
127
128ifneq ($(USE_POLL),)
129OPTIONS += -DENABLE_POLL
130endif
131
132ifneq ($(USE_EPOLL),)
133OPTIONS += -DENABLE_EPOLL
134endif
135
136ifneq ($(USE_MY_EPOLL),)
137OPTIONS += -DUSE_MY_EPOLL
138endif
139
140ifneq ($(USE_NETFILTER),)
141OPTIONS += -DNETFILTER
142endif
143
144ifneq ($(USE_EPOLL_WORKAROUND),)
145OPTIONS += -DEPOLL_CTL_MOD_WORKAROUND
146endif
147
148ifneq ($(USE_GETSOCKNAME),)
149OPTIONS += -DUSE_GETSOCKNAME
150endif
151
152ifneq ($(USE_REGPARM),)
153OPTIONS += -DCONFIG_HAP_USE_REGPARM
154endif
155
Willy Tarreau79b34bf2006-12-22 15:28:43 +0100156ifneq ($(VERSION),)
157OPTIONS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
158endif
159
160ifneq ($(VERDATE),)
161OPTIONS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
162endif
163
Willy Tarreau77074d52006-11-12 23:57:19 +0100164#### end of build options
165
166
willy tarreaueedaa9f2005-12-17 14:08:03 +0100167# global options
168TARGET_OPTS=$(COPTS.$(TARGET))
169REGEX_OPTS=$(COPTS.$(REGEX))
170CPU_OPTS=$(COPTS.$(CPU))
171
Willy Tarreau77074d52006-11-12 23:57:19 +0100172COPTS=-Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) $(OPTIONS)
willy tarreauad90a0c2005-12-18 01:09:15 +0100173LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +0100174
willy tarreaud38e72d2006-03-19 20:56:52 +0100175CFLAGS = -Wall $(COPTS) $(DEBUG)
willy tarreau0f7af912005-12-17 12:21:26 +0100176LDFLAGS = -g
177
178all: haproxy
179
Willy Tarreaubaaee002006-06-26 02:48:02 +0200180OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \
181 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
182 src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
183 src/checks.o src/queue.o src/capture.o src/client.o src/proxy.o \
184 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
Willy Tarreaue5f20dc2006-12-03 15:21:35 +0100185 src/session.o src/hdr_idx.o
Willy Tarreaubaaee002006-06-26 02:48:02 +0200186
187haproxy: $(OBJS)
willy tarreau0f7af912005-12-17 12:21:26 +0100188 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
189
Willy Tarreaubaaee002006-06-26 02:48:02 +0200190objsize: haproxy
191 @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
192
willy tarreau0f7af912005-12-17 12:21:26 +0100193%.o: %.c
194 $(CC) $(CFLAGS) -c -o $@ $<
195
196clean:
Willy Tarreau1a587492006-10-15 23:40:58 +0200197 rm -f *.[oas] src/*.[oas] core haproxy test
198 for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100199 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz
200 rm -f haproxy-$(VERSION) nohup.out gmon.out
willy tarreauefae1842005-12-17 12:51:03 +0100201
willy tarreaue114bf92006-03-19 21:30:14 +0100202tar: clean
willy tarreaucee272f2006-03-19 21:16:26 +0100203 ln -s . haproxy-$(VERSION)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200204 tar --exclude=haproxy-$(VERSION)/.git \
205 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \
206 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \
207 -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz
willy tarreaucee272f2006-03-19 21:16:26 +0100208 rm -f haproxy-$(VERSION)
209
Willy Tarreau9f0a9012006-10-15 14:24:14 +0200210git-tar: clean
Willy Tarreau9bf6c6e2006-12-23 11:12:04 +0100211 git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz