ohair@425: # ohair@425: # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. ohair@425: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@425: # ohair@425: # This code is free software; you can redistribute it and/or modify it ohair@425: # under the terms of the GNU General Public License version 2 only, as ohair@425: # published by the Free Software Foundation. Oracle designates this ohair@425: # particular file as subject to the "Classpath" exception as provided ohair@425: # by Oracle in the LICENSE file that accompanied this code. ohair@425: # ohair@425: # This code is distributed in the hope that it will be useful, but WITHOUT ohair@425: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@425: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@425: # version 2 for more details (a copy is included in the LICENSE file that ohair@425: # accompanied this code). ohair@425: # ohair@425: # You should have received a copy of the GNU General Public License version ohair@425: # 2 along with this work; if not, write to the Free Software Foundation, ohair@425: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@425: # ohair@425: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@425: # or visit www.oracle.com if you need additional information or have any ohair@425: # questions. ohair@425: # ohair@425: erikj@458: AC_DEFUN_ONCE([BDEPS_SCAN_FOR_BUILDDEPS], ohair@425: [ ihse@839: define(LIST_OF_BUILD_DEPENDENCIES,) ihse@839: if test "x$with_builddeps_server" != x || test "x$with_builddeps_conf" != x; then ihse@839: if test "x$with_builddeps_conf" != x; then ihse@839: AC_MSG_CHECKING([for supplied builddeps configuration file]) ihse@839: builddepsfile=$with_builddeps_conf ihse@839: if test -s $builddepsfile; then ihse@839: . $builddepsfile ihse@839: AC_MSG_RESULT([loaded!]) ihse@839: else ihse@839: AC_MSG_ERROR([The given builddeps conf file $with_builddeps_conf could not be loaded!]) ihse@839: fi ihse@839: else ihse@839: AC_MSG_CHECKING([for builddeps.conf files in sources...]) ihse@839: builddepsfile=`mktemp` ihse@839: touch $builddepsfile ihse@839: # Put all found confs into a single file. ihse@839: find ${SRC_ROOT} -name builddeps.conf -exec cat \{\} \; >> $builddepsfile ihse@839: # Source the file to acquire the variables ihse@839: if test -s $builddepsfile; then ihse@839: . $builddepsfile ihse@839: AC_MSG_RESULT([found at least one!]) ihse@839: else ihse@839: AC_MSG_ERROR([Could not find any builddeps.conf at all!]) ihse@839: fi ohair@425: fi ihse@839: # Create build and target names that use _ instead of "-" and ".". ihse@839: # This is necessary to use them in variable names. ihse@839: build_var=`echo ${OPENJDK_BUILD_AUTOCONF_NAME} | tr '-' '_' | tr '.' '_'` ihse@839: target_var=`echo ${OPENJDK_TARGET_AUTOCONF_NAME} | tr '-' '_' | tr '.' '_'` ihse@839: # Extract rewrite information for build and target ihse@839: eval rewritten_build=\${REWRITE_${build_var}} ihse@839: if test "x$rewritten_build" = x; then ihse@839: rewritten_build=${OPENJDK_BUILD_AUTOCONF_NAME} ihse@839: echo Build stays the same $rewritten_build ihse@839: else ihse@839: echo Rewriting build for builddeps into $rewritten_build ohair@425: fi ihse@839: eval rewritten_target=\${REWRITE_${target_var}} ihse@839: if test "x$rewritten_target" = x; then ihse@839: rewritten_target=${OPENJDK_TARGET_AUTOCONF_NAME} ihse@839: echo Target stays the same $rewritten_target ihse@839: else ihse@839: echo Rewriting target for builddeps into $rewritten_target ihse@839: fi ihse@839: rewritten_build_var=`echo ${rewritten_build} | tr '-' '_' | tr '.' '_'` ihse@839: rewritten_target_var=`echo ${rewritten_target} | tr '-' '_' | tr '.' '_'` ihse@839: fi ihse@839: AC_CHECK_PROGS(BDEPS_UNZIP, [7z unzip]) ihse@839: if test "x$BDEPS_UNZIP" = x7z; then ihse@839: BDEPS_UNZIP="7z x" ihse@839: fi ohair@425: ihse@839: AC_CHECK_PROGS(BDEPS_FTP, [wget lftp ftp]) ohair@425: ]) ohair@425: ohair@425: AC_DEFUN([BDEPS_FTPGET], ohair@425: [ ihse@839: # $1 is the ftp://abuilddeps.server.com/libs/cups.zip ihse@839: # $2 is the local file name for the downloaded file. ihse@839: VALID_TOOL=no ihse@839: if test "x$BDEPS_FTP" = xwget; then ihse@839: VALID_TOOL=yes ihse@839: wget -O $2 $1 ihse@839: fi ihse@839: if test "x$BDEPS_FTP" = xlftp; then ihse@839: VALID_TOOL=yes ihse@839: lftp -c "get $1 -o $2" ihse@839: fi ihse@839: if test "x$BDEPS_FTP" = xftp; then ihse@839: VALID_TOOL=yes ihse@839: FTPSERVER=`echo $1 | cut -f 3 -d '/'` ihse@839: FTPPATH=`echo $1 | cut -f 4- -d '/'` ihse@839: FTPUSERPWD=${FTPSERVER%%@*} ihse@839: if test "x$FTPSERVER" != "x$FTPUSERPWD"; then ihse@839: FTPUSER=${userpwd%%:*} ihse@839: FTPPWD=${userpwd#*@} ihse@839: FTPSERVER=${FTPSERVER#*@} ihse@839: else ihse@839: FTPUSER=ftp ihse@839: FTPPWD=ftp ohair@425: fi ihse@839: # the "pass" command does not work on some ihse@839: # ftp clients (read ftp.exe) but if it works, ihse@839: # passive mode is better! ihse@839: ( \ ihse@839: echo "user $FTPUSER $FTPPWD" ; \ ihse@839: echo "pass" ; \ ihse@839: echo "bin" ; \ ihse@839: echo "get $FTPPATH $2" ; \ ihse@839: ) | ftp -in $FTPSERVER ihse@839: fi ihse@839: if test "x$VALID_TOOL" != xyes; then ihse@839: AC_MSG_ERROR([I do not know how to use the tool: $BDEPS_FTP]) ihse@839: fi ohair@425: ]) ohair@425: ohair@425: AC_DEFUN([BDEPS_CHECK_MODULE], ohair@425: [ ihse@839: define([LIST_OF_BUILD_DEPENDENCIES],LIST_OF_BUILD_DEPENDENCIES[$2=$3'\n']) ihse@839: if test "x$with_builddeps_server" != x || test "x$with_builddeps_conf" != x; then ihse@839: # Source the builddeps file again, to make sure it uses the latest variables! ihse@839: . $builddepsfile ihse@839: # Look for a target and build machine specific resource! ihse@839: eval resource=\${builddep_$2_BUILD_${rewritten_build_var}_TARGET_${rewritten_target_var}} ihse@839: if test "x$resource" = x; then ihse@839: # Ok, lets instead look for a target specific resource ihse@839: eval resource=\${builddep_$2_TARGET_${rewritten_target_var}} ohair@425: fi ihse@839: if test "x$resource" = x; then ihse@839: # Ok, lets instead look for a build specific resource ihse@839: eval resource=\${builddep_$2_BUILD_${rewritten_build_var}} ihse@839: fi ihse@839: if test "x$resource" = x; then ihse@839: # Ok, lets instead look for a generic resource ihse@839: # (The $2 comes from M4 and not the shell, thus no need for eval here.) ihse@839: resource=${builddep_$2} ihse@839: fi ihse@839: if test "x$resource" != x; then ihse@839: AC_MSG_NOTICE([Using builddeps $resource for $2]) ihse@839: # If the resource in the builddeps.conf file is an existing directory, ihse@839: # for example /java/linux/cups ihse@839: if test -d ${resource}; then ihse@839: depdir=${resource} ihse@839: else ihse@839: BDEPS_FETCH($2, $resource, $with_builddeps_server, $with_builddeps_dir, depdir) ihse@839: fi ihse@839: # Source the builddeps file again, because in the previous command, the depdir ihse@839: # was updated to point at the current build dependency install directory. ihse@839: . $builddepsfile ihse@839: # Now extract variables from the builddeps.conf files. ihse@839: theroot=${builddep_$2_ROOT} ihse@839: thecflags=${builddep_$2_CFLAGS} ihse@839: thelibs=${builddep_$2_LIBS} ihse@839: if test "x$depdir" = x; then ihse@839: AC_MSG_ERROR([Could not download build dependency $2]) ihse@839: fi ihse@839: $1=$depdir ihse@839: if test "x$theroot" != x; then ihse@839: $1="$theroot" ihse@839: fi ihse@839: if test "x$thecflags" != x; then ihse@839: $1_CFLAGS="$thecflags" ihse@839: fi ihse@839: if test "x$thelibs" != x; then ihse@839: $1_LIBS="$thelibs" ihse@839: fi ihse@839: m4_default([$4], [:]) ihse@839: m4_ifvaln([$5], [else $5]) ihse@839: fi ihse@839: m4_ifvaln([$5], [else $5]) ihse@839: fi ohair@425: ]) ohair@425: ohair@425: AC_DEFUN([BDEPS_FETCH], ohair@425: [ ihse@839: # $1 is for example mymodule ihse@839: # $2 is for example libs/general/libmymod_1_2_3.zip ihse@839: # $3 is for example ftp://mybuilddeps.myserver.com/builddeps ihse@839: # $4 is for example /localhome/builddeps ihse@839: # $5 is the name of the variable into which we store the depdir, eg MYMOD ihse@839: # Will download ftp://mybuilddeps.myserver.com/builddeps/libs/general/libmymod_1_2_3.zip and ihse@839: # unzip into the directory: /localhome/builddeps/libmymod_1_2_3 ihse@839: filename=`basename $2` ihse@839: filebase=`echo $filename | sed 's/\.[[^\.]]*$//'` ihse@839: filebase=${filename%%.*} ihse@839: extension=${filename#*.} ihse@839: installdir=$4/$filebase ihse@839: if test ! -f $installdir/$filename.unpacked; then ihse@839: AC_MSG_NOTICE([Downloading build dependency $1 from $3/$2 and installing into $installdir]) ihse@839: if test ! -d $installdir; then ihse@839: mkdir -p $installdir ohair@425: fi ihse@839: if test ! -d $installdir; then ihse@839: AC_MSG_ERROR([Could not create directory $installdir]) ohair@425: fi ihse@839: tmpfile=`mktemp $installdir/$1.XXXXXXXXX` ihse@839: touch $tmpfile ihse@839: if test ! -f $tmpfile; then ihse@839: AC_MSG_ERROR([Could not create files in directory $installdir]) ihse@839: fi ihse@839: BDEPS_FTPGET([$3/$2] , [$tmpfile]) ihse@839: mv $tmpfile $installdir/$filename ihse@839: if test ! -s $installdir/$filename; then ihse@839: AC_MSG_ERROR([Could not download $3/$2]) ihse@839: fi ihse@839: case "$extension" in ihse@839: zip) echo "Unzipping $installdir/$filename..." ihse@839: (cd $installdir ; rm -f $installdir/$filename.unpacked ; $BDEPS_UNZIP $installdir/$filename > /dev/null && touch $installdir/$filename.unpacked) ihse@839: ;; ihse@839: tar.gz) echo "Untaring $installdir/$filename..." ihse@839: (cd $installdir ; rm -f $installdir/$filename.unpacked ; tar xzf $installdir/$filename && touch $installdir/$filename.unpacked) ihse@839: ;; ihse@839: tgz) echo "Untaring $installdir/$filename..." ihse@839: (cd $installdir ; rm -f $installdir/$filename.unpacked ; tar xzf $installdir/$filename && touch $installdir/$filename.unpacked) ihse@839: ;; ihse@839: *) AC_MSG_ERROR([Cannot handle build depency archive with extension $extension]) ihse@839: ;; ihse@839: esac ihse@839: fi ihse@839: if test -f $installdir/$filename.unpacked; then ihse@839: $5=$installdir ihse@839: fi ohair@425: ]) erikj@458: erikj@458: AC_DEFUN_ONCE([BDEPS_CONFIGURE_BUILDDEPS], erikj@458: [ ihse@839: AC_ARG_WITH(builddeps-conf, [AS_HELP_STRING([--with-builddeps-conf], ihse@839: [use this configuration file for the builddeps])]) erikj@458: ihse@839: AC_ARG_WITH(builddeps-server, [AS_HELP_STRING([--with-builddeps-server], ihse@839: [download and use build dependencies from this server url])]) erikj@458: ihse@839: AC_ARG_WITH(builddeps-dir, [AS_HELP_STRING([--with-builddeps-dir], ihse@839: [store downloaded build dependencies here @<:@/localhome/builddeps@:>@])], ihse@839: [], ihse@839: [with_builddeps_dir=/localhome/builddeps]) erikj@458: ihse@839: AC_ARG_WITH(builddeps-group, [AS_HELP_STRING([--with-builddeps-group], ihse@839: [chgrp the downloaded build dependencies to this group])]) erikj@458: ])