ISC BIND 9.9.x - How to compile it for Linux, Solaris and Windows

Download BIND 9.9.x
http://www.isc.org/downloads/
Can try to search on their FTP ftp://ftp.isc.org/isc/

Mirrors:
http://ftp.riken.jp/net/bind
http://www.mirrorservice.org/sites/ftp.isc.org/isc/bind9

Linux and Solaris 64 bit
Copy and extract the compressed file bind-9.9.6-P1.tar.gz

cd /opt/mydns/bind99
tar -xvf bind-9.9.6-P1.tar.gz
cd bind-9.9.6-P1
mkdir linux
mkdir linux/bind996p1
# mkdir solaris

But first, we have to compile 3rd party libraries: OpenSSL, Libxml2, Kerberos
All of them have to be Static and 64 bit
Put them at /opt/buildtools
- http://tuan.nguoianphu.com/OpenSSL_compile_for_Linux_Solaris_Windows
- http://tuan.nguoianphu.com/LibXML2_compile_for_Linux_Solaris_Windows
- http://tuan.nguoianphu.com/Kerberos_compile_for_Linux_Solaris_Windows


Create a new configure file config_bind.sh to compile BIND.
Put it in /opt/mydns/bind99/bind-9.9.6-P1

#!/bin/sh

#####################################################################
# A configured script to compile ISC BIND in Solaris and Linux in 64 bit
# Use 3rd party libraries: OpenSSL, Libxml2, Kerberos
# vohungtuan@gmail.com Dec-16-2014
#####################################################################

rm="/bin/rm -f"
$rm ./lib/bind/config.log
$rm ./lib/bind/config.status
$rm ./config.log
$rm ./config.status

if [ ."$PLATFORM" = . ]; then
    echo "Set PLATFORM env variable first. exiting"
    exit
fi

if [ "$PLATFORM" = "linux" -o $PLATFORM = "linux-gcc3" -o $PLATFORM = "linux-gcc4" ]; then
    # Use this if development
#    CFLAGS="-g -m64"; export CFLAGS
    # production build
    CFLAGS="-O2 -m64"; export CFLAGS
fi

if [ "$PLATFORM" = "solaris-2.x" ]; then
    # needs at least studio12 CC v 5.9
    CFLAGS="-xO3 -m64"; export CFLAGS
	 # Development
#    CFLAGS="-g -m64"; export CFLAGS
#    CFLAGS="-g"; export CFLAGS
fi

if [ "$PLATFORM" = "solaris-x86" ]; then
#    CFLAGS="-g -m64"; export CFLAGS
    CFLAGS="-xO3 -m64"; export CFLAGS
fi

STD_CDEFINES="-DUNIX -DEDUP -DGSSRH_MINI -DUPDSEC -DPUSH -DNTFYAL";
export STD_CDEFINES

# 64 bit versions of 3rd party libraries: OpenSSL, Libxml2, Kerberos
krb_dir=/opt/buildtools/kerberos/kerberos_64bit
openssl_dir=/opt/buildtools/openssl/openssl_64bit
libxml2_dir=/opt/buildtools/libxml2/linux-gcc3

sh ../configure --prefix=/opt/mydns/bind99/bind-9.9.6-P1/linux/bind996p1 \
               --enable-largefile \
               --enable-fixed-rrset \
               --enable-filter-aaaa \
               --enable-threads \
               --with-openssl=$openssl_dir \
               --with-gssapi=$krb_dir \
               --with-libxml2=$libxml2_dir \
	       --enable-rrl

Have new option Response Rate time Limitting

Edit these lines to match your machine's configuration

# 64 bit versions of 3rd party libraries: OpenSSL, Libxml2, Kerberos
krb_dir=/opt/buildtools/kerberos/kerberos_64bit
openssl_dir=/opt/buildtools/openssl/openssl_64bit
libxml2_dir=/opt/buildtools/libxml2/linux-gcc3
.....
--prefix=/opt/mydns/bind99/bind-9.9.6-P1/linux/bind996p1

Compile the BIND source

export PLATFORM=linux-gc33
cd /opt/mydns/bind99/bind-9.9.6-P1
chmod +x config_bind.sh
cd linux
../config_bind.sh
make
make install
cd bind996p1/sbin
./named -v
./named -V


Windows 64 bit

Build BIND with VS 2010, for VS 2013, see my page of BIND 9.10.x.

Copy and extract the compressed file bind-9.9.6-P1.tar.gz to C:\bind

We have to compile 3rd party libraries: OpenSSL, Libxml2, Kerberos
Built them as static and 64 bit for Windows.
Put them at C:\buildtools
- http://tuan.nguoianphu.com/OpenSSL_compile_for_Linux_Solaris_Windows
- http://tuan.nguoianphu.com/LibXML2_compile_for_Linux_Solaris_Windows
- http://tuan.nguoianphu.com/Kerberos_compile_for_Linux_Solaris_Windows

However, there are some errors when compile the ISC BIND. The root cause comes from BIND configured file (OMG!).
So we must do these steps for the 3rd party libraries:

Openssl
COPY
C:\buildtools\openssl\openssl-1.0.1j\win64\include
TO
C:\buildtools\openssl\openssl-1.0.1j\win64\inc32

COPY the FILES inside
C:\buildtools\openssl\openssl-1.0.1j\win64\bin
AND the FILES inside
C:\buildtools\openssl\openssl-1.0.1j\win64\lib
TO
C:\buildtools\openssl\openssl-1.0.1j\win64\out32dll
(WTF! 64 bit but looking for 32 bit =)) )

Kerberos
COPY the FILES inside
C:\buildtools\kerberos\krb5-1.13\win64\lib
TO
C:\buildtools\kerberos\krb5-1.13\win64\lib\amd64

Libxml2
COPY the FILES inside
C:\buildtools\libxml2\libxml2-2.9.2\win64\lib
AND the FILES inside
C:\buildtools\libxml2\libxml2-2.9.2\win64\bin
TO
C:\buildtools\libxml2\libxml2-2.9.2\win64\win32\bin.msvc
(OMG! 64 bit but looking for 32 bit =)) )


Run configuration for source code

Go to C:\bindbind-9.9.6-P1\win32utils

There is a error in the Configure file, we have to hack it :(
Open the Configure and replace this line:

if (!grep { -f and -x } $vcredist_path) {

TO

if (grep { -f and -x } $vcredist_path) {

BIND 9.9.6-P1: Line 1923

Skip these steps if you done when compiling Kerberos.
We have to install Perl (Active Perl) and Python (Active Python).
And the gawk tool.
Extract it to C:\gawk
Install Cygwin to get or find these files:
grep.exe
mv.exe
rm.exe
cat.exe
sed.exe
Copy them to C:\gawk\bin

Open cmd and

cd C:\bindbind-9.9.6-P1\win32utils

call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64

SET PATH=%PATH%;C:\gawk\bin

perl Configure x64 with-openssl=C:\buildtools\openssl\openssl-1.0.1j\win64 with-libxml2=C:\buildtools\libxml2\libxml2-2.9.2\win64 with-gssapi=C:\buildtools\kerberos\krb5-1.13\win64 with-vcredist="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC"

OK, let's compile it!

msbuild /t:Build /p:Configuration=Release

Loading