blob: a92e857fd4a467607c480278927b1956f3f76dcf [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
34# This is for darwin 3.0 and above
Willy Tarreau8ae42f42007-04-09 16:30:28 +020035COPTS.darwin = -DENABLE_POLL -DENABLE_KQUEUE
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020036LIBS.darwin =
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
72# set some defines when needed.
73# Known ones are -DENABLE_POLL
74# - use -DTPROXY to compile with transparent proxy support.
Willy Tarreau8ae42f42007-04-09 16:30:28 +020075DEFINE = -DTPROXY
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020076
Willy Tarreauf2ef8c52007-07-11 09:19:31 +020077# May be changed to patch PAGE_SIZE on every platform when using dlmalloc
78DLMALLOC_THRES=4096
79
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020080# global options
81TARGET_OPTS=$(COPTS.$(TARGET))
82REGEX_OPTS=$(COPTS.$(REGEX))
83CPU_OPTS=$(COPTS.$(CPU))
84
Willy Tarreauec692562007-09-09 23:31:11 +020085VERSION != cat VERSION 2>/dev/null || touch VERSION
86SUBVERS != cat SUBVERS 2>/dev/null || touch SUBVERS
87VERDATE != cat VERDATE 2>/dev/null || touch VERDATE
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020088
Willy Tarreauec692562007-09-09 23:31:11 +020089VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \
90 -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
91
92COPTS = -Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) \
93 $(SMALL_OPTS) $(VER_OPTS) $(DEFINE)
94LIBS = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
95CFLAGS = -Wall $(COPTS) $(DEBUG) -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020096LDFLAGS = -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386
97
Willy Tarreaudd815982007-10-16 12:25:14 +020098OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \
Willy Tarreaucec2e7a2007-03-25 16:55:56 +020099 src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \
100 src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \
Willy Tarreau92fb9832007-10-16 17:34:28 +0200101 src/checks.o src/queue.o src/client.o src/proxy.o src/proto_uxst.o \
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200102 src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \
Willy Tarreau91861262007-10-17 17:06:05 +0200103 src/senddata.o src/dumpstats.o \
Willy Tarreau50e608d2007-05-13 18:26:08 +0200104 src/session.o src/hdr_idx.o src/ev_select.o src/ev_poll.o src/acl.o \
105 src/memory.o
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200106
107all: haproxy
108
109haproxy: $(OBJS)
110 $(LD) $(LDFLAGS) $(OBJS) -o $@
111
112.SUFFIXES: .c.o
113
114.c.o:
115 $(CC) $(CFLAGS) -c -o $@ $<
116
Willy Tarreauf2ef8c52007-07-11 09:19:31 +0200117src/dlmalloc.o: $(DLMALLOC_SRC)
118 $(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
119
Willy Tarreaucec2e7a2007-03-25 16:55:56 +0200120clean:
121 rm -f *.[oas] src/*.[oas] core haproxy test
122 for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
123 rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out
Willy Tarreauec692562007-09-09 23:31:11 +0200124
125version:
126 @echo "VERSION: $(VERSION)"
127 @echo "SUBVERS: $(SUBVERS)"
128 @echo "VERDATE: $(VERDATE)"