1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 [[ ${PV} == *9999 ]] && SCM="git-r3"
7 inherit user versionator toolchain-funcs flag-o-matic systemd linux-info $SCM
9 MY_P="${PN}-${PV/_beta/-dev}"
11 DESCRIPTION="A TCP/HTTP reverse proxy for high availability environments"
12 HOMEPAGE="http://www.haproxy.org"
13 if [[ ${PV} != *9999 ]]; then
14 SRC_URI="http://haproxy.1wt.eu/download/$(get_version_component_range 1-2)/src/${MY_P}.tar.gz"
15 KEYWORDS="~amd64 ~arm ~ppc ~x86"
17 EGIT_REPO_URI="http://git.haproxy.org/git/haproxy-$(get_version_component_range 1-2).git/"
21 LICENSE="GPL-2 LGPL-2.1"
23 IUSE="+crypt doc examples libressl slz net_ns +pcre pcre-jit pcre2 pcre2-jit ssl
24 systemd +threads tools vim-syntax +zlib lua device-atlas 51degrees wurfl"
25 REQUIRED_USE="pcre-jit? ( pcre )
28 device-atlas? ( pcre )
34 pcre-jit? ( dev-libs/libpcre[jit] )
38 pcre2-jit? ( dev-libs/libpcre2[jit] )
41 !libressl? ( dev-libs/openssl:0=[zlib?] )
42 libressl? ( dev-libs/libressl:0= )
44 slz? ( dev-libs/libslz:= )
45 zlib? ( sys-libs/zlib )
46 lua? ( dev-lang/lua:5.3 )
47 device-atlas? ( dev-libs/device-atlas-api-c )"
50 S="${WORKDIR}/${MY_P}"
52 DOCS=( CHANGELOG CONTRIBUTING MAINTAINERS README )
53 CONTRIBS=( halog iprange )
54 # ip6range is present in 1.6, but broken.
55 version_is_at_least 1.7.0 $PV && CONTRIBS+=( ip6range spoa_example tcploop )
56 # TODO: mod_defender - requires apache / APR, modsecurity - the same
57 version_is_at_least 1.8.0 $PV && CONTRIBS+=( hpack )
60 (( $# != 2 )) && die "${FUNCNAME} <USE flag> <make option>"
62 usex "${1}" "USE_${2}=1" "USE_${2}="
67 enewuser haproxy -1 -1 -1 haproxy
70 CONFIG_CHECK="~NET_NS"
83 args+=( $(haproxy_use threads THREAD) )
84 args+=( $(haproxy_use crypt LIBCRYPT) )
85 args+=( $(haproxy_use net_ns NS) )
86 args+=( $(haproxy_use pcre PCRE) )
87 args+=( $(haproxy_use pcre-jit PCRE_JIT) )
88 args+=( $(haproxy_use ssl OPENSSL) )
89 args+=( $(haproxy_use slz SLZ) )
90 args+=( $(haproxy_use zlib ZLIB) )
91 args+=( $(haproxy_use lua LUA) )
92 args+=( $(haproxy_use 51degrees 51DEGREES) )
93 args+=( $(haproxy_use device-atlas DEVICEATLAS) )
94 args+=( $(haproxy_use wurfl WURFL) )
95 args+=( $(haproxy_use systemd SYSTEMD) )
97 # For now, until the strict-aliasing breakage will be fixed
98 append-cflags -fno-strict-aliasing
100 emake CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args[@]}
101 emake -C contrib/systemd SBINDIR=/usr/sbin
104 for contrib in ${CONTRIBS[@]} ; do
105 emake -C contrib/${contrib} \
106 CFLAGS="${CFLAGS}" OPTIMIZE="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args[@]}
113 dosym ../sbin/haproxy /usr/bin/haproxy
115 newconfd "${FILESDIR}/${PN}.confd" $PN
116 newinitd "${FILESDIR}/${PN}.initd-r6" $PN
120 systemd_dounit contrib/systemd/haproxy.service
124 # The errorfiles are used by upstream defaults.
125 insinto /etc/haproxy/errors/
126 doins examples/errorfiles/*
129 dodoc ROADMAP doc/*.txt
136 has halog "${CONTRIBS[@]}" && dobin contrib/halog/halog
137 has "iprange" "${CONTRIBS[@]}" && newbin contrib/iprange/iprange haproxy_iprange
138 has "ip6range" "${CONTRIBS[@]}" && newbin contrib/ip6range/ip6range haproxy_ip6range
139 has "spoa_example" "${CONTRIBS[@]}" && newbin contrib/spoa_example/spoa haproxy_spoa_example
140 has "spoa_example" "${CONTRIBS[@]}" && newdoc contrib/spoa_example/README README.spoa_example
141 has "tcploop" "${CONTRIBS[@]}" && newbin contrib/tcploop/tcploop haproxy_tcploop
142 has "hpack" "${CONTRIBS[@]}" && newbin contrib/hpack/gen-rht haproxy_hpack
145 if use examples ; then
148 dodoc examples/seamless_reload.txt
151 if use vim-syntax ; then
152 insinto /usr/share/vim/vimfiles/syntax
153 doins examples/haproxy.vim
158 if [[ ! -f "${EROOT}/etc/haproxy/haproxy.cfg" ]] ; then
159 ewarn "You need to create /etc/haproxy/haproxy.cfg before you start the haproxy service."
160 ewarn "It's best practice to not run haproxy as root, user and group haproxy was therefore created."
161 ewarn "Make use of them with the \"user\" and \"group\" directives."
163 if [[ -d "${EROOT}/usr/share/doc/${PF}" ]]; then
164 einfo "Please consult the installed documentation for learning the configuration file's syntax."
165 einfo "The documentation and sample configuration files are installed here:"
166 einfo " ${EROOT}usr/share/doc/${PF}"