net-proxy/haproxy: arm stable, bug #662900
[gentoo.git] / net-proxy / haproxy / haproxy-1.5.19-r2.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="5"
5
6 inherit user versionator toolchain-funcs flag-o-matic systemd
7
8 MY_P="${PN}-${PV/_beta/-dev}"
9
10 DESCRIPTION="A TCP/HTTP reverse proxy for high availability environments"
11 HOMEPAGE="http://haproxy.1wt.eu"
12 SRC_URI="http://haproxy.1wt.eu/download/$(get_version_component_range 1-2)/src/${MY_P}.tar.gz"
13
14 LICENSE="GPL-2 LGPL-2.1"
15 SLOT="0"
16 KEYWORDS="~amd64 ~arm ~ppc ~x86"
17 IUSE="+crypt examples libressl +pcre pcre-jit ssl tools vim-syntax +zlib"
18
19 DEPEND="
20         pcre? (
21                 dev-libs/libpcre
22                 pcre-jit? ( dev-libs/libpcre[jit] )
23         )
24         ssl? (
25                 !libressl? ( dev-libs/openssl:0=[zlib?] )
26                 libressl? ( dev-libs/libressl:0= )
27         )
28         zlib? ( sys-libs/zlib )"
29 RDEPEND="${DEPEND}"
30
31 S="${WORKDIR}/${MY_P}"
32
33 pkg_setup() {
34         enewgroup haproxy
35         enewuser haproxy -1 -1 -1 haproxy
36 }
37
38 src_compile() {
39         local args="TARGET=linux2628 USE_GETADDRINFO=1"
40
41         if use pcre ; then
42                 args="${args} USE_PCRE=1"
43                 if use pcre-jit; then
44                         args="${args} USE_PCRE_JIT=1"
45                 else
46                         args="${args} USE_PCRE_JIT="
47                 fi
48         else
49                 args="${args} USE_PCRE= USE_PCRE_JIT="
50         fi
51
52 #       if use kernel_linux; then
53 #               args="${args} USE_LINUX_SPLICE=1 USE_LINUX_TPROXY=1"
54 #       else
55 #               args="${args} USE_LINUX_SPLICE= USE_LINUX_TPROXY="
56 #       fi
57
58         if use crypt ; then
59                 args="${args} USE_LIBCRYPT=1"
60         else
61                 args="${args} USE_LIBCRYPT="
62         fi
63
64         if use ssl ; then
65                 args="${args} USE_OPENSSL=1"
66         else
67                 args="${args} USE_OPENSSL="
68         fi
69
70         if use zlib ; then
71                 args="${args} USE_ZLIB=1"
72         else
73                 args="${args} USE_ZLIB="
74         fi
75
76         # For now, until the strict-aliasing breakage will be fixed
77         append-cflags -fno-strict-aliasing
78
79         emake CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args}
80         emake -C contrib/systemd SBINDIR=/usr/sbin
81
82         if use tools ; then
83                 for contrib in halog iprange ; do
84                         emake -C contrib/${contrib} \
85                                 CFLAGS="${CFLAGS}" OPTIMIZE="${CFLAGS}" LDFLAGS="${LDFLAGS}" CC=$(tc-getCC) ${args}
86                 done
87         fi
88 }
89
90 src_install() {
91         dosbin haproxy
92         dosym /usr/sbin/haproxy /usr/bin/haproxy
93
94         newinitd "${FILESDIR}/haproxy.initd-r6" haproxy
95
96         # Don't install useless files
97 #       rm examples/build.cfg doc/*gpl.txt
98
99         dodoc CHANGELOG ROADMAP doc/{configuration,haproxy-en}.txt
100         doman doc/haproxy.1
101
102         dosbin haproxy-systemd-wrapper
103         dosym /usr/sbin/haproxy-systemd-wrapper /usr/bin/haproxy-systemd-wrapper
104         systemd_dounit contrib/systemd/haproxy.service
105
106         if use tools ; then
107                 for contrib in halog iprange ; do
108                         dobin contrib/${contrib}/${contrib}
109                 done
110         fi
111
112         if use examples ; then
113                 docinto examples
114                 dodoc examples/*.cfg
115         fi
116
117         if use vim-syntax ; then
118                 insinto /usr/share/vim/vimfiles/syntax
119                 doins examples/haproxy.vim
120         fi
121 }
122
123 pkg_postinst() {
124         if [[ ! -f "${ROOT}/etc/haproxy.cfg" ]] ; then
125                 ewarn "You need to create /etc/haproxy.cfg before you start the haproxy service."
126                 ewarn "It's best practice to not run haproxy as root, user and group haproxy was therefore created."
127                 ewarn "Make use of them with the \"user\" and \"group\" directives."
128
129                 if [[ -d "${ROOT}/usr/share/doc/${PF}" ]]; then
130                         einfo "Please consult the installed documentation for learning the configuration file's syntax."
131                         einfo "The documentation and sample configuration files are installed here:"
132                         einfo "   ${ROOT}usr/share/doc/${PF}"
133                 fi
134         fi
135 }