common/autoconf/builddeps.m4

Wed, 27 Apr 2016 01:39:08 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:39:08 +0800
changeset 0
75a576e87639
child 1133
50aaf272884f
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/
changeset: 1170:d117f01bfb4f
tag: jdk8u25-b17

aoqi@0 1 #
aoqi@0 2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 #
aoqi@0 5 # This code is free software; you can redistribute it and/or modify it
aoqi@0 6 # under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 # published by the Free Software Foundation. Oracle designates this
aoqi@0 8 # particular file as subject to the "Classpath" exception as provided
aoqi@0 9 # by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 #
aoqi@0 11 # This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 # version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 # accompanied this code).
aoqi@0 16 #
aoqi@0 17 # You should have received a copy of the GNU General Public License version
aoqi@0 18 # 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 #
aoqi@0 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 # or visit www.oracle.com if you need additional information or have any
aoqi@0 23 # questions.
aoqi@0 24 #
aoqi@0 25
aoqi@0 26 AC_DEFUN_ONCE([BDEPS_SCAN_FOR_BUILDDEPS],
aoqi@0 27 [
aoqi@0 28 define(LIST_OF_BUILD_DEPENDENCIES,)
aoqi@0 29 if test "x$with_builddeps_server" != x || test "x$with_builddeps_conf" != x; then
aoqi@0 30 if test "x$with_builddeps_conf" != x; then
aoqi@0 31 AC_MSG_CHECKING([for supplied builddeps configuration file])
aoqi@0 32 builddepsfile=$with_builddeps_conf
aoqi@0 33 if test -s $builddepsfile; then
aoqi@0 34 . $builddepsfile
aoqi@0 35 AC_MSG_RESULT([loaded!])
aoqi@0 36 else
aoqi@0 37 AC_MSG_ERROR([The given builddeps conf file $with_builddeps_conf could not be loaded!])
aoqi@0 38 fi
aoqi@0 39 else
aoqi@0 40 AC_MSG_CHECKING([for builddeps.conf files in sources...])
aoqi@0 41 builddepsfile=`mktemp`
aoqi@0 42 touch $builddepsfile
aoqi@0 43 # Put all found confs into a single file.
aoqi@0 44 find ${SRC_ROOT} -name builddeps.conf -exec cat \{\} \; >> $builddepsfile
aoqi@0 45 # Source the file to acquire the variables
aoqi@0 46 if test -s $builddepsfile; then
aoqi@0 47 . $builddepsfile
aoqi@0 48 AC_MSG_RESULT([found at least one!])
aoqi@0 49 else
aoqi@0 50 AC_MSG_ERROR([Could not find any builddeps.conf at all!])
aoqi@0 51 fi
aoqi@0 52 fi
aoqi@0 53 # Create build and target names that use _ instead of "-" and ".".
aoqi@0 54 # This is necessary to use them in variable names.
aoqi@0 55 build_var=`echo ${OPENJDK_BUILD_AUTOCONF_NAME} | tr '-' '_' | tr '.' '_'`
aoqi@0 56 target_var=`echo ${OPENJDK_TARGET_AUTOCONF_NAME} | tr '-' '_' | tr '.' '_'`
aoqi@0 57 # Extract rewrite information for build and target
aoqi@0 58 eval rewritten_build=\${REWRITE_${build_var}}
aoqi@0 59 if test "x$rewritten_build" = x; then
aoqi@0 60 rewritten_build=${OPENJDK_BUILD_AUTOCONF_NAME}
aoqi@0 61 echo Build stays the same $rewritten_build
aoqi@0 62 else
aoqi@0 63 echo Rewriting build for builddeps into $rewritten_build
aoqi@0 64 fi
aoqi@0 65 eval rewritten_target=\${REWRITE_${target_var}}
aoqi@0 66 if test "x$rewritten_target" = x; then
aoqi@0 67 rewritten_target=${OPENJDK_TARGET_AUTOCONF_NAME}
aoqi@0 68 echo Target stays the same $rewritten_target
aoqi@0 69 else
aoqi@0 70 echo Rewriting target for builddeps into $rewritten_target
aoqi@0 71 fi
aoqi@0 72 rewritten_build_var=`echo ${rewritten_build} | tr '-' '_' | tr '.' '_'`
aoqi@0 73 rewritten_target_var=`echo ${rewritten_target} | tr '-' '_' | tr '.' '_'`
aoqi@0 74 fi
aoqi@0 75 AC_CHECK_PROGS(BDEPS_UNZIP, [7z unzip])
aoqi@0 76 if test "x$BDEPS_UNZIP" = x7z; then
aoqi@0 77 BDEPS_UNZIP="7z x"
aoqi@0 78 fi
aoqi@0 79
aoqi@0 80 AC_CHECK_PROGS(BDEPS_FTP, [wget lftp ftp])
aoqi@0 81 ])
aoqi@0 82
aoqi@0 83 AC_DEFUN([BDEPS_FTPGET],
aoqi@0 84 [
aoqi@0 85 # $1 is the ftp://abuilddeps.server.com/libs/cups.zip
aoqi@0 86 # $2 is the local file name for the downloaded file.
aoqi@0 87 VALID_TOOL=no
aoqi@0 88 if test "x$BDEPS_FTP" = xwget; then
aoqi@0 89 VALID_TOOL=yes
aoqi@0 90 wget -O $2 $1
aoqi@0 91 fi
aoqi@0 92 if test "x$BDEPS_FTP" = xlftp; then
aoqi@0 93 VALID_TOOL=yes
aoqi@0 94 lftp -c "get $1 -o $2"
aoqi@0 95 fi
aoqi@0 96 if test "x$BDEPS_FTP" = xftp; then
aoqi@0 97 VALID_TOOL=yes
aoqi@0 98 FTPSERVER=`echo $1 | cut -f 3 -d '/'`
aoqi@0 99 FTPPATH=`echo $1 | cut -f 4- -d '/'`
aoqi@0 100 FTPUSERPWD=${FTPSERVER%%@*}
aoqi@0 101 if test "x$FTPSERVER" != "x$FTPUSERPWD"; then
aoqi@0 102 FTPUSER=${userpwd%%:*}
aoqi@0 103 FTPPWD=${userpwd#*@}
aoqi@0 104 FTPSERVER=${FTPSERVER#*@}
aoqi@0 105 else
aoqi@0 106 FTPUSER=ftp
aoqi@0 107 FTPPWD=ftp
aoqi@0 108 fi
aoqi@0 109 # the "pass" command does not work on some
aoqi@0 110 # ftp clients (read ftp.exe) but if it works,
aoqi@0 111 # passive mode is better!
aoqi@0 112 ( \
aoqi@0 113 echo "user $FTPUSER $FTPPWD" ; \
aoqi@0 114 echo "pass" ; \
aoqi@0 115 echo "bin" ; \
aoqi@0 116 echo "get $FTPPATH $2" ; \
aoqi@0 117 ) | ftp -in $FTPSERVER
aoqi@0 118 fi
aoqi@0 119 if test "x$VALID_TOOL" != xyes; then
aoqi@0 120 AC_MSG_ERROR([I do not know how to use the tool: $BDEPS_FTP])
aoqi@0 121 fi
aoqi@0 122 ])
aoqi@0 123
aoqi@0 124 AC_DEFUN([BDEPS_CHECK_MODULE],
aoqi@0 125 [
aoqi@0 126 define([LIST_OF_BUILD_DEPENDENCIES],LIST_OF_BUILD_DEPENDENCIES[$2=$3'\n'])
aoqi@0 127 if test "x$with_builddeps_server" != x || test "x$with_builddeps_conf" != x; then
aoqi@0 128 # Source the builddeps file again, to make sure it uses the latest variables!
aoqi@0 129 . $builddepsfile
aoqi@0 130 # Look for a target and build machine specific resource!
aoqi@0 131 eval resource=\${builddep_$2_BUILD_${rewritten_build_var}_TARGET_${rewritten_target_var}}
aoqi@0 132 if test "x$resource" = x; then
aoqi@0 133 # Ok, lets instead look for a target specific resource
aoqi@0 134 eval resource=\${builddep_$2_TARGET_${rewritten_target_var}}
aoqi@0 135 fi
aoqi@0 136 if test "x$resource" = x; then
aoqi@0 137 # Ok, lets instead look for a build specific resource
aoqi@0 138 eval resource=\${builddep_$2_BUILD_${rewritten_build_var}}
aoqi@0 139 fi
aoqi@0 140 if test "x$resource" = x; then
aoqi@0 141 # Ok, lets instead look for a generic resource
aoqi@0 142 # (The $2 comes from M4 and not the shell, thus no need for eval here.)
aoqi@0 143 resource=${builddep_$2}
aoqi@0 144 fi
aoqi@0 145 if test "x$resource" != x; then
aoqi@0 146 AC_MSG_NOTICE([Using builddeps $resource for $2])
aoqi@0 147 # If the resource in the builddeps.conf file is an existing directory,
aoqi@0 148 # for example /java/linux/cups
aoqi@0 149 if test -d ${resource}; then
aoqi@0 150 depdir=${resource}
aoqi@0 151 else
aoqi@0 152 BDEPS_FETCH($2, $resource, $with_builddeps_server, $with_builddeps_dir, depdir)
aoqi@0 153 fi
aoqi@0 154 # Source the builddeps file again, because in the previous command, the depdir
aoqi@0 155 # was updated to point at the current build dependency install directory.
aoqi@0 156 . $builddepsfile
aoqi@0 157 # Now extract variables from the builddeps.conf files.
aoqi@0 158 theroot=${builddep_$2_ROOT}
aoqi@0 159 thecflags=${builddep_$2_CFLAGS}
aoqi@0 160 thelibs=${builddep_$2_LIBS}
aoqi@0 161 if test "x$depdir" = x; then
aoqi@0 162 AC_MSG_ERROR([Could not download build dependency $2])
aoqi@0 163 fi
aoqi@0 164 $1=$depdir
aoqi@0 165 if test "x$theroot" != x; then
aoqi@0 166 $1="$theroot"
aoqi@0 167 fi
aoqi@0 168 if test "x$thecflags" != x; then
aoqi@0 169 $1_CFLAGS="$thecflags"
aoqi@0 170 fi
aoqi@0 171 if test "x$thelibs" != x; then
aoqi@0 172 $1_LIBS="$thelibs"
aoqi@0 173 fi
aoqi@0 174 m4_default([$4], [:])
aoqi@0 175 m4_ifvaln([$5], [else $5])
aoqi@0 176 fi
aoqi@0 177 m4_ifvaln([$5], [else $5])
aoqi@0 178 fi
aoqi@0 179 ])
aoqi@0 180
aoqi@0 181 AC_DEFUN([BDEPS_FETCH],
aoqi@0 182 [
aoqi@0 183 # $1 is for example mymodule
aoqi@0 184 # $2 is for example libs/general/libmymod_1_2_3.zip
aoqi@0 185 # $3 is for example ftp://mybuilddeps.myserver.com/builddeps
aoqi@0 186 # $4 is for example /localhome/builddeps
aoqi@0 187 # $5 is the name of the variable into which we store the depdir, eg MYMOD
aoqi@0 188 # Will download ftp://mybuilddeps.myserver.com/builddeps/libs/general/libmymod_1_2_3.zip and
aoqi@0 189 # unzip into the directory: /localhome/builddeps/libmymod_1_2_3
aoqi@0 190 filename=`basename $2`
aoqi@0 191 filebase=`echo $filename | sed 's/\.[[^\.]]*$//'`
aoqi@0 192 filebase=${filename%%.*}
aoqi@0 193 extension=${filename#*.}
aoqi@0 194 installdir=$4/$filebase
aoqi@0 195 if test ! -f $installdir/$filename.unpacked; then
aoqi@0 196 AC_MSG_NOTICE([Downloading build dependency $1 from $3/$2 and installing into $installdir])
aoqi@0 197 if test ! -d $installdir; then
aoqi@0 198 mkdir -p $installdir
aoqi@0 199 fi
aoqi@0 200 if test ! -d $installdir; then
aoqi@0 201 AC_MSG_ERROR([Could not create directory $installdir])
aoqi@0 202 fi
aoqi@0 203 tmpfile=`mktemp $installdir/$1.XXXXXXXXX`
aoqi@0 204 touch $tmpfile
aoqi@0 205 if test ! -f $tmpfile; then
aoqi@0 206 AC_MSG_ERROR([Could not create files in directory $installdir])
aoqi@0 207 fi
aoqi@0 208 BDEPS_FTPGET([$3/$2] , [$tmpfile])
aoqi@0 209 mv $tmpfile $installdir/$filename
aoqi@0 210 if test ! -s $installdir/$filename; then
aoqi@0 211 AC_MSG_ERROR([Could not download $3/$2])
aoqi@0 212 fi
aoqi@0 213 case "$extension" in
aoqi@0 214 zip) echo "Unzipping $installdir/$filename..."
aoqi@0 215 (cd $installdir ; rm -f $installdir/$filename.unpacked ; $BDEPS_UNZIP $installdir/$filename > /dev/null && touch $installdir/$filename.unpacked)
aoqi@0 216 ;;
aoqi@0 217 tar.gz) echo "Untaring $installdir/$filename..."
aoqi@0 218 (cd $installdir ; rm -f $installdir/$filename.unpacked ; tar xzf $installdir/$filename && touch $installdir/$filename.unpacked)
aoqi@0 219 ;;
aoqi@0 220 tgz) echo "Untaring $installdir/$filename..."
aoqi@0 221 (cd $installdir ; rm -f $installdir/$filename.unpacked ; tar xzf $installdir/$filename && touch $installdir/$filename.unpacked)
aoqi@0 222 ;;
aoqi@0 223 *) AC_MSG_ERROR([Cannot handle build depency archive with extension $extension])
aoqi@0 224 ;;
aoqi@0 225 esac
aoqi@0 226 fi
aoqi@0 227 if test -f $installdir/$filename.unpacked; then
aoqi@0 228 $5=$installdir
aoqi@0 229 fi
aoqi@0 230 ])
aoqi@0 231
aoqi@0 232 AC_DEFUN_ONCE([BDEPS_CONFIGURE_BUILDDEPS],
aoqi@0 233 [
aoqi@0 234 AC_ARG_WITH(builddeps-conf, [AS_HELP_STRING([--with-builddeps-conf],
aoqi@0 235 [use this configuration file for the builddeps])])
aoqi@0 236
aoqi@0 237 AC_ARG_WITH(builddeps-server, [AS_HELP_STRING([--with-builddeps-server],
aoqi@0 238 [download and use build dependencies from this server url])])
aoqi@0 239
aoqi@0 240 AC_ARG_WITH(builddeps-dir, [AS_HELP_STRING([--with-builddeps-dir],
aoqi@0 241 [store downloaded build dependencies here @<:@/localhome/builddeps@:>@])],
aoqi@0 242 [],
aoqi@0 243 [with_builddeps_dir=/localhome/builddeps])
aoqi@0 244
aoqi@0 245 AC_ARG_WITH(builddeps-group, [AS_HELP_STRING([--with-builddeps-group],
aoqi@0 246 [chgrp the downloaded build dependencies to this group])])
aoqi@0 247 ])

mercurial