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