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 : |
Willy Tarreau | 9bf6c6e | 2006-12-23 11:12:04 +0100 | [diff] [blame] | 3 | # make TARGET=os CPU=cpu REGEX=lib |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 4 | |
willy tarreau | cee272f | 2006-03-19 21:16:26 +0100 | [diff] [blame] | 5 | |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 6 | # Select target OS. TARGET must match a system for which COPTS and LIBS are |
| 7 | # correctly defined below. |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 8 | #TARGET = linux26 |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 9 | TARGET = linux24 |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 10 | #TARGET = linux24e |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 11 | #TARGET = linux22 |
| 12 | #TARGET = solaris |
willy tarreau | 750a472 | 2005-12-17 13:21:24 +0100 | [diff] [blame] | 13 | |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 14 | USE_POLL = 1 |
| 15 | |
| 16 | ifeq ($(TARGET),linux24e) |
| 17 | USE_EPOLL = 1 |
Willy Tarreau | de99e99 | 2007-04-16 00:53:59 +0200 | [diff] [blame] | 18 | USE_SEPOLL = 1 |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 19 | endif |
| 20 | |
| 21 | ifeq ($(TARGET),linux26) |
| 22 | USE_EPOLL = 1 |
Willy Tarreau | de99e99 | 2007-04-16 00:53:59 +0200 | [diff] [blame] | 23 | USE_SEPOLL = 1 |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 24 | endif |
| 25 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 26 | # pass CPU=<cpu_name> to make to optimize for a particular CPU |
| 27 | CPU = generic |
| 28 | #CPU = i586 |
| 29 | #CPU = i686 |
| 30 | #CPU = ultrasparc |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 31 | |
willy tarreau | 4373b96 | 2005-12-18 01:32:31 +0100 | [diff] [blame] | 32 | # By default, we use libc's regex. WARNING! On Solaris 8/Sparc, group |
| 33 | # references seem broken using libc ! Use pcre instead. |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 34 | REGEX=libc |
| 35 | #REGEX=pcre |
willy tarreau | 4373b96 | 2005-12-18 01:32:31 +0100 | [diff] [blame] | 36 | #REGEX=static-pcre |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 37 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 38 | # tools options |
| 39 | CC = gcc |
| 40 | LD = gcc |
| 41 | |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 42 | # 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] | 43 | PCREDIR := $(shell pcre-config --prefix 2>/dev/null || :) |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 44 | #PCREDIR=/usr/local |
| 45 | |
Willy Tarreau | 6d1a988 | 2007-01-07 02:03:04 +0100 | [diff] [blame] | 46 | # This is the directory hosting libtcpsplice.[ah] when USE_TCPSPLICE is set |
| 47 | TCPSPLICEDIR := |
| 48 | |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 49 | # This is for standard Linux 2.6 with netfilter and epoll() |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 50 | COPTS.linux26 = -DNETFILTER |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 51 | LIBS.linux26 = |
| 52 | |
willy tarreau | b952e1d | 2005-12-18 01:31:20 +0100 | [diff] [blame] | 53 | # This is for enhanced Linux 2.4 with netfilter and epoll() patch. |
| 54 | # Warning! If kernel is 2.4 with epoll-lt <= 0.21, then you must add |
| 55 | # -DEPOLL_CTL_MOD_WORKAROUND to workaround a very rare bug. |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 56 | #COPTS.linux24e = -DNETFILTER -DUSE_MY_EPOLL -DEPOLL_CTL_MOD_WORKAROUND |
| 57 | COPTS.linux24e = -DNETFILTER -DUSE_MY_EPOLL |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 58 | LIBS.linux24e = |
| 59 | |
| 60 | # This is for standard Linux 2.4 with netfilter but without epoll() |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 61 | COPTS.linux24 = -DNETFILTER |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 62 | LIBS.linux24 = |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 63 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 64 | # This is for Linux 2.2 |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 65 | COPTS.linux22 = -DUSE_GETSOCKNAME |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 66 | LIBS.linux22 = |
| 67 | |
| 68 | # This is for Solaris 8 |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 69 | COPTS.solaris = -fomit-frame-pointer -DFD_SETSIZE=65536 |
willy tarreau | 9da061b | 2005-12-17 12:29:56 +0100 | [diff] [blame] | 70 | LIBS.solaris = -lnsl -lsocket |
| 71 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 72 | # CPU dependant optimizations |
| 73 | COPTS.generic = -O2 |
Willy Tarreau | 390223b | 2006-10-15 23:43:42 +0200 | [diff] [blame] | 74 | COPTS.i586 = -O2 -march=i586 -DCONFIG_HAP_USE_REGPARM |
| 75 | COPTS.i686 = -O2 -march=i686 -DCONFIG_HAP_USE_REGPARM |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 76 | COPTS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc |
| 77 | |
| 78 | # options for standard regex library |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 79 | COPTS.libc= |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 80 | LIBS.libc= |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 81 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 82 | # options for libpcre |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 83 | COPTS.pcre=-DUSE_PCRE -I$(PCREDIR)/include |
| 84 | LIBS.pcre=-L$(PCREDIR)/lib -lpcreposix -lpcre |
| 85 | |
willy tarreau | 4373b96 | 2005-12-18 01:32:31 +0100 | [diff] [blame] | 86 | # options for static libpcre |
| 87 | COPTS.static-pcre=-DUSE_PCRE -I$(PCREDIR)/include |
| 88 | LIBS.static-pcre=-L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic |
| 89 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 90 | # 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] | 91 | #DEBUG = -g -DDEBUG_MEMORY -DDEBUG_FULL |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 92 | DEBUG = -g |
willy tarreau | 9da061b | 2005-12-17 12:29:56 +0100 | [diff] [blame] | 93 | |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 94 | # if small memory footprint is required, you can reduce the buffer size. There |
| 95 | # 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] | 96 | # with 1000 concurrent sessions. Putting it slightly lower than a page size |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 97 | # will avoid the additionnal paramters to overflow a page. 8030 bytes is |
| 98 | # exactly 5.5 TCP segments of 1460 bytes. |
| 99 | #SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024 |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 100 | SMALL_OPTS = |
| 101 | |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 102 | # redefine this if you want to add some special PATH to include/libs |
| 103 | ADDINC = |
| 104 | ADDLIB = |
| 105 | |
| 106 | # set some defines when needed. |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 107 | # - use -DTPROXY to compile with transparent proxy support. |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 108 | DEFINE = -DTPROXY |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 109 | |
Willy Tarreau | 9bf6c6e | 2006-12-23 11:12:04 +0100 | [diff] [blame] | 110 | # Now let's determine the version, sub-version and release date. |
| 111 | # If we're in the GIT tree, we can use the last commit's version and date. |
Willy Tarreau | 6620dbb | 2007-01-02 00:44:53 +0100 | [diff] [blame] | 112 | ifeq ($(IGNOREGIT),) |
Willy Tarreau | a1973c4 | 2007-04-09 22:07:11 +0200 | [diff] [blame] | 113 | VERSION := $(shell [ -d .git/. ] && ref=`git-describe --tags 2>/dev/null` && ref=$${ref%-g*} && echo "$${ref\#v}" ) |
Willy Tarreau | 6620dbb | 2007-01-02 00:44:53 +0100 | [diff] [blame] | 114 | endif |
Willy Tarreau | 9bf6c6e | 2006-12-23 11:12:04 +0100 | [diff] [blame] | 115 | |
| 116 | ifneq ($(VERSION),) |
| 117 | # OK git is there and works. |
Willy Tarreau | a1973c4 | 2007-04-09 22:07:11 +0200 | [diff] [blame] | 118 | SUBVERS := $(shell comms=`git-log --no-merges v$(VERSION).. 2>/dev/null |grep -c ^commit `; [ $$comms -gt 0 ] && echo "-$$comms" ) |
| 119 | VERDATE := $(shell date +%Y/%m/%d -d "`git-log HEAD^.. 2>/dev/null | grep -m 1 ^Date: | cut -f2- -d: | cut -f1 -d+`" ) |
Willy Tarreau | 9bf6c6e | 2006-12-23 11:12:04 +0100 | [diff] [blame] | 120 | else |
| 121 | # Otherwise, use the hard-coded version of last tag, number of changes |
| 122 | # since last tag, and release date. |
Willy Tarreau | 6e0433f | 2007-04-16 01:18:12 +0200 | [diff] [blame] | 123 | VERSION := 1.3.9 |
Willy Tarreau | 6620dbb | 2007-01-02 00:44:53 +0100 | [diff] [blame] | 124 | SUBVERS := |
Willy Tarreau | 6e0433f | 2007-04-16 01:18:12 +0200 | [diff] [blame] | 125 | VERDATE := 2007/04/15 |
Willy Tarreau | 9bf6c6e | 2006-12-23 11:12:04 +0100 | [diff] [blame] | 126 | endif |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 127 | |
| 128 | #### build options |
| 129 | |
| 130 | # do not change this one, enable USE_* variables instead. |
| 131 | OPTIONS = |
Willy Tarreau | b38651a | 2007-03-24 17:24:39 +0100 | [diff] [blame] | 132 | OPT_OBJS = |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 133 | |
Willy Tarreau | 6d1a988 | 2007-01-07 02:03:04 +0100 | [diff] [blame] | 134 | ifneq ($(USE_TCPSPLICE),) |
| 135 | OPTIONS += -DCONFIG_HAP_TCPSPLICE |
| 136 | endif |
| 137 | |
Willy Tarreau | b38651a | 2007-03-24 17:24:39 +0100 | [diff] [blame] | 138 | # - set USE_CTTPROXY to enable full transparent proxy support |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 139 | ifneq ($(USE_CTTPROXY),) |
| 140 | OPTIONS += -DCONFIG_HAP_CTTPROXY |
Willy Tarreau | b38651a | 2007-03-24 17:24:39 +0100 | [diff] [blame] | 141 | OPT_OBJS += src/cttproxy.o |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 142 | endif |
| 143 | |
| 144 | ifneq ($(USE_TPROXY),) |
| 145 | OPTIONS += -DTPROXY |
| 146 | endif |
| 147 | |
| 148 | ifneq ($(USE_POLL),) |
| 149 | OPTIONS += -DENABLE_POLL |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 150 | OPT_OBJS += src/ev_poll.o |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 151 | endif |
| 152 | |
| 153 | ifneq ($(USE_EPOLL),) |
| 154 | OPTIONS += -DENABLE_EPOLL |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 155 | OPT_OBJS += src/ev_epoll.o |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 156 | endif |
| 157 | |
Willy Tarreau | de99e99 | 2007-04-16 00:53:59 +0200 | [diff] [blame] | 158 | ifneq ($(USE_SEPOLL),) |
| 159 | OPTIONS += -DENABLE_SEPOLL |
| 160 | OPT_OBJS += src/ev_sepoll.o |
| 161 | endif |
| 162 | |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 163 | ifneq ($(USE_MY_EPOLL),) |
| 164 | OPTIONS += -DUSE_MY_EPOLL |
| 165 | endif |
| 166 | |
| 167 | ifneq ($(USE_NETFILTER),) |
| 168 | OPTIONS += -DNETFILTER |
| 169 | endif |
| 170 | |
| 171 | ifneq ($(USE_EPOLL_WORKAROUND),) |
| 172 | OPTIONS += -DEPOLL_CTL_MOD_WORKAROUND |
| 173 | endif |
| 174 | |
| 175 | ifneq ($(USE_GETSOCKNAME),) |
| 176 | OPTIONS += -DUSE_GETSOCKNAME |
| 177 | endif |
| 178 | |
| 179 | ifneq ($(USE_REGPARM),) |
| 180 | OPTIONS += -DCONFIG_HAP_USE_REGPARM |
| 181 | endif |
| 182 | |
Willy Tarreau | 79b34bf | 2006-12-22 15:28:43 +0100 | [diff] [blame] | 183 | ifneq ($(VERSION),) |
| 184 | OPTIONS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" |
| 185 | endif |
| 186 | |
| 187 | ifneq ($(VERDATE),) |
| 188 | OPTIONS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\" |
| 189 | endif |
| 190 | |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 191 | #### end of build options |
| 192 | |
| 193 | |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 194 | # global options |
| 195 | TARGET_OPTS=$(COPTS.$(TARGET)) |
| 196 | REGEX_OPTS=$(COPTS.$(REGEX)) |
| 197 | CPU_OPTS=$(COPTS.$(CPU)) |
| 198 | |
Willy Tarreau | 6d1a988 | 2007-01-07 02:03:04 +0100 | [diff] [blame] | 199 | COPTS = -Iinclude $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(DEFINE) $(OPTIONS) |
| 200 | LIBS=$(LIBS.$(TARGET)) $(LIBS.$(REGEX)) |
| 201 | |
| 202 | ifneq ($(USE_TCPSPLICE),) |
| 203 | COPTS += -I$(TCPSPLICEDIR) |
| 204 | LIBS += -L$(TCPSPLICEDIR) -ltcpsplice |
| 205 | endif |
| 206 | |
| 207 | COPTS += $(ADDINC) |
| 208 | LIBS += $(ADDLIB) |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 209 | |
willy tarreau | d38e72d | 2006-03-19 20:56:52 +0100 | [diff] [blame] | 210 | CFLAGS = -Wall $(COPTS) $(DEBUG) |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 211 | LDFLAGS = -g |
| 212 | |
| 213 | all: haproxy |
| 214 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 215 | OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \ |
| 216 | src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \ |
| 217 | src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \ |
| 218 | src/checks.o src/queue.o src/capture.o src/client.o src/proxy.o \ |
| 219 | src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \ |
Willy Tarreau | a84d374 | 2007-05-07 00:36:48 +0200 | [diff] [blame] | 220 | src/session.o src/hdr_idx.o src/ev_select.o src/acl.o |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 221 | |
Willy Tarreau | b38651a | 2007-03-24 17:24:39 +0100 | [diff] [blame] | 222 | haproxy: $(OBJS) $(OPT_OBJS) |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 223 | $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) |
| 224 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 225 | objsize: haproxy |
| 226 | @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort |
| 227 | |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 228 | %.o: %.c |
| 229 | $(CC) $(CFLAGS) -c -o $@ $< |
| 230 | |
| 231 | clean: |
Willy Tarreau | 1a58749 | 2006-10-15 23:40:58 +0200 | [diff] [blame] | 232 | rm -f *.[oas] src/*.[oas] core haproxy test |
| 233 | for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done |
Willy Tarreau | 9bf6c6e | 2006-12-23 11:12:04 +0100 | [diff] [blame] | 234 | rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz |
| 235 | rm -f haproxy-$(VERSION) nohup.out gmon.out |
willy tarreau | efae184 | 2005-12-17 12:51:03 +0100 | [diff] [blame] | 236 | |
willy tarreau | e114bf9 | 2006-03-19 21:30:14 +0100 | [diff] [blame] | 237 | tar: clean |
willy tarreau | cee272f | 2006-03-19 21:16:26 +0100 | [diff] [blame] | 238 | ln -s . haproxy-$(VERSION) |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 239 | tar --exclude=haproxy-$(VERSION)/.git \ |
| 240 | --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \ |
| 241 | --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \ |
| 242 | -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz |
willy tarreau | cee272f | 2006-03-19 21:16:26 +0100 | [diff] [blame] | 243 | rm -f haproxy-$(VERSION) |
| 244 | |
Willy Tarreau | 9f0a901 | 2006-10-15 14:24:14 +0200 | [diff] [blame] | 245 | git-tar: clean |
Willy Tarreau | 9bf6c6e | 2006-12-23 11:12:04 +0100 | [diff] [blame] | 246 | git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz |