From 487e6abc16c1b2958d371b0d4e808953646b520a Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Tue, 4 Jan 2000 20:31:10 +0000 Subject: [PATCH] basic windows-nt support --- config.h.win32 | 80 ++++++++ config.status.win32 | 432 ++++++++++++++++++++++++++++++++++++++++++ doc/design/windows-nt | 128 +++++++++++++ util/nt-kit | 171 +++++++++++++++++ 4 files changed, 811 insertions(+) create mode 100644 config.h.win32 create mode 100755 config.status.win32 create mode 100644 doc/design/windows-nt create mode 100644 util/nt-kit diff --git a/config.h.win32 b/config.h.win32 new file mode 100644 index 0000000000..10dc302c46 --- /dev/null +++ b/config.h.win32 @@ -0,0 +1,80 @@ +/* config.h. Generated automatically by configure. */ +/* config.h.in. Generated automatically from configure.in by autoheader. */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define as __inline if that's what the C compiler calls it. */ +#define inline __inline + +/* Define to `unsigned' if doesn't define. */ +/* #undef size_t */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* define on DEC OSF to enable 4.4BSD style sa_len support */ +/* #undef _SOCKADDR_LEN */ + +/* define if your system needs pthread_init() before using pthreads */ +/* #undef NEED_PTHREAD_INIT */ + +/* define if your system has sigwait() */ +/* #undef HAVE_SIGWAIT */ + +/* define on Solaris to get sigwait() to work using pthreads semantics */ +/* #undef _POSIX_PTHREAD_SEMANTICS */ + +/* define if LinuxThreads is in use */ +/* #undef HAVE_LINUXTHREADS */ + +/* define if catgets() is available */ +/* #undef HAVE_CATGETS */ + +/* define if you have the NET_RT_IFLIST sysctl variable. */ +#define HAVE_IFLIST_SYSCTL 1 + +/* define if you need to #define _XPG4_2 before including sys/socket.h */ +/* #undef NEED_XPG4_2_BEFORE_SOCKET_H */ + +/* define if you need to #define _XOPEN_SOURCE_ENTENDED before including + * sys/socket.h + */ +/* #undef NEED_XSE_BEFORE_SOCKET_H */ + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_SOCKIO_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the c_r library (-lc_r). */ +/* #undef HAVE_LIBC_R */ + +/* Define if you have the nsl library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define if you have the pthread library (-lpthread). */ +/* #undef HAVE_LIBPTHREAD */ + +/* Define if you have the socket library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ + +/* + * WIN32 specials until some other way of dealing with these is decided. + */ +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define EAFNOSUPPORT EINVAL +/* for the config file */ +typedef unsigned int uid_t; /* user id */ +typedef unsigned int gid_t; /* group id */ diff --git a/config.status.win32 b/config.status.win32 new file mode 100755 index 0000000000..0f938641f8 --- /dev/null +++ b/config.status.win32 @@ -0,0 +1,432 @@ +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host gro.dd.org: +# +# ./configure +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage=\ +"Usage: ./config.status [--recheck] [--version] [--help] destdir" +for ac_option +do + case "$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion" + exec ${CONFIG_SHELL-/bin/sh} ./configure --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "./config.status generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "$ac_cs_usage"; exit 0 ;; + -*) echo "$ac_cs_usage"; exit 1 ;; + esac +done + +case $# in +0) + dstdir=g:/work/bind9-nt + ;; +1) + dstdir=$1 + ;; +*) + echo "$ac_cs_usage"; exit 1 ;; +esac + +# Convert / to \ +dstdir="`echo $dstdir | sed 's:/:\\\\\\\:g'`" + +ac_given_srcdir=. +ac_given_INSTALL="/usr/bin/install -c" + +trap 'rm -fr make/rules + make/includes + Makefile + make/Makefile + make/mkdep + lib/Makefile + lib/isc/Makefile + lib/isc/include/Makefile + lib/isc/include/isc/Makefile + lib/isc/include/isc/platform.h + lib/isc/unix/Makefile + lib/isc/unix/include/Makefile + lib/isc/unix/include/isc/Makefile + lib/isc/nls/Makefile + lib/isc/pthreads/Makefile + lib/isc/pthreads/include/Makefile + lib/isc/pthreads/include/isc/Makefile + lib/dns/Makefile + lib/dns/include/Makefile + lib/dns/include/dns/Makefile + lib/dns/sec/Makefile + lib/dns/sec/openssl/Makefile + lib/dns/sec/openssl/include/Makefile + lib/dns/sec/openssl/include/openssl/Makefile + lib/dns/sec/dnssafe/Makefile + lib/dns/sec/dst/Makefile + lib/dns/sec/dst/include/Makefile + lib/dns/sec/dst/include/dst/Makefile + lib/dns/config/Makefile + lib/omapi/Makefile + lib/omapi/include/Makefile + lib/omapi/include/omapi/Makefile + lib/tests/Makefile + lib/tests/include/Makefile + lib/tests/include/tests/Makefile + bin/Makefile + bin/named/Makefile + bin/named/unix/Makefile + bin/tests/Makefile + bin/tests/names/Makefile + bin/tests/master/Makefile + bin/tests/rbt/Makefile + bin/tests/db/Makefile + bin/tests/tasks/Makefile + bin/tests/timers/Makefile + bin/tests/dst/Makefile + bin/tests/mem/Makefile + config.h conftest*; exit 1' 1 2 15 + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\&%]/\\&/g; + s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF +/^[ ]*VPATH[ ]*=[^:]*$/d + +s%@SHELL@%%g +s%@CFLAGS@%/nologo /MTd /D WIN32 /GZ%g +s%@CPPFLAGS@%%g +s%@CXXFLAGS@%%g +s%@FFLAGS@%%g +s%@DEFS@%-DHAVE_CONFIG_H%g +s%@LDFLAGS@%%g +s%@LIBS@%ws2_32.lib gdi32.lib%g +s%@exec_prefix@%$(prefix)%g +s%@prefix@%/usr/local%g +s%@program_transform_name@%s,x,x,%g +s%@bindir@%$(exec_prefix)/bin%g +s%@sbindir@%$(exec_prefix)/sbin%g +s%@libexecdir@%$(exec_prefix)/libexec%g +s%@datadir@%$(prefix)/share%g +s%@sysconfdir@%$(prefix)/etc%g +s%@sharedstatedir@%$(prefix)/com%g +s%@localstatedir@%$(prefix)/var%g +s%@libdir@%$(exec_prefix)/lib%g +s%@includedir@%$(prefix)/include%g +s%@oldincludedir@%/usr/include%g +s%@infodir@%$(prefix)/info%g +s%@mandir@%$(prefix)/man%g +s%@host@%i386-pc-bsdi4.0.1%g +s%@host_alias@%i386-pc-bsdi4.0.1%g +s%@host_cpu@%i386%g +s%@host_vendor@%pc%g +s%@host_os@%bsdi4.0.1%g +s%@SET_MAKE@%%g +s%@RANLIB@%echo%g +s%@INSTALL_PROGRAM@%$(INSTALL)%g +s%@INSTALL_SCRIPT@%$(INSTALL_PROGRAM)%g +s%@INSTALL_DATA@%$(INSTALL) -m 644%g +s%@STD_CINCLUDES@%%g +s%@STD_CDEFINES@%%g +s%@STD_CWARNINGS@% /W3%g +s%@AR@%link%g +s%@ARFLAGS@%/lib /nologo%g +s%@CC@%cl%g +s%@YACC@%yacc%g +s%@CPP@%cl /E%g +s%@MKDEPCC@%gcc%g +s%@MKDEPCFLAGS@%-M%g +s%@MKDEPPROG@%%g +s%@ISC_PLATFORM_HAVESALEN@%#undef ISC_NET_HAVESALEN%g +s%@ISC_PLATFORM_MSGHDRFLAVOR@% XXX IRRELEVANT? XXX %g +s%@ISC_PLATFORM_NEEDPORTT@%#define ISC_NET_NEEDPORTT 1%g +s%@build@%NONE%g +s%@build_alias@%%g +s%@build_cpu@%%g +s%@build_vendor@%%g +s%@build_os@%%g +s%@LD@%%g +s%@NM@%%g +s%@LN_S@%%g +s%@LIBTOOL@%%g +s%@O@%obj%g +s%@A@%lib%g +s%@ISC_NET_HAVEIPV6@%#undef ISC_NET_HAVEIPV6%g +s%@ISC_IPV6_H@%%g +s%@ISC_IPV6_O@%%g +s%@ISC_ISCIPV6_O@%%g +s%@ISC_IPV6_C@%%g +s%@ISC_PLATFORM_NEEDNTOP@%#define ISC_PLATFORM_NEEDNTOP 1%g +s%@ISC_PLATFORM_NEEDPTON@%#define ISC_PLATFORM_NEEDPTON 1%g +s%@ISC_PLATFORM_NEEDATON@%#define ISC_PLATFORM_NEEDATON 1%g +s%@ISC_PLATFORM_NEEDVSNPRINTF@%#define ISC_PRINT_NEEDVSNPRINTF 1%g +s%@ISC_EXTRA_OBJS@%inet_aton.obj inet_ntop.obj inet_pton.obj print.obj%g +s%@ISC_EXTRA_SRCS@%inet_aton.c inet_ntop.c inet_pton.c print.c%g +/@BIND9_INCLUDES@/r ./make/includes +s%@BIND9_INCLUDES@%%g +/@BIND9_MAKE_RULES@/r ./make/rules +s%@BIND9_MAKE_RULES@%%g +/@BIND9_VERSION@/r ./version +s%@BIND9_VERSION@%%g +/@LIBISC_API@/r ./lib/isc/api +s%@LIBISC_API@%%g +/@LIBDNS_API@/r ./lib/dns/api +s%@LIBDNS_API@%%g +/@LIBOMAPI_API@/r ./lib/omapi/api +s%@LIBOMAPI_API@%%g + +CEOF + +# Need to do shell variable substitution on $dstdir +sed >> conftest.subs < conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi + +CONFIG_FILES=${CONFIG_FILES-"make/rules + make/includes + Makefile + make/Makefile + make/mkdep + lib/Makefile + lib/isc/Makefile + lib/isc/include/Makefile + lib/isc/include/isc/Makefile + lib/isc/include/isc/platform.h + lib/isc/unix/Makefile + lib/isc/unix/include/Makefile + lib/isc/unix/include/isc/Makefile + lib/isc/nls/Makefile + lib/isc/pthreads/Makefile + lib/isc/pthreads/include/Makefile + lib/isc/pthreads/include/isc/Makefile + lib/isc/win32/Makefile + lib/isc/win32/include/Makefile + lib/isc/win32/include/isc/Makefile + lib/dns/Makefile + lib/dns/include/Makefile + lib/dns/include/dns/Makefile + lib/dns/sec/Makefile + lib/dns/sec/openssl/Makefile + lib/dns/sec/openssl/include/Makefile + lib/dns/sec/openssl/include/openssl/Makefile + lib/dns/sec/dnssafe/Makefile + lib/dns/sec/dst/Makefile + lib/dns/sec/dst/include/Makefile + lib/dns/sec/dst/include/dst/Makefile + lib/dns/config/Makefile + lib/omapi/Makefile + lib/omapi/include/Makefile + lib/omapi/include/omapi/Makefile + lib/tests/Makefile + lib/tests/include/Makefile + lib/tests/include/tests/Makefile + bin/Makefile + bin/named/Makefile + bin/named/unix/Makefile + bin/tests/Makefile + bin/tests/names/Makefile + bin/tests/master/Makefile + bin/tests/rbt/Makefile + bin/tests/db/Makefile + bin/tests/tasks/Makefile + bin/tests/timers/Makefile + bin/tests/dst/Makefile + bin/tests/mem/Makefile + bin/tests/sockaddr/Makefile +"} +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then + CONFIG_HEADERS="config.h" +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + + + +exit 0 diff --git a/doc/design/windows-nt b/doc/design/windows-nt new file mode 100644 index 0000000000..7cf60b0341 --- /dev/null +++ b/doc/design/windows-nt @@ -0,0 +1,128 @@ + Windows NT Portability Notes + +OVERVIEW + +A primary goal in the overall design of BIND9 was to isolate functions +that were specific to operating systems from those that are available +with ANSI C. Even though development was being done on Unix-like +machines, the main intention was that a Windows NT port could be done +with far less hassle if the incompatible bits were encapsulated into +their own dedicated modules. A libisc API was designed for each +operating system feature that was needed, and initial implementations +of those APIs were done for the various Unix operating systems. Some +of the APIs have been implemented in Win32, but not yet all. + +The target Windows NT build environment was specified as having nmake +and the Microsoft Visual C++ 6.0 compiler, but explicitly _not_ having +Cygwin or any other external portability package, because we wanted to +keep the prerequisites as minimal as possible. + +In the source tree, the Unix implementations for the OS APIs are in a +"unix" subdirectory of lib/isc, while the thread APIs based on POSIX +threads are in lib/isc/pthreads. The Windows versions of the APIs are +in lib/isc/win32. + +COMPILING + +XXX expand this section + +To build a kit for Windows NT, run util/nt-kit while in the top level +directory of the BIND9 sources. Its usage is: + util/nt-kit [-zip|-nozip] [remotedest [localdest]] +where "remotedest" is the path under which the sources will be +compiled on the NT machine, and "localdest" is where the munged +source tree will be placed on the local machine in preparation for +mounting/zipping/whatever to get it to the remote machine. + +The default remotedest is g:/proj/bind9-nt, because that suits my +environment and I'm the one working on this. Use forward slashes when +specifying the remote path. + +The default localdest is ../bind9-nt. + +A zip archive named "bind9-nt.zip" can be created in the parent +directory of "localdest" if the -zip flag is specified; otherwise, +none is made by default. + +...XXX describe what nt-kit does + +...XXX config.status.win32, config.h.win32 + +MODULES + +App + +This module defines several functions that are useful for writing an +application that uses the ISC library. Bob Halley originally said, +"The main reason I wrote it was to help with the sometimes difficult +problems that occur when you try to do a controlled shutdown of a +multithreaded application. This scheme [using isc_app_start/ +isc_app_run/isc_app_finish] will allow an application to use the +as-yet-unwritten single-threaded version of the ISC library without +any source code changes." XXX It has not yet been implemented for +Win32. + +Condition + +This module provides compatibility with the pthread_cond_* functions +of POSIX, which can be used to synchronize threads based on a +condition variable. + +Dir + +This module implements the directory scanning routines isc_dir_open, +isc_dir_read and isc_dir_close, used to iterate over the filenames in +a directory. XXX It also implements isc_dir_chdir to set the current +directory, but this function has not yet been written for Win32. + +Filelock + +This module implements the pthreads functions flockfile, funlockfile +and getc_unlocked, which synchronize stdio calls from multiple +threads. XXX It has not yet been written for Win32. + +Interfaceiter + +This module implements the isc_interfaceiter_first, _next, _current +and _destroy functions to list all of the network interfaces on a +machine. XXX It has not yet been written for Win32. + +Ipv6 + +XXX It has not yet been written for Win32. + +Net + +XXX It has not yet been written for Win32. + +Once + +This module ensures that a particular function, such as an +initialization routine, is only executed once, ensuring that any other +threads that need to have the target function executed before they can +work are blocked until the target function has completely finished. + +Socket + +XXX It has not yet been written for Win32. + +Stdtime + +This module defines isc_stdtime_get, which stores the number of +seconds since 1 Jan 1970 00:00:00 UTC in an isc_stdtime_t variable. + +Thread + +This module provides the isc_thread_create and isc_thread_join +functions, which behave like the POSIX Thread routines pthread_create +and pthread_join. XXX It also defines isc_thread_self to return the id of +the calling thread. + +Time + +This module defines several time management routines, such getting the +current time, adding or subtracting an interval, finding the +difference between two times, or simply determining whether one time +is earlier than another. + + diff --git a/util/nt-kit b/util/nt-kit new file mode 100644 index 0000000000..cc3ea2d711 --- /dev/null +++ b/util/nt-kit @@ -0,0 +1,171 @@ +#! /bin/sh -ex + +# XXX no command line options at all. especially useful would be a way +# to specify the target directory on the NT machine, since it is needed +# in the Makefiles and otherwise config.status.win32 needs to be edited. + +# XXX long term something different clearly needs to be done, so someone +# without any Unix boxes at all could download the source kit and compile. +# it'll happen; it has been a higher priority just to try to work +# on the code issues. + +ZIP=bind9-nt.zip +DOZIP=false + +case "$1" in +-nozip) DOZIP=false; shift ;; +-zip) DOZIP=true ; shift ;; +esac + +case $# in +0) + dstdir=../bind9-nt + rmtdir=g:/proj/bind9-nt + ;; +1) + dstdir=../bind9-nt + rmtdir="$1" + ;; +2) + dstdir="$2" + rmtdir="$1" + ;; +*) + echo "usage: $0 rmtdir [dstdir]" >&2 + exit 99 + ;; +esac + +test -f version || { + echo "$0: must be run in bind9 top level directory" >&2 + exit 1 +} + +set -- `ls -i version` +this_version=$1 +if test -e "$dstdir/version"; then + set -- `ls -i "$dstdir/version" 2>&1` +else + set -- 0 +fi +that_version=$1 + +# Try to make an effort to not wipe out current directory or non-bind directory +test "0$this_version" -eq "0$that_version" && { + echo "$0: dstdir must not be current directory" >&2 + exit 1 +} + +test ! -d $dstdir -o "$that_version" -ne 0 || { + echo "$0: existing dstdir must be a bind9 source directory" >&2 + exit 1 +} + +rm -rf $dstdir +mkdir $dstdir +tar cf - . | (cd $dstdir; tar xfp -) +cd $dstdir + +# XXX Tale BSD/OS special +rm -f stdio.h + +# Start with a clean slate. This is not done in the source tree before +# the copy so as not to disturb things there. +./configure +make clean + +# XXX header files that (currently) need to be built on Unix +##cd lib/isc +##make +##cd ../dns +##make code.h include/dns/enumtype.h include/dns/enumclass.h include/dns/rdatastruct.h +##cd ../.. + +# XXX Need a better way +perl -pi -e '$_ = "" if /chmod\(.*\)/' lib/dns/sec/dst/dst_parse.c + +# XXX grrr. +perl -pi -e 'last if /^##confparser\.c/' lib/dns/config/Makefile.in + +# Adjust Makefiles to have NT paths and nmake-compatible variable expansion. +set +x +echo doing Makefile substitutions +while read file type dates; do + case $file in + */Makefile.in|./make/includes.in|./version) + echo $file + perl -pi -e 'tr%{}/%()\\%; + s%(-I.*)unix%$1win32%; + s%(-I.*)pthreads.*?(\\?)$%$2%; + s%-I ?%/I %g; + s%-D%/D %g; + s%(\$\(ARFLAGS\)) \$@%$1 /out:\$@%; + s%\$\(UNIXOBJS\)%\$(WIN32OBJS)%; + s%\$\(PTHREADOBJS\)%%; + s%^(SUBDIRS.*)(pthreads)(.*)%$1$3%; + s%^(SUBDIRS.*)(unix)(.*)%$1win32$3%; + s%rm -f%-del /q /f%; + s%rm -rf%-rd /q /s%; + s%touch%copy NUL:%' $file + ;; + ./make/rules.in) + echo frobbing conditionals in $file + + # /K is specified in MAKEDEFS *YUCK* because nmake + # for some BRAINDAMAGED REASON does not put K + # in MAKEFLAGS (confirm with "nmake /PKN foo"; + # only P and N are in Makeflags.) However ... doing + # things this way ends up putting /K when you might not + # want it. Thanks, Microsoft. + perl -pi -e \ + 'print "MAKEDEFS = /nologo /K\$(MAKEFLAGS)\n" + if $. == 1; + + tr%{}/%()\\%; + + s%-I%/I %g; + s%-D%/D %g; + s%-c%/c %g; + + s/\.c\.o:/.c.obj:/; + + s%rm -f%-del /q /f%; + s%rm -rf%-rd /q /s%; + + s/for\ i\ in\ \$\(ALL_SUBDIRS\).* + /for %i in (\$(ALL_SUBDIRS)) do \\/x; + + s/if\ \[\ (\S+)\ !=\ "nulldir".* + /\@if NOT $1=="nulldir" \\/x; + + s/^.*echo "making .* in .*\n//; + + s/\(cd\ (\S+);\ (.*)\);\ \\ + /pushd $1 && cd && $2 && popd || popd/x; + + s/\$\$i/%i/g; + + s/^\t+(fi|done).*\n//' $file + ;; + esac +done < util/copyrights +set -x + +# Make Makefiles +./config.status.win32 $rmtdir + +# Copy win32 special files +cp config.h.win32 config.h + +if $DOZIP; then + dir="`basename $dstdir`" + cd .. + rm -f $ZIP + # q = quiet + # r = recurse + # l = LF -> CRLF + # 9 = highest compression + zip -qrl9 $ZIP $dir +fi + +exit 0