Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 1 | # This GNU Makefile supports different OS and CPU combinations. |
| 2 | # |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 3 | # You should use it this way : |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 4 | # [g]make TARGET=os CPU=cpu USE_xxx=1 ... |
Willy Tarreau | f2ef8c5 | 2007-07-11 09:19:31 +0200 | [diff] [blame] | 5 | # |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 6 | # Valid USE_* options are the following. Most of them are automatically set by |
| 7 | # the TARGET, others have to be explictly specified : |
| 8 | # USE_CTTPROXY : enable CTTPROXY on Linux (needs kernel patch). |
| 9 | # USE_EPOLL : enable epoll() on Linux 2.6. Automatic. |
| 10 | # USE_EPOLL_WORKAROUND : enable epoll() bug workaround. Automatic. |
| 11 | # USE_GETSOCKNAME : enable getsockname() on Linux 2.2. Automatic. |
| 12 | # USE_KQUEUE : enable kqueue() on BSD. Automatic. |
| 13 | # USE_MY_EPOLL : redefine epoll_* syscalls. Automatic. |
| 14 | # USE_NETFILTER : enable netfilter on Linux. Automatic. |
| 15 | # USE_PCRE : enable use of libpcre for regex. Recommended. |
| 16 | # USE_POLL : enable poll(). Automatic. |
| 17 | # USE_REGPARM : enable regparm optimization. Recommended on x86. |
| 18 | # USE_SEPOLL : enable speculative epoll(). Automatic. |
| 19 | # USE_STATIC_PCRE : enable static libpcre. Recommended. |
| 20 | # USE_TCPSPLICE : enable tcp_splice() on Linux (needs kernel patch). |
| 21 | # USE_TPROXY : enable transparent proxy. Automatic. |
Willy Tarreau | b1e52e8 | 2008-01-13 14:49:51 +0100 | [diff] [blame] | 22 | # USE_LINUX_TPROXY : enable full transparent proxy (need kernel patch). |
Willy Tarreau | f2ef8c5 | 2007-07-11 09:19:31 +0200 | [diff] [blame] | 23 | # |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 24 | # Options can be forced by specifying "USE_xxx=1" or can be disabled by using |
| 25 | # "USE_xxx=" (empty string). |
| 26 | # |
| 27 | # Variables useful for packagers : |
| 28 | # CC is set to "gcc" by default and is used for compilation only. |
| 29 | # LD is set to "gcc" by default and is used for linking only. |
| 30 | # CFLAGS is automatically set for the specified CPU and may be overridden. |
| 31 | # LDFLAGS is automatically set to -g and may be overridden. |
| 32 | # SMALL_OPTS may be used to specify some options to shrink memory usage. |
| 33 | # DEBUG may be used to set some internal debugging options. |
| 34 | # ADDINC may be used to complete the include path in the form -Ipath. |
| 35 | # ADDLIB may be used to complete the library list in the form -Lpath -llib. |
| 36 | # DEFINE may be used to specify any additional define, which will be reported |
| 37 | # by "haproxy -vv" in CFLAGS. |
| 38 | # SILENT_DEFINE may be used to specify other defines which will not be |
| 39 | # reported by "haproxy -vv". |
| 40 | # |
| 41 | # Other variables : |
| 42 | # DLMALLOC_SRC : build with dlmalloc, indicate the location of dlmalloc.c. |
| 43 | # DLMALLOC_THRES : should match PAGE_SIZE on every platform (default: 4096). |
| 44 | # PCREDIR : force the path to libpcre. |
| 45 | # IGNOREGIT : ignore GIT commit versions if set. |
| 46 | # VERSION : force haproxy version reporting. |
| 47 | # SUBVERS : add a sub-version (eg: platform, model, ...). |
| 48 | # VERDATE : force haproxy's release date. |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 49 | |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 50 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 51 | #### TARGET system |
| 52 | # Use TARGET=<target_name> to optimize for a specifc target OS among the |
| 53 | # following list (use the default "generic" if uncertain) : |
| 54 | # generic, linux22, linux24, linux24e, linux24eold, linux26, solaris, |
| 55 | # freebsd, openbsd, custom |
| 56 | TARGET = generic |
Willy Tarreau | 4f60f16 | 2007-04-08 16:39:58 +0200 | [diff] [blame] | 57 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 58 | #### TARGET CPU |
| 59 | # Use CPU=<cpu_name> to optimize for a particular CPU, among the following |
| 60 | # list : |
| 61 | # generic, i586, i686, ultrasparc, custom |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 62 | CPU = generic |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 63 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 64 | #### Toolchain options. |
| 65 | # GCC is normally used both for compiling and linking. |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 66 | CC = gcc |
| 67 | LD = gcc |
| 68 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 69 | #### Debug flags (typically "-g"). |
| 70 | # Those flags only feed CFLAGS so it is not mandatory to use this form. |
| 71 | DEBUG_CFLAGS = -g |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 72 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 73 | #### Memory usage tuning |
| 74 | # If small memory footprint is required, you can reduce the buffer size. There |
| 75 | # are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory |
| 76 | # with 1000 concurrent sessions. Putting it slightly lower than a page size |
| 77 | # will prevent the additional parameters to go beyond a page. 8030 bytes is |
| 78 | # exactly 5.5 TCP segments of 1460 bytes and is generally good. Useful tuning |
| 79 | # macros include : |
| 80 | # SYSTEM_MAXCONN, BUFSIZE, MAXREWRITE, REQURI_LEN, CAPTURE_LEN. |
| 81 | # Example: SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024 |
| 82 | SMALL_OPTS = |
Willy Tarreau | 6d1a988 | 2007-01-07 02:03:04 +0100 | [diff] [blame] | 83 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 84 | #### Debug settings |
| 85 | # You can enable debugging on specific code parts by setting DEBUG=-DDEBUG_xxx. |
| 86 | # Currently defined DEBUG macros include DEBUG_FULL, DEBUG_MEMORY, DEBUG_FSM, |
| 87 | # DEBUG_HASH and DEBUG_PARSE_NO_SPEEDUP. Please consult sources for exact |
| 88 | # meaning or do not use at all. |
| 89 | DEBUG = |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 90 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 91 | #### Additional include and library dirs |
| 92 | # Redefine this if you want to add some special PATH to include/libs |
| 93 | ADDINC = |
| 94 | ADDLIB = |
willy tarreau | 64a3cc3 | 2005-12-18 01:13:11 +0100 | [diff] [blame] | 95 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 96 | #### Specific macro definitions |
| 97 | # Use DEFINE=-Dxxx to set any tunable macro. Anything declared here will appear |
| 98 | # in the build options reported by "haproxy -vv". Use SILENT_DEFINE if you do |
| 99 | # not want to pollute the report with complex defines. |
| 100 | DEFINE = |
| 101 | SILENT_DEFINE = |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 102 | |
willy tarreau | 5cbea6f | 2005-12-17 12:48:26 +0100 | [diff] [blame] | 103 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 104 | #### CPU dependant optimizations |
| 105 | # Some CFLAGS are set by default depending on the target CPU. Those flags only |
| 106 | # feed CPU_CFLAGS, which in turn feed CFLAGS, so it is not mandatory to use |
| 107 | # them. You should not have to change these options. Better use CPU_CFLAGS or |
| 108 | # even CFLAGS instead. |
| 109 | CPU_CFLAGS.generic = -O2 |
| 110 | CPU_CFLAGS.i586 = -O2 -march=i586 |
| 111 | CPU_CFLAGS.i686 = -O2 -march=i686 |
| 112 | CPU_CFLAGS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc |
| 113 | CPU_CFLAGS = $(CPU_CFLAGS.$(CPU)) |
willy tarreau | 9da061b | 2005-12-17 12:29:56 +0100 | [diff] [blame] | 114 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 115 | #### Common CFLAGS |
| 116 | # These CFLAGS contain general optimization options, CPU-specific optimizations |
| 117 | # and debug flags. They may be overridden by some distributions which prefer to |
| 118 | # set all of them at once instead of playing with the CPU and DEBUG variables. |
| 119 | CFLAGS = $(CPU_CFLAGS) $(DEBUG_CFLAGS) |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 120 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 121 | #### Common LDFLAGS |
| 122 | # These LDFLAGS are used as the first "ld" options, regardless of any library |
| 123 | # path or any other option. They may be changed to add any linker-specific |
| 124 | # option at the beginning of the ld command line. |
| 125 | LDFLAGS = -g |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 126 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 127 | #### Target system options |
| 128 | # Depending on the target platform, some options are set, as well as some |
| 129 | # CFLAGS and LDFLAGS. The USE_* values are set to "implicit" so that they are |
| 130 | # not reported in the build options string. You should not have to change |
| 131 | # anything there. |
| 132 | ifeq ($(TARGET),generic) |
| 133 | # generic system target has nothing specific |
| 134 | USE_POLL = implicit |
| 135 | USE_TPROXY = implicit |
| 136 | else |
| 137 | ifeq ($(TARGET),linux22) |
| 138 | # This is for Linux 2.2 |
| 139 | USE_GETSOCKNAME = implicit |
| 140 | USE_POLL = implicit |
| 141 | USE_TPROXY = implicit |
| 142 | else |
| 143 | ifeq ($(TARGET),linux24) |
| 144 | # This is for standard Linux 2.4 with netfilter but without epoll() |
| 145 | USE_GETSOCKNAME = implicit |
| 146 | USE_NETFILTER = implicit |
| 147 | USE_POLL = implicit |
| 148 | USE_TPROXY = implicit |
| 149 | else |
| 150 | ifeq ($(TARGET),linux24e) |
| 151 | # This is for enhanced Linux 2.4 with netfilter and epoll() patch > 0.21 |
| 152 | USE_GETSOCKNAME = implicit |
| 153 | USE_NETFILTER = implicit |
| 154 | USE_POLL = implicit |
| 155 | USE_EPOLL = implicit |
| 156 | USE_SEPOLL = implicit |
| 157 | USE_MY_EPOLL = implicit |
| 158 | USE_TPROXY = implicit |
| 159 | else |
| 160 | ifeq ($(TARGET),linux24eold) |
| 161 | # This is for enhanced Linux 2.4 with netfilter and epoll() patch <= 0.21, |
| 162 | # which needs a workaround for a very rare bug. |
| 163 | USE_GETSOCKNAME = implicit |
| 164 | USE_NETFILTER = implicit |
| 165 | USE_POLL = implicit |
| 166 | USE_EPOLL = implicit |
| 167 | USE_SEPOLL = implicit |
| 168 | USE_MY_EPOLL = implicit |
| 169 | USE_EPOLL_WORKAROUND = implicit |
| 170 | USE_TPROXY = implicit |
| 171 | else |
| 172 | ifeq ($(TARGET),linux26) |
| 173 | # This is for standard Linux 2.6 with netfilter and standard epoll() |
| 174 | USE_GETSOCKNAME = implicit |
| 175 | USE_NETFILTER = implicit |
| 176 | USE_POLL = implicit |
| 177 | USE_EPOLL = implicit |
| 178 | USE_SEPOLL = implicit |
| 179 | USE_TPROXY = implicit |
| 180 | else |
| 181 | ifeq ($(TARGET),solaris) |
| 182 | # This is for Solaris 8 |
| 183 | USE_POLL = implicit |
| 184 | TARGET_CFLAGS = -fomit-frame-pointer -DFD_SETSIZE=65536 -D_REENTRANT |
| 185 | TARGET_LDFLAGS = -lnsl -lsocket |
| 186 | USE_TPROXY = implicit |
| 187 | else |
| 188 | ifeq ($(TARGET),freebsd) |
| 189 | # This is for FreeBSD |
| 190 | USE_POLL = implicit |
| 191 | USE_KQUEUE = implicit |
| 192 | USE_TPROXY = implicit |
| 193 | else |
| 194 | ifeq ($(TARGET),openbsd) |
| 195 | # This is for OpenBSD >= 3.0 |
| 196 | USE_POLL = implicit |
| 197 | USE_KQUEUE = implicit |
| 198 | USE_TPROXY = implicit |
| 199 | endif # openbsd |
| 200 | endif # freebsd |
| 201 | endif # solaris |
| 202 | endif # linux26 |
| 203 | endif # linux24eold |
| 204 | endif # linux24e |
| 205 | endif # linux24 |
| 206 | endif # linux22 |
| 207 | endif # generic |
willy tarreau | 036e1ce | 2005-12-17 13:46:33 +0100 | [diff] [blame] | 208 | |
willy tarreau | 4373b96 | 2005-12-18 01:32:31 +0100 | [diff] [blame] | 209 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 210 | #### Old-style REGEX library settings for compatibility with previous setups. |
| 211 | # It is still possible to use REGEX=<regex_lib> to select an alternative regex |
| 212 | # library. By default, we use libc's regex. On Solaris 8/Sparc, grouping seems |
| 213 | # to be broken using libc, so consider using pcre instead. Supported values are |
| 214 | # "libc", "pcre", and "static-pcre". Use of this method is deprecated in favor |
| 215 | # of "USE_PCRE" and "USE_STATIC_PCRE" (see build options below). |
| 216 | REGEX = libc |
willy tarreau | 9da061b | 2005-12-17 12:29:56 +0100 | [diff] [blame] | 217 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 218 | ifeq ($(REGEX),pcre) |
| 219 | USE_PCRE = 1 |
| 220 | $(warning WARNING! use of "REGEX=pcre" is deprecated, consider using "USE_PCRE=1" instead.) |
| 221 | endif |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 222 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 223 | ifeq ($(REGEX),static-pcre) |
| 224 | USE_STATIC_PCRE = 1 |
| 225 | $(warning WARNING! use of "REGEX=pcre-static" is deprecated, consider using "USE_STATIC_PCRE=1" instead.) |
| 226 | endif |
willy tarreau | 1c2ad21 | 2005-12-18 01:11:29 +0100 | [diff] [blame] | 227 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 228 | #### Old-style TPROXY settings |
| 229 | ifneq ($(findstring -DTPROXY,$(DEFINE)),) |
| 230 | USE_TPROXY = 1 |
| 231 | $(warning WARNING! use of "DEFINE=-DTPROXY" is deprecated, consider using "USE_TPROXY=1" instead.) |
| 232 | endif |
| 233 | |
| 234 | |
| 235 | #### Determine version, sub-version and release date. |
| 236 | # If GIT is found, and IGNOREGIT is not set, VERSION, SUBVERS and VERDATE are |
| 237 | # extracted from the last commit. Otherwise, use the contents of the files |
| 238 | # holding the same names in the current directory. |
willy tarreau | 0174f31 | 2005-12-18 01:02:42 +0100 | [diff] [blame] | 239 | |
Willy Tarreau | 6620dbb | 2007-01-02 00:44:53 +0100 | [diff] [blame] | 240 | ifeq ($(IGNOREGIT),) |
Willy Tarreau | ec69256 | 2007-09-09 23:31:11 +0200 | [diff] [blame] | 241 | VERSION := $(shell [ -d .git/. ] && ref=`(git-describe --tags) 2>/dev/null` && ref=$${ref%-g*} && echo "$${ref\#v}") |
Willy Tarreau | 9bf6c6e | 2006-12-23 11:12:04 +0100 | [diff] [blame] | 242 | ifneq ($(VERSION),) |
| 243 | # OK git is there and works. |
Willy Tarreau | a1973c4 | 2007-04-09 22:07:11 +0200 | [diff] [blame] | 244 | SUBVERS := $(shell comms=`git-log --no-merges v$(VERSION).. 2>/dev/null |grep -c ^commit `; [ $$comms -gt 0 ] && echo "-$$comms" ) |
| 245 | 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 | ec69256 | 2007-09-09 23:31:11 +0200 | [diff] [blame] | 246 | endif |
| 247 | endif |
| 248 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 249 | # Last commit version not found, take it from the files. |
Willy Tarreau | ec69256 | 2007-09-09 23:31:11 +0200 | [diff] [blame] | 250 | ifeq ($(VERSION),) |
| 251 | VERSION := $(shell cat VERSION 2>/dev/null || touch VERSION) |
| 252 | endif |
| 253 | ifeq ($(SUBVERS),) |
| 254 | SUBVERS := $(shell cat SUBVERS 2>/dev/null || touch SUBVERS) |
| 255 | endif |
| 256 | ifeq ($(VERDATE),) |
| 257 | VERDATE := $(shell cat VERDATE 2>/dev/null || touch VERDATE) |
Willy Tarreau | 9bf6c6e | 2006-12-23 11:12:04 +0100 | [diff] [blame] | 258 | endif |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 259 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 260 | #### Build options |
| 261 | # Do not change these ones, enable USE_* variables instead. |
| 262 | OPTIONS_CFLAGS = |
| 263 | OPTIONS_LDFLAGS = |
| 264 | OPTIONS_OBJS = |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 265 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 266 | # This variable collects all USE_* values except those set to "implicit". This |
| 267 | # is used to report a list of all flags which were used to build this version. |
| 268 | # Do not assign anything to it. |
| 269 | BUILD_OPTIONS = |
| 270 | |
| 271 | # Return USE_xxx=$(USE_xxx) unless $(USE_xxx) = "implicit" |
| 272 | # Usage: |
| 273 | # BUILD_OPTIONS += $(call ignore_implicit,USE_xxx) |
| 274 | ignore_implicit = $(patsubst %=implicit,,$(1)=$($(1))) |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 275 | |
Willy Tarreau | 6d1a988 | 2007-01-07 02:03:04 +0100 | [diff] [blame] | 276 | ifneq ($(USE_TCPSPLICE),) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 277 | # This is the directory hosting libtcpsplice.[ah] |
| 278 | TCPSPLICEDIR := |
| 279 | OPTIONS_CFLAGS += -DCONFIG_HAP_TCPSPLICE -I$(TCPSPLICEDIR) |
| 280 | OPTIONS_LDFLAGS += -L$(TCPSPLICEDIR) -ltcpsplice |
| 281 | BUILD_OPTIONS += $(call ignore_implicit,USE_TCPSPLICE) |
Willy Tarreau | 6d1a988 | 2007-01-07 02:03:04 +0100 | [diff] [blame] | 282 | endif |
| 283 | |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 284 | ifneq ($(USE_CTTPROXY),) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 285 | OPTIONS_CFLAGS += -DCONFIG_HAP_CTTPROXY |
| 286 | OPTIONS_OBJS += src/cttproxy.o |
| 287 | BUILD_OPTIONS += $(call ignore_implicit,USE_CTTPROXY) |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 288 | endif |
| 289 | |
| 290 | ifneq ($(USE_TPROXY),) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 291 | OPTIONS_CFLAGS += -DTPROXY |
| 292 | BUILD_OPTIONS += $(call ignore_implicit,USE_TPROXY) |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 293 | endif |
| 294 | |
Willy Tarreau | b1e52e8 | 2008-01-13 14:49:51 +0100 | [diff] [blame] | 295 | ifneq ($(USE_LINUX_TPROXY),) |
| 296 | OPTIONS_CFLAGS += -DCONFIG_HAP_LINUX_TPROXY |
| 297 | BUILD_OPTIONS += $(call ignore_implicit,USE_LINUX_TPROXY) |
| 298 | endif |
| 299 | |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 300 | ifneq ($(USE_POLL),) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 301 | OPTIONS_CFLAGS += -DENABLE_POLL |
| 302 | OPTIONS_OBJS += src/ev_poll.o |
| 303 | BUILD_OPTIONS += $(call ignore_implicit,USE_POLL) |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 304 | endif |
| 305 | |
| 306 | ifneq ($(USE_EPOLL),) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 307 | OPTIONS_CFLAGS += -DENABLE_EPOLL |
| 308 | OPTIONS_OBJS += src/ev_epoll.o |
| 309 | BUILD_OPTIONS += $(call ignore_implicit,USE_EPOLL) |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 310 | endif |
| 311 | |
Willy Tarreau | de99e99 | 2007-04-16 00:53:59 +0200 | [diff] [blame] | 312 | ifneq ($(USE_SEPOLL),) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 313 | OPTIONS_CFLAGS += -DENABLE_SEPOLL |
| 314 | OPTIONS_OBJS += src/ev_sepoll.o |
| 315 | BUILD_OPTIONS += $(call ignore_implicit,USE_SEPOLL) |
Willy Tarreau | de99e99 | 2007-04-16 00:53:59 +0200 | [diff] [blame] | 316 | endif |
| 317 | |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 318 | ifneq ($(USE_MY_EPOLL),) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 319 | OPTIONS_CFLAGS += -DUSE_MY_EPOLL |
| 320 | BUILD_OPTIONS += $(call ignore_implicit,USE_MY_EPOLL) |
| 321 | endif |
| 322 | |
| 323 | ifneq ($(USE_KQUEUE),) |
| 324 | OPTIONS_CFLAGS += -DENABLE_KQUEUE |
| 325 | OPTIONS_OBJS += src/ev_kqueue.o |
| 326 | BUILD_OPTIONS += $(call ignore_implicit,USE_KQUEUE) |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 327 | endif |
| 328 | |
| 329 | ifneq ($(USE_NETFILTER),) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 330 | OPTIONS_CFLAGS += -DNETFILTER |
| 331 | BUILD_OPTIONS += $(call ignore_implicit,USE_NETFILTER) |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 332 | endif |
| 333 | |
| 334 | ifneq ($(USE_EPOLL_WORKAROUND),) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 335 | OPTIONS_CFLAGS += -DEPOLL_CTL_MOD_WORKAROUND |
| 336 | BUILD_OPTIONS += $(call ignore_implicit,USE_EPOLL_WORKAROUND) |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 337 | endif |
| 338 | |
| 339 | ifneq ($(USE_GETSOCKNAME),) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 340 | OPTIONS_CFLAGS += -DUSE_GETSOCKNAME |
| 341 | BUILD_OPTIONS += $(call ignore_implicit,USE_GETSOCKNAME) |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 342 | endif |
| 343 | |
| 344 | ifneq ($(USE_REGPARM),) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 345 | OPTIONS_CFLAGS += -DCONFIG_HAP_USE_REGPARM |
| 346 | BUILD_OPTIONS += $(call ignore_implicit,USE_REGPARM) |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 347 | endif |
| 348 | |
Willy Tarreau | f2ef8c5 | 2007-07-11 09:19:31 +0200 | [diff] [blame] | 349 | ifneq ($(DLMALLOC_SRC),) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 350 | # May be changed to match PAGE_SIZE on every platform |
| 351 | DLMALLOC_THRES = 4096 |
| 352 | OPTIONS_OBJS += src/dlmalloc.o |
| 353 | BUILD_OPTIONS += DLMALLOC_SRC=$(DLMALLOC_SRC) |
Willy Tarreau | f2ef8c5 | 2007-07-11 09:19:31 +0200 | [diff] [blame] | 354 | endif |
| 355 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 356 | ifneq ($(USE_PCRE),) |
| 357 | # PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is |
| 358 | # automatically detected but can be forced if required. |
| 359 | ifeq ($(PCREDIR),) |
| 360 | PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local) |
Willy Tarreau | 79b34bf | 2006-12-22 15:28:43 +0100 | [diff] [blame] | 361 | endif |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 362 | OPTIONS_CFLAGS += -DUSE_PCRE -I$(PCREDIR)/include |
| 363 | OPTIONS_LDFLAGS += -L$(PCREDIR)/lib -lpcreposix -lpcre |
| 364 | BUILD_OPTIONS += $(call ignore_implicit,USE_PCRE) |
Willy Tarreau | 79b34bf | 2006-12-22 15:28:43 +0100 | [diff] [blame] | 365 | endif |
| 366 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 367 | ifneq ($(USE_STATIC_PCRE),) |
| 368 | # PCREDIR is the directory hosting include/pcre.h and lib/libpcre.*. It is |
| 369 | # automatically detected but can be forced if required. |
| 370 | ifeq ($(PCREDIR),) |
| 371 | PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local) |
| 372 | endif |
| 373 | OPTIONS_CFLAGS += -DUSE_PCRE -I$(PCREDIR)/include |
| 374 | OPTIONS_LDFLAGS += -L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic |
| 375 | BUILD_OPTIONS += $(call ignore_implicit,USE_STATIC_PCRE) |
| 376 | endif |
Willy Tarreau | 77074d5 | 2006-11-12 23:57:19 +0100 | [diff] [blame] | 377 | |
| 378 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 379 | #### Global compile options |
| 380 | VERBOSE_CFLAGS = $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE) |
| 381 | COPTS = -Iinclude -Wall |
| 382 | COPTS += $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE) $(SILENT_DEFINE) |
| 383 | COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(ADDINC) |
willy tarreau | eedaa9f | 2005-12-17 14:08:03 +0100 | [diff] [blame] | 384 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 385 | ifneq ($(VERSION)$(SUBVERS),) |
| 386 | COPTS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" |
| 387 | endif |
Willy Tarreau | 6d1a988 | 2007-01-07 02:03:04 +0100 | [diff] [blame] | 388 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 389 | ifneq ($(VERDATE),) |
| 390 | COPTS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\" |
Willy Tarreau | 6d1a988 | 2007-01-07 02:03:04 +0100 | [diff] [blame] | 391 | endif |
| 392 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 393 | #### Global link options |
| 394 | # These options are added at the end of the "ld" command line. Use LDFLAGS to |
| 395 | # add options at the beginning of the "ld" command line if needed. |
| 396 | LDOPTS = $(TARGET_LDFLAGS) $(OPTIONS_LDFLAGS) $(ADDLIB) |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 397 | |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 398 | |
| 399 | all: haproxy |
| 400 | |
Willy Tarreau | dd81598 | 2007-10-16 12:25:14 +0200 | [diff] [blame] | 401 | OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 402 | src/uri_auth.o src/standard.o src/buffers.o src/log.o src/task.o \ |
| 403 | src/time.o src/fd.o src/regex.o src/cfgparse.o src/server.o \ |
Willy Tarreau | 92fb983 | 2007-10-16 17:34:28 +0200 | [diff] [blame] | 404 | src/checks.o src/queue.o src/client.o src/proxy.o src/proto_uxst.o \ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 405 | src/proto_http.o src/stream_sock.o src/appsession.o src/backend.o \ |
Willy Tarreau | e6b9894 | 2007-10-29 01:09:36 +0100 | [diff] [blame] | 406 | src/senddata.o src/dumpstats.o src/proto_tcp.o \ |
Willy Tarreau | e6d2e4d | 2007-11-15 23:56:17 +0100 | [diff] [blame] | 407 | src/session.o src/hdr_idx.o src/ev_select.o \ |
| 408 | src/acl.o src/memory.o \ |
| 409 | src/ebtree.o src/eb32tree.o |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 410 | |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 411 | haproxy: $(OBJS) $(OPTIONS_OBJS) |
| 412 | $(LD) $(LDFLAGS) -o $@ $^ $(LDOPTS) |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 413 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 414 | objsize: haproxy |
| 415 | @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort |
| 416 | |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 417 | %.o: %.c |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 418 | $(CC) $(COPTS) -c -o $@ $< |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 419 | |
Willy Tarreau | 7b066db | 2007-12-02 11:28:59 +0100 | [diff] [blame] | 420 | src/haproxy.o: src/haproxy.c |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 421 | $(CC) $(COPTS) \ |
| 422 | -DBUILD_TARGET='"$(strip $(TARGET))"' \ |
| 423 | -DBUILD_CPU='"$(strip $(CPU))"' \ |
| 424 | -DBUILD_CC='"$(strip $(CC))"' \ |
| 425 | -DBUILD_CFLAGS='"$(strip $(VERBOSE_CFLAGS))"' \ |
| 426 | -DBUILD_OPTIONS='"$(strip $(BUILD_OPTIONS))"' \ |
| 427 | -c -o $@ $< |
Willy Tarreau | 7b066db | 2007-12-02 11:28:59 +0100 | [diff] [blame] | 428 | |
Willy Tarreau | f2ef8c5 | 2007-07-11 09:19:31 +0200 | [diff] [blame] | 429 | src/dlmalloc.o: $(DLMALLOC_SRC) |
Willy Tarreau | 9f2b730 | 2008-01-02 20:48:34 +0100 | [diff] [blame] | 430 | $(CC) $(COPTS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $< |
Willy Tarreau | f2ef8c5 | 2007-07-11 09:19:31 +0200 | [diff] [blame] | 431 | |
willy tarreau | 0f7af91 | 2005-12-17 12:21:26 +0100 | [diff] [blame] | 432 | clean: |
Willy Tarreau | 1a58749 | 2006-10-15 23:40:58 +0200 | [diff] [blame] | 433 | rm -f *.[oas] src/*.[oas] core haproxy test |
| 434 | 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] | 435 | rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz |
| 436 | rm -f haproxy-$(VERSION) nohup.out gmon.out |
willy tarreau | efae184 | 2005-12-17 12:51:03 +0100 | [diff] [blame] | 437 | |
willy tarreau | e114bf9 | 2006-03-19 21:30:14 +0100 | [diff] [blame] | 438 | tar: clean |
willy tarreau | cee272f | 2006-03-19 21:16:26 +0100 | [diff] [blame] | 439 | ln -s . haproxy-$(VERSION) |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 440 | tar --exclude=haproxy-$(VERSION)/.git \ |
| 441 | --exclude=haproxy-$(VERSION)/haproxy-$(VERSION) \ |
| 442 | --exclude=haproxy-$(VERSION)/haproxy-$(VERSION).tar.gz \ |
| 443 | -cf - haproxy-$(VERSION)/* | gzip -c9 >haproxy-$(VERSION).tar.gz |
willy tarreau | cee272f | 2006-03-19 21:16:26 +0100 | [diff] [blame] | 444 | rm -f haproxy-$(VERSION) |
| 445 | |
Willy Tarreau | 9f0a901 | 2006-10-15 14:24:14 +0200 | [diff] [blame] | 446 | git-tar: clean |
Willy Tarreau | 9bf6c6e | 2006-12-23 11:12:04 +0100 | [diff] [blame] | 447 | git-tar-tree HEAD haproxy-$(VERSION) | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz |
Willy Tarreau | ec69256 | 2007-09-09 23:31:11 +0200 | [diff] [blame] | 448 | |
| 449 | version: |
| 450 | @echo "VERSION: $(VERSION)" |
| 451 | @echo "SUBVERS: $(SUBVERS)" |
| 452 | @echo "VERDATE: $(VERDATE)" |
| 453 | |
| 454 | # never use this one if you don't know what it is used for. |
| 455 | update-version: |
| 456 | @echo "Ready to update the following versions :" |
| 457 | @echo "VERSION: $(VERSION)" |
| 458 | @echo "SUBVERS: $(SUBVERS)" |
| 459 | @echo "VERDATE: $(VERDATE)" |
| 460 | @echo "Press [ENTER] to continue or Ctrl-C to abort now.";read |
| 461 | echo "$(VERSION)" > VERSION |
| 462 | echo "$(SUBVERS)" > SUBVERS |
| 463 | echo "$(VERDATE)" > VERDATE |