blob: 1eef960aef93f98ef0b668950cf4431a4c00c3ad [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 :
3# make TARGET=os CPU=cpu
4
Willy Tarreau9c9fea42006-10-16 00:03:35 +02005VERSION := 1.3.3
willy tarreaucee272f2006-03-19 21:16:26 +01006
willy tarreau750a4722005-12-17 13:21:24 +01007# Select target OS. TARGET must match a system for which COPTS and LIBS are
8# correctly defined below.
willy tarreau1c2ad212005-12-18 01:11:29 +01009#TARGET = linux26
willy tarreau750a4722005-12-17 13:21:24 +010010TARGET = linux24
willy tarreau64a3cc32005-12-18 01:13:11 +010011#TARGET = linux24e
willy tarreau750a4722005-12-17 13:21:24 +010012#TARGET = linux22
13#TARGET = solaris
willy tarreau750a4722005-12-17 13:21:24 +010014
willy tarreaueedaa9f2005-12-17 14:08:03 +010015# pass CPU=<cpu_name> to make to optimize for a particular CPU
16CPU = generic
17#CPU = i586
18#CPU = i686
19#CPU = ultrasparc
willy tarreau0f7af912005-12-17 12:21:26 +010020
willy tarreau4373b962005-12-18 01:32:31 +010021# By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group
22# references seem broken using libc ! Use pcre instead.
willy tarreau036e1ce2005-12-17 13:46:33 +010023REGEX=libc
24#REGEX=pcre
willy tarreau4373b962005-12-18 01:32:31 +010025#REGEX=static-pcre
willy tarreau036e1ce2005-12-17 13:46:33 +010026
willy tarreaueedaa9f2005-12-17 14:08:03 +010027# tools options
28CC = gcc
29LD = gcc
30
willy tarreau036e1ce2005-12-17 13:46:33 +010031# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
willy tarreau2f6ba652005-12-17 13:57:42 +010032PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :)
willy tarreau036e1ce2005-12-17 13:46:33 +010033#PCREDIR=/usr/local
34
willy tarreau64a3cc32005-12-18 01:13:11 +010035# This is for standard Linux 2.6 with netfilter and epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010036COPTS.linux26 = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL
37LIBS.linux26 =
38
willy tarreaub952e1d2005-12-18 01:31:20 +010039# This is for enhanced Linux 2.4 with netfilter and epoll() patch.
40# Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add
41# -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug.
42#COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND
willy tarreau64a3cc32005-12-18 01:13:11 +010043COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL
44LIBS.linux24e =
45
46# This is for standard Linux 2.4 with netfilter but without epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010047COPTS.linux24 = -DNETFILTER -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010048LIBS.linux24 =
willy tarreau0f7af912005-12-17 12:21:26 +010049
willy tarreau5cbea6f2005-12-17 12:48:26 +010050# This is for Linux 2.2
willy tarreau1c2ad212005-12-18 01:11:29 +010051COPTS.linux22 = -DUSE_GETSOCKNAME -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010052LIBS.linux22 =
53
54# This is for Solaris 8
willy tarreau64a3cc32005-12-18 01:13:11 +010055COPTS.solaris = -fomit-frame-pointer -DENABLE_POLL -DFD_SETSIZE=65536
willy tarreau9da061b2005-12-17 12:29:56 +010056LIBS.solaris = -lnsl -lsocket
57
willy tarreaueedaa9f2005-12-17 14:08:03 +010058# CPU dependant optimizations
59COPTS.generic = -O2
Willy Tarreau390223b2006-10-15 23:43:42 +020060COPTS.i586 = -O2 -march=i586 -DCONFIG_HAP_USE_REGPARM
61COPTS.i686 = -O2 -march=i686 -DCONFIG_HAP_USE_REGPARM
willy tarreaueedaa9f2005-12-17 14:08:03 +010062COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
63
64# options for standard regex library
willy tarreau036e1ce2005-12-17 13:46:33 +010065COPTS.libc=
willy tarreaueedaa9f2005-12-17 14:08:03 +010066LIBS.libc=
willy tarreau036e1ce2005-12-17 13:46:33 +010067
willy tarreaueedaa9f2005-12-17 14:08:03 +010068# options for libpcre
willy tarreau036e1ce2005-12-17 13:46:33 +010069COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
70LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
71
willy tarreau4373b962005-12-18 01:32:31 +010072# options for static libpcre
73COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
74LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
75
willy tarreaueedaa9f2005-12-17 14:08:03 +010076# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
willy tarreaud38e72d2006-03-19 20:56:52 +010077#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
willy tarreau5cbea6f2005-12-17 12:48:26 +010078DEBUG = -g
willy tarreau9da061b2005-12-17 12:29:56 +010079
willy tarreau0174f312005-12-18 01:02:42 +010080# if small memory footprint is required, you can reduce the buffer size. There
81# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
willy tarreau64a3cc32005-12-18 01:13:11 +010082# with 1000 concurrent sessions. Putting it slightly lower than a page size
willy tarreaud38e72d2006-03-19 20:56:52 +010083# will avoid the additionnal paramters to overflow a page. 8030 bytes is
84# exactly 5.5 TCP segments of 1460 bytes.
85#SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
willy tarreau0174f312005-12-18 01:02:42 +010086SMALL_OPTS =
87
willy tarreau1c2ad212005-12-18 01:11:29 +010088# redefine this if you want to add some special PATH to include/libs
89ADDINC =
90ADDLIB =
91
92# set some defines when needed.
93# Known ones are -DENABLE_POLL, -DENABLE_EPOLL, and -DUSE_MY_EPOLL
willy tarreaud38e72d2006-03-19 20:56:52 +010094# - use -DTPROXY to compile with transparent proxy support.
Willy Tarreau77074d52006-11-12 23:57:19 +010095# - use -DCONFIG_HAP_CTTPROXY to enable full transparent proxy support
Willy Tarreaubaaee002006-06-26 02:48:02 +020096DEFINE = -DTPROXY
willy tarreau0174f312005-12-18 01:02:42 +010097
Willy Tarreau77074d52006-11-12 23:57:19 +010098
99#### build options
100
101# do not change this one, enable USE_* variables instead.
102OPTIONS =
103
104ifneq ($(USE_CTTPROXY),)
105OPTIONS += -DCONFIG_HAP_CTTPROXY
106endif
107
108ifneq ($(USE_TPROXY),)
109OPTIONS += -DTPROXY
110endif
111
112ifneq ($(USE_POLL),)
113OPTIONS += -DENABLE_POLL
114endif
115
116ifneq ($(USE_EPOLL),)
117OPTIONS += -DENABLE_EPOLL
118endif
119
120ifneq ($(USE_MY_EPOLL),)
121OPTIONS += -DUSE_MY_EPOLL
122endif
123
124ifneq ($(USE_NETFILTER),)
125OPTIONS += -DNETFILTER
126endif
127
128ifneq ($(USE_EPOLL_WORKAROUND),)
129OPTIONS += -DEPOLL_CTL_MOD_WORKAROUND
130endif
131
132ifneq ($(USE_GETSOCKNAME),)
133OPTIONS += -DUSE_GETSOCKNAME
134endif
135
136ifneq ($(USE_REGPARM),)
137OPTIONS += -DCONFIG_HAP_USE_REGPARM
138endif
139
140#### end of build options
141
142
willy tarreaueedaa9f2005-12-17 14:08:03 +0100143# global options
144TARGET_OPTS=$(COPTS.$(TARGET))
145REGEX_OPTS=$(COPTS.$(REGEX))
146CPU_OPTS=$(COPTS.$(CPU))
147
Willy Tarreau77074d52006-11-12 23:57:19 +0100148COPTS=-Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) $(OPTIONS)
willy tarreauad90a0c2005-12-18 01:09:15 +0100149LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +0100150
willy tarreaud38e72d2006-03-19 20:56:52 +0100151CFLAGS = -Wall $(COPTS) $(DEBUG)
willy tarreau0f7af912005-12-17 12:21:26 +0100152LDFLAGS = -g
153
154all: haproxy
155
Willy Tarreaubaaee002006-06-26 02:48:02 +0200156OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \
157 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
158 src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
159 src/checks.o src/queue.o src/capture.o src/client.o src/proxy.o \
160 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
161 src/session.o
162
163haproxy: $(OBJS)
willy tarreau0f7af912005-12-17 12:21:26 +0100164 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
165
Willy Tarreaubaaee002006-06-26 02:48:02 +0200166objsize: haproxy
167 @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
168
willy tarreau0f7af912005-12-17 12:21:26 +0100169%.o: %.c
170 $(CC) $(CFLAGS) -c -o $@ $<
171
172clean:
Willy Tarreau1a587492006-10-15 23:40:58 +0200173 rm -f *.[oas] src/*.[oas] core haproxy test
174 for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
Willy Tarreaubaaee002006-06-26 02:48:02 +0200175 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out
willy tarreauefae1842005-12-17 12:51:03 +0100176
willy tarreaue114bf92006-03-19 21:30:14 +0100177tar: clean
willy tarreaucee272f2006-03-19 21:16:26 +0100178 ln -s . haproxy-$(VERSION)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200179 tar --exclude=haproxy-$(VERSION)/.git \
180 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \
181 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \
182 -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz
willy tarreaucee272f2006-03-19 21:16:26 +0100183 rm -f haproxy-$(VERSION)
184
Willy Tarreau9f0a9012006-10-15 14:24:14 +0200185git-tar: clean
186 ref=$(shell git-describe --tags); ver=$${ref#v};\
187 comms=$(shell git-log $$ref..|grep -c ^commit); \
188 git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$$ver-$$comms.tar.gz