1255577Sdes#!/bin/sh
2255779Sdes#
3255779Sdes# $FreeBSD: stable/11/contrib/unbound/freebsd-configure.sh 356345 2020-01-04 01:09:33Z cy $
4255779Sdes#
5255577Sdes
6255577Sdesset -e
7255577Sdes
8255577Sdeserror() {
9255577Sdes	echo "$@" >&2
10255577Sdes	exit 1
11255577Sdes}
12255577Sdes
13255577Sdesunbound=$(dirname $(realpath $0))
14255577Sdescd $unbound
15255577Sdes
16356345Scy# Run autotools before we drop LOCALBASE out of PATH
17356345Scy(cd $unbound && libtoolize --copy && autoheader && autoconf)
18356345Scy
19356345Scy# Ensure we use the correct toolchain and clean our environment
20356345Scyexport CC=$(echo ".include <bsd.lib.mk>" | make -f /dev/stdin -VCC)
21356345Scyexport CPP=$(echo ".include <bsd.lib.mk>" | make -f /dev/stdin -VCPP)
22356345Scyunset CFLAGS CPPFLAGS LDFLAGS LD_LIBRARY_PATH LIBS
23356345Scyexport PATH=/bin:/sbin:/usr/bin:/usr/sbin
24356345Scy
25255577Sdesldnssrc=$(realpath $unbound/../ldns)
26255577Sdes[ -f $ldnssrc/ldns/ldns.h ] || error "can't find LDNS sources"
27255577Sdesexport CFLAGS="-I$ldnssrc"
28255577Sdes
29255577Sdesldnsbld=$(realpath $unbound/../../lib/libldns)
30255577Sdes[ -f $ldnsbld/Makefile ] || error "can't find LDNS build directory"
31255577Sdes
32255577Sdesldnsobj=$(realpath $(make -C$ldnsbld -V.OBJDIR))
33287917Sdes[ -f $ldnsobj/libprivateldns.a ] || error "can't find LDNS object directory"
34255577Sdesexport LDFLAGS="-L$ldnsobj"
35255577Sdes
36356345Scycd $unbound
37255577Sdes./configure \
38255594Sdes	--prefix= --exec-prefix=/usr \
39255839Sdes	--with-conf-file=/var/unbound/unbound.conf \
40255577Sdes	--with-run-dir=/var/unbound \
41255577Sdes	--with-username=unbound
42