blob: c7139f7a630d9e870bb021e4506163e660a8122c [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 tarreau036e1ce2005-12-17 13:46:33 +010020# By default, we use libc's regex.
21REGEX=libc
22#REGEX=pcre
23
willy tarreaueedaa9f2005-12-17 14:08:03 +010024# tools options
25CC = gcc
26LD = gcc
27
willy tarreau036e1ce2005-12-17 13:46:33 +010028# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
willy tarreau2f6ba652005-12-17 13:57:42 +010029PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :)
willy tarreau036e1ce2005-12-17 13:46:33 +010030#PCREDIR=/usr/local
31
willy tarreau64a3cc32005-12-18 01:13:11 +010032# This is for standard Linux 2.6 with netfilter and epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010033COPTS.linux26 = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL
34LIBS.linux26 =
35
willy tarreaub952e1d2005-12-18 01:31:20 +010036# This is for enhanced Linux 2.4 with netfilter and epoll() patch.
37# Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add
38# -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug.
39#COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND
willy tarreau64a3cc32005-12-18 01:13:11 +010040COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL
41LIBS.linux24e =
42
43# This is for standard Linux 2.4 with netfilter but without epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010044COPTS.linux24 = -DNETFILTER -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010045LIBS.linux24 =
willy tarreau0f7af912005-12-17 12:21:26 +010046
willy tarreau5cbea6f2005-12-17 12:48:26 +010047# This is for Linux 2.2
willy tarreau1c2ad212005-12-18 01:11:29 +010048COPTS.linux22 = -DUSE_GETSOCKNAME -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010049LIBS.linux22 =
50
51# This is for Solaris 8
willy tarreau64a3cc32005-12-18 01:13:11 +010052COPTS.solaris = -fomit-frame-pointer -DENABLE_POLL -DFD_SETSIZE=65536
willy tarreau9da061b2005-12-17 12:29:56 +010053LIBS.solaris = -lnsl -lsocket
54
willy tarreau5cbea6f2005-12-17 12:48:26 +010055# This is for OpenBSD 3.0
willy tarreau1c2ad212005-12-18 01:11:29 +010056COPTS.openbsd = -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010057LIBS.openbsd =
58
willy tarreaueedaa9f2005-12-17 14:08:03 +010059# CPU dependant optimizations
60COPTS.generic = -O2
61COPTS.i586 = -O2 -march=i586
62COPTS.i686 = -O2 -march=i686
63COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
64
65# options for standard regex library
willy tarreau036e1ce2005-12-17 13:46:33 +010066COPTS.libc=
willy tarreaueedaa9f2005-12-17 14:08:03 +010067LIBS.libc=
willy tarreau036e1ce2005-12-17 13:46:33 +010068
willy tarreaueedaa9f2005-12-17 14:08:03 +010069# options for libpcre
willy tarreau036e1ce2005-12-17 13:46:33 +010070COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
71LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
72
willy tarreaueedaa9f2005-12-17 14:08:03 +010073# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
willy tarreau64a3cc32005-12-18 01:13:11 +010074#DEBUG = -g -DDEBUG_MEMORY
willy tarreau5cbea6f2005-12-17 12:48:26 +010075DEBUG = -g
willy tarreau9da061b2005-12-17 12:29:56 +010076
willy tarreau0174f312005-12-18 01:02:42 +010077# if small memory footprint is required, you can reduce the buffer size. There
78# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
willy tarreau64a3cc32005-12-18 01:13:11 +010079# with 1000 concurrent sessions. Putting it slightly lower than a page size
80# will avoid the additionnal paramters to overflow a page.
81#SMALL_OPTS = -DBUFSIZE=8100 -DMAXREWRITE=1000
willy tarreau0174f312005-12-18 01:02:42 +010082SMALL_OPTS =
83
willy tarreau1c2ad212005-12-18 01:11:29 +010084# redefine this if you want to add some special PATH to include/libs
85ADDINC =
86ADDLIB =
87
88# set some defines when needed.
89# Known ones are -DENABLE_POLL, -DENABLE_EPOLL, and -DUSE_MY_EPOLL
90DEFINE =
willy tarreau0174f312005-12-18 01:02:42 +010091
willy tarreaueedaa9f2005-12-17 14:08:03 +010092# global options
93TARGET_OPTS=$(COPTS.$(TARGET))
94REGEX_OPTS=$(COPTS.$(REGEX))
95CPU_OPTS=$(COPTS.$(CPU))
96
willy tarreau1c2ad212005-12-18 01:11:29 +010097COPTS=-I. $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE)
willy tarreauad90a0c2005-12-18 01:09:15 +010098LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +010099
willy tarreau5cbea6f2005-12-17 12:48:26 +0100100# - use -DSTATTIME=0 to disable statistics, else specify an interval in
101# milliseconds.
willy tarreaua1598082005-12-17 13:08:06 +0100102# - use -DTPROXY to compile with transparent proxy support.
103CFLAGS = -Wall $(COPTS) $(DEBUG) -DSTATTIME=0 -DTPROXY
willy tarreau0f7af912005-12-17 12:21:26 +0100104LDFLAGS = -g
105
106all: haproxy
107
willy tarreau12350152005-12-18 01:03:27 +0100108haproxy: src/list.o src/chtbl.o src/hashpjw.o haproxy.o
willy tarreau0f7af912005-12-17 12:21:26 +0100109 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
110
111%.o: %.c
112 $(CC) $(CFLAGS) -c -o $@ $<
113
114clean:
willy tarreau12350152005-12-18 01:03:27 +0100115 rm -f *.[oas] *~ *.rej core haproxy test nohup.out gmon.out src/*.[oas]
willy tarreauefae1842005-12-17 12:51:03 +0100116