blob: c12e51944b76f41cc91b483118d38040a5c2d56f [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 Tarreau690f9aa2006-09-03 11:23:06 +02005VERSION := 1.3.2
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
60COPTS.i586 = -O2 -march=i586
61COPTS.i686 = -O2 -march=i686
62COPTS.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 Tarreaubaaee002006-06-26 02:48:02 +020095DEFINE = -DTPROXY
willy tarreau0174f312005-12-18 01:02:42 +010096
willy tarreaueedaa9f2005-12-17 14:08:03 +010097# global options
98TARGET_OPTS=$(COPTS.$(TARGET))
99REGEX_OPTS=$(COPTS.$(REGEX))
100CPU_OPTS=$(COPTS.$(CPU))
101
Willy Tarreaubaaee002006-06-26 02:48:02 +0200102COPTS=-Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE)
willy tarreauad90a0c2005-12-18 01:09:15 +0100103LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +0100104
willy tarreaud38e72d2006-03-19 20:56:52 +0100105CFLAGS = -Wall $(COPTS) $(DEBUG)
willy tarreau0f7af912005-12-17 12:21:26 +0100106LDFLAGS = -g
107
108all: haproxy
109
Willy Tarreaubaaee002006-06-26 02:48:02 +0200110OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \
111 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
112 src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
113 src/checks.o src/queue.o src/capture.o src/client.o src/proxy.o \
114 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
115 src/session.o
116
117haproxy: $(OBJS)
willy tarreau0f7af912005-12-17 12:21:26 +0100118 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
119
Willy Tarreaubaaee002006-06-26 02:48:02 +0200120objsize: haproxy
121 @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
122
willy tarreau0f7af912005-12-17 12:21:26 +0100123%.o: %.c
124 $(CC) $(CFLAGS) -c -o $@ $<
125
126clean:
Willy Tarreaubaaee002006-06-26 02:48:02 +0200127 rm -f {.,src}/*.[oas] {.,src,include/*,doc}/*{~,.rej} core haproxy test
128 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out
willy tarreauefae1842005-12-17 12:51:03 +0100129
willy tarreaue114bf92006-03-19 21:30:14 +0100130tar: clean
willy tarreaucee272f2006-03-19 21:16:26 +0100131 ln -s . haproxy-$(VERSION)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200132 tar --exclude=haproxy-$(VERSION)/.git \
133 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \
134 --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \
135 -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz
willy tarreaucee272f2006-03-19 21:16:26 +0100136 rm -f haproxy-$(VERSION)
137
Willy Tarreau9f0a9012006-10-15 14:24:14 +0200138git-tar: clean
139 ref=$(shell git-describe --tags); ver=$${ref#v};\
140 comms=$(shell git-log $$ref..|grep -c ^commit); \
141 git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$$ver-$$comms.tar.gz