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