blob: 22dc3e778ff7b6936fe87fe8eec969083cfcee5e [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
16#CPU = i586
17#CPU = i686
18#CPU = ultrasparc
19
20# By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group
21# references seem broken using libc ! Use pcre instead.
22REGEX=libc
23#REGEX=pcre
24#REGEX=static-pcre
25
26# tools options
27CC = gcc
28LD = gcc
29
Willy Tarreau4eeec092006-10-15 23:50:42 +020030# This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre
31PCREDIR!= pcre-config --prefix 2>/dev/null || :
32#PCREDIR=/usr/local
willy tarreaud38e72d2006-03-19 20:56:52 +010033
Willy Tarreau4eeec092006-10-15 23:50:42 +020034# This is for OpenBSD 3.0 and above
Willy Tarreau1e63130a2007-04-09 12:03:06 +020035COPTS.openbsd = -DENABLE_POLL -DENABLE_KQUEUE
willy tarreaud38e72d2006-03-19 20:56:52 +010036LIBS.openbsd =
37
38# CPU dependant optimizations
39COPTS.generic = -O2
40COPTS.i586 = -O2 -march=i586
41COPTS.i686 = -O2 -march=i686
42COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
43
44# options for standard regex library
45COPTS.libc=
46LIBS.libc=
47
48# options for libpcre
49COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
50LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
51
52# options for static libpcre
53COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
54LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
55
56# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
57#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
58DEBUG = -g
59
60# if small memory footprint is required, you can reduce the buffer size. There
61# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
62# with 1000 concurrent sessions. Putting it slightly lower than a page size
63# will avoid the additionnal paramters to overflow a page. 8030 bytes is
64# exactly 5.5 TCP segments of 1460 bytes.
65#SMALL_OPTS =
66SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
67
68# redefine this if you want to add some special PATH to include/libs
69ADDINC =
70ADDLIB =
71
Willy Tarreauf2ef8c52007-07-11 09:19:31 +020072# redefine this if you want to add some special .o files
73OPT_OBJS =
74
willy tarreaud38e72d2006-03-19 20:56:52 +010075# set some defines when needed.
Willy Tarreau4eeec092006-10-15 23:50:42 +020076# Known ones are -DENABLE_POLL
willy tarreaud38e72d2006-03-19 20:56:52 +010077# - use -DTPROXY to compile with transparent proxy support.
Willy Tarreaubaaee002006-06-26 02:48:02 +020078DEFINE = -DTPROXY
willy tarreaud38e72d2006-03-19 20:56:52 +010079
Willy Tarreauf2ef8c52007-07-11 09:19:31 +020080# May be changed to patch PAGE_SIZE on every platform when using dlmalloc
81DLMALLOC_THRES=4096
82
willy tarreaud38e72d2006-03-19 20:56:52 +010083# global options
84TARGET_OPTS=$(COPTS.$(TARGET))
85REGEX_OPTS=$(COPTS.$(REGEX))
86CPU_OPTS=$(COPTS.$(CPU))
87
Willy Tarreauec692562007-09-09 23:31:11 +020088VERSION != cat VERSION 2>/dev/null || touch VERSION
89SUBVERS != cat SUBVERS 2>/dev/null || touch SUBVERS
90VERDATE != cat VERDATE 2>/dev/null || touch VERDATE
willy tarreaud38e72d2006-03-19 20:56:52 +010091
Willy Tarreauec692562007-09-09 23:31:11 +020092VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \
93 -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
94
95COPTS = -Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) \
96 $(SMALL_OPTS) $(VER_OPTS) $(DEFINE)
97LIBS = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
98CFLAGS = -Wall $(COPTS) $(DEBUG)
willy tarreaud38e72d2006-03-19 20:56:52 +010099LDFLAGS = -g
100
Willy Tarreaudd815982007-10-16 12:25:14 +0200101OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \
Willy Tarreau4eeec092006-10-15 23:50:42 +0200102 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
Willy Tarreau982b6e32009-01-25 13:49:53 +0100103 src/time.o src/fd.o src/pipe.o src/regex.o src/cfgparse.o src/server.o \
Willy Tarreau92fb9832007-10-16 17:34:28 +0200104 src/checks.o src/queue.o src/client.o src/proxy.o src/proto_uxst.o \
Willy Tarreau4eeec092006-10-15 23:50:42 +0200105 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
Ross West1df24702009-01-22 18:32:41 -0500106 src/stream_interface.o src/dumpstats.o src/proto_tcp.o \
Willy Tarreaue6d2e4d2007-11-15 23:56:17 +0100107 src/session.o src/hdr_idx.o src/ev_select.o \
108 src/ev_poll.o src/ev_kqueue.o \
109 src/acl.o src/memory.o \
110 src/ebtree.o src/eb32tree.o
Willy Tarreau4eeec092006-10-15 23:50:42 +0200111
willy tarreaud38e72d2006-03-19 20:56:52 +0100112all: haproxy
113
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200114haproxy: $(OBJS) $(OPT_OBJS)
willy tarreaud38e72d2006-03-19 20:56:52 +0100115 $(LD) $(LDFLAGS) -o $@ $> $(LIBS)
116
Willy Tarreau4eeec092006-10-15 23:50:42 +0200117.SUFFIXES: .c.o
willy tarreaud0a05bd2006-05-18 01:22:27 +0200118
Willy Tarreau4eeec092006-10-15 23:50:42 +0200119.c.o:
120 $(CC) $(CFLAGS) -c -o $@ $>
willy tarreaud38e72d2006-03-19 20:56:52 +0100121
Willy Tarreau7b066db2007-12-02 11:28:59 +0100122src/haproxy.o: src/haproxy.c
123 $(CC) $(CFLAGS) -DBUILD_TARGET='"$(TARGET)"' -DBUILD_CC='"$(CC)"' \
124 -DBUILD_CPU='"$(CPU)"' -DBUILD_REGEX='"$(REGEX)"' \
125 -DBUILD_OPTS='"$(COPTS)"' -c -o $@ $>
126
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200127src/dlmalloc.o: $(DLMALLOC_SRC)
128 $(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $>
129
willy tarreaud38e72d2006-03-19 20:56:52 +0100130clean:
Willy Tarreau4eeec092006-10-15 23:50:42 +0200131 rm -f *.[oas] src/*.[oas] core haproxy test
132 for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
133 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out
Willy Tarreauec692562007-09-09 23:31:11 +0200134
135version:
136 @echo "VERSION: $(VERSION)"
137 @echo "SUBVERS: $(SUBVERS)"
138 @echo "VERDATE: $(VERDATE)"