nt-kit revision 70e5a7403f0e0a3bd292b8287c5fed5772c15270
87N/A#! /bin/sh -ex
87N/A#
87N/A# Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
87N/A# Copyright (C) 1999-2001 Internet Software Consortium.
87N/A#
87N/A# Permission to use, copy, modify, and/or distribute this software for any
87N/A# purpose with or without fee is hereby granted, provided that the above
87N/A# copyright notice and this permission notice appear in all copies.
87N/A#
87N/A# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
87N/A# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
87N/A# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
87N/A# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
87N/A# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
87N/A# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
87N/A# PERFORMANCE OF THIS SOFTWARE.
87N/A
87N/A# $Id: nt-kit,v 1.9 2007/06/19 23:47:24 tbox Exp $
87N/A
87N/A# XXX no command line options at all. especially useful would be a way
87N/A# to specify the target directory on the NT machine, since it is needed
87N/A# in the Makefiles and otherwise config.status.win32 needs to be edited.
87N/A
87N/A# XXX long term something different clearly needs to be done, so someone
87N/A# without any Unix boxes at all could download the source kit and compile.
87N/A# it'll happen; it has been a higher priority just to try to work
87N/A# on the code issues.
87N/A
87N/AZIP=bind9-nt.zip
87N/ADOZIP=false
87N/A
87N/Acase "$1" in
87N/A-nozip) DOZIP=false; shift ;;
87N/A-zip) DOZIP=true ; shift ;;
87N/Aesac
87N/A
87N/Acase $# in
87N/A0)
87N/A dstdir=../bind9-nt
87N/A rmtdir=g:/proj/bind9-nt
87N/A ;;
87N/A1)
87N/A dstdir=../bind9-nt
87N/A rmtdir="$1"
87N/A ;;
87N/A2)
87N/A dstdir="$2"
87N/A rmtdir="$1"
87N/A ;;
87N/A*)
87N/A echo "usage: $0 rmtdir [dstdir]" >&2
87N/A exit 99
87N/A ;;
87N/Aesac
87N/A
87N/Atest -f version || {
87N/A echo "$0: must be run in bind9 top level directory" >&2
87N/A exit 1
87N/A}
87N/A
87N/Aset -- `ls -i version`
87N/Athis_version=$1
87N/Aif test -e "$dstdir/version"; then
87N/A set -- `ls -i "$dstdir/version" 2>&1`
87N/Aelse
87N/A set -- 0
87N/Afi
87N/Athat_version=$1
87N/A
87N/A# Try to make an effort to not wipe out current directory or non-bind directory
87N/Atest "0$this_version" -eq "0$that_version" && {
87N/A echo "$0: dstdir must not be current directory" >&2
87N/A exit 1
87N/A}
87N/A
87N/Atest ! -d $dstdir -o "$that_version" -ne 0 || {
87N/A echo "$0: existing dstdir must be a bind9 source directory" >&2
87N/A exit 1
87N/A}
87N/A
87N/Arm -rf $dstdir
87N/Amkdir $dstdir
87N/Atar cf - . | (cd $dstdir; tar xfp -)
87N/Acd $dstdir
87N/A
87N/A# XXX Tale BSD/OS special
87N/Arm -f stdio.h
87N/A
87N/A# Start with a clean slate. This is not done in the source tree before
87N/A# the copy so as not to disturb things there.
87N/A./configure
87N/Amake clean
87N/A
87N/A# XXX header files that (currently) need to be built on Unix
87N/A##cd lib/isc
87N/A##make
87N/A##cd ../dns
87N/A##make code.h include/dns/enumtype.h include/dns/enumclass.h include/dns/rdatastruct.h
87N/A##cd ../..
87N/A
87N/A# XXX Need a better way
87N/Aperl -pi -e '$_ = "" if /chmod\(.*\)/' lib/dns/sec/dst/dst_parse.c
87N/A
87N/A# XXX grrr.
87N/Aperl -pi -e 'last if /^##confparser\.c/' lib/dns/config/Makefile.in
87N/A
87N/A# Adjust Makefiles to have NT paths and nmake-compatible variable expansion.
87N/Aset +x
87N/Aecho doing Makefile substitutions
87N/Awhile read file type dates; do
87N/A case $file in
87N/A */Makefile.in|./make/includes.in|./version)
87N/A echo $file
87N/A perl -pi -e 'tr%{}/%()\\%;
87N/A s%(-I.*)unix%$1win32%;
87N/A s%(-I.*)pthreads.*?(\\?)$%$2%;
87N/A s%-I ?%/I %g;
87N/A s%-D%/D %g;
87N/A s%(\$\(ARFLAGS\)) \$@%$1 /out:\$@%;
87N/A s%\$\(UNIXOBJS\)%\$(WIN32OBJS)%;
87N/A s%\$\(PTHREADOBJS\)%%;
87N/A s%^(SUBDIRS.*)(pthreads)(.*)%$1$3%;
87N/A s%^(SUBDIRS.*)(unix)(.*)%$1win32$3%;
87N/A s%rm -f%-del /q /f%;
87N/A s%rm -rf%-rd /q /s%;
87N/A s%touch%copy NUL:%' $file
87N/A ;;
87N/A ./make/rules.in)
87N/A echo frobbing conditionals in $file
87N/A
87N/A # /K is specified in MAKEDEFS *YUCK* because nmake
87N/A # for some BRAINDAMAGED REASON does not put K
87N/A # in MAKEFLAGS (confirm with "nmake /PKN foo";
87N/A # only P and N are in Makeflags.) However ... doing
87N/A # things this way ends up putting /K when you might not
87N/A # want it. Thanks, Microsoft.
87N/A perl -pi -e \
87N/A 'print "MAKEDEFS = /nologo /K\$(MAKEFLAGS)\n"
87N/A if $. == 1;
87N/A
87N/A tr%{}/%()\\%;
87N/A
87N/A s%-I%/I %g;
87N/A s%-D%/D %g;
87N/A s%-c%/c %g;
87N/A
87N/A s/\.c\.o:/.c.obj:/;
87N/A
87N/A s%rm -f%-del /q /f%;
87N/A s%rm -rf%-rd /q /s%;
87N/A
87N/A s/for\ i\ in\ \$\(ALL_SUBDIRS\).*
87N/A /for %i in (\$(ALL_SUBDIRS)) do \\/x;
87N/A
87N/A s/if\ \[\ (\S+)\ !=\ "nulldir".*
87N/A /\@if NOT $1=="nulldir" \\/x;
87N/A
87N/A s/^.*echo "making .* in .*\n//;
87N/A
87N/A s/\(cd\ (\S+);\ (.*)\);\ \\
87N/A /pushd $1 && cd && $2 && popd || popd/x;
87N/A
87N/A s/\$\$i/%i/g;
87N/A
87N/A s/^\t+(fi|done).*\n//' $file
87N/A ;;
87N/A esac
87N/Adone < util/copyrights
87N/Aset -x
87N/A
87N/A# Make Makefiles
87N/A./config.status.win32 $rmtdir
87N/A
87N/A# Copy win32 special files
87N/Acp config.h.win32 config.h
87N/A
87N/Aif $DOZIP; then
87N/A dir="`basename $dstdir`"
87N/A cd ..
87N/A rm -f $ZIP
87N/A # q = quiet
87N/A # r = recurse
87N/A # l = LF -> CRLF
87N/A # 9 = highest compression
87N/A zip -qrl9 $ZIP $dir
87N/Afi
87N/A
87N/Aexit 0
87N/A