willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 1 | # This makefile supports different OS and CPU setups. |
| 2 | # You should use it this way : |
| 3 | # make TARGET=os CPU=cpu |
| 4 | |
Willy Tarreau | 9c9fea4 | 2006-10-16 00:03:35 +0200 | [diff] [blame] | 5 | VERSION := 1.3.3 |
willy tarreau | cee272f | 2006-03-19 21:16:26 +0100 | [diff] [blame] | 6 | |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 7 | # Select target OS. TARGET must match a system for which COPTS and LIBS are |
| 8 | # correctly defined below. |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 9 | #TARGET = linux26 |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 10 | TARGET = linux24 |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 11 | #TARGET = linux24e |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 12 | #TARGET = linux22 |
| 13 | #TARGET = solaris |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 14 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 15 | # pass CPU=<cpu_name> to make to optimize for a particular CPU |
| 16 | CPU = generic |
| 17 | #CPU = i586 |
| 18 | #CPU = i686 |
| 19 | #CPU = ultrasparc |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 20 | |
willy tarreau | 4373b96 | 2005-12-18 01:32:31 +0100 | [diff] [blame] | 21 | # By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group |
| 22 | # references seem broken using libc ! Use pcre instead. |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 23 | REGEX=libc |
| 24 | #REGEX=pcre |
willy tarreau | 4373b96 | 2005-12-18 01:32:31 +0100 | [diff] [blame] | 25 | #REGEX=static-pcre |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 26 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 27 | # tools options |
| 28 | CC = gcc |
| 29 | LD = gcc |
| 30 | |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 31 | # This is the directory hosting include/pcre.h and lib/libpcre.* when REGEX=pcre |
willy tarreau | 2f6ba65 | 2005-12-17 13:57:42 +0100 | [diff] [blame] | 32 | PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :) |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 33 | #PCREDIR=/usr/local |
| 34 | |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 35 | # This is for standard Linux 2.6 with netfilter and epoll() |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 36 | COPTS.linux26 = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL |
| 37 | LIBS.linux26 = |
| 38 | |
willy tarreau | b952e1d | 2005-12-18 01:31:20 +0100 | [diff] [blame] | 39 | # This is for enhanced Linux 2.4 with netfilter and epoll() patch. |
| 40 | # Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add |
| 41 | # -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug. |
| 42 | #COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 43 | COPTS.linux24e = -DNETFILTER -DENABLE_POLL -DENABLE_EPOLL -DUSE_MY_EPOLL |
| 44 | LIBS.linux24e = |
| 45 | |
| 46 | # This is for standard Linux 2.4 with netfilter but without epoll() |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 47 | COPTS.linux24 = -DNETFILTER -DENABLE_POLL |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 48 | LIBS.linux24 = |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 49 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 50 | # This is for Linux 2.2 |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 51 | COPTS.linux22 = -DUSE_GETSOCKNAME -DENABLE_POLL |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 52 | LIBS.linux22 = |
| 53 | |
| 54 | # This is for Solaris 8 |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 55 | COPTS.solaris = -fomit-frame-pointer -DENABLE_POLL -DFD_SETSIZE=65536 |
willy tarreau | 9da061b | 2005-12-17 12:29:56 +0100 | [diff] [blame] | 56 | LIBS.solaris = -lnsl -lsocket |
| 57 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 58 | # CPU dependant optimizations |
| 59 | COPTS.generic = -O2 |
Willy Tarreau | 390223b | 2006-10-15 23:43:42 +0200 | [diff] [blame] | 60 | COPTS.i586 = -O2 -march=i586 -DCONFIG_HAP_USE_REGPARM |
| 61 | COPTS.i686 = -O2 -march=i686 -DCONFIG_HAP_USE_REGPARM |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 62 | COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc |
| 63 | |
| 64 | # options for standard regex library |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 65 | COPTS.libc= |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 66 | LIBS.libc= |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 67 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 68 | # options for libpcre |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 69 | COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include |
| 70 | LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre |
| 71 | |
willy tarreau | 4373b96 | 2005-12-18 01:32:31 +0100 | [diff] [blame] | 72 | # options for static libpcre |
| 73 | COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include |
| 74 | LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic |
| 75 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 76 | # you can enable debug arguments with "DEBUG=-g" or disable them with "DEBUG=" |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 77 | #DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 78 | DEBUG = -g |
willy tarreau | 9da061b | 2005-12-17 12:29:56 +0100 | [diff] [blame] | 79 | |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 80 | # if small memory footprint is required, you can reduce the buffer size. There |
| 81 | # are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 82 | # with 1000 concurrent sessions. Putting it slightly lower than a page size |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 83 | # will avoid the additionnal paramters to overflow a page. 8030 bytes is |
| 84 | # exactly 5.5 TCP segments of 1460 bytes. |
| 85 | #SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024 |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 86 | SMALL_OPTS = |
| 87 | |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 88 | # redefine this if you want to add some special PATH to include/libs |
| 89 | ADDINC = |
| 90 | ADDLIB = |
| 91 | |
| 92 | # set some defines when needed. |
| 93 | # Known ones are -DENABLE_POLL, -DENABLE_EPOLL, and -DUSE_MY_EPOLL |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 94 | # - use -DTPROXY to compile with transparent proxy support. |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 95 | # - use -DCONFIG_HAP_CTTPROXY to enable full transparent proxy support |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 96 | DEFINE = -DTPROXY |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 97 | |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 98 | |
| 99 | #### build options |
| 100 | |
| 101 | # do not change this one, enable USE_* variables instead. |
| 102 | OPTIONS = |
| 103 | |
| 104 | ifneq ($(USE_CTTPROXY),) |
| 105 | OPTIONS += -DCONFIG_HAP_CTTPROXY |
| 106 | endif |
| 107 | |
| 108 | ifneq ($(USE_TPROXY),) |
| 109 | OPTIONS += -DTPROXY |
| 110 | endif |
| 111 | |
| 112 | ifneq ($(USE_POLL),) |
| 113 | OPTIONS += -DENABLE_POLL |
| 114 | endif |
| 115 | |
| 116 | ifneq ($(USE_EPOLL),) |
| 117 | OPTIONS += -DENABLE_EPOLL |
| 118 | endif |
| 119 | |
| 120 | ifneq ($(USE_MY_EPOLL),) |
| 121 | OPTIONS += -DUSE_MY_EPOLL |
| 122 | endif |
| 123 | |
| 124 | ifneq ($(USE_NETFILTER),) |
| 125 | OPTIONS += -DNETFILTER |
| 126 | endif |
| 127 | |
| 128 | ifneq ($(USE_EPOLL_WORKAROUND),) |
| 129 | OPTIONS += -DEPOLL_CTL_MOD_WORKAROUND |
| 130 | endif |
| 131 | |
| 132 | ifneq ($(USE_GETSOCKNAME),) |
| 133 | OPTIONS += -DUSE_GETSOCKNAME |
| 134 | endif |
| 135 | |
| 136 | ifneq ($(USE_REGPARM),) |
| 137 | OPTIONS += -DCONFIG_HAP_USE_REGPARM |
| 138 | endif |
| 139 | |
| 140 | #### end of build options |
| 141 | |
| 142 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 143 | # global options |
| 144 | TARGET_OPTS=$(COPTS.$(TARGET)) |
| 145 | REGEX_OPTS=$(COPTS.$(REGEX)) |
| 146 | CPU_OPTS=$(COPTS.$(CPU)) |
| 147 | |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 148 | COPTS=-Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) $(OPTIONS) |
willy tarreau | ad90a0c | 2005-12-18 01:09:15 +0100 | [diff] [blame] | 149 | LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB) |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 150 | |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 151 | CFLAGS = -Wall $(COPTS) $(DEBUG) |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 152 | LDFLAGS = -g |
| 153 | |
| 154 | all: haproxy |
| 155 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 156 | OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \ |
| 157 | src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \ |
| 158 | src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \ |
| 159 | src/checks.o src/queue.o src/capture.o src/client.o src/proxy.o \ |
| 160 | src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \ |
Willy Tarreau | e5f20dc | 2006-12-03 15:21:35 +0100 | [diff] [blame] | 161 | src/session.o src/hdr_idx.o |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 162 | |
| 163 | haproxy: $(OBJS) |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 164 | $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) |
| 165 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 166 | objsize: haproxy |
| 167 | @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort |
| 168 | |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 169 | %.o: %.c |
| 170 | $(CC) $(CFLAGS) -c -o $@ $< |
| 171 | |
| 172 | clean: |
Willy Tarreau | 1a58749 | 2006-10-15 23:40:58 +0200 | [diff] [blame] | 173 | rm -f *.[oas] src/*.[oas] core haproxy test |
| 174 | for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 175 | rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out |
willy tarreau | efae184 | 2005-12-17 12:51:03 +0100 | [diff] [blame] | 176 | |
willy tarreau | e114bf9 | 2006-03-19 21:30:14 +0100 | [diff] [blame] | 177 | tar: clean |
willy tarreau | cee272f | 2006-03-19 21:16:26 +0100 | [diff] [blame] | 178 | ln -s . haproxy-$(VERSION) |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 179 | tar --exclude=haproxy-$(VERSION)/.git \ |
| 180 | --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \ |
| 181 | --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \ |
| 182 | -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz |
willy tarreau | cee272f | 2006-03-19 21:16:26 +0100 | [diff] [blame] | 183 | rm -f haproxy-$(VERSION) |
| 184 | |
Willy Tarreau | 9f0a901 | 2006-10-15 14:24:14 +0200 | [diff] [blame] | 185 | git-tar: clean |
| 186 | ref=$(shell git-describe --tags); ver=$${ref#v};\ |
| 187 | comms=$(shell git-log $$ref..|grep -c ^commit); \ |
| 188 | git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$$ver-$$comms.tar.gz |