blob: 3991baa4cfe540ed0e71e07553e0896f0a73449c [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
9#TARGET = linux22
10#TARGET = solaris
willy tarreau750a4722005-12-17 13:21:24 +010011#TARGET = openbsd
12
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 tarreau036e1ce2005-12-17 13:46:33 +010019# By default, we use libc's regex.
20REGEX=libc
21#REGEX=pcre
22
willy tarreaueedaa9f2005-12-17 14:08:03 +010023# tools options
24CC = gcc
25LD = gcc
26
willy tarreau036e1ce2005-12-17 13:46:33 +010027# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
willy tarreau2f6ba652005-12-17 13:57:42 +010028PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :)
willy tarreau036e1ce2005-12-17 13:46:33 +010029#PCREDIR=/usr/local
30
willy tarreau1c2ad212005-12-18 01:11:29 +010031# This is for Linux 2.6 with netfilter and EPOLL
32COPTS.linux26 = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL
33LIBS.linux26 =
34
willy tarreau5cbea6f2005-12-17 12:48:26 +010035# This is for Linux 2.4 with netfilter
willy tarreau1c2ad212005-12-18 01:11:29 +010036COPTS.linux24 = -DNETFILTER -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010037LIBS.linux24 =
willy tarreau0f7af912005-12-17 12:21:26 +010038
willy tarreau5cbea6f2005-12-17 12:48:26 +010039# This is for Linux 2.2
willy tarreau1c2ad212005-12-18 01:11:29 +010040COPTS.linux22 = -DUSE_GETSOCKNAME -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010041LIBS.linux22 =
42
43# This is for Solaris 8
willy tarreau1c2ad212005-12-18 01:11:29 +010044COPTS.solaris = -fomit-frame-pointer -DSOLARIS -DENABLE_POLL
willy tarreau9da061b2005-12-17 12:29:56 +010045LIBS.solaris = -lnsl -lsocket
46
willy tarreau5cbea6f2005-12-17 12:48:26 +010047# This is for OpenBSD 3.0
willy tarreau1c2ad212005-12-18 01:11:29 +010048COPTS.openbsd = -DENABLE_POLL
willy tarreau5cbea6f2005-12-17 12:48:26 +010049LIBS.openbsd =
50
willy tarreaueedaa9f2005-12-17 14:08:03 +010051# CPU dependant optimizations
52COPTS.generic = -O2
53COPTS.i586 = -O2 -march=i586
54COPTS.i686 = -O2 -march=i686
55COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
56
57# options for standard regex library
willy tarreau036e1ce2005-12-17 13:46:33 +010058COPTS.libc=
willy tarreaueedaa9f2005-12-17 14:08:03 +010059LIBS.libc=
willy tarreau036e1ce2005-12-17 13:46:33 +010060
willy tarreaueedaa9f2005-12-17 14:08:03 +010061# options for libpcre
willy tarreau036e1ce2005-12-17 13:46:33 +010062COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
63LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
64
willy tarreaueedaa9f2005-12-17 14:08:03 +010065# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
willy tarreau5cbea6f2005-12-17 12:48:26 +010066#DEBUG =
67DEBUG = -g
willy tarreau9da061b2005-12-17 12:29:56 +010068
willy tarreau0174f312005-12-18 01:02:42 +010069# if small memory footprint is required, you can reduce the buffer size. There
70# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
71# with 1000 concurrent sessions.
72#SMALL_OPTS = -DBUFSIZE=8192 -DMAXREWRITE=1024
73SMALL_OPTS =
74
willy tarreau1c2ad212005-12-18 01:11:29 +010075# redefine this if you want to add some special PATH to include/libs
76ADDINC =
77ADDLIB =
78
79# set some defines when needed.
80# Known ones are -DENABLE_POLL, -DENABLE_EPOLL, and -DUSE_MY_EPOLL
81DEFINE =
willy tarreau0174f312005-12-18 01:02:42 +010082
willy tarreaueedaa9f2005-12-17 14:08:03 +010083# global options
84TARGET_OPTS=$(COPTS.$(TARGET))
85REGEX_OPTS=$(COPTS.$(REGEX))
86CPU_OPTS=$(COPTS.$(CPU))
87
willy tarreau1c2ad212005-12-18 01:11:29 +010088COPTS=-I. $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE)
willy tarreauad90a0c2005-12-18 01:09:15 +010089LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
willy tarreau0f7af912005-12-17 12:21:26 +010090
willy tarreau5cbea6f2005-12-17 12:48:26 +010091# - use -DSTATTIME=0 to disable statistics, else specify an interval in
92# milliseconds.
willy tarreaua1598082005-12-17 13:08:06 +010093# - use -DTPROXY to compile with transparent proxy support.
94CFLAGS = -Wall $(COPTS) $(DEBUG) -DSTATTIME=0 -DTPROXY
willy tarreau0f7af912005-12-17 12:21:26 +010095LDFLAGS = -g
96
97all: haproxy
98
willy tarreau12350152005-12-18 01:03:27 +010099haproxy: src/list.o src/chtbl.o src/hashpjw.o haproxy.o
willy tarreau0f7af912005-12-17 12:21:26 +0100100 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
101
102%.o: %.c
103 $(CC) $(CFLAGS) -c -o $@ $<
104
105clean:
willy tarreau12350152005-12-18 01:03:27 +0100106 rm -f *.[oas] *~ *.rej core haproxy test nohup.out gmon.out src/*.[oas]
willy tarreauefae1842005-12-17 12:51:03 +0100107