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