1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 [[ ${PV} == *9999 ]] && SCM="git-r3"
7 inherit 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/$(ver_cut 1-2)/src/${MY_P}.tar.gz"
15 KEYWORDS="~amd64 ~arm ~ppc ~x86"
17 EGIT_REPO_URI="http://git.haproxy.org/git/haproxy-$(ver_cut 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 )"
52 S="${WORKDIR}/${MY_P}"
54 DOCS=( CHANGELOG CONTRIBUTING MAINTAINERS README )
55 CONTRIBS=( halog iprange )
56 # ip6range is present in 1.6, but broken.
57 ver_test $PV -ge 1.7.0 && CONTRIBS+=( ip6range spoa_example tcploop )
58 # TODO: mod_defender - requires apache / APR, modsecurity - the same
59 ver_test $PV -ge 1.8.0 && CONTRIBS+=( hpack )
62 (( $# != 2 )) && die "${FUNCNAME} <USE flag> <make option>"
64 usex "${1}" "USE_${2}=1" "USE_${2}="
69 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 pcre2 PCRE2) )
89 args+=( $(haproxy_use pcre2-jit PCRE2_JIT) )
90 args+=( $(haproxy_use ssl OPENSSL) )
91 args+=( $(haproxy_use slz SLZ) )
92 args+=( $(haproxy_use zlib ZLIB) )
93 args+=( $(haproxy_use lua LUA) )
94 args+=( $(haproxy_use 51degrees 51DEGREES) )
95 args+=( $(haproxy_use device-atlas DEVICEATLAS) )
96 args+=( $(haproxy_use wurfl WURFL) )
97 args+=( $(haproxy_use systemd SYSTEMD) )
99 # For now, until the strict-aliasing breakage will be fixed
100 append-cflags -fno-strict-aliasing
102 emake CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args[@]}
103 emake -C contrib/systemd SBINDIR=/usr/sbin
106 for contrib in ${CONTRIBS[@]} ; do
107 # Those two includes are a workaround for hpack Makefile missing those
108 emake -C contrib/${contrib} \
109 CFLAGS="${CFLAGS} -I../../include/ -I../../ebtree/" OPTIMIZE="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args[@]}
116 dosym ../sbin/haproxy /usr/bin/haproxy
118 newconfd "${FILESDIR}/${PN}.confd" $PN
119 newinitd "${FILESDIR}/${PN}.initd-r6" $PN
123 systemd_dounit contrib/systemd/haproxy.service
127 # The errorfiles are used by upstream defaults.
128 insinto /etc/haproxy/errors/
129 doins examples/errorfiles/*
132 dodoc ROADMAP doc/*.txt
139 has halog "${CONTRIBS[@]}" && dobin contrib/halog/halog
140 has "iprange" "${CONTRIBS[@]}" && newbin contrib/iprange/iprange haproxy_iprange
141 has "ip6range" "${CONTRIBS[@]}" && newbin contrib/ip6range/ip6range haproxy_ip6range
142 has "spoa_example" "${CONTRIBS[@]}" && newbin contrib/spoa_example/spoa haproxy_spoa_example
143 has "spoa_example" "${CONTRIBS[@]}" && newdoc contrib/spoa_example/README README.spoa_example
144 has "tcploop" "${CONTRIBS[@]}" && newbin contrib/tcploop/tcploop haproxy_tcploop
145 has "hpack" "${CONTRIBS[@]}" && newbin contrib/hpack/gen-rht haproxy_hpack
148 if use examples ; then
151 dodoc examples/seamless_reload.txt
154 if use vim-syntax ; then
155 insinto /usr/share/vim/vimfiles/syntax
156 doins examples/haproxy.vim
161 if [[ ! -f "${EROOT}/etc/haproxy/haproxy.cfg" ]] ; then
162 ewarn "You need to create /etc/haproxy/haproxy.cfg before you start the haproxy service."
163 ewarn "It's best practice to not run haproxy as root, user and group haproxy was therefore created."
164 ewarn "Make use of them with the \"user\" and \"group\" directives."
166 if [[ -d "${EROOT}/usr/share/doc/${PF}" ]]; then
167 einfo "Please consult the installed documentation for learning the configuration file's syntax."
168 einfo "The documentation and sample configuration files are installed here:"
169 einfo " ${EROOT}/usr/share/doc/${PF}"