echo off
rem
rem Copyright (C) 2001-2002,2004,2016  Internet Systems Consortium, Inc. ("ISC")
rem 
rem This Source Code Form is subject to the terms of the Mozilla Public
rem License, v. 2.0. If a copy of the MPL was not distributed with this
rem file, You can obtain one at http://mozilla.org/MPL/2.0/.

rem BuildAll.bat
rem This script sets up the files necessary ready to build BIND 9
rem and then builds all of the binaries that make up the installation kit.
rem This requires perl to be installed on the system.

rem IMPORTANT NOTE:
rem OpenSSL is a prerequisite for building and running this release of
rem BIND 9. You must fetch the OpenSSL sources yourself from
rem http://www.OpenSSL.org/ and compile it yourself.  The code must reside
rem at the same level as the bind 9.2.0 source tree and it's top-level
rem directory be named openssl-0.9.6k. This restriction will be lifted in
rem a future release of BIND 9 for Windows NT/2000/XP.

echo Setting up the BIND files required for the build

rem Setup the files
call BuildSetup.bat

echo Build all of the Library files

cd ..\..\lib

cd isc\win32
nmake /nologo -f libisc.mak CFG="libisc - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd dns\win32
nmake /nologo -f libdns.mak CFG="libdns - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd isccfg\win32
nmake /nologo -f libisccfg.mak CFG="libisccfg - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd isccc\win32
nmake /nologo -f libisccc.mak CFG="libisccc - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd bind9\win32
nmake /nologo -f libbind9.mak CFG="libbind9 - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd lwres\win32
nmake /nologo -f liblwres.mak CFG="liblwres - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd irs\win32
nmake /nologo -f libirs.mak CFG="libirs - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

@IF TESTS
cd tests\win32
nmake /nologo -f libtests.mak CFG="libtests - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..
@END TESTS

@IF SAMPLES
cd samples\win32
nmake /nologo -f resolve.mak CFG="resolve - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f async.mak CFG="async - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f gai.mak CFG="gai - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f update.mak CFG="update - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f request.mak CFG="request - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f nsprobe.mak CFG="nsprobe - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..
@END SAMPLES

rem This is the DLL required for the event Viewer

cd win32\bindevt
nmake /nologo -f bindevt.mak CFG="bindevt - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd ..

echo Now build the apps

cd bin

cd named\win32
nmake /nologo -f named.mak CFG="named - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"

cd ..\..

cd rndc\win32
nmake /nologo -f rndc.mak CFG="rndc - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"

cd ..\..

cd confgen\win32
nmake /nologo -f rndcconfgen.mak CFG="rndcconfgen - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f ddnsconfgen.mak CFG="ddnsconfgen - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"

cd ..\..

cd dig\win32
nmake /nologo -f dig.mak CFG="dig - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo /nologo -f host.mak CFG="host - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f nslookup.mak CFG="nslookup - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd delv\win32
nmake /nologo -f delv.mak CFG="delv - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd nsupdate\win32
nmake /nologo -f nsupdate.mak CFG="nsupdate - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd check\win32
nmake /nologo -f checkconf.mak CFG="checkconf - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f checkzone.mak CFG="checkzone - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd dnssec\win32
nmake /nologo -f keygen.mak CFG="keygen - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f signzone.mak CFG="signzone - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f dsfromkey.mak CFG="dsfromkey - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f keyfromlabel.mak CFG="keyfromlabel - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f revoke.mak CFG="revoke - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f settime.mak CFG="settime - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f verify.mak CFG="verify - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f importkey.mak CFG="importkey - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

@IF PKCS11
cd pkcs11\win32
nmake /nologo -f pk11keygen.mak CFG="pk11keygen - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f pk11list.mak CFG="pk11list - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f pk11destroy.mak CFG="pk11destroy - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f pk11tokens.mak CFG="pk11tokens - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..
@END PKCS11

cd tools\win32
nmake /nologo -f arpaname.mak CFG="arpaname - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f genrandom.mak CFG="genrandom - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f nsec3hash.mak CFG="nsec3hash - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f journalprint.mak CFG="journalprint - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f ischmacfixup.mak CFG="ischmacfixup - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f rrchecker.mak CFG="rrchecker - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f mdig.mak CFG="mdig - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

@IF TESTS
cd tests
@IF ATOMIC
cd atomic\win32
nmake /nologo -f t_atomic.mak CFG="t_atomic - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..
@END ATOMIC

cd db\win32
nmake /nologo -f t_db.mak CFG="t_db - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd dst\win32
nmake /nologo -f t_dst.mak CFG="t_dst - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd master\win32
nmake /nologo -f t_master.mak CFG="t_master - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd mem\win32
nmake /nologo -f t_mem.mak CFG="t_mem - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd hashes\win32
nmake /nologo -f t_hashes.mak CFG="t_hashes - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd names\win32
nmake /nologo -f t_names.mak CFG="t_names - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd rbt\win32
nmake /nologo -f t_rbt.mak CFG="t_rbt - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd resolver\win32
nmake /nologo -f t_resolver.mak CFG="t_resolver - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd sockaddr\win32
nmake /nologo -f t_sockaddr.mak CFG="t_sockaddr - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd tasks\win32
nmake /nologo -f t_tasks.mak CFG="t_tasks - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd timers\win32
nmake /nologo -f t_timers.mak CFG="t_timers - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd ..
@END TESTS

@IF XTESTS
cd tests\win32
nmake /nologo -f backtrace_test.mak CFG="backtrace_test - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f inter_test.mak CFG="inter_test - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f rwlock_test.mak CFG="rwlock_test - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f shutdown_test.mak CFG="shutdown_test - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f sock_test.mak CFG="sock_test - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f task_test.mak CFG="task_test - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f timer_test.mak CFG="timer_test - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..
@END XTESTS

@IF STESTS
cd tests\win32
nmake /nologo -f makejournal.mak CFG="makejournal - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\system\win32
nmake /nologo -f gencheck.mak CFG="gencheck - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f lwtest.mak CFG="lwtest - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f bigkey.mak CFG="bigkey - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f pipequeries.mak CFG="pipequeries - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f keycreate.mak CFG="keycreate - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f keydelete.mak CFG="keydelete - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
nmake /nologo -f feature-test.mak CFG="feature-test - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..\..
@END STESTS

rem This is the BIND 9 Installer

cd win32\BINDInstall
nmake /nologo -f BINDInstall.mak CFG="BINDInstall - @PLATFORM@ Release"  NO_EXTERNAL_DEPS="1"
cd ..\..

cd ..

cd win32utils\legacy

call BuildPost.bat

echo Done.

rem exit here.
