< prev index next >

make/autoconf/basics.m4

Print this page

        

@@ -21,10 +21,11 @@
 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
 
+###############################################################################
 # Create a function/macro that takes a series of named arguments. The call is
 # similar to AC_DEFUN, but the setup of the function looks like this:
 # BASIC_DEFUN_NAMED([MYFUNC], [FOO *BAR], [$@], [
 # ... do something
 #   AC_MSG_NOTICE([Value of BAR is ARG_BAR])

@@ -89,10 +90,46 @@
 
     m4_set_delete(defined_args)
   ])
 ])
 
+###############################################################################
+# Check if a list of space-separated words are selected only from a list of
+# space-separated legal words. Typical use is to see if a user-specified
+# set of words is selected from a set of legal words.
+#
+# Sets the specified variable to list of non-matching (offending) words, or to
+# the empty string if all words are matching the legal set.
+#
+# $1: result variable name
+# $2: list of values to check
+# $3: list of legal values
+AC_DEFUN([BASIC_GET_NON_MATCHING_VALUES],
+[
+  # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326
+  # Notice that the original variant fails on SLES 10 and 11
+  values_to_check=`$ECHO $2 | $TR ' ' '\n'`
+  legal_values=`$ECHO $3 | $TR ' ' '\n'`
+  result=`$GREP -Fvx "$legal_values" <<< "$values_to_check" | $GREP -v '^$'`
+  $1=${result//$'\n'/ }
+])
+
+###############################################################################
+# Sort a space-separated list, and remove duplicates.
+#
+# Sets the specified variable to the resulting list.
+#
+# $1: result variable name
+# $2: list of values to sort
+AC_DEFUN([BASIC_SORT_LIST],
+[
+  values_to_sort=`$ECHO $2 | $TR ' ' '\n'`
+  result=`$SORT -u <<< "$values_to_sort" | $GREP -v '^$'`
+  $1=${result//$'\n'/ }
+])
+
+###############################################################################
 # Test if $1 is a valid argument to $3 (often is $JAVA passed as $3)
 # If so, then append $1 to $2 \
 # Also set JVM_ARG_OK to true/false depending on outcome.
 AC_DEFUN([ADD_JVM_ARG_IF_OK],
 [

@@ -133,10 +170,11 @@
       $1="$2:[$]$1"
     fi
   fi
 ])
 
+###############################################################################
 # This will make sure the given variable points to a full and proper
 # path. This means:
 # 1) There will be no spaces in the path. On unix platforms,
 #    spaces in the path will result in an error. On Windows,
 #    the path will be rewritten using short-style to be space-free.

@@ -176,10 +214,11 @@
       fi
     fi
   fi
 ])
 
+###############################################################################
 # This will make sure the given variable points to a executable
 # with a full and proper path. This means:
 # 1) There will be no spaces in the path. On unix platforms,
 #    spaces in the path will result in an error. On Windows,
 #    the path will be rewritten using short-style to be space-free.

@@ -247,10 +286,11 @@
       AC_MSG_NOTICE([Rewriting $1 to "$new_complete"])
     fi
   fi
 ])
 
+###############################################################################
 AC_DEFUN([BASIC_REMOVE_SYMBOLIC_LINKS],
 [
   if test "x$OPENJDK_BUILD_OS" != xwindows; then
     # Follow a chain of symbolic links. Use readlink
     # where it exists, else fall back to horribly

@@ -293,19 +333,21 @@
       $1=$sym_link_dir/$sym_link_file
     fi
   fi
 ])
 
+###############################################################################
 # Register a --with argument but mark it as deprecated
 # $1: The name of the with argument to deprecate, not including --with-
 AC_DEFUN([BASIC_DEPRECATED_ARG_WITH],
 [
   AC_ARG_WITH($1, [AS_HELP_STRING([--with-$1],
       [Deprecated. Option is kept for backwards compatibility and is ignored])],
       [AC_MSG_WARN([Option --with-$1 is deprecated and will be ignored.])])
 ])
 
+###############################################################################
 # Register a --enable argument but mark it as deprecated
 # $1: The name of the with argument to deprecate, not including --enable-
 # $2: The name of the argument to deprecate, in shell variable style (i.e. with _ instead of -)
 # $3: Messages to user.
 AC_DEFUN([BASIC_DEPRECATED_ARG_ENABLE],

@@ -320,10 +362,11 @@
     fi
 
   fi
 ])
 
+###############################################################################
 AC_DEFUN_ONCE([BASIC_INIT],
 [
   # Save the original command line. This is passed to us by the wrapper configure script.
   AC_SUBST(CONFIGURE_COMMAND_LINE)
   # Save the path variable before it gets changed

@@ -332,19 +375,21 @@
   DATE_WHEN_CONFIGURED=`LANG=C date`
   AC_SUBST(DATE_WHEN_CONFIGURED)
   AC_MSG_NOTICE([Configuration created at $DATE_WHEN_CONFIGURED.])
 ])
 
+###############################################################################
 # Test that variable $1 denoting a program is not empty. If empty, exit with an error.
 # $1: variable to check
 AC_DEFUN([BASIC_CHECK_NONEMPTY],
 [
   if test "x[$]$1" = x; then
     AC_MSG_ERROR([Could not find required tool for $1])
   fi
 ])
 
+###############################################################################
 # Check that there are no unprocessed overridden variables left.
 # If so, they are an incorrect argument and we will exit with an error.
 AC_DEFUN([BASIC_CHECK_LEFTOVER_OVERRIDDEN],
 [
   if test "x$CONFIGURE_OVERRIDDEN_VARIABLES" != x; then

@@ -352,10 +397,11 @@
     unknown_variables=${CONFIGURE_OVERRIDDEN_VARIABLES//!/ }
     AC_MSG_WARN([The following variables might be unknown to configure: $unknown_variables])
   fi
 ])
 
+###############################################################################
 # Setup a tool for the given variable. If correctly specified by the user,
 # use that value, otherwise search for the tool using the supplied code snippet.
 # $1: variable to set
 # $2: code snippet to call to look for the tool
 # $3: code snippet to call if variable was used to find tool

@@ -418,46 +464,51 @@
     fi
     $3
   fi
 ])
 
+###############################################################################
 # Call BASIC_SETUP_TOOL with AC_PATH_PROGS to locate the tool
 # $1: variable to set
 # $2: executable name (or list of names) to look for
 # $3: [path]
 AC_DEFUN([BASIC_PATH_PROGS],
 [
   BASIC_SETUP_TOOL($1, [AC_PATH_PROGS($1, $2, , $3)])
 ])
 
+###############################################################################
 # Call BASIC_SETUP_TOOL with AC_CHECK_TOOLS to locate the tool
 # $1: variable to set
 # $2: executable name (or list of names) to look for
 AC_DEFUN([BASIC_CHECK_TOOLS],
 [
   BASIC_SETUP_TOOL($1, [AC_CHECK_TOOLS($1, $2)])
 ])
 
+###############################################################################
 # Like BASIC_PATH_PROGS but fails if no tool was found.
 # $1: variable to set
 # $2: executable name (or list of names) to look for
 # $3: [path]
 AC_DEFUN([BASIC_REQUIRE_PROGS],
 [
   BASIC_PATH_PROGS($1, $2, , $3)
   BASIC_CHECK_NONEMPTY($1)
 ])
 
+###############################################################################
 # Like BASIC_SETUP_TOOL but fails if no tool was found.
 # $1: variable to set
 # $2: autoconf macro to call to look for the special tool
 AC_DEFUN([BASIC_REQUIRE_SPECIAL],
 [
   BASIC_SETUP_TOOL($1, [$2])
   BASIC_CHECK_NONEMPTY($1)
 ])
 
+###############################################################################
 # Setup the most fundamental tools that relies on not much else to set up,
 # but is used by much of the early bootstrap code.
 AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS],
 [
   # Start with tools that do not need have cross compilation support

@@ -526,10 +577,11 @@
   BASIC_PATH_PROGS(CPIO, [cpio bsdcpio])
   BASIC_PATH_PROGS(NICE, nice)
   BASIC_PATH_PROGS(PANDOC, pandoc)
 ])
 
+###############################################################################
 # Setup basic configuration paths, and platform-specific stuff related to PATHs.
 AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
 [
   # Save the current directory this script was started from
   CURDIR="$PWD"

@@ -567,19 +619,21 @@
   # Outer [ ] to quote m4.
   [ USERNAME=`$ECHO "$USER" | $TR -d -c '[a-z][A-Z][0-9]'` ]
   AC_SUBST(USERNAME)
 ])
 
+###############################################################################
 # Evaluates platform specific overrides for devkit variables.
 # $1: Name of variable
 AC_DEFUN([BASIC_EVAL_DEVKIT_VARIABLE],
 [
   if test "x[$]$1" = x; then
     eval $1="\${$1_${OPENJDK_TARGET_CPU}}"
   fi
 ])
 
+###############################################################################
 AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT],
 [
   AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
       [use this devkit for compilers, tools and resources])])
 

@@ -754,10 +808,11 @@
   AC_MSG_RESULT([$TOOLCHAIN_PATH])
   AC_MSG_CHECKING([for extra path])
   AC_MSG_RESULT([$EXTRA_PATH])
 ])
 
+###############################################################################
 AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
 [
 
   AC_ARG_WITH(conf-name, [AS_HELP_STRING([--with-conf-name],
       [use this as the name of the configuration @<:@generated from important configuration options@:>@])],

@@ -853,10 +908,11 @@
   AC_CONFIG_FILES([$OUTPUTDIR/Makefile:$AUTOCONF_DIR/Makefile.in])
 ])
 
 #%%% Simple tools %%%
 
+###############################################################################
 # Check if we have found a usable version of make
 # $1: the path to a potential make binary (or empty)
 # $2: the description on how we found this
 AC_DEFUN([BASIC_CHECK_MAKE_VERSION],
 [

@@ -906,10 +962,11 @@
       fi
     fi
   fi
 ])
 
+###############################################################################
 AC_DEFUN([BASIC_CHECK_MAKE_OUTPUT_SYNC],
 [
   # Check if make supports the output sync option and if so, setup using it.
   AC_MSG_CHECKING([if make --output-sync is supported])
   if $MAKE --version -O > /dev/null 2>&1; then

@@ -932,10 +989,11 @@
   fi
   AC_SUBST(OUTPUT_SYNC_SUPPORTED)
   AC_SUBST(OUTPUT_SYNC)
 ])
 
+###############################################################################
 # Goes looking for a usable version of GNU make.
 AC_DEFUN([BASIC_CHECK_GNU_MAKE],
 [
   BASIC_SETUP_TOOL([MAKE],
   [

@@ -979,10 +1037,11 @@
   AC_MSG_NOTICE([Using GNU make at $FOUND_MAKE (version: $MAKE_VERSION_STRING)])
 
   BASIC_CHECK_MAKE_OUTPUT_SYNC
 ])
 
+###############################################################################
 AC_DEFUN([BASIC_CHECK_FIND_DELETE],
 [
   # Test if find supports -delete
   AC_MSG_CHECKING([if find supports -delete])
   FIND_DELETE="-delete"

@@ -1007,10 +1066,11 @@
   fi
   $RMDIR $DELETEDIR
   AC_SUBST(FIND_DELETE)
 ])
 
+###############################################################################
 AC_DEFUN([BASIC_CHECK_TAR],
 [
   # Test which kind of tar was found
   if test "x$($TAR --version | $GREP "GNU tar")" != "x"; then
     TAR_TYPE="gnu"

@@ -1041,10 +1101,11 @@
   AC_SUBST(TAR_CREATE_EXTRA_PARAM)
   AC_SUBST(TAR_INCLUDE_PARAM)
   AC_SUBST(TAR_SUPPORTS_TRANSFORM)
 ])
 
+###############################################################################
 AC_DEFUN([BASIC_CHECK_GREP],
 [
   # Test that grep supports -Fx with a list of pattern which includes null pattern.
   # This is a problem for the grep resident on AIX.
   AC_MSG_CHECKING([that grep ($GREP) -Fx handles empty lines in the pattern list correctly])

@@ -1064,10 +1125,11 @@
     fi
     AC_MSG_ERROR([grep does not handle -Fx correctly. ${ADDINFO}])
   fi
 ])
 
+###############################################################################
 AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
 [
   BASIC_CHECK_GNU_MAKE
 
   BASIC_CHECK_FIND_DELETE

@@ -1130,10 +1192,11 @@
   elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
     BASIC_REQUIRE_PROGS(ELFEDIT, elfedit)
   fi
 ])
 
+###############################################################################
 # Check if build directory is on local disk. If not possible to determine,
 # we prefer to claim it's local.
 # Argument 1: directory to test
 # Argument 2: what to do if it is on local disk
 # Argument 3: what to do otherwise (remote disk or failure)

@@ -1169,10 +1232,11 @@
       $3
     fi
   fi
 ])
 
+###############################################################################
 # Check that source files have basic read permissions set. This might
 # not be the case in cygwin in certain conditions.
 AC_DEFUN_ONCE([BASIC_CHECK_SRC_PERMS],
 [
   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then

@@ -1181,10 +1245,11 @@
       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.])
     fi
   fi
 ])
 
+###############################################################################
 AC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES],
 [
   AC_MSG_CHECKING([if build directory is on local disk])
   BASIC_CHECK_DIR_ON_LOCAL_DISK($OUTPUTDIR,
       [OUTPUT_DIR_IS_LOCAL="yes"],

@@ -1203,10 +1268,11 @@
   else
     IS_RECONFIGURE=no
   fi
 ])
 
+###############################################################################
 # Check for support for specific options in bash
 AC_DEFUN_ONCE([BASIC_CHECK_BASH_OPTIONS],
 [
   # Check bash version
   # Extra [ ] to stop m4 mangling

@@ -1258,10 +1324,11 @@
   fi
 
   AC_SUBST(DEFAULT_MAKE_TARGET)
 ])
 
+###############################################################################
 # Setup the default value for LOG=
 #
 AC_DEFUN_ONCE([BASIC_SETUP_DEFAULT_LOG],
 [
   AC_ARG_WITH(log, [AS_HELP_STRING([--with-log],

@@ -1276,10 +1343,11 @@
   fi
   AC_MSG_RESULT([$DEFAULT_LOG])
   AC_SUBST(DEFAULT_LOG)
 ])
 
+###############################################################################
 # Code to run after AC_OUTPUT
 AC_DEFUN_ONCE([BASIC_POST_CONFIG_OUTPUT],
 [
   # Try to move config.log (generated by autoconf) to the configure-support directory.
   if test -e ./config.log; then
< prev index next >