blob: 1ce871b72420a43b80b50f17b7f3bc767b745c6b [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 tarreaud38e72d2006-03-19 20:56:52 +010010# Select target OS. TARGET must match a system for which COPTS and LIBS are
11# correctly defined below.
12TARGET = openbsd
13
14# pass CPU=<cpu_name> to make to optimize for a particular CPU
15CPU = generic
Willy Tarreaua5899aa2010-11-28 07:41:00 +010016#CPU = native
willy tarreaud38e72d2006-03-19 20:56:52 +010017#CPU = i586
18#CPU = i686
19#CPU = ultrasparc
20
21# By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group
22# references seem broken using libc ! Use pcre instead.
23REGEX=libc
24#REGEX=pcre
25#REGEX=static-pcre
26
27# tools options
28CC = gcc
29LD = gcc
30
Willy Tarreau4eeec092006-10-15 23:50:42 +020031# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
32PCREDIR!= pcre-config --prefix 2>/dev/null || :
33#PCREDIR=/usr/local
willy tarreaud38e72d2006-03-19 20:56:52 +010034
Willy Tarreau4eeec092006-10-15 23:50:42 +020035# This is for OpenBSD 3.0 and above
Willy Tarreau1e63130a2007-04-09 12:03:06 +020036COPTS.openbsd = -DENABLE_POLL -DENABLE_KQUEUE
willy tarreaud38e72d2006-03-19 20:56:52 +010037LIBS.openbsd =
38
39# CPU dependant optimizations
40COPTS.generic = -O2
Willy Tarreaua5899aa2010-11-28 07:41:00 +010041COPTS.native = -O2 -march=native
willy tarreaud38e72d2006-03-19 20:56:52 +010042COPTS.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))
Willy Tarreau3c9a3fb2010-11-28 08:28:15 +010089SPEC_OPTS=-fno-strict-aliasing
willy tarreaud38e72d2006-03-19 20:56:52 +010090
Willy Tarreauec692562007-09-09 23:31:11 +020091VERSION != cat VERSION 2>/dev/null || touch VERSION
92SUBVERS != cat SUBVERS 2>/dev/null || touch SUBVERS
93VERDATE != cat VERDATE 2>/dev/null || touch VERDATE
willy tarreaud38e72d2006-03-19 20:56:52 +010094
Willy Tarreauec692562007-09-09 23:31:11 +020095VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \
96 -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
97
Willy Tarreau45cb4fb2009-10-26 21:10:04 +010098# This one can be changed to look for ebtree files in an external directory
99EBTREE_DIR := ebtree
100
101COPTS = -Iinclude -I$(EBTREE_DIR) $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) \
Willy Tarreau3c9a3fb2010-11-28 08:28:15 +0100102 $(SPEC_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(VER_OPTS) $(DEFINE)
Willy Tarreauec692562007-09-09 23:31:11 +0200103LIBS = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
104CFLAGS = -Wall $(COPTS) $(DEBUG)
willy tarreaud38e72d2006-03-19 20:56:52 +0100105LDFLAGS = -g
106
Willy Tarreaudd815982007-10-16 12:25:14 +0200107OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \
Willy Tarreau4eeec092006-10-15 23:50:42 +0200108 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
Willy Tarreau982b6e32009-01-25 13:49:53 +0100109 src/time.o src/fd.o src/pipe.o src/regex.o src/cfgparse.o src/server.o \
Willy Tarreau03fa5df2010-05-24 21:02:37 +0200110 src/checks.o src/queue.o src/frontend.o src/proxy.o src/proto_uxst.o \
Willy Tarreau4eeec092006-10-15 23:50:42 +0200111 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
Emeric Brun2b920a12010-09-23 18:30:22 +0200112 src/peers.o src/stream_interface.o src/dumpstats.o src/proto_tcp.o \
Willy Tarreaubc5258d2009-05-10 09:00:20 +0200113 src/session.o src/hdr_idx.o src/ev_select.o src/signal.o \
Willy Tarreau6b2e11b2009-10-01 07:52:15 +0200114 src/lb_chash.o src/lb_fwlc.o src/lb_fwrr.o src/lb_map.o \
Willy Tarreaue6d2e4d2007-11-15 23:56:17 +0100115 src/ev_poll.o src/ev_kqueue.o \
Willy Tarreauf2d9d842010-02-26 21:36:32 +0100116 src/acl.o src/memory.o src/freq_ctr.o \
117 src/auth.o src/stick_table.o src/pattern.o
Willy Tarreau45cb4fb2009-10-26 21:10:04 +0100118
119EBTREE_OBJS = $(EBTREE_DIR)/ebtree.o \
120 $(EBTREE_DIR)/eb32tree.o $(EBTREE_DIR)/eb64tree.o \
121 $(EBTREE_DIR)/ebmbtree.o $(EBTREE_DIR)/ebsttree.o \
122 $(EBTREE_DIR)/ebimtree.o $(EBTREE_DIR)/ebistree.o
Willy Tarreau4eeec092006-10-15 23:50:42 +0200123
willy tarreaud38e72d2006-03-19 20:56:52 +0100124all: haproxy
125
Willy Tarreau45cb4fb2009-10-26 21:10:04 +0100126haproxy: $(OBJS) $(OPT_OBJS) $(EBTREE_OBJS)
willy tarreaud38e72d2006-03-19 20:56:52 +0100127 $(LD) $(LDFLAGS) -o $@ $> $(LIBS)
128
Willy Tarreau4eeec092006-10-15 23:50:42 +0200129.SUFFIXES: .c.o
willy tarreaud0a05bd2006-05-18 01:22:27 +0200130
Willy Tarreau4eeec092006-10-15 23:50:42 +0200131.c.o:
132 $(CC) $(CFLAGS) -c -o $@ $>
willy tarreaud38e72d2006-03-19 20:56:52 +0100133
Willy Tarreau7b066db2007-12-02 11:28:59 +0100134src/haproxy.o: src/haproxy.c
135 $(CC) $(CFLAGS) -DBUILD_TARGET='"$(TARGET)"' -DBUILD_CC='"$(CC)"' \
136 -DBUILD_CPU='"$(CPU)"' -DBUILD_REGEX='"$(REGEX)"' \
137 -DBUILD_OPTS='"$(COPTS)"' -c -o $@ $>
138
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200139src/dlmalloc.o: $(DLMALLOC_SRC)
140 $(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $>
141
willy tarreaud38e72d2006-03-19 20:56:52 +0100142clean:
Willy Tarreau45cb4fb2009-10-26 21:10:04 +0100143 rm -f *.[oas] src/*.[oas] ebtree/*.[oas] haproxy test
144 for dir in . src include/* doc ebtree; do rm -f $$dir/*~ $$dir/*.rej $$dir/core; done
Willy Tarreau4eeec092006-10-15 23:50:42 +0200145 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out
Willy Tarreauec692562007-09-09 23:31:11 +0200146
147version:
148 @echo "VERSION: $(VERSION)"
149 @echo "SUBVERS: $(SUBVERS)"
150 @echo "VERDATE: $(VERDATE)"