blob: 025bc4593feddec1a5afa42d2a67ac02642f034a [file] [log] [blame]
willy tarreaud38e72d2006-03-19 20:56:52 +01001# This makefile is dedicated to OpenBSD (and possibly other BSDs)
Willy Tarreau4eeec092006-10-15 23:50:42 +02002# You should use it this way :
3# make TARGET=os CPU=cpu
Willy Tarreauf2ef8c52007-07-11 09:19:31 +02004#
5# Some optional components may be added, such as DLMALLOC :
6#
7# make TARGET=freebsd CPU=i686 DLMALLOC_SRC=/usr/local/src/dlmalloc.c \
8# OPT_OBJS=src/dlmalloc.o
Willy Tarreau4eeec092006-10-15 23:50:42 +02009
Willy Tarreaub21152b2007-06-17 23:41:40 +020010VERSION := 1.3.12
willy tarreaud38e72d2006-03-19 20:56:52 +010011
12# Select target OS. TARGET must match a system for which COPTS and LIBS are
13# correctly defined below.
14TARGET = openbsd
15
16# pass CPU=<cpu_name> to make to optimize for a particular CPU
17CPU = generic
18#CPU = i586
19#CPU = i686
20#CPU = ultrasparc
21
22# By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group
23# references seem broken using libc ! Use pcre instead.
24REGEX=libc
25#REGEX=pcre
26#REGEX=static-pcre
27
28# tools options
29CC = gcc
30LD = gcc
31
Willy Tarreau4eeec092006-10-15 23:50:42 +020032# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
33PCREDIR!= pcre-config --prefix 2>/dev/null || :
34#PCREDIR=/usr/local
willy tarreaud38e72d2006-03-19 20:56:52 +010035
Willy Tarreau4eeec092006-10-15 23:50:42 +020036# This is for OpenBSD 3.0 and above
Willy Tarreau1e63130a2007-04-09 12:03:06 +020037COPTS.openbsd = -DENABLE_POLL -DENABLE_KQUEUE
willy tarreaud38e72d2006-03-19 20:56:52 +010038LIBS.openbsd =
39
40# CPU dependant optimizations
41COPTS.generic = -O2
42COPTS.i586 = -O2 -march=i586
43COPTS.i686 = -O2 -march=i686
44COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
45
46# options for standard regex library
47COPTS.libc=
48LIBS.libc=
49
50# options for libpcre
51COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
52LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
53
54# options for static libpcre
55COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
56LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
57
58# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
59#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
60DEBUG = -g
61
62# if small memory footprint is required, you can reduce the buffer size. There
63# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
64# with 1000 concurrent sessions. Putting it slightly lower than a page size
65# will avoid the additionnal paramters to overflow a page. 8030 bytes is
66# exactly 5.5 TCP segments of 1460 bytes.
67#SMALL_OPTS =
68SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
69
70# redefine this if you want to add some special PATH to include/libs
71ADDINC =
72ADDLIB =
73
Willy Tarreauf2ef8c52007-07-11 09:19:31 +020074# redefine this if you want to add some special .o files
75OPT_OBJS =
76
willy tarreaud38e72d2006-03-19 20:56:52 +010077# set some defines when needed.
Willy Tarreau4eeec092006-10-15 23:50:42 +020078# Known ones are -DENABLE_POLL
willy tarreaud38e72d2006-03-19 20:56:52 +010079# - use -DTPROXY to compile with transparent proxy support.
Willy Tarreaubaaee002006-06-26 02:48:02 +020080DEFINE = -DTPROXY
willy tarreaud38e72d2006-03-19 20:56:52 +010081
Willy Tarreauf2ef8c52007-07-11 09:19:31 +020082# May be changed to patch PAGE_SIZE on every platform when using dlmalloc
83DLMALLOC_THRES=4096
84
willy tarreaud38e72d2006-03-19 20:56:52 +010085# global options
86TARGET_OPTS=$(COPTS.$(TARGET))
87REGEX_OPTS=$(COPTS.$(REGEX))
88CPU_OPTS=$(COPTS.$(CPU))
89
Willy Tarreau4eeec092006-10-15 23:50:42 +020090COPTS=-Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE)
willy tarreaud38e72d2006-03-19 20:56:52 +010091LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
92
93CFLAGS = -Wall $(COPTS) $(DEBUG)
94LDFLAGS = -g
95
Willy Tarreau4eeec092006-10-15 23:50:42 +020096OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \
97 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
98 src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
Willy Tarreau086b3b42007-05-13 21:45:51 +020099 src/checks.o src/queue.o src/client.o src/proxy.o \
Willy Tarreau4eeec092006-10-15 23:50:42 +0200100 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
Willy Tarreau2e8eb672007-04-30 17:30:59 +0200101 src/session.o src/hdr_idx.o src/ev_select.o src/ev_poll.o \
Willy Tarreau50e608d2007-05-13 18:26:08 +0200102 src/ev_kqueue.o src/acl.o src/memory.o
Willy Tarreau4eeec092006-10-15 23:50:42 +0200103
willy tarreaud38e72d2006-03-19 20:56:52 +0100104all: haproxy
105
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200106haproxy: $(OBJS) $(OPT_OBJS)
willy tarreaud38e72d2006-03-19 20:56:52 +0100107 $(LD) $(LDFLAGS) -o $@ $> $(LIBS)
108
Willy Tarreau4eeec092006-10-15 23:50:42 +0200109.SUFFIXES: .c.o
willy tarreaud0a05bd2006-05-18 01:22:27 +0200110
Willy Tarreau4eeec092006-10-15 23:50:42 +0200111.c.o:
112 $(CC) $(CFLAGS) -c -o $@ $>
willy tarreaud38e72d2006-03-19 20:56:52 +0100113
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200114src/dlmalloc.o: $(DLMALLOC_SRC)
115 $(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $>
116
willy tarreaud38e72d2006-03-19 20:56:52 +0100117clean:
Willy Tarreau4eeec092006-10-15 23:50:42 +0200118 rm -f *.[oas] src/*.[oas] core haproxy test
119 for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
120 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out