summaryrefslogtreecommitdiff
blob: 0337902092719c301e882dc59b855bedc2d75656 (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
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit flag-o-matic readme.gentoo-r1 toolchain-funcs

DESCRIPTION="Synchronize local workstation with time offered by remote webservers"
HOMEPAGE="https://github.com/angeloc/htpdate"
if [[ "${PV}" == *9999 ]] ; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/angeloc/htpdate.git"
else
	SRC_URI="https://github.com/angeloc/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~s390 ~x86 ~amd64-linux ~x86-linux"
fi
IUSE="+ssl"
LICENSE="GPL-2"
SLOT="0"

DEPEND="ssl? ( dev-libs/openssl:0= )"
RDEPEND="${DEPEND}"
BDEPEND="ssl? ( virtual/pkgconfig )"

DOC_CONTENTS="If you would like to run htpdate as a daemon, set
appropriate http servers in /etc/conf.d/htpdate!"

PATCHES=( "${FILESDIR}/${PN}-1.2.6-ldlibs.patch" )

src_prepare() {
	default

	# Use more standard adjtimex() to fix uClibc builds.
	sed -i 's:ntp_adjtime:adjtimex:g' htpdate.[8c] || die
	# Don't compress man pages by default
	sed '/gzip/d' -i Makefile || die
}

src_compile() {
	if use ssl ; then
		append-cflags -DENABLE_HTTPS
		export PKG_CONFIG="$(tc-getPKG_CONFIG)"
	fi

	emake CFLAGS="-Wall ${CFLAGS}" CC="$(tc-getCC)" \
		$(usex ssl 'ENABLE_HTTPS=1' '')
}

src_install() {
	emake DESTDIR="${D}" bindir='$(prefix)/sbin' install
	dodoc README.md Changelog

	newconfd "${FILESDIR}"/htpdate.conf htpdate
	newinitd "${FILESDIR}"/htpdate.init-r1 htpdate

	readme.gentoo_create_doc
}