1# This GNU Makefile supports different OS and CPU combinations. 2# 3# You should use it this way : 4# [g]make TARGET=os [ARCH=arch] [CPU=cpu] USE_xxx=1 ... 5# 6# When in doubt, invoke help, possibly with a known target : 7# [g]make help 8# [g]make help TARGET=linux-glibc 9# 10# By default the detailed commands are hidden for a cleaner output, but you may 11# see them by appending "V=1" to the make command. 12# 13# Valid USE_* options are enumerated in the "use_opts" variable and are listed 14# below. Most of them are automatically set by the TARGET, others have to be 15# explicitly specified : 16# USE_EPOLL : enable epoll() on Linux 2.6. Automatic. 17# USE_KQUEUE : enable kqueue() on BSD. Automatic. 18# USE_EVPORTS : enable event ports on SunOS systems. Automatic. 19# USE_MY_EPOLL : redefine epoll_* syscalls. Automatic. 20# USE_MY_SPLICE : redefine the splice syscall if build fails without. 21# USE_NETFILTER : enable netfilter on Linux. Automatic. 22# USE_PCRE : enable use of libpcre for regex. Recommended. 23# USE_PCRE_JIT : enable JIT for faster regex on libpcre >= 8.32 24# USE_PCRE2 : enable use of libpcre2 for regex. 25# USE_PCRE2_JIT : enable JIT for faster regex on libpcre2 26# USE_POLL : enable poll(). Automatic. 27# USE_PRIVATE_CACHE : disable shared memory cache of ssl sessions. 28# USE_THREAD : enable threads support. 29# USE_PTHREAD_PSHARED : enable pthread process shared mutex on sslcache. 30# USE_REGPARM : enable regparm optimization. Recommended on x86. 31# USE_STATIC_PCRE : enable static libpcre. Recommended. 32# USE_STATIC_PCRE2 : enable static libpcre2. 33# USE_TPROXY : enable transparent proxy. Automatic. 34# USE_LINUX_TPROXY : enable full transparent proxy. Automatic. 35# USE_LINUX_SPLICE : enable kernel 2.6 splicing. Automatic. 36# USE_LIBCRYPT : enable crypted passwords using -lcrypt 37# USE_CRYPT_H : set it if your system requires including crypt.h 38# USE_VSYSCALL : enable vsyscall on Linux x86, bypassing libc 39# USE_GETADDRINFO : use getaddrinfo() to resolve IPv6 host names. 40# USE_OPENSSL : enable use of OpenSSL. Recommended, but see below. 41# USE_LUA : enable Lua support. 42# USE_FUTEX : enable use of futex on kernel 2.6. Automatic. 43# USE_ACCEPT4 : enable use of accept4() on linux. Automatic. 44# USE_MY_ACCEPT4 : use own implementation of accept4() if glibc < 2.10. 45# USE_CLOSEFROM : enable use of closefrom() on *bsd, solaris. Automatic. 46# USE_PRCTL : enable use of prctl(). Automatic. 47# USE_ZLIB : enable zlib library support. 48# USE_SLZ : enable slz library instead of zlib (pick at most one). 49# USE_CPU_AFFINITY : enable pinning processes to CPU on Linux. Automatic. 50# USE_TFO : enable TCP fast open. Supported on Linux >= 3.7. 51# USE_NS : enable network namespace support. Supported on Linux >= 2.6.24. 52# USE_DL : enable it if your system requires -ldl. Automatic on Linux. 53# USE_RT : enable it if your system requires -lrt. Automatic on Linux. 54# USE_BACKTRACE : enable backtrace(). Automatic on Linux. 55# USE_DEVICEATLAS : enable DeviceAtlas api. 56# USE_51DEGREES : enable third party device detection library from 51Degrees 57# USE_WURFL : enable WURFL detection library from Scientiamobile 58# USE_SYSTEMD : enable sd_notify() support. 59# USE_OBSOLETE_LINKER : use when the linker fails to emit __start_init/__stop_init 60# USE_THREAD_DUMP : use the more advanced thread state dump system. Automatic. 61# 62# Options can be forced by specifying "USE_xxx=1" or can be disabled by using 63# "USE_xxx=" (empty string). The list of enabled and disabled options for a 64# given TARGET is enumerated at the end of "make help". 65# 66# Variables useful for packagers : 67# CC is set to "gcc" by default and is used for compilation only. 68# LD is set to "gcc" by default and is used for linking only. 69# ARCH may be useful to force build of 32-bit binary on 64-bit systems 70# CFLAGS is automatically set for the specified CPU and may be overridden. 71# LDFLAGS is automatically set to -g and may be overridden. 72# DEP may be cleared to ignore changes to include files during development 73# SMALL_OPTS may be used to specify some options to shrink memory usage. 74# DEBUG may be used to set some internal debugging options. 75# ERR may be set to non-empty to pass -Werror to the compiler 76# ADDINC may be used to complete the include path in the form -Ipath. 77# ADDLIB may be used to complete the library list in the form -Lpath -llib. 78# DEFINE may be used to specify any additional define, which will be reported 79# by "haproxy -vv" in CFLAGS. 80# SILENT_DEFINE may be used to specify other defines which will not be 81# reported by "haproxy -vv". 82# EXTRA is used to force building or not building some extra tools. 83# DESTDIR is not set by default and is used for installation only. 84# It might be useful to set DESTDIR if you want to install haproxy 85# in a sandbox. 86# PREFIX is set to "/usr/local" by default and is used for installation only. 87# SBINDIR is set to "$(PREFIX)/sbin" by default and is used for installation 88# only. 89# MANDIR is set to "$(PREFIX)/share/man" by default and is used for 90# installation only. 91# DOCDIR is set to "$(PREFIX)/doc/haproxy" by default and is used for 92# installation only. 93# HLUA_PREPEND_PATH may be used to prepend a folder to Lua's default package.path. 94# HLUA_PREPEND_CPATH may be used to prepend a folder to Lua's default package.cpath. 95# 96# Other variables : 97# PCRE_CONFIG : force the binary path to get pcre config (by default 98# pcre-config) 99# PCREDIR : force the path to libpcre. 100# PCRE_LIB : force the lib path to libpcre (defaults to $PCREDIR/lib). 101# PCRE_INC : force the include path to libpcre ($PCREDIR/inc) 102# PCRE2_CONFIG : force the binary path to get pcre2 config (by default 103# pcre2-config) 104# SSL_LIB : force the lib path to libssl/libcrypto 105# SSL_INC : force the include path to libssl/libcrypto 106# LUA_LIB : force the lib path to lua 107# LUA_INC : force the include path to lua 108# LUA_LIB_NAME : force the lib name (or automatically evaluated, by order of 109# priority : lua5.3, lua53, lua). 110# IGNOREGIT : ignore GIT commit versions if set. 111# VERSION : force haproxy version reporting. 112# SUBVERS : add a sub-version (eg: platform, model, ...). 113# VERDATE : force haproxy's release date. 114# VTEST_PROGRAM : location of the vtest program to run reg-tests. 115 116# verbosity: pass V=1 for verbose shell invocation 117V = 0 118Q = @ 119ifeq ($V,1) 120Q= 121endif 122 123# Function used to detect support of a given option by the compiler. 124# Usage: CFLAGS += $(call cc-opt,option). Eg: $(call cc-opt,-fwrapv) 125# Note: ensure the referencing variable is assigned using ":=" and not "=" to 126# call it only once. 127cc-opt = $(shell set -e; if $(CC) $(1) -E -xc - -o /dev/null </dev/null >&0 2>&0; then echo "$(1)"; fi;) 128 129# same but emits $2 if $1 is not supported 130cc-opt-alt = $(shell set -e; if $(CC) $(1) -E -xc - -o /dev/null </dev/null >&0 2>&0; then echo "$(1)"; else echo "$(2)"; fi;) 131 132# Disable a warning when supported by the compiler. Don't put spaces around the 133# warning! And don't use cc-opt which doesn't always report an error until 134# another one is also returned. 135# Usage: CFLAGS += $(call cc-nowarn,warning). Eg: $(call cc-opt,format-truncation) 136cc-nowarn = $(shell set -e; if $(CC) -W$(1) -E -xc - -o /dev/null </dev/null >&0 2>&0; then echo "-Wno-$(1)"; fi;) 137 138#### Installation options. 139DESTDIR = 140PREFIX = /usr/local 141SBINDIR = $(PREFIX)/sbin 142MANDIR = $(PREFIX)/share/man 143DOCDIR = $(PREFIX)/doc/haproxy 144 145#### TARGET system 146# Use TARGET=<target_name> to optimize for a specific target OS among the 147# following list (use the default "generic" if uncertain) : 148# linux-glibc, linux-glibc-legacy, linux-musl, solaris, freebsd, openbsd, 149# netbsd, cygwin, haiku, aix51, aix52, aix72-gcc, osx, generic, custom 150TARGET = 151 152#### TARGET CPU 153# Use CPU=<cpu_name> to optimize for a particular CPU, among the following 154# list : 155# generic, native, i586, i686, ultrasparc, power8, power9, custom 156CPU = generic 157 158#### Architecture, used when not building for native architecture 159# Use ARCH=<arch_name> to force build for a specific architecture. Known 160# architectures will lead to "-m32" or "-m64" being added to CFLAGS and 161# LDFLAGS. This can be required to build 32-bit binaries on 64-bit targets. 162# Currently, only 32, 64, x86_64, i386, i486, i586 and i686 are understood. 163ARCH = 164 165#### Toolchain options. 166# GCC is normally used both for compiling and linking. 167CC = gcc 168LD = $(CC) 169 170#### Debug flags (typically "-g"). 171# Those flags only feed CFLAGS so it is not mandatory to use this form. 172DEBUG_CFLAGS = -g 173 174#### Add -Werror when set to non-empty 175ERR = 176 177#### May be used to force running a specific set of reg-tests 178REG_TEST_FILES = 179REG_TEST_SCRIPT=./scripts/run-regtests.sh 180 181#### Compiler-specific flags that may be used to disable some negative over- 182# optimization or to silence some warnings. -fno-strict-aliasing is needed with 183# gcc >= 4.4. 184# We rely on signed integer wraparound on overflow, however clang think it 185# can do whatever it wants since it's an undefined behavior, so use -fwrapv 186# to be sure we get the intended behavior. 187SPEC_CFLAGS := -fno-strict-aliasing -Wdeclaration-after-statement 188SPEC_CFLAGS += $(call cc-opt-alt,-fwrapv,$(call cc-opt,-fno-strict-overflow)) 189SPEC_CFLAGS += $(call cc-nowarn,address-of-packed-member) 190SPEC_CFLAGS += $(call cc-nowarn,unused-label) 191SPEC_CFLAGS += $(call cc-nowarn,sign-compare) 192SPEC_CFLAGS += $(call cc-nowarn,unused-parameter) 193SPEC_CFLAGS += $(call cc-nowarn,old-style-declaration) 194SPEC_CFLAGS += $(call cc-nowarn,ignored-qualifiers) 195SPEC_CFLAGS += $(call cc-nowarn,clobbered) 196SPEC_CFLAGS += $(call cc-nowarn,missing-field-initializers) 197SPEC_CFLAGS += $(call cc-nowarn,implicit-fallthrough) 198SPEC_CFLAGS += $(call cc-nowarn,stringop-overflow) 199SPEC_CFLAGS += $(call cc-nowarn,cast-function-type) 200SPEC_CFLAGS += $(call cc-nowarn,string-plus-int) 201SPEC_CFLAGS += $(call cc-opt,-Wtype-limits) 202SPEC_CFLAGS += $(call cc-opt,-Wshift-negative-value) 203SPEC_CFLAGS += $(call cc-opt,-Wshift-overflow=2) 204SPEC_CFLAGS += $(call cc-opt,-Wduplicated-cond) 205SPEC_CFLAGS += $(call cc-opt,-Wnull-dereference) 206 207#### Memory usage tuning 208# If small memory footprint is required, you can reduce the buffer size. There 209# are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory 210# with 1000 concurrent sessions. Putting it slightly lower than a page size 211# will prevent the additional parameters to go beyond a page. 8030 bytes is 212# exactly 5.5 TCP segments of 1460 bytes and is generally good. Useful tuning 213# macros include : 214# SYSTEM_MAXCONN, BUFSIZE, MAXREWRITE, REQURI_LEN, CAPTURE_LEN. 215# Example: SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024 216SMALL_OPTS = 217 218#### Debug settings 219# You can enable debugging on specific code parts by setting DEBUG=-DDEBUG_xxx. 220# Currently defined DEBUG macros include DEBUG_FULL, DEBUG_MEMORY, DEBUG_FSM, 221# DEBUG_HASH, DEBUG_AUTH, DEBUG_SPOE, DEBUG_UAF and DEBUG_THREAD, DEBUG_STRICT, 222# DEBUG_DEV. Please check sources for exact meaning or do not use at all. 223DEBUG = 224 225#### Trace options 226# Use TRACE=1 to trace function calls to file "trace.out" or to stderr if not 227# possible. 228TRACE = 229 230#### Additional include and library dirs 231# Redefine this if you want to add some special PATH to include/libs 232ADDINC = 233ADDLIB = 234 235#### Specific macro definitions 236# Use DEFINE=-Dxxx to set any tunable macro. Anything declared here will appear 237# in the build options reported by "haproxy -vv". Use SILENT_DEFINE if you do 238# not want to pollute the report with complex defines. 239# The following settings might be of interest when SSL is enabled : 240# LISTEN_DEFAULT_CIPHERS is a cipher suite string used to set the default SSL 241# ciphers on "bind" lines instead of using OpenSSL's defaults. 242# CONNECT_DEFAULT_CIPHERS is a cipher suite string used to set the default 243# SSL ciphers on "server" lines instead of using OpenSSL's defaults. 244DEFINE = 245SILENT_DEFINE = 246 247#### extra programs to build 248# Force this to enable building extra programs or to disable them. 249# It's automatically appended depending on the targets. 250EXTRA = 251 252#### CPU dependent optimizations 253# Some CFLAGS are set by default depending on the target CPU. Those flags only 254# feed CPU_CFLAGS, which in turn feed CFLAGS, so it is not mandatory to use 255# them. You should not have to change these options. Better use CPU_CFLAGS or 256# even CFLAGS instead. 257CPU_CFLAGS.generic = -O2 258CPU_CFLAGS.native = -O2 -march=native 259CPU_CFLAGS.i586 = -O2 -march=i586 260CPU_CFLAGS.i686 = -O2 -march=i686 261CPU_CFLAGS.ultrasparc = -O6 -mcpu=v9 -mtune=ultrasparc 262CPU_CFLAGS.power8 = -O2 -mcpu=power8 -mtune=power8 263CPU_CFLAGS.power9 = -O2 -mcpu=power9 -mtune=power9 264CPU_CFLAGS = $(CPU_CFLAGS.$(CPU)) 265 266#### ARCH dependent flags, may be overridden by CPU flags 267ARCH_FLAGS.32 = -m32 268ARCH_FLAGS.64 = -m64 269ARCH_FLAGS.i386 = -m32 -march=i386 270ARCH_FLAGS.i486 = -m32 -march=i486 271ARCH_FLAGS.i586 = -m32 -march=i586 272ARCH_FLAGS.i686 = -m32 -march=i686 273ARCH_FLAGS.x86_64 = -m64 -march=x86-64 274ARCH_FLAGS = $(ARCH_FLAGS.$(ARCH)) 275 276#### Common CFLAGS 277# These CFLAGS contain general optimization options, CPU-specific optimizations 278# and debug flags. They may be overridden by some distributions which prefer to 279# set all of them at once instead of playing with the CPU and DEBUG variables. 280CFLAGS = $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(SPEC_CFLAGS) 281 282#### Common LDFLAGS 283# These LDFLAGS are used as the first "ld" options, regardless of any library 284# path or any other option. They may be changed to add any linker-specific 285# option at the beginning of the ld command line. 286LDFLAGS = $(ARCH_FLAGS) -g 287 288#### list of all "USE_*" options. These ones must be updated if new options are 289# added, so that the relevant options are properly added to the CFLAGS and to 290# the reported build options. 291use_opts = USE_EPOLL USE_KQUEUE USE_MY_EPOLL USE_MY_SPLICE USE_NETFILTER \ 292 USE_PCRE USE_PCRE_JIT USE_PCRE2 USE_PCRE2_JIT USE_POLL \ 293 USE_PRIVATE_CACHE USE_THREAD USE_PTHREAD_PSHARED USE_REGPARM \ 294 USE_STATIC_PCRE USE_STATIC_PCRE2 USE_TPROXY USE_LINUX_TPROXY \ 295 USE_LINUX_SPLICE USE_LIBCRYPT USE_CRYPT_H USE_VSYSCALL USE_BACKTRACE \ 296 USE_GETADDRINFO USE_OPENSSL USE_LUA USE_FUTEX USE_ACCEPT4 \ 297 USE_CLOSEFROM USE_MY_ACCEPT4 USE_ZLIB USE_SLZ USE_CPU_AFFINITY USE_TFO USE_NS \ 298 USE_DL USE_RT USE_DEVICEATLAS USE_51DEGREES USE_WURFL USE_SYSTEMD \ 299 USE_OBSOLETE_LINKER USE_PRCTL USE_THREAD_DUMP USE_EVPORTS 300 301#### Target system options 302# Depending on the target platform, some options are set, as well as some 303# CFLAGS and LDFLAGS. All variables pre-set here will not appear in the build 304# options string. They may be set to any value, but are historically set to 305# "implicit" which eases debugging. You should not have to change anything 306# there unless you're adding support for a new platform. 307default_opts = $(foreach name,$(1),$(eval $(name)=implicit)) 308 309# poll() is always supported, unless explicitly disabled by passing USE_POLL="" 310# on the make command line. 311USE_POLL = default 312 313# Always enable threads support by default and let the Makefile detect if 314# HAProxy can be compiled with threads or not. 315 316# generic system target has nothing specific 317ifeq ($(TARGET),generic) 318 set_target_defaults = $(call default_opts,USE_POLL USE_TPROXY) 319endif 320 321# Haiku 322ifeq ($(TARGET),haiku) 323 TARGET_LDFLAGS = -lnetwork 324 set_target_defaults = $(call default_opts,USE_POLL USE_TPROXY) 325endif 326 327# For linux >= 2.6.28 and glibc 328ifeq ($(TARGET),linux-glibc) 329 set_target_defaults = $(call default_opts, \ 330 USE_POLL USE_TPROXY USE_LIBCRYPT USE_DL USE_RT USE_CRYPT_H USE_NETFILTER \ 331 USE_CPU_AFFINITY USE_THREAD USE_EPOLL USE_FUTEX USE_LINUX_TPROXY \ 332 USE_ACCEPT4 USE_LINUX_SPLICE USE_PRCTL USE_THREAD_DUMP USE_NS USE_TFO \ 333 USE_GETADDRINFO USE_BACKTRACE) 334ifneq ($(shell echo __arm__/__aarch64__ | $(CC) -E -xc - | grep '^[^\#]'),__arm__/__aarch64__) 335 TARGET_LDFLAGS=-latomic 336endif 337endif 338 339# For linux >= 2.6.28, glibc without new features 340ifeq ($(TARGET),linux-glibc-legacy) 341 set_target_defaults = $(call default_opts, \ 342 USE_POLL USE_TPROXY USE_LIBCRYPT USE_DL USE_RT USE_CRYPT_H USE_NETFILTER \ 343 USE_CPU_AFFINITY USE_THREAD USE_EPOLL USE_FUTEX USE_LINUX_TPROXY \ 344 USE_ACCEPT4 USE_LINUX_SPLICE USE_PRCTL USE_THREAD_DUMP USE_GETADDRINFO) 345endif 346 347# For linux >= 2.6.28 and musl 348ifeq ($(TARGET),linux-musl) 349 set_target_defaults = $(call default_opts, \ 350 USE_POLL USE_TPROXY USE_LIBCRYPT USE_DL USE_RT USE_CRYPT_H USE_NETFILTER \ 351 USE_CPU_AFFINITY USE_THREAD USE_EPOLL USE_FUTEX USE_LINUX_TPROXY \ 352 USE_ACCEPT4 USE_LINUX_SPLICE USE_PRCTL USE_THREAD_DUMP USE_NS USE_TFO \ 353 USE_GETADDRINFO) 354ifneq ($(shell echo __arm__/__aarch64__ | $(CC) -E -xc - | grep '^[^\#]'),__arm__/__aarch64__) 355 TARGET_LDFLAGS=-latomic 356endif 357endif 358 359# Solaris 8 and above 360ifeq ($(TARGET),solaris) 361 # We also enable getaddrinfo() which works since solaris 8. 362 set_target_defaults = $(call default_opts, \ 363 USE_POLL USE_TPROXY USE_LIBCRYPT USE_CRYPT_H USE_GETADDRINFO USE_THREAD \ 364 USE_RT USE_OBSOLETE_LINKER USE_EVPORTS) 365 TARGET_CFLAGS = -DFD_SETSIZE=65536 -D_REENTRANT -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ 366 TARGET_LDFLAGS = -lnsl -lsocket 367endif 368 369# FreeBSD 5 and above 370ifeq ($(TARGET),freebsd) 371 set_target_defaults = $(call default_opts, \ 372 USE_POLL USE_TPROXY USE_LIBCRYPT USE_THREAD USE_CPU_AFFINITY USE_KQUEUE \ 373 USE_CLOSEFROM) 374endif 375 376# Mac OS/X 377ifeq ($(TARGET),osx) 378 set_target_defaults = $(call default_opts, \ 379 USE_POLL USE_TPROXY USE_LIBCRYPT USE_THREAD USE_CPU_AFFINITY USE_KQUEUE) 380 EXPORT_SYMBOL = -export_dynamic 381endif 382 383# OpenBSD 5.7 and above 384ifeq ($(TARGET),openbsd) 385 set_target_defaults = $(call default_opts, \ 386 USE_POLL USE_TPROXY USE_THREAD USE_KQUEUE USE_ACCEPT4) 387endif 388 389# NetBSD 390ifeq ($(TARGET),netbsd) 391 set_target_defaults = $(call default_opts, \ 392 USE_POLL USE_TPROXY USE_KQUEUE) 393endif 394 395# AIX 5.1 only 396ifeq ($(TARGET),aix51) 397 set_target_defaults = $(call default_opts, \ 398 USE_POLL USE_LIBCRYPT USE_OBSOLETE_LINKER USE_PRIVATE_CACHE) 399 TARGET_CFLAGS = -Dss_family=__ss_family -Dip6_hdr=ip6hdr -DSTEVENS_API -D_LINUX_SOURCE_COMPAT -Dunsetenv=my_unsetenv 400 DEBUG_CFLAGS = 401endif 402 403# AIX 5.2 404ifeq ($(TARGET),aix52) 405 set_target_defaults = $(call default_opts, \ 406 USE_POLL USE_LIBCRYPT USE_OBSOLETE_LINKER) 407 TARGET_CFLAGS = -D_MSGQSUPPORT 408 DEBUG_CFLAGS = 409endif 410 411# AIX 7.2 and above 412ifeq ($(TARGET),aix72-gcc) 413 set_target_defaults = $(call default_opts, \ 414 USE_POLL USE_THREAD USE_LIBCRYPT USE_OBSOLETE_LINKER USE_GETADDRINFO) 415 TARGET_CFLAGS = -D_H_XMEM -D_H_VAR 416 TARGET_LDFLAGS = -latomic 417endif 418 419# Cygwin 420ifeq ($(TARGET),cygwin) 421 set_target_defaults = $(call default_opts, \ 422 USE_POLL USE_TPROXY USE_OBSOLETE_LINKER) 423 # Cygwin adds IPv6 support only in version 1.7 (in beta right now). 424 TARGET_CFLAGS = $(if $(filter 1.5.%, $(shell uname -r)), -DUSE_IPV6 -DAF_INET6=23 -DINET6_ADDRSTRLEN=46, ) 425endif 426 427# set the default settings according to the target above 428$(set_target_defaults) 429 430#### Determine version, sub-version and release date. 431# If GIT is found, and IGNOREGIT is not set, VERSION, SUBVERS and VERDATE are 432# extracted from the last commit. Otherwise, use the contents of the files 433# holding the same names in the current directory. 434 435ifeq ($(IGNOREGIT),) 436VERSION := $(shell [ -d .git/. ] && (git describe --tags --match 'v*' --abbrev=0 | cut -c 2-) 2>/dev/null) 437ifneq ($(VERSION),) 438# OK git is there and works. 439SUBVERS := $(shell comms=`git log --format=oneline --no-merges v$(VERSION).. 2>/dev/null | wc -l | tr -d '[:space:]'`; commit=`(git log -1 --pretty=%h --abbrev=6) 2>/dev/null`; [ $$comms -gt 0 ] && echo "-$$commit-$$comms") 440VERDATE := $(shell git log -1 --pretty=format:%ci | cut -f1 -d' ' | tr '-' '/') 441endif 442endif 443 444# Last commit version not found, take it from the files. 445ifeq ($(VERSION),) 446VERSION := $(shell cat VERSION 2>/dev/null || touch VERSION) 447endif 448ifeq ($(SUBVERS),) 449SUBVERS := $(shell (grep -v '\$$Format' SUBVERS 2>/dev/null || touch SUBVERS) | head -n 1) 450endif 451ifeq ($(VERDATE),) 452VERDATE := $(shell (grep -v '^\$$Format' VERDATE 2>/dev/null || touch VERDATE) | head -n 1 | cut -f1 -d' ' | tr '-' '/') 453endif 454 455#### Build options 456# Do not change these ones, enable USE_* variables instead. 457OPTIONS_CFLAGS = 458OPTIONS_LDFLAGS = 459OPTIONS_OBJS = 460 461#### Extra objects to be built and integrated (used only for development) 462EXTRA_OBJS = 463 464# Return USE_xxx=$(USE_xxx) if the variable was set from the environment or the 465# command line. 466# Usage: 467# BUILD_OPTIONS += $(call ignore_implicit,USE_xxx) 468ignore_implicit = $(if $(subst environment,,$(origin $(1))), \ 469 $(if $(subst command line,,$(origin $(1))),, \ 470 $(1)=$($(1))), \ 471 $(1)=$($(1))) \ 472 473# This variable collects all USE_* values except those set to "implicit". This 474# is used to report a list of all flags which were used to build this version. 475# Do not assign anything to it. 476BUILD_OPTIONS := $(foreach opt,$(use_opts),$(call ignore_implicit,$(opt))) 477BUILD_FEATURES := $(foreach opt,$(patsubst USE_%,%,$(use_opts)),$(if $(USE_$(opt)),+$(opt),-$(opt))) 478 479# All USE_* options have their equivalent macro defined in the code (some might 480# possibly be unused though) 481OPTIONS_CFLAGS += $(foreach opt,$(use_opts),$(if $($(opt)),-D$(opt),)) 482 483ifneq ($(USE_LIBCRYPT),) 484ifneq ($(TARGET),osx) 485OPTIONS_LDFLAGS += -lcrypt 486endif 487endif 488 489ifneq ($(USE_SLZ),) 490# Use SLZ_INC and SLZ_LIB to force path to zlib.h and libz.{a,so} if needed. 491SLZ_INC = 492SLZ_LIB = 493OPTIONS_CFLAGS += $(if $(SLZ_INC),-I$(SLZ_INC)) 494OPTIONS_LDFLAGS += $(if $(SLZ_LIB),-L$(SLZ_LIB)) -lslz 495endif 496 497ifneq ($(USE_ZLIB),) 498# Use ZLIB_INC and ZLIB_LIB to force path to zlib.h and libz.{a,so} if needed. 499ZLIB_INC = 500ZLIB_LIB = 501OPTIONS_CFLAGS += $(if $(ZLIB_INC),-I$(ZLIB_INC)) 502OPTIONS_LDFLAGS += $(if $(ZLIB_LIB),-L$(ZLIB_LIB)) -lz 503endif 504 505ifneq ($(USE_POLL),) 506OPTIONS_OBJS += src/ev_poll.o 507endif 508 509ifneq ($(USE_EPOLL),) 510OPTIONS_OBJS += src/ev_epoll.o 511endif 512 513ifneq ($(USE_KQUEUE),) 514OPTIONS_OBJS += src/ev_kqueue.o 515endif 516 517ifneq ($(USE_EVPORTS),) 518OPTIONS_OBJS += src/ev_evports.o 519endif 520 521ifneq ($(USE_VSYSCALL),) 522OPTIONS_OBJS += src/i386-linux-vsys.o 523endif 524 525ifneq ($(USE_REGPARM),) 526OPTIONS_CFLAGS += -DCONFIG_REGPARM=3 527endif 528 529ifneq ($(USE_DL),) 530OPTIONS_LDFLAGS += -ldl 531endif 532 533ifneq ($(USE_RT),) 534OPTIONS_LDFLAGS += -lrt 535endif 536 537ifneq ($(USE_THREAD),) 538OPTIONS_LDFLAGS += -lpthread 539endif 540 541ifneq ($(USE_BACKTRACE),) 542OPTIONS_LDFLAGS += -Wl,$(if $(EXPORT_SYMBOL),$(EXPORT_SYMBOL),--export-dynamic) 543endif 544 545ifneq ($(USE_OPENSSL),) 546# OpenSSL is packaged in various forms and with various dependencies. 547# In general -lssl is enough, but on some platforms, -lcrypto may be needed, 548# reason why it's added by default. Some even need -lz, then you'll need to 549# pass it in the "ADDLIB" variable if needed. If your SSL libraries are not 550# in the usual path, use SSL_INC=/path/to/inc and SSL_LIB=/path/to/lib. 551OPTIONS_CFLAGS += $(if $(SSL_INC),-I$(SSL_INC)) 552OPTIONS_LDFLAGS += $(if $(SSL_LIB),-L$(SSL_LIB)) -lssl -lcrypto 553ifneq ($(USE_DL),) 554OPTIONS_LDFLAGS += -ldl 555endif 556OPTIONS_OBJS += src/ssl_sock.o 557endif 558 559# The private cache option affect the way the shctx is built 560ifeq ($(USE_PRIVATE_CACHE),) 561ifneq ($(USE_PTHREAD_PSHARED),) 562OPTIONS_LDFLAGS += -lpthread 563endif 564endif 565 566ifneq ($(USE_LUA),) 567check_lua_lib = $(shell echo "int main(){}" | $(CC) -o /dev/null -x c - $(2) -l$(1) 2>/dev/null && echo $(1)) 568check_lua_inc = $(shell if [ -d $(2)$(1) ]; then echo $(2)$(1); fi;) 569 570OPTIONS_CFLAGS += $(if $(LUA_INC),-I$(LUA_INC)) 571LUA_LD_FLAGS := -Wl,$(if $(EXPORT_SYMBOL),$(EXPORT_SYMBOL),--export-dynamic) $(if $(LUA_LIB),-L$(LUA_LIB)) 572ifeq ($(LUA_LIB_NAME),) 573# Try to automatically detect the Lua library 574LUA_LIB_NAME := $(firstword $(foreach lib,lua5.3 lua53 lua,$(call check_lua_lib,$(lib),$(LUA_LD_FLAGS)))) 575ifeq ($(LUA_LIB_NAME),) 576$(error unable to automatically detect the Lua library name, you can enforce its name with LUA_LIB_NAME=<name> (where <name> can be lua5.3, lua53, lua, ...)) 577endif 578LUA_INC := $(firstword $(foreach lib,lua5.3 lua53 lua,$(call check_lua_inc,$(lib),"/usr/include/"))) 579ifneq ($(LUA_INC),) 580OPTIONS_CFLAGS += -I$(LUA_INC) 581endif 582ifneq ($(HLUA_PREPEND_PATH),) 583OPTIONS_CFLAGS += -DHLUA_PREPEND_PATH=$(HLUA_PREPEND_PATH) 584BUILD_OPTIONS += HLUA_PREPEND_PATH=$(HLUA_PREPEND_PATH) 585endif 586ifneq ($(HLUA_PREPEND_CPATH),) 587OPTIONS_CFLAGS += -DHLUA_PREPEND_CPATH=$(HLUA_PREPEND_CPATH) 588BUILD_OPTIONS += HLUA_PREPEND_CPATH=$(HLUA_PREPEND_CPATH) 589endif 590endif 591 592OPTIONS_LDFLAGS += $(LUA_LD_FLAGS) -l$(LUA_LIB_NAME) -lm 593ifneq ($(USE_DL),) 594OPTIONS_LDFLAGS += -ldl 595endif 596OPTIONS_OBJS += src/hlua.o src/hlua_fcn.o 597endif 598 599ifneq ($(USE_DEVICEATLAS),) 600ifeq ($(USE_PCRE),) 601$(error the DeviceAtlas module needs the PCRE library in order to compile) 602endif 603# Use DEVICEATLAS_SRC and possibly DEVICEATLAS_INC and DEVICEATLAS_LIB to force path 604# to DeviceAtlas headers and libraries if needed. 605DEVICEATLAS_SRC = 606DEVICEATLAS_INC = $(DEVICEATLAS_SRC) 607DEVICEATLAS_LIB = $(DEVICEATLAS_SRC) 608ifeq ($(DEVICEATLAS_SRC),) 609OPTIONS_LDFLAGS += -lda 610else 611OPTIONS_OBJS += $(DEVICEATLAS_LIB)/json.o 612OPTIONS_OBJS += $(DEVICEATLAS_LIB)/dac.o 613endif 614OPTIONS_OBJS += src/da.o 615OPTIONS_CFLAGS += $(if $(DEVICEATLAS_INC),-I$(DEVICEATLAS_INC)) 616endif 617 618ifneq ($(USE_51DEGREES),) 619# Use 51DEGREES_SRC and possibly 51DEGREES_INC and 51DEGREES_LIB to force path 620# to 51degrees headers and libraries if needed. 62151DEGREES_SRC = 62251DEGREES_INC = $(51DEGREES_SRC) 62351DEGREES_LIB = $(51DEGREES_SRC) 624OPTIONS_OBJS += $(51DEGREES_LIB)/../cityhash/city.o 625OPTIONS_OBJS += $(51DEGREES_LIB)/51Degrees.o 626OPTIONS_OBJS += src/51d.o 627OPTIONS_CFLAGS += $(if $(51DEGREES_INC),-I$(51DEGREES_INC)) 628ifeq ($(USE_THREAD),) 629OPTIONS_CFLAGS += -DFIFTYONEDEGREES_NO_THREADING 630else 631OPTIONS_OBJS += $(51DEGREES_LIB)/../threading.o 632endif 633 634OPTIONS_LDFLAGS += $(if $(51DEGREES_LIB),-L$(51DEGREES_LIB)) -lm 635endif 636 637ifneq ($(USE_WURFL),) 638# Use WURFL_SRC and possibly WURFL_INC and WURFL_LIB to force path 639# to WURFL headers and libraries if needed. 640WURFL_SRC = 641WURFL_INC = $(WURFL_SRC) 642WURFL_LIB = $(WURFL_SRC) 643OPTIONS_OBJS += src/wurfl.o 644OPTIONS_CFLAGS += $(if $(WURFL_INC),-I$(WURFL_INC)) 645ifneq ($(WURFL_DEBUG),) 646OPTIONS_CFLAGS += -DWURFL_DEBUG 647endif 648ifneq ($(WURFL_HEADER_WITH_DETAILS),) 649OPTIONS_CFLAGS += -DWURFL_HEADER_WITH_DETAILS 650endif 651OPTIONS_LDFLAGS += $(if $(WURFL_LIB),-L$(WURFL_LIB)) -lwurfl 652endif 653 654ifneq ($(USE_SYSTEMD),) 655OPTIONS_LDFLAGS += -lsystemd 656endif 657 658ifneq ($(USE_PCRE)$(USE_STATIC_PCRE)$(USE_PCRE_JIT),) 659ifneq ($(USE_PCRE2)$(USE_STATIC_PCRE2)$(USE_PCRE2_JIT),) 660$(error cannot compile both PCRE and PCRE2 support) 661endif 662# PCREDIR is used to automatically construct the PCRE_INC and PCRE_LIB paths, 663# by appending /include and /lib respectively. If your system does not use the 664# same sub-directories, simply force these variables instead of PCREDIR. It is 665# automatically detected but can be forced if required (for cross-compiling). 666# Forcing PCREDIR to an empty string will let the compiler use the default 667# locations. 668 669PCRE_CONFIG := pcre-config 670PCREDIR := $(shell $(PCRE_CONFIG) --prefix 2>/dev/null || echo /usr/local) 671ifneq ($(PCREDIR),) 672PCRE_INC := $(PCREDIR)/include 673PCRE_LIB := $(PCREDIR)/lib 674endif 675 676ifeq ($(USE_STATIC_PCRE),) 677# dynamic PCRE 678OPTIONS_CFLAGS += -DUSE_PCRE $(if $(PCRE_INC),-I$(PCRE_INC)) 679OPTIONS_LDFLAGS += $(if $(PCRE_LIB),-L$(PCRE_LIB)) -lpcreposix -lpcre 680else 681# static PCRE 682OPTIONS_CFLAGS += -DUSE_PCRE $(if $(PCRE_INC),-I$(PCRE_INC)) 683OPTIONS_LDFLAGS += $(if $(PCRE_LIB),-L$(PCRE_LIB)) -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic 684endif 685endif 686 687ifneq ($(USE_PCRE2)$(USE_STATIC_PCRE2)$(USE_PCRE2_JIT),) 688PCRE2_CONFIG := pcre2-config 689PCRE2DIR := $(shell $(PCRE2_CONFIG) --prefix 2>/dev/null || echo /usr/local) 690ifneq ($(PCRE2DIR),) 691PCRE2_INC := $(PCRE2DIR)/include 692PCRE2_LIB := $(PCRE2DIR)/lib 693 694ifeq ($(PCRE2_WIDTH),) 695PCRE2_WIDTH = 8 696endif 697 698ifneq ($(PCRE2_WIDTH),8) 699ifneq ($(PCRE2_WIDTH),16) 700ifneq ($(PCRE2_WIDTH),32) 701$(error PCRE2_WIDTH needs to be set to either 8,16 or 32) 702endif 703endif 704endif 705 706 707PCRE2_LDFLAGS := $(shell $(PCRE2_CONFIG) --libs$(PCRE2_WIDTH) 2>/dev/null || echo -L/usr/local/lib -lpcre2-$(PCRE2_WIDTH)) 708 709ifeq ($(PCRE2_LDFLAGS),) 710$(error libpcre2-$(PCRE2_WIDTH) not found) 711else 712ifeq ($(PCRE2_WIDTH),8) 713PCRE2_LDFLAGS += -lpcre2-posix 714endif 715endif 716 717OPTIONS_CFLAGS += -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=$(PCRE2_WIDTH) 718OPTIONS_CFLAGS += $(if $(PCRE2_INC), -I$(PCRE2_INC)) 719 720ifneq ($(USE_STATIC_PCRE2),) 721OPTIONS_LDFLAGS += $(if $(PCRE2_LIB),-L$(PCRE2_LIB)) -Wl,-Bstatic -L$(PCRE2_LIB) $(PCRE2_LDFLAGS) -Wl,-Bdynamic 722else 723OPTIONS_LDFLAGS += $(if $(PCRE2_LIB),-L$(PCRE2_LIB)) -L$(PCRE2_LIB) $(PCRE2_LDFLAGS) 724endif 725 726endif 727endif 728 729# This one can be changed to look for ebtree files in an external directory 730EBTREE_DIR := ebtree 731 732#### Global compile options 733VERBOSE_CFLAGS = $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE) 734COPTS = -Iinclude -I$(EBTREE_DIR) -Wall -Wextra 735 736ifneq ($(ERR),) 737COPTS += -Werror 738endif 739 740COPTS += $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE) $(SILENT_DEFINE) 741COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(ADDINC) 742 743ifneq ($(VERSION)$(SUBVERS),) 744COPTS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" 745endif 746 747ifneq ($(VERDATE),) 748COPTS += -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\" 749endif 750 751ifneq ($(TRACE),) 752# if tracing is enabled, we want it to be as fast as possible 753TRACE_COPTS := $(filter-out -O0 -O1 -O2 -pg -finstrument-functions,$(COPTS)) -O3 -fomit-frame-pointer 754COPTS += -finstrument-functions 755endif 756 757ifneq ($(USE_NS),) 758OPTIONS_OBJS += src/namespace.o 759endif 760 761#### Global link options 762# These options are added at the end of the "ld" command line. Use LDFLAGS to 763# add options at the beginning of the "ld" command line if needed. 764LDOPTS = $(TARGET_LDFLAGS) $(OPTIONS_LDFLAGS) $(ADDLIB) 765 766ifeq ($V,1) 767cmd_CC = $(CC) 768cmd_LD = $(LD) 769cmd_AR = $(AR) 770else 771cmd_CC = $(Q)echo " CC $@";$(CC) 772cmd_LD = $(Q)echo " LD $@";$(LD) 773cmd_AR = $(Q)echo " AR $@";$(AR) 774endif 775 776ifeq ($(TARGET),) 777all: 778 @echo 779 @echo "Due to too many reports of suboptimized setups, building without" 780 @echo "specifying the target is no longer supported. Please specify the" 781 @echo "target OS in the TARGET variable, in the following form:" 782 @echo 783 @echo " $ make TARGET=xxx" 784 @echo 785 @echo "Please choose the target among the following supported list :" 786 @echo 787 @echo " linux-glibc, linux-glibc-legacy, linux-musl, solaris, freebsd, openbsd, " 788 @echo " netbsd, cygwin, haiku, aix51, aix52, aix72-gcc, osx, generic, custom" 789 @echo 790 @echo "Use \"generic\" if you don't want any optimization, \"custom\" if you" 791 @echo "want to precisely tweak every option, or choose the target which" 792 @echo "matches your OS the most in order to gain the maximum performance" 793 @echo "out of it. Please check the Makefile in case of doubts." 794 @echo 795 @exit 1 796else 797ifneq ($(filter $(TARGET), linux linux22 linux24 linux24e linux26 linux2628),) 798all: 799 @echo 800 @echo "Target '$(TARGET)' was removed from HAProxy 2.0 due to being irrelevant and" 801 @echo "often wrong. Please use 'linux-glibc' instead or define your custom target" 802 @echo "by checking available options using 'make help TARGET=<your-target>'." 803 @echo 804 @exit 1 805else 806all: haproxy $(EXTRA) 807endif 808endif 809 810OBJS = src/mux_h2.o src/stream.o src/mux_fcgi.o src/cfgparse-listen.o \ 811 src/http_ana.o src/stats.o src/mux_h1.o src/flt_spoe.o src/server.o \ 812 src/cfgparse.o src/checks.o src/backend.o src/log.o src/peers.o \ 813 src/cli.o src/haproxy.o src/stick_table.o src/standard.o src/sample.o \ 814 src/proxy.o src/stream_interface.o src/pattern.o src/dns.o \ 815 src/proto_tcp.o src/listener.o src/cfgparse-global.o src/h1.o \ 816 src/http_rules.o src/http_fetch.o src/cache.o src/session.o \ 817 src/fcgi-app.o src/connection.o src/tcp_rules.o src/filters.o \ 818 src/task.o src/mworker.o src/map.o src/h1_htx.o src/trace.o \ 819 src/flt_trace.o src/acl.o src/http_htx.o src/flt_http_comp.o \ 820 src/payload.o src/vars.o src/debug.o src/mux_pt.o src/http_act.o \ 821 src/h2.o src/queue.o src/fd.o src/proto_uxst.o src/lb_chash.o \ 822 src/ring.o src/frontend.o src/raw_sock.o src/xprt_handshake.o \ 823 src/htx.o src/memory.o src/applet.o src/channel.o src/signal.o \ 824 src/lb_fwrr.o src/ev_select.o src/sink.o src/http_conv.o \ 825 src/proto_sockpair.o src/mworker-prog.o src/activity.o src/lb_fwlc.o \ 826 src/http.o src/lb_fas.o src/uri_auth.o src/hathreads.o src/regex.o \ 827 src/auth.o src/buffer.o src/compression.o src/proto_udp.o src/lb_map.o \ 828 src/chunk.o src/wdt.o src/hpack-dec.o src/action.o src/xxhash.o \ 829 src/pipe.o src/shctx.o src/hpack-tbl.o src/http_acl.o src/sha1.o \ 830 src/time.o src/hpack-enc.o src/fcgi.o src/arg.o src/base64.o \ 831 src/protocol.o src/freq_ctr.o src/lru.o src/hpack-huff.o src/dict.o \ 832 src/hash.o src/mailers.o src/version.o 833 834EBTREE_OBJS = $(EBTREE_DIR)/ebtree.o $(EBTREE_DIR)/eb32sctree.o \ 835 $(EBTREE_DIR)/eb32tree.o $(EBTREE_DIR)/eb64tree.o \ 836 $(EBTREE_DIR)/ebmbtree.o $(EBTREE_DIR)/ebsttree.o \ 837 $(EBTREE_DIR)/ebimtree.o $(EBTREE_DIR)/ebistree.o 838 839ifneq ($(TRACE),) 840OBJS += src/calltrace.o 841endif 842 843ifneq ($(EXTRA_OBJS),) 844OBJS += $(EXTRA_OBJS) 845endif 846 847# Not used right now 848LIB_EBTREE = $(EBTREE_DIR)/libebtree.a 849 850# Used only for forced dependency checking. May be cleared during development. 851INCLUDES = $(wildcard include/*/*.h ebtree/*.h) 852DEP = $(INCLUDES) .build_opts 853 854help: 855 $(Q)sed -ne "/^[^#]*$$/q;s/^# \{0,1\}\(.*\)/\1/;p" Makefile 856 $(Q)echo; \ 857 if [ -n "$(TARGET)" ]; then \ 858 if [ -n "$(set_target_defaults)" ]; then \ 859 echo "Current TARGET: $(TARGET)"; \ 860 else \ 861 echo "Current TARGET: $(TARGET) (custom target)"; \ 862 fi; \ 863 else \ 864 echo "TARGET not set, you may pass 'TARGET=xxx' to set one among :";\ 865 echo " linux-glibc, linux-glibc-legacy, solaris, freebsd, netbsd, osx,"; \ 866 echo " openbsd, aix51, aix52, aix72-gcc, cygwin, haiku, generic, custom"; \ 867 fi 868 $(Q)echo;echo "Enabled features for TARGET '$(TARGET)' (disable with 'USE_xxx=') :" 869 $(Q)set -- $(foreach opt,$(patsubst USE_%,%,$(use_opts)),$(if $(USE_$(opt)),$(opt),)); echo " $$*" | (fmt || cat) 2>/dev/null 870 $(Q)echo;echo "Disabled features for TARGET '$(TARGET)' (enable with 'USE_xxx=1') :" 871 $(Q)set -- $(foreach opt,$(patsubst USE_%,%,$(use_opts)),$(if $(USE_$(opt)),,$(opt))); echo " $$*" | (fmt || cat) 2>/dev/null 872 873# Used only to force a rebuild if some build options change 874build_opts = $(shell rm -f .build_opts.new; echo \'$(TARGET) $(BUILD_OPTIONS) $(VERBOSE_CFLAGS)\' > .build_opts.new; if cmp -s .build_opts .build_opts.new; then rm -f .build_opts.new; else mv -f .build_opts.new .build_opts; fi) 875.build_opts: $(build_opts) 876 877haproxy: $(OPTIONS_OBJS) $(OBJS) $(EBTREE_OBJS) 878 $(cmd_LD) $(LDFLAGS) -o $@ $^ $(LDOPTS) 879 880$(LIB_EBTREE): $(EBTREE_OBJS) 881 $(cmd_AR) rv $@ $^ 882 883objsize: haproxy 884 $(Q)objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort 885 886%.o: %.c $(DEP) 887 $(cmd_CC) $(COPTS) -c -o $@ $< 888 889# rebuild it every time 890.PHONY: src/version.c 891 892src/calltrace.o: src/calltrace.c $(DEP) 893 $(cmd_CC) $(TRACE_COPTS) -c -o $@ $< 894 895src/haproxy.o: src/haproxy.c $(DEP) 896 $(cmd_CC) $(COPTS) \ 897 -DBUILD_TARGET='"$(strip $(TARGET))"' \ 898 -DBUILD_ARCH='"$(strip $(ARCH))"' \ 899 -DBUILD_CPU='"$(strip $(CPU))"' \ 900 -DBUILD_CC='"$(strip $(CC))"' \ 901 -DBUILD_CFLAGS='"$(strip $(VERBOSE_CFLAGS))"' \ 902 -DBUILD_OPTIONS='"$(strip $(BUILD_OPTIONS))"' \ 903 -DBUILD_FEATURES='"$(strip $(BUILD_FEATURES))"' \ 904 -c -o $@ $< 905 906install-man: 907 $(Q)install -v -d "$(DESTDIR)$(MANDIR)"/man1 908 $(Q)install -v -m 644 doc/haproxy.1 "$(DESTDIR)$(MANDIR)"/man1 909 910EXCLUDE_DOCUMENTATION = lgpl gpl coding-style 911DOCUMENTATION = $(filter-out $(EXCLUDE_DOCUMENTATION),$(patsubst doc/%.txt,%,$(wildcard doc/*.txt))) 912 913install-doc: 914 $(Q)install -v -d "$(DESTDIR)$(DOCDIR)" 915 $(Q)for x in $(DOCUMENTATION); do \ 916 install -v -m 644 doc/$$x.txt "$(DESTDIR)$(DOCDIR)" ; \ 917 done 918 919install-bin: 920 $(Q)for i in haproxy $(EXTRA); do \ 921 if ! [ -e "$$i" ]; then \ 922 echo "Please run 'make' before 'make install'."; \ 923 exit 1; \ 924 fi; \ 925 done 926 $(Q)install -v -d "$(DESTDIR)$(SBINDIR)" 927 $(Q)install -v haproxy $(EXTRA) "$(DESTDIR)$(SBINDIR)" 928 929install: install-bin install-man install-doc 930 931uninstall: 932 $(Q)rm -f "$(DESTDIR)$(MANDIR)"/man1/haproxy.1 933 $(Q)for x in $(DOCUMENTATION); do \ 934 rm -f "$(DESTDIR)$(DOCDIR)"/$$x.txt ; \ 935 done 936 $(Q)-rmdir "$(DESTDIR)$(DOCDIR)" 937 $(Q)rm -f "$(DESTDIR)$(SBINDIR)"/haproxy 938 939clean: 940 $(Q)rm -f *.[oas] src/*.[oas] ebtree/*.[oas] haproxy test .build_opts .build_opts.new 941 $(Q)for dir in . src include/* doc ebtree; do rm -f $$dir/*~ $$dir/*.rej $$dir/core; done 942 $(Q)rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz 943 $(Q)rm -f haproxy-$(VERSION) haproxy-$(VERSION)$(SUBVERS) nohup.out gmon.out 944 $(Q)rm -f contrib/*/*.[oas] contrib/*/*/*.[oas] contrib/*/*/*/*.[oas] 945 946tags: 947 $(Q)find src include \( -name '*.c' -o -name '*.h' \) -print0 | \ 948 xargs -0 etags --declarations --members 949 950cscope: 951 $(Q)find src include -name "*.[ch]" -print | cscope -q -b -i - 952 953tar: clean 954 $(Q)ln -s . haproxy-$(VERSION)$(SUBVERS) 955 $(Q)tar --exclude=haproxy-$(VERSION)$(SUBVERS)/.git \ 956 --exclude=haproxy-$(VERSION)$(SUBVERS)/haproxy-$(VERSION)$(SUBVERS) \ 957 --exclude=haproxy-$(VERSION)$(SUBVERS)/haproxy-$(VERSION)$(SUBVERS).tar.gz \ 958 -cf - haproxy-$(VERSION)$(SUBVERS)/* | gzip -c9 >haproxy-$(VERSION)$(SUBVERS).tar.gz 959 $(Q)echo haproxy-$(VERSION)$(SUBVERS).tar.gz 960 $(Q)rm -f haproxy-$(VERSION)$(SUBVERS) 961 962git-tar: 963 $(Q)git archive --format=tar --prefix="haproxy-$(VERSION)$(SUBVERS)/" HEAD | gzip -9 > haproxy-$(VERSION)$(SUBVERS).tar.gz 964 $(Q)echo haproxy-$(VERSION)$(SUBVERS).tar.gz 965 966version: 967 @echo "VERSION: $(VERSION)" 968 @echo "SUBVERS: $(SUBVERS)" 969 @echo "VERDATE: $(VERDATE)" 970 971# never use this one if you don't know what it is used for. 972update-version: 973 @echo "Ready to update the following versions :" 974 @echo "VERSION: $(VERSION)" 975 @echo "SUBVERS: $(SUBVERS)" 976 @echo "VERDATE: $(VERDATE)" 977 @echo "Press [ENTER] to continue or Ctrl-C to abort now.";read 978 echo "$(VERSION)" > VERSION 979 echo "$(SUBVERS)" > SUBVERS 980 echo "$(VERDATE)" > VERDATE 981 982# just display the build options 983opts: 984 @echo -n 'Using: ' 985 @echo -n 'TARGET="$(strip $(TARGET))" ' 986 @echo -n 'ARCH="$(strip $(ARCH))" ' 987 @echo -n 'CPU="$(strip $(CPU))" ' 988 @echo -n 'CC="$(strip $(CC))" ' 989 @echo -n 'ARCH_FLAGS="$(strip $(ARCH_FLAGS))" ' 990 @echo -n 'CPU_CFLAGS="$(strip $(CPU_CFLAGS))" ' 991 @echo -n 'DEBUG_CFLAGS="$(strip $(DEBUG_CFLAGS))" ' 992 @echo "$(strip $(BUILD_OPTIONS))" 993 @echo 'COPTS="$(strip $(COPTS))"' 994 @echo 'LDFLAGS="$(strip $(LDFLAGS))"' 995 @echo 'LDOPTS="$(strip $(LDOPTS))"' 996 @echo 'OPTIONS_OBJS="$(strip $(OPTIONS_OBJS))"' 997 @echo 'OBJS="$(strip $(OBJS))"' 998 999ifeq (reg-tests, $(firstword $(MAKECMDGOALS))) 1000 REGTEST_ARGS := $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS)) 1001 $(eval $(REGTEST_ARGS):;@true) 1002endif 1003 1004# Target to run the regression testing script files. 1005reg-tests: 1006 $(Q)$(REG_TEST_SCRIPT) --type "$(REGTESTS_TYPES)" $(REGTEST_ARGS) $(REG_TEST_FILES) 1007.PHONY: $(REGTEST_ARGS) 1008 1009reg-tests-help: 1010 @echo 1011 @echo "To launch the reg tests for haproxy, first export to your environment " 1012 @echo "VTEST_PROGRAM variable to point to your vtest program:" 1013 @echo " $$ export VTEST_PROGRAM=/opt/local/bin/vtest" 1014 @echo "or" 1015 @echo " $$ setenv VTEST_PROGRAM /opt/local/bin/vtest" 1016 @echo 1017 @echo "The same thing may be done to set your haproxy program with HAPROXY_PROGRAM " 1018 @echo "but with ./haproxy as default value." 1019 @echo 1020 @echo "To run all the tests:" 1021 @echo " $$ make reg-tests" 1022 @echo 1023 @echo "You can also set the programs to be used on the command line:" 1024 @echo " $$ VTEST_PROGRAM=<...> HAPROXY_PROGRAM=<...> make reg-tests" 1025 @echo 1026 @echo "To run tests with specific types:" 1027 @echo " $$ REGTESTS_TYPES=slow,default make reg-tests" 1028 @echo 1029 @echo "with 'default,bug,devel,slow' as default value for REGTESTS_TYPES variable." 1030 @echo 1031 @echo "About the reg test types:" 1032 @echo " any : all the tests without distinction (this is the default" 1033 @echo " value of REGTESTS_TYPES." 1034 @echo " default : dedicated to pure haproxy compliance tests." 1035 @echo " slow : scripts which take non negligible time to run." 1036 @echo " bug : scripts in relation with bugs they help to reproduce." 1037 @echo " broken : scripts triggering known broken behaviors for which" 1038 @echo " there is still no fix." 1039 @echo " experimental: for scripts which are experimental, typically used to" 1040 @echo " develop new scripts." 1041 @echo 1042 @echo "Note that 'reg-tests' target run '"$(REG_TEST_SCRIPT)"' script" 1043 @echo "(see --help option of this script for more information)." 1044 1045.PHONY: reg-tests reg-tests-help 1046