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