0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Copyright (C) 1999-2001, 2004, 2007, 2012, 2016 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# file, You can obtain one at http://mozilla.org/MPL/2.0/.
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# XXX no command line options at all. especially useful would be a way
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# to specify the target directory on the NT machine, since it is needed
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# in the Makefiles and otherwise config.status.win32 needs to be edited.
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# XXX long term something different clearly needs to be done, so someone
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# without any Unix boxes at all could download the source kit and compile.
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# it'll happen; it has been a higher priority just to try to work
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# on the code issues.
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence echo "$0: must be run in bind9 top level directory" >&2
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrenceif test -e "$dstdir/version"; then
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# Try to make an effort to not wipe out current directory or non-bind directory
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencetest "0$this_version" -eq "0$that_version" && {
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence echo "$0: dstdir must not be current directory" >&2
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrencetest ! -d $dstdir -o "$that_version" -ne 0 || {
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence echo "$0: existing dstdir must be a bind9 source directory" >&2
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# XXX Tale BSD/OS special
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# Start with a clean slate. This is not done in the source tree before
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# the copy so as not to disturb things there.
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# XXX header files that (currently) need to be built on Unix
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence##make code.h include/dns/enumtype.h include/dns/enumclass.h include/dns/rdatastruct.h
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# XXX Need a better way
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrenceperl -pi -e '$_ = "" if /chmod\(.*\)/' lib/dns/sec/dst/dst_parse.c
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrenceperl -pi -e 'last if /^##confparser\.c/' lib/dns/config/Makefile.in
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# Adjust Makefiles to have NT paths and nmake-compatible variable expansion.
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s%(-I.*)unix%$1win32%;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s%(-I.*)pthreads.*?(\\?)$%$2%;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s%-I ?%/I %g;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s%(\$\(ARFLAGS\)) \$@%$1 /out:\$@%;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s%\$\(UNIXOBJS\)%\$(WIN32OBJS)%;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s%\$\(PTHREADOBJS\)%%;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s%^(SUBDIRS.*)(pthreads)(.*)%$1$3%;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s%^(SUBDIRS.*)(unix)(.*)%$1win32$3%;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s%rm -f%-del /q /f%;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s%rm -rf%-rd /q /s%;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence # /K is specified in MAKEDEFS *YUCK* because nmake
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence # for some BRAINDAMAGED REASON does not put K
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence # in MAKEFLAGS (confirm with "nmake /PKN foo";
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence # only P and N are in Makeflags.) However ... doing
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence # things this way ends up putting /K when you might not
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence # want it. Thanks, Microsoft.
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence 'print "MAKEDEFS = /nologo /K\$(MAKEFLAGS)\n"
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence tr%{}/%()\\%;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s%rm -f%-del /q /f%;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s%rm -rf%-rd /q /s%;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s/for\ i\ in\ \$\(ALL_SUBDIRS\).*
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence /for %i in (\$(ALL_SUBDIRS)) do \\/x;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s/if\ \[\ (\S+)\ !=\ "nulldir".*
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence /\@if NOT $1=="nulldir" \\/x;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s/^.*echo "making .* in .*\n//;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s/\(cd\ (\S+);\ (.*)\);\ \\
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence /pushd $1 && cd && $2 && popd || popd/x;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence s/\$\$i/%i/g;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# Make Makefiles
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence# Copy win32 special files
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence # r = recurse
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence # l = LF -> CRLF
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence # 9 = highest compression