1 #
   2 # Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 m4_include([basic_tools.m4])
  27 m4_include([basic_windows.m4])
  28 
  29 ###############################################################################
  30 AC_DEFUN_ONCE([BASIC_INIT],
  31 [
  32   # Save the original command line. This is passed to us by the wrapper configure script.
  33   AC_SUBST(CONFIGURE_COMMAND_LINE)
  34   # AUTOCONF might be set in the environment by the user. Preserve for "make reconfigure".
  35   AC_SUBST(AUTOCONF)
  36   # Save the path variable before it gets changed
  37   ORIGINAL_PATH="$PATH"
  38   AC_SUBST(ORIGINAL_PATH)
  39   DATE_WHEN_CONFIGURED=`date`
  40   AC_SUBST(DATE_WHEN_CONFIGURED)
  41   AC_MSG_NOTICE([Configuration created at $DATE_WHEN_CONFIGURED.])
  42 ])
  43 
  44 ###############################################################################
  45 # Check that there are no unprocessed overridden variables left.
  46 # If so, they are an incorrect argument and we will exit with an error.
  47 AC_DEFUN([BASIC_CHECK_LEFTOVER_OVERRIDDEN],
  48 [
  49   if test "x$CONFIGURE_OVERRIDDEN_VARIABLES" != x; then
  50     # Replace the separating ! with spaces before presenting for end user.
  51     unknown_variables=${CONFIGURE_OVERRIDDEN_VARIABLES//!/ }
  52     AC_MSG_WARN([The following variables might be unknown to configure: $unknown_variables])
  53   fi
  54 ])
  55 
  56 ###############################################################################
  57 # Setup basic configuration paths, and platform-specific stuff related to PATHs.
  58 AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
  59 [
  60   # Save the current directory this script was started from
  61   CONFIGURE_START_DIR="$PWD"
  62 
  63   # We might need to rewrite ORIGINAL_PATH, if it includes "#", to quote them
  64   # for make. We couldn't do this when we retrieved ORIGINAL_PATH, since SED
  65   # was not available at that time.
  66   REWRITTEN_PATH=`$ECHO "$ORIGINAL_PATH" | $SED -e 's/#/\\\\#/g'`
  67   if test "x$REWRITTEN_PATH" != "x$ORIGINAL_PATH"; then
  68     ORIGINAL_PATH="$REWRITTEN_PATH"
  69     AC_MSG_NOTICE([Rewriting ORIGINAL_PATH to $REWRITTEN_PATH])
  70   fi
  71 
  72   if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
  73     PATH_SEP=";"
  74     EXE_SUFFIX=".exe"
  75     BASIC_CHECK_PATHS_WINDOWS
  76   else
  77     PATH_SEP=":"
  78     EXE_SUFFIX=""
  79   fi
  80   AC_SUBST(PATH_SEP)
  81   AC_SUBST(EXE_SUFFIX)
  82 
  83   # We get the top-level directory from the supporting wrappers.
  84   AC_MSG_CHECKING([for top-level directory])
  85   AC_MSG_RESULT([$TOPDIR])
  86   AC_SUBST(TOPDIR)
  87   AC_SUBST(CONFIGURE_START_DIR)
  88 
  89   # We can only call UTIL_FIXUP_PATH after BASIC_CHECK_PATHS_WINDOWS.
  90   UTIL_FIXUP_PATH(TOPDIR)
  91   UTIL_FIXUP_PATH(CONFIGURE_START_DIR)
  92 
  93   if test "x$CUSTOM_ROOT" != x; then
  94     UTIL_FIXUP_PATH(CUSTOM_ROOT)
  95     WORKSPACE_ROOT="${CUSTOM_ROOT}"
  96   else
  97     WORKSPACE_ROOT="${TOPDIR}"
  98   fi
  99   AC_SUBST(WORKSPACE_ROOT)
 100 
 101   # Locate the directory of this script.
 102   AUTOCONF_DIR=$TOPDIR/make/autoconf
 103 
 104   # Setup username (for use in adhoc version strings etc)
 105   # Outer [ ] to quote m4.
 106   [ USERNAME=`$ECHO "$USER" | $TR -d -c '[a-z][A-Z][0-9]'` ]
 107   AC_SUBST(USERNAME)
 108 ])
 109 
 110 ###############################################################################
 111 # Evaluates platform specific overrides for devkit variables.
 112 # $1: Name of variable
 113 AC_DEFUN([BASIC_EVAL_DEVKIT_VARIABLE],
 114 [
 115   if test "x[$]$1" = x; then
 116     eval $1="\${$1_${OPENJDK_TARGET_CPU}}"
 117   fi
 118 ])
 119 
 120 ###############################################################################
 121 # Evaluates platform specific overrides for build devkit variables.
 122 # $1: Name of variable
 123 AC_DEFUN([BASIC_EVAL_BUILD_DEVKIT_VARIABLE],
 124 [
 125   if test "x[$]$1" = x; then
 126     eval $1="\${$1_${OPENJDK_BUILD_CPU}}"
 127   fi
 128 ])
 129 
 130 ###############################################################################
 131 AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT],
 132 [
 133   AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
 134       [use this devkit for compilers, tools and resources])])
 135 
 136   if test "x$with_devkit" = xyes; then
 137     AC_MSG_ERROR([--with-devkit must have a value])
 138   elif test "x$with_devkit" != x && test "x$with_devkit" != xno; then
 139     UTIL_FIXUP_PATH([with_devkit])
 140     DEVKIT_ROOT="$with_devkit"
 141     # Check for a meta data info file in the root of the devkit
 142     if test -f "$DEVKIT_ROOT/devkit.info"; then
 143       . $DEVKIT_ROOT/devkit.info
 144       # This potentially sets the following:
 145       # A descriptive name of the devkit
 146       BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_NAME])
 147       # Corresponds to --with-extra-path
 148       BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_EXTRA_PATH])
 149       # Corresponds to --with-toolchain-path
 150       BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_TOOLCHAIN_PATH])
 151       # Corresponds to --with-sysroot
 152       BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_SYSROOT])
 153 
 154       # Identifies the Visual Studio version in the devkit
 155       BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_VERSION])
 156       # The Visual Studio include environment variable
 157       BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_INCLUDE])
 158       # The Visual Studio lib environment variable
 159       BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_LIB])
 160       # Corresponds to --with-msvcr-dll
 161       BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_MSVCR_DLL])
 162       # Corresponds to --with-vcruntime-1-dll
 163       BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VCRUNTIME_1_DLL])
 164       # Corresponds to --with-msvcp-dll
 165       BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_MSVCP_DLL])
 166       # Corresponds to --with-ucrt-dll-dir
 167       BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_UCRT_DLL_DIR])
 168     fi
 169 
 170     AC_MSG_CHECKING([for devkit])
 171     if test "x$DEVKIT_NAME" != x; then
 172       AC_MSG_RESULT([$DEVKIT_NAME in $DEVKIT_ROOT])
 173     else
 174       AC_MSG_RESULT([$DEVKIT_ROOT])
 175     fi
 176 
 177     UTIL_PREPEND_TO_PATH([EXTRA_PATH],$DEVKIT_EXTRA_PATH)
 178 
 179     # Fallback default of just /bin if DEVKIT_PATH is not defined
 180     if test "x$DEVKIT_TOOLCHAIN_PATH" = x; then
 181       DEVKIT_TOOLCHAIN_PATH="$DEVKIT_ROOT/bin"
 182     fi
 183     UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH],$DEVKIT_TOOLCHAIN_PATH)
 184 
 185     # If DEVKIT_SYSROOT is set, use that, otherwise try a couple of known
 186     # places for backwards compatiblity.
 187     if test "x$DEVKIT_SYSROOT" != x; then
 188       SYSROOT="$DEVKIT_SYSROOT"
 189     elif test -d "$DEVKIT_ROOT/$host_alias/libc"; then
 190       SYSROOT="$DEVKIT_ROOT/$host_alias/libc"
 191     elif test -d "$DEVKIT_ROOT/$host/sys-root"; then
 192       SYSROOT="$DEVKIT_ROOT/$host/sys-root"
 193     fi
 194 
 195     if test "x$DEVKIT_ROOT" != x; then
 196       DEVKIT_LIB_DIR="$DEVKIT_ROOT/lib"
 197       if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
 198         DEVKIT_LIB_DIR="$DEVKIT_ROOT/lib64"
 199       fi
 200       AC_SUBST(DEVKIT_LIB_DIR)
 201     fi
 202   fi
 203 
 204   # You can force the sysroot if the sysroot encoded into the compiler tools
 205   # is not correct.
 206   AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root],
 207       [alias for --with-sysroot for backwards compatability])],
 208       [SYSROOT=$with_sys_root]
 209   )
 210 
 211   AC_ARG_WITH(sysroot, [AS_HELP_STRING([--with-sysroot],
 212       [use this directory as sysroot])],
 213       [SYSROOT=$with_sysroot]
 214   )
 215 
 216   AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir],
 217       [alias for --with-toolchain-path for backwards compatibility])],
 218       [UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH],$with_tools_dir)]
 219   )
 220 
 221   AC_ARG_WITH([toolchain-path], [AS_HELP_STRING([--with-toolchain-path],
 222       [prepend these directories when searching for toolchain binaries (compilers etc)])],
 223       [UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH],$with_toolchain_path)]
 224   )
 225 
 226   AC_ARG_WITH([extra-path], [AS_HELP_STRING([--with-extra-path],
 227       [prepend these directories to the default path])],
 228       [UTIL_PREPEND_TO_PATH([EXTRA_PATH],$with_extra_path)]
 229   )
 230 
 231   if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then
 232     # If a devkit has been supplied, find xcodebuild in the toolchain_path.
 233     # If not, detect if Xcode is installed by running xcodebuild -version
 234     # if no Xcode installed, xcodebuild exits with 1
 235     # if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0
 236     if test "x$DEVKIT_ROOT" != x || /usr/bin/xcodebuild -version >/dev/null 2>&1; then
 237       # We need to use xcodebuild in the toolchain dir provided by the user, this will
 238       # fall back on the stub binary in /usr/bin/xcodebuild
 239       AC_PATH_PROG([XCODEBUILD], [xcodebuild], [/usr/bin/xcodebuild], [$TOOLCHAIN_PATH])
 240     else
 241       # this should result in SYSROOT being empty, unless --with-sysroot is provided
 242       # when only the command line tools are installed there are no SDKs, so headers
 243       # are copied into the system frameworks
 244       XCODEBUILD=
 245       AC_SUBST(XCODEBUILD)
 246     fi
 247 
 248     AC_MSG_CHECKING([for sdk name])
 249     AC_ARG_WITH([sdk-name], [AS_HELP_STRING([--with-sdk-name],
 250         [use the platform SDK of the given name. @<:@macosx@:>@])],
 251         [SDKNAME=$with_sdk_name]
 252     )
 253     AC_MSG_RESULT([$SDKNAME])
 254 
 255     # if toolchain path is specified then don't rely on system headers, they may not compile
 256     HAVE_SYSTEM_FRAMEWORK_HEADERS=0
 257     test -z "$TOOLCHAIN_PATH" && \
 258       HAVE_SYSTEM_FRAMEWORK_HEADERS=`test ! -f /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h; echo $?`
 259 
 260     if test -z "$SYSROOT"; then
 261       if test -n "$XCODEBUILD"; then
 262         # if we don't have system headers, use default SDK name (last resort)
 263         if test -z "$SDKNAME" -a $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then
 264           SDKNAME=${SDKNAME:-macosx}
 265         fi
 266 
 267         if test -n "$SDKNAME"; then
 268           # Call xcodebuild to determine SYSROOT
 269           SYSROOT=`"$XCODEBUILD" -sdk $SDKNAME -version | $GREP '^Path: ' | $SED 's/Path: //'`
 270         fi
 271       else
 272         if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then
 273           AC_MSG_ERROR([No xcodebuild tool and no system framework headers found, use --with-sysroot or --with-sdk-name to provide a path to a valid SDK])
 274         fi
 275       fi
 276     else
 277       # warn user if --with-sdk-name was also set
 278       if test -n "$with_sdk_name"; then
 279         AC_MSG_WARN([Both SYSROOT and --with-sdk-name are set, only SYSROOT will be used])
 280       fi
 281     fi
 282 
 283     if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0 -a -z "$SYSROOT"; then
 284       # If no system framework headers, then SYSROOT must be set, or we won't build
 285       AC_MSG_ERROR([Unable to determine SYSROOT and no headers found in /System/Library/Frameworks. Check Xcode configuration, --with-sysroot or --with-sdk-name arguments.])
 286     fi
 287 
 288     # Perform a basic sanity test
 289     if test ! -f "$SYSROOT/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then
 290       if test -z "$SYSROOT"; then
 291         AC_MSG_ERROR([Unable to find required framework headers, provide a path to an SDK via --with-sysroot or --with-sdk-name and be sure Xcode is installed properly])
 292       else
 293         AC_MSG_ERROR([Invalid SDK or SYSROOT path, dependent framework headers not found])
 294       fi
 295     fi
 296 
 297     # set SDKROOT too, Xcode tools will pick it up
 298     SDKROOT="$SYSROOT"
 299     AC_SUBST(SDKROOT)
 300   fi
 301 
 302   # Prepend the extra path to the global path
 303   UTIL_PREPEND_TO_PATH([PATH],$EXTRA_PATH)
 304 
 305   AC_MSG_CHECKING([for sysroot])
 306   AC_MSG_RESULT([$SYSROOT])
 307   AC_MSG_CHECKING([for toolchain path])
 308   AC_MSG_RESULT([$TOOLCHAIN_PATH])
 309   AC_MSG_CHECKING([for extra path])
 310   AC_MSG_RESULT([$EXTRA_PATH])
 311 ])
 312 
 313 ###############################################################################
 314 AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
 315 [
 316 
 317   AC_ARG_WITH(conf-name, [AS_HELP_STRING([--with-conf-name],
 318       [use this as the name of the configuration @<:@generated from important configuration options@:>@])],
 319       [ CONF_NAME=${with_conf_name} ])
 320 
 321   # Test from where we are running configure, in or outside of src root.
 322   AC_MSG_CHECKING([where to store configuration])
 323   if test "x$CONFIGURE_START_DIR" = "x$TOPDIR" \
 324       || test "x$CONFIGURE_START_DIR" = "x$CUSTOM_ROOT" \
 325       || test "x$CONFIGURE_START_DIR" = "x$TOPDIR/make/autoconf" \
 326       || test "x$CONFIGURE_START_DIR" = "x$TOPDIR/make" ; then
 327     # We are running configure from the src root.
 328     # Create a default ./build/target-variant-debuglevel output root.
 329     if test "x${CONF_NAME}" = x; then
 330       AC_MSG_RESULT([in default location])
 331       CONF_NAME="${OPENJDK_TARGET_OS}-${OPENJDK_TARGET_CPU}-${JVM_VARIANTS_WITH_AND}-${DEBUG_LEVEL}"
 332     else
 333       AC_MSG_RESULT([in build directory with custom name])
 334     fi
 335 
 336     OUTPUTDIR="${WORKSPACE_ROOT}/build/${CONF_NAME}"
 337     $MKDIR -p "$OUTPUTDIR"
 338     if test ! -d "$OUTPUTDIR"; then
 339       AC_MSG_ERROR([Could not create build directory $OUTPUTDIR])
 340     fi
 341   else
 342     # We are running configure from outside of the src dir.
 343     # Then use the current directory as output dir!
 344     # If configuration is situated in normal build directory, just use the build
 345     # directory name as configuration name, otherwise use the complete path.
 346     if test "x${CONF_NAME}" = x; then
 347       CONF_NAME=`$ECHO $CONFIGURE_START_DIR | $SED -e "s!^${TOPDIR}/build/!!"`
 348     fi
 349     OUTPUTDIR="$CONFIGURE_START_DIR"
 350     AC_MSG_RESULT([in current directory])
 351 
 352     # WARNING: This might be a bad thing to do. You need to be sure you want to
 353     # have a configuration in this directory. Do some sanity checks!
 354 
 355     if test ! -e "$OUTPUTDIR/spec.gmk"; then
 356       # If we have a spec.gmk, we have run here before and we are OK. Otherwise, check for
 357       # other files
 358       files_present=`$LS $OUTPUTDIR`
 359       # Configure has already touched config.log and confdefs.h in the current dir when this check
 360       # is performed.
 361       filtered_files=`$ECHO "$files_present" \
 362           | $SED -e 's/config.log//g' \
 363               -e 's/configure.log//g' \
 364               -e 's/confdefs.h//g' \
 365               -e 's/configure-support//g' \
 366               -e 's/ //g' \
 367           | $TR -d '\n'`
 368       if test "x$filtered_files" != x; then
 369         AC_MSG_NOTICE([Current directory is $CONFIGURE_START_DIR.])
 370         AC_MSG_NOTICE([Since this is not the source root, configure will output the configuration here])
 371         AC_MSG_NOTICE([(as opposed to creating a configuration in <src_root>/build/<conf-name>).])
 372         AC_MSG_NOTICE([However, this directory is not empty. This is not allowed, since it could])
 373         AC_MSG_NOTICE([seriously mess up just about everything.])
 374         AC_MSG_NOTICE([Try 'cd $TOPDIR' and restart configure])
 375         AC_MSG_NOTICE([(or create a new empty directory and cd to it).])
 376         AC_MSG_ERROR([Will not continue creating configuration in $CONFIGURE_START_DIR])
 377       fi
 378     fi
 379   fi
 380   AC_MSG_CHECKING([what configuration name to use])
 381   AC_MSG_RESULT([$CONF_NAME])
 382 
 383   UTIL_FIXUP_PATH(OUTPUTDIR)
 384 
 385   CONFIGURESUPPORT_OUTPUTDIR="$OUTPUTDIR/configure-support"
 386   $MKDIR -p "$CONFIGURESUPPORT_OUTPUTDIR"
 387 
 388   SPEC="$OUTPUTDIR/spec.gmk"
 389   AC_SUBST(SPEC)
 390   AC_SUBST(CONF_NAME)
 391   AC_SUBST(OUTPUTDIR)
 392   AC_SUBST(CONFIGURESUPPORT_OUTPUTDIR)
 393 
 394   # The spec.gmk file contains all variables for the make system.
 395   AC_CONFIG_FILES([$OUTPUTDIR/spec.gmk:$AUTOCONF_DIR/spec.gmk.in])
 396   # The bootcycle-spec.gmk file contains support for boot cycle builds.
 397   AC_CONFIG_FILES([$OUTPUTDIR/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in])
 398   # The buildjdk-spec.gmk file contains support for building a buildjdk when cross compiling.
 399   AC_CONFIG_FILES([$OUTPUTDIR/buildjdk-spec.gmk:$AUTOCONF_DIR/buildjdk-spec.gmk.in])
 400   # The compare.sh is used to compare the build output to other builds.
 401   AC_CONFIG_FILES([$OUTPUTDIR/compare.sh:$AUTOCONF_DIR/compare.sh.in])
 402   # The generated Makefile knows where the spec.gmk is and where the source is.
 403   # You can run make from the OUTPUTDIR, or from the top-level Makefile
 404   # which will look for generated configurations
 405   AC_CONFIG_FILES([$OUTPUTDIR/Makefile:$AUTOCONF_DIR/Makefile.in])
 406 ])
 407 
 408 ###############################################################################
 409 # Check if build directory is on local disk. If not possible to determine,
 410 # we prefer to claim it's local.
 411 # Argument 1: directory to test
 412 # Argument 2: what to do if it is on local disk
 413 # Argument 3: what to do otherwise (remote disk or failure)
 414 AC_DEFUN([BASIC_CHECK_DIR_ON_LOCAL_DISK],
 415 [
 416   # df -l lists only local disks; if the given directory is not found then
 417   # a non-zero exit code is given
 418   if test "x$DF" = x; then
 419     if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
 420       # msys does not have df; use Windows "net use" instead.
 421       IS_NETWORK_DISK=`net use | grep \`pwd -W | cut -d ":" -f 1 | tr a-z A-Z\`:`
 422       if test "x$IS_NETWORK_DISK" = x; then
 423         $2
 424       else
 425         $3
 426       fi
 427     else
 428       # No df here, say it's local
 429       $2
 430     fi
 431   else
 432     # JDK-8189619
 433     # df on AIX does not understand -l. On modern AIXes it understands "-T local" which
 434     # is the same. On older AIXes we just continue to live with a "not local build" warning.
 435     if test "x$OPENJDK_TARGET_OS" = xaix; then
 436       DF_LOCAL_ONLY_OPTION='-T local'
 437     elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.wsl"; then
 438       # In WSL, we can only build on a drvfs file system (that is, a mounted real Windows drive)
 439       DF_LOCAL_ONLY_OPTION='-t drvfs'
 440     else
 441       DF_LOCAL_ONLY_OPTION='-l'
 442     fi
 443     if $DF $DF_LOCAL_ONLY_OPTION $1 > /dev/null 2>&1; then
 444       $2
 445     else
 446       $3
 447     fi
 448   fi
 449 ])
 450 
 451 ###############################################################################
 452 # Check that source files have basic read permissions set. This might
 453 # not be the case in cygwin in certain conditions.
 454 AC_DEFUN_ONCE([BASIC_CHECK_SRC_PERMS],
 455 [
 456   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
 457     file_to_test="$TOPDIR/LICENSE"
 458     if test `$STAT -c '%a' "$file_to_test"` -lt 400; then
 459       AC_MSG_ERROR([Bad file permissions on src files. This is usually caused by cloning the repositories with a non cygwin hg in a directory not created in cygwin.])
 460     fi
 461   fi
 462 ])
 463 
 464 ###############################################################################
 465 AC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES],
 466 [
 467   AC_MSG_CHECKING([if build directory is on local disk])
 468   BASIC_CHECK_DIR_ON_LOCAL_DISK($OUTPUTDIR,
 469       [OUTPUT_DIR_IS_LOCAL="yes"],
 470       [OUTPUT_DIR_IS_LOCAL="no"])
 471   AC_MSG_RESULT($OUTPUT_DIR_IS_LOCAL)
 472 
 473   BASIC_CHECK_SRC_PERMS
 474 
 475   # Check if the user has any old-style ALT_ variables set.
 476   FOUND_ALT_VARIABLES=`env | grep ^ALT_`
 477 
 478   # Before generating output files, test if they exist. If they do, this is a reconfigure.
 479   # Since we can't properly handle the dependencies for this, warn the user about the situation
 480   if test -e $OUTPUTDIR/spec.gmk; then
 481     IS_RECONFIGURE=yes
 482   else
 483     IS_RECONFIGURE=no
 484   fi
 485 ])
 486 
 487 ################################################################################
 488 #
 489 # Default make target
 490 #
 491 AC_DEFUN_ONCE([BASIC_SETUP_DEFAULT_MAKE_TARGET],
 492 [
 493   AC_ARG_WITH(default-make-target, [AS_HELP_STRING([--with-default-make-target],
 494       [set the default make target @<:@exploded-image@:>@])])
 495   if test "x$with_default_make_target" = "x" \
 496       || test "x$with_default_make_target" = "xyes"; then
 497     DEFAULT_MAKE_TARGET="exploded-image"
 498   elif test "x$with_default_make_target" = "xno"; then
 499     AC_MSG_ERROR([--without-default-make-target is not a valid option])
 500   else
 501     DEFAULT_MAKE_TARGET="$with_default_make_target"
 502   fi
 503 
 504   AC_SUBST(DEFAULT_MAKE_TARGET)
 505 ])
 506 
 507 ###############################################################################
 508 # Setup the default value for LOG=
 509 #
 510 AC_DEFUN_ONCE([BASIC_SETUP_DEFAULT_LOG],
 511 [
 512   AC_ARG_WITH(log, [AS_HELP_STRING([--with-log],
 513       [[default vaue for make LOG argument [warn]]])])
 514   AC_MSG_CHECKING([for default LOG value])
 515   if test "x$with_log" = x; then
 516     DEFAULT_LOG=""
 517   else
 518     # Syntax for valid LOG options is a bit too complex for it to be worth
 519     # implementing a test for correctness in configure. Just accept it.
 520     DEFAULT_LOG=$with_log
 521   fi
 522   AC_MSG_RESULT([$DEFAULT_LOG])
 523   AC_SUBST(DEFAULT_LOG)
 524 ])
 525 
 526 ###############################################################################
 527 # Code to run after AC_OUTPUT
 528 AC_DEFUN_ONCE([BASIC_POST_CONFIG_OUTPUT],
 529 [
 530   # Try to move config.log (generated by autoconf) to the configure-support directory.
 531   if test -e ./config.log; then
 532     $MV -f ./config.log "$CONFIGURESUPPORT_OUTPUTDIR/config.log" 2> /dev/null
 533   fi
 534 
 535   # Rotate our log file (configure.log)
 536   if test -e "$OUTPUTDIR/configure.log.old"; then
 537     $RM -f "$OUTPUTDIR/configure.log.old"
 538   fi
 539   if test -e "$OUTPUTDIR/configure.log"; then
 540     $MV -f "$OUTPUTDIR/configure.log" "$OUTPUTDIR/configure.log.old" 2> /dev/null
 541   fi
 542 
 543   # Move configure.log from current directory to the build output root
 544   if test -e ./configure.log; then
 545     $MV -f ./configure.log "$OUTPUTDIR/configure.log" 2> /dev/null
 546   fi
 547 
 548   # Make the compare script executable
 549   $CHMOD +x $OUTPUTDIR/compare.sh
 550 ])