1#!/bin/sh 2# 3# $FreeBSD$ 4# 5 6set -e 7 8error() { 9 echo "$@" >&2 10 exit 1 11} 12 13unbound=$(dirname $(realpath $0)) 14cd $unbound 15 16# Run autotools before we drop LOCALBASE out of PATH 17(cd $unbound && libtoolize --copy && autoheader && autoconf) 18 19# Ensure we use the correct toolchain and clean our environment 20export CC=$(echo ".include <bsd.lib.mk>" | make -f /dev/stdin -VCC) 21export CPP=$(echo ".include <bsd.lib.mk>" | make -f /dev/stdin -VCPP) 22unset CFLAGS CPPFLAGS LDFLAGS LD_LIBRARY_PATH LIBS 23export PATH=/bin:/sbin:/usr/bin:/usr/sbin 24 25ldnssrc=$(realpath $unbound/../ldns) 26[ -f $ldnssrc/ldns/ldns.h ] || error "can't find LDNS sources" 27export CFLAGS="-I$ldnssrc" 28 29ldnsbld=$(realpath $unbound/../../lib/libldns) 30[ -f $ldnsbld/Makefile ] || error "can't find LDNS build directory" 31 32ldnsobj=$(realpath $(make -C$ldnsbld -V.OBJDIR)) 33[ -f $ldnsobj/libprivateldns.a ] || error "can't find LDNS object directory" 34export LDFLAGS="-L$ldnsobj" 35 36cd $unbound 37./configure \ 38 --prefix= --exec-prefix=/usr \ 39 --with-conf-file=/var/unbound/unbound.conf \ 40 --with-run-dir=/var/unbound \ 41 --with-username=unbound 42mv config.h ../../lib/libunbound 43