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