PortSystem 1.0

name		ntp
version		4.2.8p18
categories	sysutils net
maintainers	{geeklair.net:dluke @danielluke}
description	NTP is a protocol designed to synchronize the clocks of computers over a network.
#license	NTP (http://www.eecis.udel.edu/~mills/ntp/html/copyright.html), see http://opensource.org/licenses/NTP
license		Permissive
PortGroup	legacysupport 1.0

long_description	NTP is an implementation of RFC-5905. It is widely \
			used to synchronize a computer to Internet time \
			servers or other sources.
homepage	http://www.ntp.org/
master_sites	https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-[join [lrange [split ${version} .] 0 1] .]/

checksums	md5	516bdabd94ab7c824e9771390761a46c \
		rmd160	bab88bc0699fca0d165e8ac4ca5374104a8782ca \
		sha256	cf84c5f3fb1a295284942624d823fffa634144e096cfc4f9969ac98ef5f468e5 \
		size	7210799

platforms	darwin

configure.args  --with-ntpsnmpd=no \
                --enable-ipv6 \
                --enable-SHM \
                --enable-GPSD \
                --enable-NMEA \
                --enable-ATOM \
                ac_cv_search_nlist=no

depends_lib	path:lib/libssl.dylib:openssl port:libevent port:libedit
depends_build	port:pkgconfig

startupitem.create	yes
startupitem.netchange	yes
startupitem.executable	${prefix}/sbin/ntpd -n -g -p ${prefix}/var/run/ntpd.pid -f ${prefix}/var/db/ntp.drift -c ${prefix}/etc/ntp.conf

# High Sierra doesn't like the way libntp.a is set up
# see https://lists.macports.org/pipermail/macports-dev/2017-October/036569.html
platform darwin 17 {
	post-configure {
		reinplace "s|^RANLIB = ranlib|RANLIB = ranlib -c|" \
			$worksrcpath/libntp/Makefile
	}
}

platform darwin 18 {
	post-configure {
		reinplace "s|^RANLIB = ranlib|RANLIB = ranlib -c|" \
			$worksrcpath/libntp/Makefile
	}
}

platform darwin 19 {
        post-configure {
                reinplace "s|^RANLIB = ranlib|RANLIB = ranlib -c|" \
                        $worksrcpath/libntp/Makefile
        }
}

platform darwin 20 {
	post-configure {
		reinplace "s|^RANLIB = ranlib|RANLIB = ranlib -c|" \
			$worksrcpath/libntp/Makefile
	}
}

platform darwin 21 {
        post-configure {
                reinplace "s|^RANLIB = ranlib|RANLIB = ranlib -c|" \
                        $worksrcpath/libntp/Makefile
        }
}

platform darwin 22 {
        post-configure {
                reinplace "s|^RANLIB = ranlib|RANLIB = ranlib -c|" \
                        $worksrcpath/libntp/Makefile
        }
}

post-destroot	{
			xinstall -o root -m 644 ${filespath}/ntp.conf \
				${destroot}${prefix}/etc/ntp.conf.dist

			xinstall -m 755 -d ${destroot}${prefix}/var/run \
				${destroot}${prefix}/var/db

			destroot.keepdirs ${destroot}${prefix}/var/run \
				${destroot}${prefix}/var/db
		}

#- our conf file contains restrictions to mitigate CVE-2013-5211
post-activate	{
			if {![file exists ${prefix}/etc/ntp.conf]} {
				file copy ${prefix}/etc/ntp.conf.dist ${prefix}/etc/ntp.conf
			}
		}

livecheck.type regex
livecheck.url http://support.ntp.org/rss/releases.xml
livecheck.regex (\\d+\.\\d+.\\d+p\\d+)\.\*Stable
