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