blob: 8201a6a7a4f4319df17a2c89c055051d5a1b6c4d [file] [log] [blame]
Willy Tarreaucec2e7a2007-03-25 16:55:56 +02001# This makefile is dedicated to darwin (and possibly other BSDs)
2# 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 DLMALLOC_SRC=/usr/local/src/dlmalloc.c \
8# OPT_OBJS=src/dlmalloc.o
Willy Tarreaucec2e7a2007-03-25 16:55:56 +02009
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020010# Select target OS. TARGET must match a system for which COPTS and LIBS are
11# correctly defined below.
12TARGET = generic
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 Tarreaucec2e7a2007-03-25 16:55:56 +020017#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
31# 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
34
Willy Tarreau45cb4fb2009-10-26 21:10:04 +010035# This one can be changed to look for ebtree files in an external directory
36EBTREE_DIR = ebtree
37
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020038# This is for darwin 3.0 and above
Willy Tarreau8ae42f42007-04-09 16:30:28 +020039COPTS.darwin = -DENABLE_POLL -DENABLE_KQUEUE
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020040LIBS.darwin =
41
42# CPU dependant optimizations
43COPTS.generic = -O2
Willy Tarreaua5899aa2010-11-28 07:41:00 +010044COPTS.native = -O2 -march=native
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020045COPTS.i586 = -O2 -march=i586
46COPTS.i686 = -O2 -march=i686
47COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
48
49# options for standard regex library
50COPTS.libc=
51LIBS.libc=
52
53# options for libpcre
54COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
55LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
56
57# options for static libpcre
58COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
59LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
60
61# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
62#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
63DEBUG = -g
64
65# if small memory footprint is required, you can reduce the buffer size. There
66# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
67# with 1000 concurrent sessions. Putting it slightly lower than a page size
68# will avoid the additionnal paramters to overflow a page. 8030 bytes is
69# exactly 5.5 TCP segments of 1460 bytes.
70#SMALL_OPTS =
71SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
72
73# redefine this if you want to add some special PATH to include/libs
74ADDINC =
75ADDLIB =
76
77# set some defines when needed.
78# Known ones are -DENABLE_POLL
79# - use -DTPROXY to compile with transparent proxy support.
Willy Tarreau64bc40b2011-03-23 20:00:53 +010080# - use -DUSE_GETADDRINFO to use of getaddrinfo() to resolve IPv6 host names
Willy Tarreau8ae42f42007-04-09 16:30:28 +020081DEFINE = -DTPROXY
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020082
Willy Tarreauf2ef8c52007-07-11 09:19:31 +020083# May be changed to patch PAGE_SIZE on every platform when using dlmalloc
84DLMALLOC_THRES=4096
85
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020086# global options
87TARGET_OPTS=$(COPTS.$(TARGET))
88REGEX_OPTS=$(COPTS.$(REGEX))
89CPU_OPTS=$(COPTS.$(CPU))
Willy Tarreau3c9a3fb2010-11-28 08:28:15 +010090SPEC_OPTS=-fno-strict-aliasing
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020091
Willy Tarreauec692562007-09-09 23:31:11 +020092VERSION != cat VERSION 2>/dev/null || touch VERSION
93SUBVERS != cat SUBVERS 2>/dev/null || touch SUBVERS
94VERDATE != cat VERDATE 2>/dev/null || touch VERDATE
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020095
Willy Tarreauec692562007-09-09 23:31:11 +020096VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \
97 -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
98
Willy Tarreau45cb4fb2009-10-26 21:10:04 +010099COPTS = -Iinclude -I$(EBTREE_DIR) $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) \
Willy Tarreau3c9a3fb2010-11-28 08:28:15 +0100100 $(SPEC_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(VER_OPTS) $(DEFINE)
Willy Tarreauec692562007-09-09 23:31:11 +0200101LIBS = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
Willy Tarreau7ad15da2008-02-10 17:00:13 +0100102CFLAGS = -Wall $(COPTS) $(DEBUG) -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -mmacosx-version-min=10.4
103LDFLAGS = -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -mmacosx-version-min=10.4
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200104
Willy Tarreaud1d54542012-09-12 22:58:11 +0200105OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocol.o \
Willy Tarreauc7e42382012-08-24 19:22:53 +0200106 src/uri_auth.o src/standard.o src/buffer.o src/log.o src/task.o \
Willy Tarreaud1d54542012-09-12 22:58:11 +0200107 src/chunk.o src/channel.o src/listener.o \
Willy Tarreau982b6e32009-01-25 13:49:53 +0100108 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 +0200109 src/checks.o src/queue.o src/frontend.o src/proxy.o src/proto_uxst.o \
Willy Tarreau75bf2c92012-08-20 17:01:35 +0200110 src/proto_http.o src/raw_sock.o src/appsession.o src/backend.o \
Emeric Brun2b920a12010-09-23 18:30:22 +0200111 src/peers.o src/stream_interface.o src/dumpstats.o src/proto_tcp.o \
Willy Tarreaubc5258d2009-05-10 09:00:20 +0200112 src/session.o src/hdr_idx.o src/ev_select.o src/signal.o \
Willy Tarreauf09c6602012-02-13 17:12:08 +0100113 src/lb_chash.o src/lb_fwlc.o src/lb_fwrr.o src/lb_map.o src/lb_fas.o \
Willy Tarreau59f98392012-07-06 14:13:49 +0200114 src/ev_poll.o src/connection.o \
Willy Tarreau2ac57182012-04-19 15:24:50 +0200115 src/arg.o src/acl.o src/memory.o src/freq_ctr.o \
Willy Tarreaucd3b0942012-04-27 21:52:18 +0200116 src/auth.o src/stick_table.o src/sample.o
Willy Tarreau45cb4fb2009-10-26 21:10:04 +0100117
118EBTREE_OBJS = $(EBTREE_DIR)/ebtree.o \
119 $(EBTREE_DIR)/eb32tree.o $(EBTREE_DIR)/eb64tree.o \
120 $(EBTREE_DIR)/ebmbtree.o $(EBTREE_DIR)/ebsttree.o \
121 $(EBTREE_DIR)/ebimtree.o $(EBTREE_DIR)/ebistree.o
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200122
123all: haproxy
124
Willy Tarreau45cb4fb2009-10-26 21:10:04 +0100125haproxy: $(OBJS) $(EBTREE_OBJS)
126 $(LD) $(LDFLAGS) $(OBJS) $(EBTREE_OBJS) -o $@
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200127
128.SUFFIXES: .c.o
129
130.c.o:
131 $(CC) $(CFLAGS) -c -o $@ $<
132
Willy Tarreau7b066db2007-12-02 11:28:59 +0100133src/haproxy.o: src/haproxy.c
134 $(CC) $(CFLAGS) -DBUILD_TARGET='"$(TARGET)"' -DBUILD_CC='"$(CC)"' \
135 -DBUILD_CPU='"$(CPU)"' -DBUILD_REGEX='"$(REGEX)"' \
136 -DBUILD_OPTS='"$(COPTS)"' -c -o $@ $<
137
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200138src/dlmalloc.o: $(DLMALLOC_SRC)
139 $(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
140
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200141clean:
Willy Tarreau45cb4fb2009-10-26 21:10:04 +0100142 rm -f *.[oas] src/*.[oas] ebtree/*.[oas] haproxy test
143 for dir in . src include/* doc ebtree; do rm -f $$dir/*~ $$dir/*.rej $$dir/core; done
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200144 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out
Willy Tarreauec692562007-09-09 23:31:11 +0200145
146version:
147 @echo "VERSION: $(VERSION)"
148 @echo "SUBVERS: $(SUBVERS)"
149 @echo "VERDATE: $(VERDATE)"