blob: 71ceeeefd93f6ca520d04499e930a8b2de1f7e0a [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 tarreauc0d4bbd2006-04-15 21:47:50 +02005VERSION := 1.2.12
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 -DSTATTIME=0 to disable statistics, else specify an interval in
95# milliseconds.
96# - use -DTPROXY to compile with transparent proxy support.
97DEFINE = -DSTATTIME=0 -DTPROXY
willy tarreau0174f312005-12-18 01:02:42 +010098
willy tarreaueedaa9f2005-12-17 14:08:03 +010099# global options
100TARGET_OPTS=$(COPTS.$(TARGET))
101REGEX_OPTS=$(COPTS.$(REGEX))
102CPU_OPTS=$(COPTS.$(CPU))
103
willy tarreau1c2ad212005-12-18 01:11:29 +0100104COPTS=-I. $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE)
willy tarreauad90a0c2005-12-18 01:09:15 +0100105LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +0100106
willy tarreaud38e72d2006-03-19 20:56:52 +0100107CFLAGS = -Wall $(COPTS) $(DEBUG)
willy tarreau0f7af912005-12-17 12:21:26 +0100108LDFLAGS = -g
109
110all: haproxy
111
willy tarreau12350152005-12-18 01:03:27 +0100112haproxy: src/list.o src/chtbl.o src/hashpjw.o haproxy.o
willy tarreau0f7af912005-12-17 12:21:26 +0100113 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
114
115%.o: %.c
116 $(CC) $(CFLAGS) -c -o $@ $<
117
118clean:
willy tarreau12350152005-12-18 01:03:27 +0100119 rm -f *.[oas] *~ *.rej core haproxy test nohup.out gmon.out src/*.[oas]
willy tarreaue114bf92006-03-19 21:30:14 +0100120 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)
willy tarreauefae1842005-12-17 12:51:03 +0100121
willy tarreaue114bf92006-03-19 21:30:14 +0100122tar: clean
willy tarreaucee272f2006-03-19 21:16:26 +0100123 ln -s . haproxy-$(VERSION)
124 tar --exclude=haproxy-$(VERSION)/.git --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz
125 rm -f haproxy-$(VERSION)
126