blob: 5fa0da025043f0fa46ea40d5d7c76fcfe9dcafbf [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
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
30# 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
33
Willy Tarreau45cb4fb2009-10-26 21:10:04 +010034# This one can be changed to look for ebtree files in an external directory
35EBTREE_DIR = ebtree
36
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020037# This is for darwin 3.0 and above
Willy Tarreau8ae42f42007-04-09 16:30:28 +020038COPTS.darwin = -DENABLE_POLL -DENABLE_KQUEUE
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020039LIBS.darwin =
40
41# CPU dependant optimizations
42COPTS.generic = -O2
43COPTS.i586 = -O2 -march=i586
44COPTS.i686 = -O2 -march=i686
45COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc
46
47# options for standard regex library
48COPTS.libc=
49LIBS.libc=
50
51# options for libpcre
52COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include
53LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre
54
55# options for static libpcre
56COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include
57LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic
58
59# you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG="
60#DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL
61DEBUG = -g
62
63# if small memory footprint is required, you can reduce the buffer size. There
64# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
65# with 1000 concurrent sessions. Putting it slightly lower than a page size
66# will avoid the additionnal paramters to overflow a page. 8030 bytes is
67# exactly 5.5 TCP segments of 1460 bytes.
68#SMALL_OPTS =
69SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
70
71# redefine this if you want to add some special PATH to include/libs
72ADDINC =
73ADDLIB =
74
75# set some defines when needed.
76# Known ones are -DENABLE_POLL
77# - use -DTPROXY to compile with transparent proxy support.
Willy Tarreau8ae42f42007-04-09 16:30:28 +020078DEFINE = -DTPROXY
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020079
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 Tarreaucec2e7a2007-03-25 16:55:56 +020083# 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 Tarreaucec2e7a2007-03-25 16:55:56 +020091
Willy Tarreauec692562007-09-09 23:31:11 +020092VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \
93 -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
94
Willy Tarreau45cb4fb2009-10-26 21:10:04 +010095COPTS = -Iinclude -I$(EBTREE_DIR) $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) \
96 $(REGEX_OPTS) $(SMALL_OPTS) $(VER_OPTS) $(DEFINE)
Willy Tarreauec692562007-09-09 23:31:11 +020097LIBS = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
Willy Tarreau7ad15da2008-02-10 17:00:13 +010098CFLAGS = -Wall $(COPTS) $(DEBUG) -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -mmacosx-version-min=10.4
99LDFLAGS = -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -mmacosx-version-min=10.4
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200100
Willy Tarreaudd815982007-10-16 12:25:14 +0200101OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \
Willy Tarreaucec2e7a2007-03-25 16:55:56 +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 Tarreaucec2e7a2007-03-25 16:55:56 +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 Tarreaubc5258d2009-05-10 09:00:20 +0200107 src/session.o src/hdr_idx.o src/ev_select.o src/signal.o \
Willy Tarreau6b2e11b2009-10-01 07:52:15 +0200108 src/lb_chash.o src/lb_fwlc.o src/lb_fwrr.o src/lb_map.o \
Willy Tarreaue6d2e4d2007-11-15 23:56:17 +0100109 src/ev_poll.o \
Willy Tarreau45cb4fb2009-10-26 21:10:04 +0100110 src/acl.o src/memory.o src/freq_ctr.o
111
112EBTREE_OBJS = $(EBTREE_DIR)/ebtree.o \
113 $(EBTREE_DIR)/eb32tree.o $(EBTREE_DIR)/eb64tree.o \
114 $(EBTREE_DIR)/ebmbtree.o $(EBTREE_DIR)/ebsttree.o \
115 $(EBTREE_DIR)/ebimtree.o $(EBTREE_DIR)/ebistree.o
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200116
117all: haproxy
118
Willy Tarreau45cb4fb2009-10-26 21:10:04 +0100119haproxy: $(OBJS) $(EBTREE_OBJS)
120 $(LD) $(LDFLAGS) $(OBJS) $(EBTREE_OBJS) -o $@
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200121
122.SUFFIXES: .c.o
123
124.c.o:
125 $(CC) $(CFLAGS) -c -o $@ $<
126
Willy Tarreau7b066db2007-12-02 11:28:59 +0100127src/haproxy.o: src/haproxy.c
128 $(CC) $(CFLAGS) -DBUILD_TARGET='"$(TARGET)"' -DBUILD_CC='"$(CC)"' \
129 -DBUILD_CPU='"$(CPU)"' -DBUILD_REGEX='"$(REGEX)"' \
130 -DBUILD_OPTS='"$(COPTS)"' -c -o $@ $<
131
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200132src/dlmalloc.o: $(DLMALLOC_SRC)
133 $(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
134
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200135clean:
Willy Tarreau45cb4fb2009-10-26 21:10:04 +0100136 rm -f *.[oas] src/*.[oas] ebtree/*.[oas] haproxy test
137 for dir in . src include/* doc ebtree; do rm -f $$dir/*~ $$dir/*.rej $$dir/core; done
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200138 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out
Willy Tarreauec692562007-09-09 23:31:11 +0200139
140version:
141 @echo "VERSION: $(VERSION)"
142 @echo "SUBVERS: $(SUBVERS)"
143 @echo "VERDATE: $(VERDATE)"