common/autoconf/basics.m4

changeset 2204
0e87966d7ff1
parent 2203
28b247535e18
child 2205
54eb4c29ece4
equal deleted inserted replaced
2203:28b247535e18 2204:0e87966d7ff1
234 AC_MSG_NOTICE([configure script generated at timestamp $DATE_WHEN_GENERATED.]) 234 AC_MSG_NOTICE([configure script generated at timestamp $DATE_WHEN_GENERATED.])
235 ]) 235 ])
236 236
237 # Test that variable $1 denoting a program is not empty. If empty, exit with an error. 237 # Test that variable $1 denoting a program is not empty. If empty, exit with an error.
238 # $1: variable to check 238 # $1: variable to check
239 # $2: executable name to print in warning (optional)
240 AC_DEFUN([BASIC_CHECK_NONEMPTY], 239 AC_DEFUN([BASIC_CHECK_NONEMPTY],
241 [ 240 [
242 if test "x[$]$1" = x; then 241 if test "x[$]$1" = x; then
243 if test "x$2" = x; then 242 AC_MSG_ERROR([Could not find required tool for $1])
244 PROG_NAME=translit($1,A-Z,a-z) 243 fi
244 ])
245
246 # Check that there are no unprocessed overridden variables left.
247 # If so, they are an incorrect argument and we will exit with an error.
248 AC_DEFUN([BASIC_CHECK_LEFTOVER_OVERRIDDEN],
249 [
250 if test "x$CONFIGURE_OVERRIDDEN_VARIABLES" != x; then
251 # Replace the separating ! with spaces before presenting for end user.
252 unknown_variables=${CONFIGURE_OVERRIDDEN_VARIABLES//!/ }
253 AC_MSG_ERROR([The following variables are unknown to configure: $unknown_variables])
254 fi
255 ])
256
257 # Setup a tool for the given variable. If correctly specified by the user,
258 # use that value, otherwise search for the tool using the supplied code snippet.
259 # $1: variable to set
260 # $2: code snippet to call to look for the tool
261 AC_DEFUN([BASIC_SETUP_TOOL],
262 [
263 # Publish this variable in the help.
264 AC_ARG_VAR($1, [Override default value for $1])
265
266 if test "x[$]$1" = x; then
267 # The variable is not set by user, try to locate tool using the code snippet
268 $2
269 else
270 # The variable is set, but is it from the command line or the environment?
271
272 # Try to remove the string !$1! from our list.
273 try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!$1!/}
274 if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
275 # If it failed, the variable was not from the command line. Ignore it,
276 # but warn the user (except for BASH, which is always set by the calling BASH).
277 if test "x$1" != xBASH; then
278 AC_MSG_WARN([Ignoring value of $1 from the environment. Use command line variables instead.])
279 fi
280 # Try to locate tool using the code snippet
281 $2
245 else 282 else
246 PROG_NAME=$2 283 # If it succeeded, then it was overridden by the user. We will use it
247 fi 284 # for the tool.
248 AC_MSG_NOTICE([Could not find $PROG_NAME!]) 285
249 AC_MSG_ERROR([Cannot continue]) 286 # First remove it from the list of overridden variables, so we can test
250 fi 287 # for unknown variables in the end.
251 ]) 288 CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
252 289
253 # Does AC_PATH_PROG followed by BASIC_CHECK_NONEMPTY. 290 # Check if the provided tool contains a complete path.
254 # Arguments as AC_PATH_PROG: 291 tool_specified="[$]$1"
292 tool_basename="${tool_specified##*/}"
293 if test "x$tool_basename" = "x$tool_specified"; then
294 # A command without a complete path is provided, search $PATH.
295 AC_MSG_NOTICE([Will search for user supplied tool $1=$tool_basename])
296 AC_PATH_PROG($1, $tool_basename)
297 if test "x[$]$1" = x; then
298 AC_MSG_ERROR([User supplied tool $tool_basename could not be found])
299 fi
300 else
301 # Otherwise we believe it is a complete path. Use it as it is.
302 AC_MSG_NOTICE([Will use user supplied tool $1=$tool_specified])
303 AC_MSG_CHECKING([for $1])
304 if test ! -x "$tool_specified"; then
305 AC_MSG_RESULT([not found])
306 AC_MSG_ERROR([User supplied tool $1=$tool_specified does not exist or is not executable])
307 fi
308 AC_MSG_RESULT([$tool_specified])
309 fi
310 fi
311 fi
312 ])
313
314 # Call BASIC_SETUP_TOOL with AC_PATH_PROGS to locate the tool
255 # $1: variable to set 315 # $1: variable to set
256 # $2: executable name to look for 316 # $2: executable name (or list of names) to look for
257 AC_DEFUN([BASIC_REQUIRE_PROG], 317 AC_DEFUN([BASIC_PATH_PROGS],
258 [ 318 [
259 AC_PATH_PROGS($1, $2) 319 BASIC_SETUP_TOOL($1, [AC_PATH_PROGS($1, $2)])
260 BASIC_CHECK_NONEMPTY($1, $2) 320 ])
321
322 # Call BASIC_SETUP_TOOL with AC_CHECK_TOOLS to locate the tool
323 # $1: variable to set
324 # $2: executable name (or list of names) to look for
325 AC_DEFUN([BASIC_CHECK_TOOLS],
326 [
327 BASIC_SETUP_TOOL($1, [AC_CHECK_TOOLS($1, $2)])
328 ])
329
330 # Like BASIC_PATH_PROGS but fails if no tool was found.
331 # $1: variable to set
332 # $2: executable name (or list of names) to look for
333 AC_DEFUN([BASIC_REQUIRE_PROGS],
334 [
335 BASIC_PATH_PROGS($1, $2)
336 BASIC_CHECK_NONEMPTY($1)
337 ])
338
339 # Like BASIC_SETUP_TOOL but fails if no tool was found.
340 # $1: variable to set
341 # $2: autoconf macro to call to look for the special tool
342 AC_DEFUN([BASIC_REQUIRE_SPECIAL],
343 [
344 BASIC_SETUP_TOOL($1, [$2])
345 BASIC_CHECK_NONEMPTY($1)
261 ]) 346 ])
262 347
263 # Setup the most fundamental tools that relies on not much else to set up, 348 # Setup the most fundamental tools that relies on not much else to set up,
264 # but is used by much of the early bootstrap code. 349 # but is used by much of the early bootstrap code.
265 AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS], 350 AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS],
266 [ 351 [
267
268 # Start with tools that do not need have cross compilation support 352 # Start with tools that do not need have cross compilation support
269 # and can be expected to be found in the default PATH. These tools are 353 # and can be expected to be found in the default PATH. These tools are
270 # used by configure. Nor are these tools expected to be found in the 354 # used by configure. Nor are these tools expected to be found in the
271 # devkit from the builddeps server either, since they are 355 # devkit from the builddeps server either, since they are
272 # needed to download the devkit. 356 # needed to download the devkit.
273 357
274 # First are all the simple required tools. 358 # First are all the simple required tools.
275 BASIC_REQUIRE_PROG(BASENAME, basename) 359 BASIC_REQUIRE_PROGS(BASENAME, basename)
276 BASIC_REQUIRE_PROG(BASH, bash) 360 BASIC_REQUIRE_PROGS(BASH, bash)
277 BASIC_REQUIRE_PROG(CAT, cat) 361 BASIC_REQUIRE_PROGS(CAT, cat)
278 BASIC_REQUIRE_PROG(CHMOD, chmod) 362 BASIC_REQUIRE_PROGS(CHMOD, chmod)
279 BASIC_REQUIRE_PROG(CMP, cmp) 363 BASIC_REQUIRE_PROGS(CMP, cmp)
280 BASIC_REQUIRE_PROG(COMM, comm) 364 BASIC_REQUIRE_PROGS(COMM, comm)
281 BASIC_REQUIRE_PROG(CP, cp) 365 BASIC_REQUIRE_PROGS(CP, cp)
282 BASIC_REQUIRE_PROG(CPIO, cpio) 366 BASIC_REQUIRE_PROGS(CPIO, cpio)
283 BASIC_REQUIRE_PROG(CUT, cut) 367 BASIC_REQUIRE_PROGS(CUT, cut)
284 BASIC_REQUIRE_PROG(DATE, date) 368 BASIC_REQUIRE_PROGS(DATE, date)
285 BASIC_REQUIRE_PROG(DIFF, [gdiff diff]) 369 BASIC_REQUIRE_PROGS(DIFF, [gdiff diff])
286 BASIC_REQUIRE_PROG(DIRNAME, dirname) 370 BASIC_REQUIRE_PROGS(DIRNAME, dirname)
287 BASIC_REQUIRE_PROG(ECHO, echo) 371 BASIC_REQUIRE_PROGS(ECHO, echo)
288 BASIC_REQUIRE_PROG(EXPR, expr) 372 BASIC_REQUIRE_PROGS(EXPR, expr)
289 BASIC_REQUIRE_PROG(FILE, file) 373 BASIC_REQUIRE_PROGS(FILE, file)
290 BASIC_REQUIRE_PROG(FIND, find) 374 BASIC_REQUIRE_PROGS(FIND, find)
291 BASIC_REQUIRE_PROG(HEAD, head) 375 BASIC_REQUIRE_PROGS(HEAD, head)
292 BASIC_REQUIRE_PROG(LN, ln) 376 BASIC_REQUIRE_PROGS(LN, ln)
293 BASIC_REQUIRE_PROG(LS, ls) 377 BASIC_REQUIRE_PROGS(LS, ls)
294 BASIC_REQUIRE_PROG(MKDIR, mkdir) 378 BASIC_REQUIRE_PROGS(MKDIR, mkdir)
295 BASIC_REQUIRE_PROG(MKTEMP, mktemp) 379 BASIC_REQUIRE_PROGS(MKTEMP, mktemp)
296 BASIC_REQUIRE_PROG(MV, mv) 380 BASIC_REQUIRE_PROGS(MV, mv)
297 BASIC_REQUIRE_PROG(PRINTF, printf) 381 BASIC_REQUIRE_PROGS(NAWK, [nawk gawk awk])
298 BASIC_REQUIRE_PROG(RM, rm) 382 BASIC_REQUIRE_PROGS(PRINTF, printf)
299 BASIC_REQUIRE_PROG(SH, sh) 383 BASIC_REQUIRE_PROGS(RM, rm)
300 BASIC_REQUIRE_PROG(SORT, sort) 384 BASIC_REQUIRE_PROGS(SH, sh)
301 BASIC_REQUIRE_PROG(TAIL, tail) 385 BASIC_REQUIRE_PROGS(SORT, sort)
302 BASIC_REQUIRE_PROG(TAR, tar) 386 BASIC_REQUIRE_PROGS(TAIL, tail)
303 BASIC_REQUIRE_PROG(TEE, tee) 387 BASIC_REQUIRE_PROGS(TAR, tar)
304 BASIC_REQUIRE_PROG(TOUCH, touch) 388 BASIC_REQUIRE_PROGS(TEE, tee)
305 BASIC_REQUIRE_PROG(TR, tr) 389 BASIC_REQUIRE_PROGS(TOUCH, touch)
306 BASIC_REQUIRE_PROG(UNAME, uname) 390 BASIC_REQUIRE_PROGS(TR, tr)
307 BASIC_REQUIRE_PROG(UNIQ, uniq) 391 BASIC_REQUIRE_PROGS(UNAME, uname)
308 BASIC_REQUIRE_PROG(WC, wc) 392 BASIC_REQUIRE_PROGS(UNIQ, uniq)
309 BASIC_REQUIRE_PROG(WHICH, which) 393 BASIC_REQUIRE_PROGS(WC, wc)
310 BASIC_REQUIRE_PROG(XARGS, xargs) 394 BASIC_REQUIRE_PROGS(WHICH, which)
395 BASIC_REQUIRE_PROGS(XARGS, xargs)
311 396
312 # Then required tools that require some special treatment. 397 # Then required tools that require some special treatment.
313 AC_PROG_AWK 398 BASIC_REQUIRE_SPECIAL(AWK, [AC_PROG_AWK])
314 BASIC_CHECK_NONEMPTY(AWK) 399 BASIC_REQUIRE_SPECIAL(GREP, [AC_PROG_GREP])
315 AC_PROG_GREP 400 BASIC_REQUIRE_SPECIAL(EGREP, [AC_PROG_EGREP])
316 BASIC_CHECK_NONEMPTY(GREP) 401 BASIC_REQUIRE_SPECIAL(FGREP, [AC_PROG_FGREP])
317 AC_PROG_EGREP 402 BASIC_REQUIRE_SPECIAL(SED, [AC_PROG_SED])
318 BASIC_CHECK_NONEMPTY(EGREP)
319 AC_PROG_FGREP
320 BASIC_CHECK_NONEMPTY(FGREP)
321 AC_PROG_SED
322 BASIC_CHECK_NONEMPTY(SED)
323
324 AC_PATH_PROGS(NAWK, [nawk gawk awk])
325 BASIC_CHECK_NONEMPTY(NAWK)
326 403
327 # Always force rm. 404 # Always force rm.
328 RM="$RM -f" 405 RM="$RM -f"
329 406
330 # pwd behaves differently on various platforms and some don't support the -L flag. 407 # pwd behaves differently on various platforms and some don't support the -L flag.
331 # Always use the bash builtin pwd to get uniform behavior. 408 # Always use the bash builtin pwd to get uniform behavior.
332 THEPWDCMD=pwd 409 THEPWDCMD=pwd
333 410
334 # These are not required on all platforms 411 # These are not required on all platforms
335 AC_PATH_PROG(CYGPATH, cygpath) 412 BASIC_PATH_PROGS(CYGPATH, cygpath)
336 AC_PATH_PROG(READLINK, readlink) 413 BASIC_PATH_PROGS(READLINK, [greadlink readlink])
337 AC_PATH_PROG(DF, df) 414 BASIC_PATH_PROGS(DF, df)
338 AC_PATH_PROG(SETFILE, SetFile) 415 BASIC_PATH_PROGS(SETFILE, SetFile)
339 ]) 416 ])
340 417
341 # Setup basic configuration paths, and platform-specific stuff related to PATHs. 418 # Setup basic configuration paths, and platform-specific stuff related to PATHs.
342 AC_DEFUN_ONCE([BASIC_SETUP_PATHS], 419 AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
343 [ 420 [
626 703
627 BASIC_CHECK_FIND_DELETE 704 BASIC_CHECK_FIND_DELETE
628 705
629 # These tools might not be installed by default, 706 # These tools might not be installed by default,
630 # need hint on how to install them. 707 # need hint on how to install them.
631 BASIC_REQUIRE_PROG(UNZIP, unzip) 708 BASIC_REQUIRE_PROGS(UNZIP, unzip)
632 BASIC_REQUIRE_PROG(ZIP, zip) 709 BASIC_REQUIRE_PROGS(ZIP, zip)
633 710
634 # Non-required basic tools 711 # Non-required basic tools
635 712
636 AC_PATH_PROG(LDD, ldd) 713 BASIC_PATH_PROGS(LDD, ldd)
637 if test "x$LDD" = "x"; then 714 if test "x$LDD" = "x"; then
638 # List shared lib dependencies is used for 715 # List shared lib dependencies is used for
639 # debug output and checking for forbidden dependencies. 716 # debug output and checking for forbidden dependencies.
640 # We can build without it. 717 # We can build without it.
641 LDD="true" 718 LDD="true"
642 fi 719 fi
643 AC_PATH_PROGS(READELF, [readelf greadelf]) 720 BASIC_PATH_PROGS(READELF, [readelf greadelf])
644 AC_PATH_PROG(HG, hg) 721 BASIC_PATH_PROGS(HG, hg)
645 AC_PATH_PROG(STAT, stat) 722 BASIC_PATH_PROGS(STAT, stat)
646 AC_PATH_PROG(TIME, time) 723 BASIC_PATH_PROGS(TIME, time)
647 # Check if it's GNU time 724 # Check if it's GNU time
648 IS_GNU_TIME=`$TIME --version 2>&1 | $GREP 'GNU time'` 725 IS_GNU_TIME=`$TIME --version 2>&1 | $GREP 'GNU time'`
649 if test "x$IS_GNU_TIME" != x; then 726 if test "x$IS_GNU_TIME" != x; then
650 IS_GNU_TIME=yes 727 IS_GNU_TIME=yes
651 else 728 else
652 IS_GNU_TIME=no 729 IS_GNU_TIME=no
653 fi 730 fi
654 AC_SUBST(IS_GNU_TIME) 731 AC_SUBST(IS_GNU_TIME)
655 732
656 if test "x$OPENJDK_TARGET_OS" = "xwindows"; then 733 if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
657 BASIC_REQUIRE_PROG(COMM, comm) 734 BASIC_REQUIRE_PROGS(COMM, comm)
658 fi 735 fi
659 736
660 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then 737 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
661 BASIC_REQUIRE_PROG(DSYMUTIL, dsymutil) 738 BASIC_REQUIRE_PROGS(DSYMUTIL, dsymutil)
662 BASIC_REQUIRE_PROG(XATTR, xattr) 739 BASIC_REQUIRE_PROGS(XATTR, xattr)
663 AC_PATH_PROG(CODESIGN, codesign) 740 BASIC_PATH_PROGS(CODESIGN, codesign)
664 if test "x$CODESIGN" != "x"; then 741 if test "x$CODESIGN" != "x"; then
665 # Verify that the openjdk_codesign certificate is present 742 # Verify that the openjdk_codesign certificate is present
666 AC_MSG_CHECKING([if openjdk_codesign certificate is present]) 743 AC_MSG_CHECKING([if openjdk_codesign certificate is present])
667 rm -f codesign-testfile 744 rm -f codesign-testfile
668 touch codesign-testfile 745 touch codesign-testfile
720 fi 797 fi
721 ]) 798 ])
722 799
723 AC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES], 800 AC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES],
724 [ 801 [
802 # Did user specify any unknown variables?
803 BASIC_CHECK_LEFTOVER_OVERRIDDEN
804
725 AC_MSG_CHECKING([if build directory is on local disk]) 805 AC_MSG_CHECKING([if build directory is on local disk])
726 BASIC_CHECK_DIR_ON_LOCAL_DISK($OUTPUT_ROOT, 806 BASIC_CHECK_DIR_ON_LOCAL_DISK($OUTPUT_ROOT,
727 [OUTPUT_DIR_IS_LOCAL="yes"], 807 [OUTPUT_DIR_IS_LOCAL="yes"],
728 [OUTPUT_DIR_IS_LOCAL="no"]) 808 [OUTPUT_DIR_IS_LOCAL="no"])
729 AC_MSG_RESULT($OUTPUT_DIR_IS_LOCAL) 809 AC_MSG_RESULT($OUTPUT_DIR_IS_LOCAL)

mercurial