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 AC_DEFUN_ONCE([HELP_SETUP_DEPENDENCY_HELP],
  27 [
  28   AC_CHECK_PROGS(PKGHANDLER, zypper apt-get yum brew port pkgutil pkgadd)
  29 ])
  30 
  31 AC_DEFUN([HELP_MSG_MISSING_DEPENDENCY],
  32 [
  33   # Print a helpful message on how to acquire the necessary build dependency.
  34   # $1 is the help tag: cups, alsa etc
  35   MISSING_DEPENDENCY=$1
  36 
  37   if test "x$MISSING_DEPENDENCY" = "xopenjdk"; then
  38     HELP_MSG="OpenJDK distributions are available at http://jdk.java.net/."
  39   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
  40     cygwin_help $MISSING_DEPENDENCY
  41   elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
  42     msys_help $MISSING_DEPENDENCY
  43   else
  44     PKGHANDLER_COMMAND=
  45 
  46     case $PKGHANDLER in
  47       apt-get)
  48         apt_help     $MISSING_DEPENDENCY ;;
  49       yum)
  50         yum_help     $MISSING_DEPENDENCY ;;
  51       brew)
  52         brew_help    $MISSING_DEPENDENCY ;;
  53       port)
  54         port_help    $MISSING_DEPENDENCY ;;
  55       pkgutil)
  56         pkgutil_help $MISSING_DEPENDENCY ;;
  57       pkgadd)
  58         pkgadd_help  $MISSING_DEPENDENCY ;;
  59       zypper)
  60         zypper_help  $MISSING_DEPENDENCY ;;
  61     esac
  62 
  63     if test "x$PKGHANDLER_COMMAND" != x; then
  64       HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'."
  65     fi
  66   fi
  67 ])
  68 
  69 cygwin_help() {
  70   case $1 in
  71     unzip)
  72       PKGHANDLER_COMMAND="( cd <location of cygwin setup.exe> && cmd /c setup -q -P unzip )"
  73       HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'."
  74       ;;
  75     zip)
  76       PKGHANDLER_COMMAND="( cd <location of cygwin setup.exe> && cmd /c setup -q -P zip )"
  77       HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'."
  78       ;;
  79     make)
  80       PKGHANDLER_COMMAND="( cd <location of cygwin setup.exe> && cmd /c setup -q -P make )"
  81       HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'."
  82       ;;
  83   esac
  84 }
  85 
  86 msys_help() {
  87   PKGHANDLER_COMMAND=""
  88 }
  89 
  90 apt_help() {
  91   case $1 in
  92     reduced)
  93       PKGHANDLER_COMMAND="sudo apt-get install gcc-multilib g++-multilib" ;;
  94     devkit)
  95       PKGHANDLER_COMMAND="sudo apt-get install build-essential" ;;
  96     alsa)
  97       PKGHANDLER_COMMAND="sudo apt-get install libasound2-dev" ;;
  98     cups)
  99       PKGHANDLER_COMMAND="sudo apt-get install libcups2-dev" ;;
 100     fontconfig)
 101       PKGHANDLER_COMMAND="sudo apt-get install libfontconfig1-dev" ;;
 102     freetype)
 103       PKGHANDLER_COMMAND="sudo apt-get install libfreetype6-dev" ;;
 104     harfbuzz)
 105       PKGHANDLER_COMMAND="sudo apt-get install libharfbuzz-dev" ;;
 106     ffi)
 107       PKGHANDLER_COMMAND="sudo apt-get install libffi-dev" ;;
 108     x11)
 109       PKGHANDLER_COMMAND="sudo apt-get install libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev" ;;
 110     ccache)
 111       PKGHANDLER_COMMAND="sudo apt-get install ccache" ;;
 112     dtrace)
 113       PKGHANDLER_COMMAND="sudo apt-get install systemtap-sdt-dev" ;;
 114   esac
 115 }
 116 
 117 zypper_help() {
 118   case $1 in
 119     devkit)
 120       PKGHANDLER_COMMAND="sudo zypper install gcc gcc-c++" ;;
 121     alsa)
 122       PKGHANDLER_COMMAND="sudo zypper install alsa-devel" ;;
 123     cups)
 124       PKGHANDLER_COMMAND="sudo zypper install cups-devel" ;;
 125     fontconfig)
 126       PKGHANDLER_COMMAND="sudo zypper install fontconfig-devel" ;;
 127     freetype)
 128       PKGHANDLER_COMMAND="sudo zypper install freetype-devel" ;;
 129     harfbuzz)
 130       PKGHANDLER_COMMAND="sudo zypper install harfbuzz-devel" ;;
 131     x11)
 132       PKGHANDLER_COMMAND="sudo zypper install libX11-devel libXext-devel libXrender-devel libXrandr-devel libXtst-devel libXt-devel libXi-devel" ;;
 133     ccache)
 134       PKGHANDLER_COMMAND="sudo zypper install ccache" ;;
 135   esac
 136 }
 137 
 138 yum_help() {
 139   case $1 in
 140     devkit)
 141       PKGHANDLER_COMMAND="sudo yum groupinstall \"Development Tools\"" ;;
 142     alsa)
 143       PKGHANDLER_COMMAND="sudo yum install alsa-lib-devel" ;;
 144     cups)
 145       PKGHANDLER_COMMAND="sudo yum install cups-devel" ;;
 146     fontconfig)
 147       PKGHANDLER_COMMAND="sudo yum install fontconfig-devel" ;;
 148     freetype)
 149       PKGHANDLER_COMMAND="sudo yum install freetype-devel" ;;
 150     harfbuzz)
 151       PKGHANDLER_COMMAND="sudo yum install harfbuzz-devel" ;;
 152     x11)
 153       PKGHANDLER_COMMAND="sudo yum install libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel" ;;
 154     ccache)
 155       PKGHANDLER_COMMAND="sudo yum install ccache" ;;
 156   esac
 157 }
 158 
 159 brew_help() {
 160   case $1 in
 161     freetype)
 162       PKGHANDLER_COMMAND="brew install freetype" ;;
 163     ccache)
 164       PKGHANDLER_COMMAND="brew install ccache" ;;
 165   esac
 166 }
 167 
 168 port_help() {
 169   PKGHANDLER_COMMAND=""
 170 }
 171 
 172 pkgutil_help() {
 173   PKGHANDLER_COMMAND=""
 174 }
 175 
 176 pkgadd_help() {
 177   PKGHANDLER_COMMAND=""
 178 }
 179 
 180 # This function will check if we're called from the "configure" wrapper while
 181 # printing --help. If so, we will print out additional information that can
 182 # only be extracted within the autoconf script, and then exit. This must be
 183 # called at the very beginning in configure.ac.
 184 AC_DEFUN_ONCE([HELP_PRINT_ADDITIONAL_HELP_AND_EXIT],
 185 [
 186   if test "x$CONFIGURE_PRINT_ADDITIONAL_HELP" != x; then
 187 
 188     # Print available toolchains
 189     $PRINTF "The following toolchains are valid as arguments to --with-toolchain-type.\n"
 190     $PRINTF "Which are available to use depends on the build platform.\n"
 191     for toolchain in $VALID_TOOLCHAINS_all; do
 192       # Use indirect variable referencing
 193       toolchain_var_name=TOOLCHAIN_DESCRIPTION_$toolchain
 194       TOOLCHAIN_DESCRIPTION=${!toolchain_var_name}
 195       $PRINTF "  %-22s  %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION"
 196     done
 197     $PRINTF "\n"
 198 
 199     # Print available JVM features
 200     $PRINTF "The following JVM features are valid as arguments to --with-jvm-features.\n"
 201     $PRINTF "Which are available to use depends on the environment and JVM variant.\n"
 202     m4_foreach(FEATURE, m4_split(jvm_features_valid), [
 203       # Create an m4 variable containing the description for FEATURE.
 204       m4_define(FEATURE_DESCRIPTION, [jvm_feature_desc_]m4_translit(FEATURE, -, _))
 205       $PRINTF "  %-22s  %s\n" FEATURE "FEATURE_DESCRIPTION"
 206       m4_undefine([FEATURE_DESCRIPTION])
 207     ])
 208 
 209     # And now exit directly
 210     exit 0
 211   fi
 212 ])
 213 
 214 AC_DEFUN_ONCE([HELP_PRINT_SUMMARY_AND_WARNINGS],
 215 [
 216   # Finally output some useful information to the user
 217 
 218   printf "\n"
 219   printf "====================================================\n"
 220   if test "x$no_create" != "xyes"; then
 221     if test "x$IS_RECONFIGURE" != "xyes"; then
 222       printf "A new configuration has been successfully created in\n%s\n" "$OUTPUTDIR"
 223     else
 224       printf "The existing configuration has been successfully updated in\n%s\n" "$OUTPUTDIR"
 225     fi
 226   else
 227     if test "x$IS_RECONFIGURE" != "xyes"; then
 228       printf "A configuration has been successfully checked but not created\n"
 229     else
 230       printf "The existing configuration has been successfully checked in\n%s\n" "$OUTPUTDIR"
 231     fi
 232   fi
 233   if test "x$CONFIGURE_COMMAND_LINE" != x; then
 234     printf "using configure arguments '$CONFIGURE_COMMAND_LINE'.\n"
 235   else
 236     printf "using default settings.\n"
 237   fi
 238 
 239   printf "\n"
 240   printf "Configuration summary:\n"
 241   printf "* Debug level:    $DEBUG_LEVEL\n"
 242   printf "* HS debug level: $HOTSPOT_DEBUG_LEVEL\n"
 243   printf "* JVM variants:   $JVM_VARIANTS\n"
 244   printf "* JVM features:   "
 245 
 246   for variant in $JVM_VARIANTS; do
 247     features_var_name=JVM_FEATURES_$variant
 248     JVM_FEATURES_FOR_VARIANT=${!features_var_name}
 249     printf "$variant: \'$JVM_FEATURES_FOR_VARIANT\' "
 250   done
 251   printf "\n"
 252 
 253   printf "* OpenJDK target: OS: $OPENJDK_TARGET_OS, CPU architecture: $OPENJDK_TARGET_CPU_ARCH, address length: $OPENJDK_TARGET_CPU_BITS\n"
 254   printf "* Version string: $VERSION_STRING ($VERSION_SHORT)\n"
 255 
 256   printf "\n"
 257   printf "Tools summary:\n"
 258   if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
 259     printf "* Environment:    $WINDOWS_ENV_VENDOR version $WINDOWS_ENV_VERSION. Windows version $WINDOWS_VERSION"
 260     if test "x$WINDOWS_ENV_ROOT_PATH" != "x"; then
 261       printf ". Root at $WINDOWS_ENV_ROOT_PATH"
 262     fi
 263     printf "\n"
 264   fi
 265   printf "* Boot JDK:       $BOOT_JDK_VERSION (at $BOOT_JDK)\n"
 266   printf "* Toolchain:      $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)\n"
 267   printf "* C Compiler:     Version $CC_VERSION_NUMBER (at $CC)\n"
 268   printf "* C++ Compiler:   Version $CXX_VERSION_NUMBER (at $CXX)\n"
 269 
 270   printf "\n"
 271   printf "Build performance summary:\n"
 272   printf "* Cores to use:   $JOBS\n"
 273   printf "* Memory limit:   $MEMORY_SIZE MB\n"
 274   if test "x$CCACHE_STATUS" != "x"; then
 275     printf "* ccache status:  $CCACHE_STATUS\n"
 276   fi
 277   printf "\n"
 278 
 279   if test "x$BUILDING_MULTIPLE_JVM_VARIANTS" = "xtrue"; then
 280     printf "NOTE: You have requested to build more than one version of the JVM, which\n"
 281     printf "will result in longer build times.\n"
 282     printf "\n"
 283   fi
 284 
 285   if test "x$FOUND_ALT_VARIABLES" != "x"; then
 286     printf "WARNING: You have old-style ALT_ environment variables set.\n"
 287     printf "These are not respected, and will be ignored. It is recommended\n"
 288     printf "that you clean your environment. The following variables are set:\n"
 289     printf "$FOUND_ALT_VARIABLES\n"
 290     printf "\n"
 291   fi
 292 
 293   if test "x$OUTPUT_DIR_IS_LOCAL" != "xyes"; then
 294     printf "WARNING: Your build output directory is not on a local disk.\n"
 295     printf "This will severely degrade build performance!\n"
 296     printf "It is recommended that you create an output directory on a local disk,\n"
 297     printf "and run the configure script again from that directory.\n"
 298     printf "\n"
 299   fi
 300 
 301   if test "x$IS_RECONFIGURE" = "xyes" && test "x$no_create" != "xyes"; then
 302     printf "WARNING: The result of this configuration has overridden an older\n"
 303     printf "configuration. You *should* run 'make clean' to make sure you get a\n"
 304     printf "proper build. Failure to do so might result in strange build problems.\n"
 305     printf "\n"
 306   fi
 307 
 308   if test "x$IS_RECONFIGURE" != "xyes" && test "x$no_create" = "xyes"; then
 309     printf "WARNING: The result of this configuration was not saved.\n"
 310     printf "You should run without '--no-create | -n' to create the configuration.\n"
 311     printf "\n"
 312   fi
 313 
 314   if test "x$UNSUPPORTED_TOOLCHAIN_VERSION" = "xyes"; then
 315     printf "WARNING: The toolchain version used is known to have issues. Please\n"
 316     printf "consider using a supported version unless you know what you are doing.\n"
 317     printf "\n"
 318   fi
 319 ])
 320 
 321 AC_DEFUN_ONCE([HELP_REPEAT_WARNINGS],
 322 [
 323   # Locate config.log.
 324   if test -e "$CONFIGURESUPPORT_OUTPUTDIR/config.log"; then
 325     CONFIG_LOG_PATH="$CONFIGURESUPPORT_OUTPUTDIR"
 326   elif test -e "./config.log"; then
 327     CONFIG_LOG_PATH="."
 328   fi
 329 
 330   if test -e "$CONFIG_LOG_PATH/config.log"; then
 331     $GREP '^configure:.*: WARNING:' "$CONFIG_LOG_PATH/config.log" > /dev/null 2>&1
 332     if test $? -eq 0; then
 333       printf "The following warnings were produced. Repeated here for convenience:\n"
 334       # We must quote sed expression (using []) to stop m4 from eating the [].
 335       $GREP '^configure:.*: WARNING:' "$CONFIG_LOG_PATH/config.log" | $SED -e [ 's/^configure:[0-9]*: //' ]
 336       printf "\n"
 337     fi
 338   fi
 339 ])