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