blob: b10fa21abf9789d4d55cd9969b7c8c4ff6123222 [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 Tarreau79b34bf2006-12-22 15:28:43 +01005# Version of last tag
Willy Tarreau9c9fea42006-10-16 00:03:35 +02006VERSION := 1.3.3
Willy Tarreau79b34bf2006-12-22 15:28:43 +01007# number of changes since last tag
8SUBVERS := -34
9VERDATE := 2006/12/22
willy tarreaucee272f2006-03-19 21:16:26 +010010
willy tarreau750a4722005-12-17 13:21:24 +010011# Select target OS. TARGET must match a system for which COPTS and LIBS are
12# correctly defined below.
willy tarreau1c2ad212005-12-18 01:11:29 +010013#TARGET = linux26
willy tarreau750a4722005-12-17 13:21:24 +010014TARGET = linux24
willy tarreau64a3cc32005-12-18 01:13:11 +010015#TARGET = linux24e
willy tarreau750a4722005-12-17 13:21:24 +010016#TARGET = linux22
17#TARGET = solaris
willy tarreau750a4722005-12-17 13:21:24 +010018
willy tarreaueedaa9f2005-12-17 14:08:03 +010019# pass CPU=<cpu_name> to make to optimize for a particular CPU
20CPU = generic
21#CPU = i586
22#CPU = i686
23#CPU = ultrasparc
willy tarreau0f7af912005-12-17 12:21:26 +010024
willy tarreau4373b962005-12-18 01:32:31 +010025# By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group
26# references seem broken using libc ! Use pcre instead.
willy tarreau036e1ce2005-12-17 13:46:33 +010027REGEX=libc
28#REGEX=pcre
willy tarreau4373b962005-12-18 01:32:31 +010029#REGEX=static-pcre
willy tarreau036e1ce2005-12-17 13:46:33 +010030
willy tarreaueedaa9f2005-12-17 14:08:03 +010031# tools options
32CC = gcc
33LD = gcc
34
willy tarreau036e1ce2005-12-17 13:46:33 +010035# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
willy tarreau2f6ba652005-12-17 13:57:42 +010036PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :)
willy tarreau036e1ce2005-12-17 13:46:33 +010037#PCREDIR=/usr/local
38
willy tarreau64a3cc32005-12-18 01:13:11 +010039# This is for standard Linux 2.6 with netfilter and epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010040COPTS.linux26 = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL
41LIBS.linux26 =
42
willy tarreaub952e1d2005-12-18 01:31:20 +010043# This is for enhanced Linux 2.4 with netfilter and epoll() patch.
44# Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add
45# -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug.
46#COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND
willy tarreau64a3cc32005-12-18 01:13:11 +010047COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL
48LIBS.linux24e =
49
50# This is for standard Linux 2.4 with netfilter but without epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010051COPTS.linux24 = -DNETFILTER -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010052LIBS.linux24 =
willy tarreau0f7af912005-12-17 12:21:26 +010053
willy tarreau5cbea6f2005-12-17 12:48:26 +010054# This is for Linux 2.2
willy tarreau1c2ad212005-12-18 01:11:29 +010055COPTS.linux22 = -DUSE_GETSOCKNAME -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010056LIBS.linux22 =
57
58# This is for Solaris 8
willy tarreau64a3cc32005-12-18 01:13:11 +010059COPTS.solaris = -fomit-frame-pointer -DENABLE_POLL -DFD_SETSIZE=65536
willy tarreau9da061b2005-12-17 12:29:56 +010060LIBS.solaris = -lnsl -lsocket
61
willy tarreaueedaa9f2005-12-17 14:08:03 +010062# CPU dependant optimizations
63COPTS.generic = -O2
Willy Tarreau390223b2006-10-15 23:43:42 +020064COPTS.i586 = -O2 -march=i586 -DCONFIG_HAP_USE_REGPARM
65COPTS.i686 = -O2 -march=i686 -DCONFIG_HAP_USE_REGPARM
willy tarreaueedaa9f2005-12-17 14:08:03 +010066COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
67
68# options for standard regex library
willy tarreau036e1ce2005-12-17 13:46:33 +010069COPTS.libc=
willy tarreaueedaa9f2005-12-17 14:08:03 +010070LIBS.libc=
willy tarreau036e1ce2005-12-17 13:46:33 +010071
willy tarreaueedaa9f2005-12-17 14:08:03 +010072# options for libpcre
willy tarreau036e1ce2005-12-17 13:46:33 +010073COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
74LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
75
willy tarreau4373b962005-12-18 01:32:31 +010076# options for static libpcre
77COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
78LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
79
willy tarreaueedaa9f2005-12-17 14:08:03 +010080# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
willy tarreaud38e72d2006-03-19 20:56:52 +010081#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
willy tarreau5cbea6f2005-12-17 12:48:26 +010082DEBUG = -g
willy tarreau9da061b2005-12-17 12:29:56 +010083
willy tarreau0174f312005-12-18 01:02:42 +010084# if small memory footprint is required, you can reduce the buffer size. There
85# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
willy tarreau64a3cc32005-12-18 01:13:11 +010086# with 1000 concurrent sessions. Putting it slightly lower than a page size
willy tarreaud38e72d2006-03-19 20:56:52 +010087# will avoid the additionnal paramters to overflow a page. 8030 bytes is
88# exactly 5.5 TCP segments of 1460 bytes.
89#SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
willy tarreau0174f312005-12-18 01:02:42 +010090SMALL_OPTS =
91
willy tarreau1c2ad212005-12-18 01:11:29 +010092# redefine this if you want to add some special PATH to include/libs
93ADDINC =
94ADDLIB =
95
96# set some defines when needed.
97# Known ones are -DENABLE_POLL, -DENABLE_EPOLL, and -DUSE_MY_EPOLL
willy tarreaud38e72d2006-03-19 20:56:52 +010098# - use -DTPROXY to compile with transparent proxy support.
Willy Tarreau77074d52006-11-12 23:57:19 +010099# - use -DCONFIG_HAP_CTTPROXY to enable full transparent proxy support
Willy Tarreaubaaee002006-06-26 02:48:02 +0200100DEFINE = -DTPROXY
willy tarreau0174f312005-12-18 01:02:42 +0100101
Willy Tarreau77074d52006-11-12 23:57:19 +0100102
103#### build options
104
105# do not change this one, enable USE_* variables instead.
106OPTIONS =
107
108ifneq ($(USE_CTTPROXY),)
109OPTIONS += -DCONFIG_HAP_CTTPROXY
110endif
111
112ifneq ($(USE_TPROXY),)
113OPTIONS += -DTPROXY
114endif
115
116ifneq ($(USE_POLL),)
117OPTIONS += -DENABLE_POLL
118endif
119
120ifneq ($(USE_EPOLL),)
121OPTIONS += -DENABLE_EPOLL
122endif
123
124ifneq ($(USE_MY_EPOLL),)
125OPTIONS += -DUSE_MY_EPOLL
126endif
127
128ifneq ($(USE_NETFILTER),)
129OPTIONS += -DNETFILTER
130endif
131
132ifneq ($(USE_EPOLL_WORKAROUND),)
133OPTIONS += -DEPOLL_CTL_MOD_WORKAROUND
134endif
135
136ifneq ($(USE_GETSOCKNAME),)
137OPTIONS += -DUSE_GETSOCKNAME
138endif
139
140ifneq ($(USE_REGPARM),)
141OPTIONS += -DCONFIG_HAP_USE_REGPARM
142endif
143
Willy Tarreau79b34bf2006-12-22 15:28:43 +0100144ifneq ($(VERSION),)
145OPTIONS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
146endif
147
148ifneq ($(VERDATE),)
149OPTIONS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
150endif
151
Willy Tarreau77074d52006-11-12 23:57:19 +0100152#### end of build options
153
154
willy tarreaueedaa9f2005-12-17 14:08:03 +0100155# global options
156TARGET_OPTS=$(COPTS.$(TARGET))
157REGEX_OPTS=$(COPTS.$(REGEX))
158CPU_OPTS=$(COPTS.$(CPU))
159
Willy Tarreau77074d52006-11-12 23:57:19 +0100160COPTS=-Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) $(OPTIONS)
willy tarreauad90a0c2005-12-18 01:09:15 +0100161LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +0100162
willy tarreaud38e72d2006-03-19 20:56:52 +0100163CFLAGS = -Wall $(COPTS) $(DEBUG)
willy tarreau0f7af912005-12-17 12:21:26 +0100164LDFLAGS = -g
165
166all: haproxy
167
Willy Tarreaubaaee002006-06-26 02:48:02 +0200168OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \
169 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
170 src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
171 src/checks.o src/queue.o src/capture.o src/client.o src/proxy.o \
172 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
Willy Tarreaue5f20dc2006-12-03 15:21:35 +0100173 src/session.o src/hdr_idx.o
Willy Tarreaubaaee002006-06-26 02:48:02 +0200174
175haproxy: $(OBJS)
willy tarreau0f7af912005-12-17 12:21:26 +0100176 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
177
Willy Tarreaubaaee002006-06-26 02:48:02 +0200178objsize: haproxy
179 @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
180
willy tarreau0f7af912005-12-17 12:21:26 +0100181%.o: %.c
182 $(CC) $(CFLAGS) -c -o $@ $<
183
184clean:
Willy Tarreau1a587492006-10-15 23:40:58 +0200185 rm -f *.[oas] src/*.[oas] core haproxy test
186 for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
Willy Tarreaubaaee002006-06-26 02:48:02 +0200187 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out
willy tarreauefae1842005-12-17 12:51:03 +0100188
willy tarreaue114bf92006-03-19 21:30:14 +0100189tar: clean
willy tarreaucee272f2006-03-19 21:16:26 +0100190 ln -s . haproxy-$(VERSION)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200191 tar --exclude=haproxy-$(VERSION)/.git \
192 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \
193 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \
194 -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz
willy tarreaucee272f2006-03-19 21:16:26 +0100195 rm -f haproxy-$(VERSION)
196
Willy Tarreau9f0a9012006-10-15 14:24:14 +0200197git-tar: clean
Willy Tarreauc21aa082006-12-18 00:15:06 +0100198 ref=$$(git-describe --tags); ref=$${ref%-g*}; ver=$${ref#v};\
199 comms=$$(git-log $$ref..|grep -c ^commit); \
Willy Tarreau9f0a9012006-10-15 14:24:14 +0200200 git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$$ver-$$comms.tar.gz