blob: 29a79fcb646226c465db141d3e93defe8d136844 [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 tarreau750a4722005-12-17 13:21:24 +01007TARGET = linux24
8#TARGET = linux22
9#TARGET = solaris
willy tarreau750a4722005-12-17 13:21:24 +010010#TARGET = openbsd
11
willy tarreaueedaa9f2005-12-17 14:08:03 +010012# pass CPU=<cpu_name> to make to optimize for a particular CPU
13CPU = generic
14#CPU = i586
15#CPU = i686
16#CPU = ultrasparc
willy tarreau0f7af912005-12-17 12:21:26 +010017
willy tarreau036e1ce2005-12-17 13:46:33 +010018# By default, we use libc's regex.
19REGEX=libc
20#REGEX=pcre
21
willy tarreaueedaa9f2005-12-17 14:08:03 +010022# tools options
23CC = gcc
24LD = gcc
25
willy tarreau036e1ce2005-12-17 13:46:33 +010026# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
willy tarreau2f6ba652005-12-17 13:57:42 +010027PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :)
willy tarreau036e1ce2005-12-17 13:46:33 +010028#PCREDIR=/usr/local
29
willy tarreau5cbea6f2005-12-17 12:48:26 +010030# This is for Linux 2.4 with netfilter
willy tarreaueedaa9f2005-12-17 14:08:03 +010031COPTS.linux24 = -DNETFILTER
willy tarreau5cbea6f2005-12-17 12:48:26 +010032LIBS.linux24 =
willy tarreau0f7af912005-12-17 12:21:26 +010033
willy tarreau5cbea6f2005-12-17 12:48:26 +010034# This is for Linux 2.2
willy tarreaueedaa9f2005-12-17 14:08:03 +010035COPTS.linux22 = -DUSE_GETSOCKNAME
willy tarreau5cbea6f2005-12-17 12:48:26 +010036LIBS.linux22 =
37
38# This is for Solaris 8
willy tarreaueedaa9f2005-12-17 14:08:03 +010039COPTS.solaris = -fomit-frame-pointer -DSOLARIS
willy tarreau9da061b2005-12-17 12:29:56 +010040LIBS.solaris = -lnsl -lsocket
41
willy tarreau5cbea6f2005-12-17 12:48:26 +010042# This is for OpenBSD 3.0
willy tarreaueedaa9f2005-12-17 14:08:03 +010043COPTS.openbsd =
willy tarreau5cbea6f2005-12-17 12:48:26 +010044LIBS.openbsd =
45
willy tarreaueedaa9f2005-12-17 14:08:03 +010046# CPU dependant optimizations
47COPTS.generic = -O2
48COPTS.i586 = -O2 -march=i586
49COPTS.i686 = -O2 -march=i686
50COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
51
52# options for standard regex library
willy tarreau036e1ce2005-12-17 13:46:33 +010053COPTS.libc=
willy tarreaueedaa9f2005-12-17 14:08:03 +010054LIBS.libc=
willy tarreau036e1ce2005-12-17 13:46:33 +010055
willy tarreaueedaa9f2005-12-17 14:08:03 +010056# options for libpcre
willy tarreau036e1ce2005-12-17 13:46:33 +010057COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
58LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
59
willy tarreaueedaa9f2005-12-17 14:08:03 +010060# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
willy tarreau5cbea6f2005-12-17 12:48:26 +010061#DEBUG =
62DEBUG = -g
willy tarreau9da061b2005-12-17 12:29:56 +010063
willy tarreau0174f312005-12-18 01:02:42 +010064# if small memory footprint is required, you can reduce the buffer size. There
65# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
66# with 1000 concurrent sessions.
67#SMALL_OPTS = -DBUFSIZE=8192 -DMAXREWRITE=1024
68SMALL_OPTS =
69
70
willy tarreaueedaa9f2005-12-17 14:08:03 +010071# global options
72TARGET_OPTS=$(COPTS.$(TARGET))
73REGEX_OPTS=$(COPTS.$(REGEX))
74CPU_OPTS=$(COPTS.$(CPU))
75
willy tarreau12350152005-12-18 01:03:27 +010076COPTS=-I. $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS)
willy tarreau036e1ce2005-12-17 13:46:33 +010077LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX))
willy tarreau0f7af912005-12-17 12:21:26 +010078
willy tarreau5cbea6f2005-12-17 12:48:26 +010079# - use -DSTATTIME=0 to disable statistics, else specify an interval in
80# milliseconds.
willy tarreaua1598082005-12-17 13:08:06 +010081# - use -DTPROXY to compile with transparent proxy support.
82CFLAGS = -Wall $(COPTS) $(DEBUG) -DSTATTIME=0 -DTPROXY
willy tarreau0f7af912005-12-17 12:21:26 +010083LDFLAGS = -g
84
85all: haproxy
86
willy tarreau12350152005-12-18 01:03:27 +010087haproxy: src/list.o src/chtbl.o src/hashpjw.o haproxy.o
willy tarreau0f7af912005-12-17 12:21:26 +010088 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
89
90%.o: %.c
91 $(CC) $(CFLAGS) -c -o $@ $<
92
93clean:
willy tarreau12350152005-12-18 01:03:27 +010094 rm -f *.[oas] *~ *.rej core haproxy test nohup.out gmon.out src/*.[oas]
willy tarreauefae1842005-12-17 12:51:03 +010095