blob: c99933af76f090d30b52b9fbfa4b880b4edbca0c [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 tarreau64a3cc32005-12-18 01:13:11 +010036# This is for enhanced Linux 2.4 with netfilter and epoll() patch
37COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL
38LIBS.linux24e =
39
40# This is for standard Linux 2.4 with netfilter but without epoll()
willy tarreau1c2ad212005-12-18 01:11:29 +010041COPTS.linux24 = -DNETFILTER -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010042LIBS.linux24 =
willy tarreau0f7af912005-12-17 12:21:26 +010043
willy tarreau5cbea6f2005-12-17 12:48:26 +010044# This is for Linux 2.2
willy tarreau1c2ad212005-12-18 01:11:29 +010045COPTS.linux22 = -DUSE_GETSOCKNAME -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010046LIBS.linux22 =
47
48# This is for Solaris 8
willy tarreau64a3cc32005-12-18 01:13:11 +010049COPTS.solaris = -fomit-frame-pointer -DENABLE_POLL -DFD_SETSIZE=65536
willy tarreau9da061b2005-12-17 12:29:56 +010050LIBS.solaris = -lnsl -lsocket
51
willy tarreau5cbea6f2005-12-17 12:48:26 +010052# This is for OpenBSD 3.0
willy tarreau1c2ad212005-12-18 01:11:29 +010053COPTS.openbsd = -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010054LIBS.openbsd =
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 tarreaueedaa9f2005-12-17 14:08:03 +010070# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
willy tarreau64a3cc32005-12-18 01:13:11 +010071#DEBUG = -g -DDEBUG_MEMORY
willy tarreau5cbea6f2005-12-17 12:48:26 +010072DEBUG = -g
willy tarreau9da061b2005-12-17 12:29:56 +010073
willy tarreau0174f312005-12-18 01:02:42 +010074# if small memory footprint is required, you can reduce the buffer size. There
75# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
willy tarreau64a3cc32005-12-18 01:13:11 +010076# with 1000 concurrent sessions. Putting it slightly lower than a page size
77# will avoid the additionnal paramters to overflow a page.
78#SMALL_OPTS = -DBUFSIZE=8100 -DMAXREWRITE=1000
willy tarreau0174f312005-12-18 01:02:42 +010079SMALL_OPTS =
80
willy tarreau1c2ad212005-12-18 01:11:29 +010081# redefine this if you want to add some special PATH to include/libs
82ADDINC =
83ADDLIB =
84
85# set some defines when needed.
86# Known ones are -DENABLE_POLL, -DENABLE_EPOLL, and -DUSE_MY_EPOLL
87DEFINE =
willy tarreau0174f312005-12-18 01:02:42 +010088
willy tarreaueedaa9f2005-12-17 14:08:03 +010089# global options
90TARGET_OPTS=$(COPTS.$(TARGET))
91REGEX_OPTS=$(COPTS.$(REGEX))
92CPU_OPTS=$(COPTS.$(CPU))
93
willy tarreau1c2ad212005-12-18 01:11:29 +010094COPTS=-I. $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE)
willy tarreauad90a0c2005-12-18 01:09:15 +010095LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +010096
willy tarreau5cbea6f2005-12-17 12:48:26 +010097# - use -DSTATTIME=0 to disable statistics, else specify an interval in
98# milliseconds.
willy tarreaua1598082005-12-17 13:08:06 +010099# - use -DTPROXY to compile with transparent proxy support.
100CFLAGS = -Wall $(COPTS) $(DEBUG) -DSTATTIME=0 -DTPROXY
willy tarreau0f7af912005-12-17 12:21:26 +0100101LDFLAGS = -g
102
103all: haproxy
104
willy tarreau12350152005-12-18 01:03:27 +0100105haproxy: src/list.o src/chtbl.o src/hashpjw.o haproxy.o
willy tarreau0f7af912005-12-17 12:21:26 +0100106 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
107
108%.o: %.c
109 $(CC) $(CFLAGS) -c -o $@ $<
110
111clean:
willy tarreau12350152005-12-18 01:03:27 +0100112 rm -f *.[oas] *~ *.rej core haproxy test nohup.out gmon.out src/*.[oas]
willy tarreauefae1842005-12-17 12:51:03 +0100113