blob: 358e5cccc2d09cc0899acdccc5951409d9757b61 [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#TARGET = openbsd
13
willy tarreaueedaa9f2005-12-17 14:08:03 +010014# pass CPU=<cpu_name> to make to optimize for a particular CPU
15CPU = generic
16#CPU = i586
17#CPU = i686
18#CPU = ultrasparc
willy tarreau0f7af912005-12-17 12:21:26 +010019
willy tarreau4373b962005-12-18 01:32:31 +010020# By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group
21# references seem broken using libc ! Use pcre instead.
willy tarreau036e1ce2005-12-17 13:46:33 +010022REGEX=libc
23#REGEX=pcre
willy tarreau4373b962005-12-18 01:32:31 +010024#REGEX=static-pcre
willy tarreau036e1ce2005-12-17 13:46:33 +010025
willy tarreaueedaa9f2005-12-17 14:08:03 +010026# tools options
27CC = gcc
28LD = gcc
29
willy tarreau036e1ce2005-12-17 13:46:33 +010030# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
willy tarreau2f6ba652005-12-17 13:57:42 +010031PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :)
willy tarreau036e1ce2005-12-17 13:46:33 +010032#PCREDIR=/usr/local
33
willy tarreau64a3cc32005-12-18 01:13:11 +010034# This is for standard Linux 2.6 with netfilter and epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010035COPTS.linux26 = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL
36LIBS.linux26 =
37
willy tarreaub952e1d2005-12-18 01:31:20 +010038# This is for enhanced Linux 2.4 with netfilter and epoll() patch.
39# Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add
40# -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug.
41#COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND
willy tarreau64a3cc32005-12-18 01:13:11 +010042COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL
43LIBS.linux24e =
44
45# This is for standard Linux 2.4 with netfilter but without epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010046COPTS.linux24 = -DNETFILTER -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010047LIBS.linux24 =
willy tarreau0f7af912005-12-17 12:21:26 +010048
willy tarreau5cbea6f2005-12-17 12:48:26 +010049# This is for Linux 2.2
willy tarreau1c2ad212005-12-18 01:11:29 +010050COPTS.linux22 = -DUSE_GETSOCKNAME -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010051LIBS.linux22 =
52
53# This is for Solaris 8
willy tarreau64a3cc32005-12-18 01:13:11 +010054COPTS.solaris = -fomit-frame-pointer -DENABLE_POLL -DFD_SETSIZE=65536
willy tarreau9da061b2005-12-17 12:29:56 +010055LIBS.solaris = -lnsl -lsocket
56
willy tarreau5cbea6f2005-12-17 12:48:26 +010057# This is for OpenBSD 3.0
willy tarreau1c2ad212005-12-18 01:11:29 +010058COPTS.openbsd = -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010059LIBS.openbsd =
60
willy tarreaueedaa9f2005-12-17 14:08:03 +010061# CPU dependant optimizations
62COPTS.generic = -O2
63COPTS.i586 = -O2 -march=i586
64COPTS.i686 = -O2 -march=i686
65COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
66
67# options for standard regex library
willy tarreau036e1ce2005-12-17 13:46:33 +010068COPTS.libc=
willy tarreaueedaa9f2005-12-17 14:08:03 +010069LIBS.libc=
willy tarreau036e1ce2005-12-17 13:46:33 +010070
willy tarreaueedaa9f2005-12-17 14:08:03 +010071# options for libpcre
willy tarreau036e1ce2005-12-17 13:46:33 +010072COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
73LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
74
willy tarreau4373b962005-12-18 01:32:31 +010075# options for static libpcre
76COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
77LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
78
willy tarreaueedaa9f2005-12-17 14:08:03 +010079# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
willy tarreau64a3cc32005-12-18 01:13:11 +010080#DEBUG = -g -DDEBUG_MEMORY
willy tarreau5cbea6f2005-12-17 12:48:26 +010081DEBUG = -g
willy tarreau9da061b2005-12-17 12:29:56 +010082
willy tarreau0174f312005-12-18 01:02:42 +010083# if small memory footprint is required, you can reduce the buffer size. There
84# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
willy tarreau64a3cc32005-12-18 01:13:11 +010085# with 1000 concurrent sessions. Putting it slightly lower than a page size
86# will avoid the additionnal paramters to overflow a page.
87#SMALL_OPTS = -DBUFSIZE=8100 -DMAXREWRITE=1000
willy tarreau0174f312005-12-18 01:02:42 +010088SMALL_OPTS =
89
willy tarreau1c2ad212005-12-18 01:11:29 +010090# redefine this if you want to add some special PATH to include/libs
91ADDINC =
92ADDLIB =
93
94# set some defines when needed.
95# Known ones are -DENABLE_POLL, -DENABLE_EPOLL, and -DUSE_MY_EPOLL
96DEFINE =
willy tarreau0174f312005-12-18 01:02:42 +010097
willy tarreaueedaa9f2005-12-17 14:08:03 +010098# global options
99TARGET_OPTS=$(COPTS.$(TARGET))
100REGEX_OPTS=$(COPTS.$(REGEX))
101CPU_OPTS=$(COPTS.$(CPU))
102
willy tarreau1c2ad212005-12-18 01:11:29 +0100103COPTS=-I. $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE)
willy tarreauad90a0c2005-12-18 01:09:15 +0100104LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +0100105
willy tarreau5cbea6f2005-12-17 12:48:26 +0100106# - use -DSTATTIME=0 to disable statistics, else specify an interval in
107# milliseconds.
willy tarreaua1598082005-12-17 13:08:06 +0100108# - use -DTPROXY to compile with transparent proxy support.
109CFLAGS = -Wall $(COPTS) $(DEBUG) -DSTATTIME=0 -DTPROXY
willy tarreau0f7af912005-12-17 12:21:26 +0100110LDFLAGS = -g
111
112all: haproxy
113
Willy TARREAUedb12df2006-01-29 23:19:04 +0100114# on OpenBSD, you have to do it this way :
115haproxy.bsd: src/list.o src/chtbl.o src/hashpjw.o haproxy.o
116 $(LD) $(LDFLAGS) -o $@ $> $(LIBS)
117
willy tarreau12350152005-12-18 01:03:27 +0100118haproxy: src/list.o src/chtbl.o src/hashpjw.o haproxy.o
willy tarreau0f7af912005-12-17 12:21:26 +0100119 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
120
121%.o: %.c
122 $(CC) $(CFLAGS) -c -o $@ $<
123
124clean:
willy tarreau12350152005-12-18 01:03:27 +0100125 rm -f *.[oas] *~ *.rej core haproxy test nohup.out gmon.out src/*.[oas]
willy tarreauefae1842005-12-17 12:51:03 +0100126