blob: bf6245071c99ab433aa8154fa98eddb364cf5013 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# Copyright 2019-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit flag-o-matic multilib multiprocessing toolchain-funcs
DESCRIPTION="Minimal CGI library for web applications"
HOMEPAGE="https://kristaps.bsd.lv/kcgi/"
if [[ ${PV} == 9999 ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/kristapsdz/${PN}"
else
SRC_URI="https://kristaps.bsd.lv/${PN}/snapshots/${P}.tgz"
KEYWORDS="~amd64 ~x86"
fi
LICENSE="ISC"
SLOT="0"
IUSE="static-libs test"
RESTRICT="!test? ( test )"
BDEPEND="dev-build/bmake"
RDEPEND="
app-crypt/libmd
virtual/libcrypt
"
DEPEND="${RDEPEND}
test? ( net-misc/curl[static-libs(-)] )
"
PATCHES=( "${FILESDIR}"/${PN}-$(ver_cut 1-2)-ldflags.patch )
_get_version_component_count() {
local cnt=( $(ver_rs 1- ' ') )
echo ${#cnt[@]} || die
}
static_to_shared() {
local libstatic=${1}
shift
local libname=$(basename ${libstatic%.a})
local soname=${libname}$(get_libname $(ver_cut 1-2))
local libdir=$(dirname ${libstatic})
einfo "Making ${soname} from ${libstatic}"
if [[ ${CHOST} == *-darwin* ]] ; then
${LINK:-$(tc-getCC)} ${LDFLAGS} \
-dynamiclib -install_name "${EPREFIX}"/usr/lib/"${soname}" \
-Wl,-all_load -Wl,${libstatic} \
"$@" -o ${libdir}/${soname} || die "${soname} failed"
else
${LINK:-$(tc-getCC)} ${LDFLAGS} \
-shared -Wl,-soname=${soname} \
-Wl,--whole-archive ${libstatic} -Wl,--no-whole-archive \
"$@" -o ${libdir}/${soname} || die "${soname} failed"
if [[ $(_get_version_component_count) -ge 1 ]] ; then
ln -s ${soname} ${libdir}/${libname}$(get_libname $(ver_cut 1)) || die
fi
ln -s ${soname} ${libdir}/${libname}$(get_libname) || die
fi
}
src_prepare() {
default
# disable failing tests
sed -e '/\s*regress\/test-debug-.*/d' -i Makefile || die
# ld: multiple definition of `dummy'
local deselect=( sandbox-{capsicum,darwin,pledge,seccomp-filter}.o )
case ${CHOST} in
*-linux-*)
deselect=( "${deselect[@]/sandbox-seccomp-filter.o}" )
;;
*-darwin*)
deselect=( "${deselect[@]/sandbox-darwin.o}" )
;;
*-freebsd*)
deselect=( "${deselect[@]/sandbox-capsicum.o}" )
;;
*-openbsd*)
deselect=( "${deselect[@]/sandbox-pledge.o}" )
;;
esac
for obj in "${deselect[@]}"; do
# elements are not deleted completely from the array
if [[ -n "${obj}" ]]; then
sed "/${obj}/d" -i Makefile || die
fi
done
}
src_configure() {
tc-export CC AR
append-cflags -fPIC
# note: not an autoconf configure script
conf_args=(
CPPFLAGS="${CPPFLAGS}"
LDFLAGS="${LDFLAGS}"
PREFIX="${EPREFIX}"/usr
MANDIR="${EPREFIX}"/usr/share/man
LIBDIR="${EPREFIX}"/usr/$(get_libdir)
SBINDIR="${EPREFIX}"/usr/sbin
)
./configure "${conf_args[@]}" || die
}
src_compile() {
bmake -j$(makeopts_jobs) || die
static_to_shared libkcgi.a -lz -lmd
static_to_shared libkcgihtml.a
static_to_shared libkcgijson.a -lm
static_to_shared libkcgiregress.a
static_to_shared libkcgixml.a
}
src_test() {
# TODO: add `afl` tests
bmake -j$(makeopts_jobs) regress || die
}
src_install() {
bmake -j$(makeopts_jobs) \
DESTDIR="${D}" \
DATADIR="/usr/share/doc/${PF}/examples" \
install || die
dolib.so lib*$(get_libname)*
if ! use static-libs; then
find "${ED}" -name '*.a' -delete || die
fi
einstalldocs
}
|