blob: 63ba90fff4fb2ff330281c289599ce8736e433dd [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 tarreau750a4722005-12-17 13:21:24 +01005# Select target OS. TARGET must match a system for which COPTS and LIBS are
6# correctly defined below.
willy tarreau1c2ad212005-12-18 01:11:29 +01007#TARGET = linux26
willy tarreau750a4722005-12-17 13:21:24 +01008TARGET = linux24
willy tarreau64a3cc32005-12-18 01:13:11 +01009#TARGET = linux24e
willy tarreau750a4722005-12-17 13:21:24 +010010#TARGET = linux22
11#TARGET = solaris
willy tarreau750a4722005-12-17 13:21:24 +010012
willy tarreaueedaa9f2005-12-17 14:08:03 +010013# pass CPU=<cpu_name> to make to optimize for a particular CPU
14CPU = generic
15#CPU = i586
16#CPU = i686
17#CPU = ultrasparc
willy tarreau0f7af912005-12-17 12:21:26 +010018
willy tarreau4373b962005-12-18 01:32:31 +010019# By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group
20# references seem broken using libc ! Use pcre instead.
willy tarreau036e1ce2005-12-17 13:46:33 +010021REGEX=libc
22#REGEX=pcre
willy tarreau4373b962005-12-18 01:32:31 +010023#REGEX=static-pcre
willy tarreau036e1ce2005-12-17 13:46:33 +010024
willy tarreaueedaa9f2005-12-17 14:08:03 +010025# tools options
26CC = gcc
27LD = gcc
28
willy tarreau036e1ce2005-12-17 13:46:33 +010029# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
willy tarreau2f6ba652005-12-17 13:57:42 +010030PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :)
willy tarreau036e1ce2005-12-17 13:46:33 +010031#PCREDIR=/usr/local
32
willy tarreau64a3cc32005-12-18 01:13:11 +010033# This is for standard Linux 2.6 with netfilter and epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010034COPTS.linux26 = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL
35LIBS.linux26 =
36
willy tarreaub952e1d2005-12-18 01:31:20 +010037# This is for enhanced Linux 2.4 with netfilter and epoll() patch.
38# Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add
39# -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug.
40#COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND
willy tarreau64a3cc32005-12-18 01:13:11 +010041COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL
42LIBS.linux24e =
43
44# This is for standard Linux 2.4 with netfilter but without epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010045COPTS.linux24 = -DNETFILTER -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010046LIBS.linux24 =
willy tarreau0f7af912005-12-17 12:21:26 +010047
willy tarreau5cbea6f2005-12-17 12:48:26 +010048# This is for Linux 2.2
willy tarreau1c2ad212005-12-18 01:11:29 +010049COPTS.linux22 = -DUSE_GETSOCKNAME -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010050LIBS.linux22 =
51
52# This is for Solaris 8
willy tarreau64a3cc32005-12-18 01:13:11 +010053COPTS.solaris = -fomit-frame-pointer -DENABLE_POLL -DFD_SETSIZE=65536
willy tarreau9da061b2005-12-17 12:29:56 +010054LIBS.solaris = -lnsl -lsocket
55
willy tarreaueedaa9f2005-12-17 14:08:03 +010056# CPU dependant optimizations
57COPTS.generic = -O2
58COPTS.i586 = -O2 -march=i586
59COPTS.i686 = -O2 -march=i686
60COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
61
62# options for standard regex library
willy tarreau036e1ce2005-12-17 13:46:33 +010063COPTS.libc=
willy tarreaueedaa9f2005-12-17 14:08:03 +010064LIBS.libc=
willy tarreau036e1ce2005-12-17 13:46:33 +010065
willy tarreaueedaa9f2005-12-17 14:08:03 +010066# options for libpcre
willy tarreau036e1ce2005-12-17 13:46:33 +010067COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
68LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
69
willy tarreau4373b962005-12-18 01:32:31 +010070# options for static libpcre
71COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
72LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
73
willy tarreaueedaa9f2005-12-17 14:08:03 +010074# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
willy tarreaud38e72d2006-03-19 20:56:52 +010075#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
willy tarreau5cbea6f2005-12-17 12:48:26 +010076DEBUG = -g
willy tarreau9da061b2005-12-17 12:29:56 +010077
willy tarreau0174f312005-12-18 01:02:42 +010078# if small memory footprint is required, you can reduce the buffer size. There
79# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
willy tarreau64a3cc32005-12-18 01:13:11 +010080# with 1000 concurrent sessions. Putting it slightly lower than a page size
willy tarreaud38e72d2006-03-19 20:56:52 +010081# will avoid the additionnal paramters to overflow a page. 8030 bytes is
82# exactly 5.5 TCP segments of 1460 bytes.
83#SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
willy tarreau0174f312005-12-18 01:02:42 +010084SMALL_OPTS =
85
willy tarreau1c2ad212005-12-18 01:11:29 +010086# redefine this if you want to add some special PATH to include/libs
87ADDINC =
88ADDLIB =
89
90# set some defines when needed.
91# Known ones are -DENABLE_POLL, -DENABLE_EPOLL, and -DUSE_MY_EPOLL
willy tarreaud38e72d2006-03-19 20:56:52 +010092# - use -DSTATTIME=0 to disable statistics, else specify an interval in
93# milliseconds.
94# - use -DTPROXY to compile with transparent proxy support.
95DEFINE = -DSTATTIME=0 -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 tarreau1c2ad212005-12-18 01:11:29 +0100102COPTS=-I. $(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 tarreau12350152005-12-18 01:03:27 +0100110haproxy: src/list.o src/chtbl.o src/hashpjw.o haproxy.o
willy tarreau0f7af912005-12-17 12:21:26 +0100111 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
112
113%.o: %.c
114 $(CC) $(CFLAGS) -c -o $@ $<
115
116clean:
willy tarreau12350152005-12-18 01:03:27 +0100117 rm -f *.[oas] *~ *.rej core haproxy test nohup.out gmon.out src/*.[oas]
willy tarreauefae1842005-12-17 12:51:03 +0100118