common/autoconf/builddeps.m4

Mon, 29 Jun 2020 21:30:12 +0100

author
andrew
date
Mon, 29 Jun 2020 21:30:12 +0100
changeset 2537
a8da94d779b3
parent 839
174a54ce39c4
child 1133
50aaf272884f
permissions
-rw-r--r--

Merge

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 [
ihse@839 28 define(LIST_OF_BUILD_DEPENDENCIES,)
ihse@839 29 if test "x$with_builddeps_server" != x || test "x$with_builddeps_conf" != x; then
ihse@839 30 if test "x$with_builddeps_conf" != x; then
ihse@839 31 AC_MSG_CHECKING([for supplied builddeps configuration file])
ihse@839 32 builddepsfile=$with_builddeps_conf
ihse@839 33 if test -s $builddepsfile; then
ihse@839 34 . $builddepsfile
ihse@839 35 AC_MSG_RESULT([loaded!])
ihse@839 36 else
ihse@839 37 AC_MSG_ERROR([The given builddeps conf file $with_builddeps_conf could not be loaded!])
ihse@839 38 fi
ihse@839 39 else
ihse@839 40 AC_MSG_CHECKING([for builddeps.conf files in sources...])
ihse@839 41 builddepsfile=`mktemp`
ihse@839 42 touch $builddepsfile
ihse@839 43 # Put all found confs into a single file.
ihse@839 44 find ${SRC_ROOT} -name builddeps.conf -exec cat \{\} \; >> $builddepsfile
ihse@839 45 # Source the file to acquire the variables
ihse@839 46 if test -s $builddepsfile; then
ihse@839 47 . $builddepsfile
ihse@839 48 AC_MSG_RESULT([found at least one!])
ihse@839 49 else
ihse@839 50 AC_MSG_ERROR([Could not find any builddeps.conf at all!])
ihse@839 51 fi
ohair@425 52 fi
ihse@839 53 # Create build and target names that use _ instead of "-" and ".".
ihse@839 54 # This is necessary to use them in variable names.
ihse@839 55 build_var=`echo ${OPENJDK_BUILD_AUTOCONF_NAME} | tr '-' '_' | tr '.' '_'`
ihse@839 56 target_var=`echo ${OPENJDK_TARGET_AUTOCONF_NAME} | tr '-' '_' | tr '.' '_'`
ihse@839 57 # Extract rewrite information for build and target
ihse@839 58 eval rewritten_build=\${REWRITE_${build_var}}
ihse@839 59 if test "x$rewritten_build" = x; then
ihse@839 60 rewritten_build=${OPENJDK_BUILD_AUTOCONF_NAME}
ihse@839 61 echo Build stays the same $rewritten_build
ihse@839 62 else
ihse@839 63 echo Rewriting build for builddeps into $rewritten_build
ohair@425 64 fi
ihse@839 65 eval rewritten_target=\${REWRITE_${target_var}}
ihse@839 66 if test "x$rewritten_target" = x; then
ihse@839 67 rewritten_target=${OPENJDK_TARGET_AUTOCONF_NAME}
ihse@839 68 echo Target stays the same $rewritten_target
ihse@839 69 else
ihse@839 70 echo Rewriting target for builddeps into $rewritten_target
ihse@839 71 fi
ihse@839 72 rewritten_build_var=`echo ${rewritten_build} | tr '-' '_' | tr '.' '_'`
ihse@839 73 rewritten_target_var=`echo ${rewritten_target} | tr '-' '_' | tr '.' '_'`
ihse@839 74 fi
ihse@839 75 AC_CHECK_PROGS(BDEPS_UNZIP, [7z unzip])
ihse@839 76 if test "x$BDEPS_UNZIP" = x7z; then
ihse@839 77 BDEPS_UNZIP="7z x"
ihse@839 78 fi
ohair@425 79
ihse@839 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 [
ihse@839 85 # $1 is the ftp://abuilddeps.server.com/libs/cups.zip
ihse@839 86 # $2 is the local file name for the downloaded file.
ihse@839 87 VALID_TOOL=no
ihse@839 88 if test "x$BDEPS_FTP" = xwget; then
ihse@839 89 VALID_TOOL=yes
ihse@839 90 wget -O $2 $1
ihse@839 91 fi
ihse@839 92 if test "x$BDEPS_FTP" = xlftp; then
ihse@839 93 VALID_TOOL=yes
ihse@839 94 lftp -c "get $1 -o $2"
ihse@839 95 fi
ihse@839 96 if test "x$BDEPS_FTP" = xftp; then
ihse@839 97 VALID_TOOL=yes
ihse@839 98 FTPSERVER=`echo $1 | cut -f 3 -d '/'`
ihse@839 99 FTPPATH=`echo $1 | cut -f 4- -d '/'`
ihse@839 100 FTPUSERPWD=${FTPSERVER%%@*}
ihse@839 101 if test "x$FTPSERVER" != "x$FTPUSERPWD"; then
ihse@839 102 FTPUSER=${userpwd%%:*}
ihse@839 103 FTPPWD=${userpwd#*@}
ihse@839 104 FTPSERVER=${FTPSERVER#*@}
ihse@839 105 else
ihse@839 106 FTPUSER=ftp
ihse@839 107 FTPPWD=ftp
ohair@425 108 fi
ihse@839 109 # the "pass" command does not work on some
ihse@839 110 # ftp clients (read ftp.exe) but if it works,
ihse@839 111 # passive mode is better!
ihse@839 112 ( \
ihse@839 113 echo "user $FTPUSER $FTPPWD" ; \
ihse@839 114 echo "pass" ; \
ihse@839 115 echo "bin" ; \
ihse@839 116 echo "get $FTPPATH $2" ; \
ihse@839 117 ) | ftp -in $FTPSERVER
ihse@839 118 fi
ihse@839 119 if test "x$VALID_TOOL" != xyes; then
ihse@839 120 AC_MSG_ERROR([I do not know how to use the tool: $BDEPS_FTP])
ihse@839 121 fi
ohair@425 122 ])
ohair@425 123
ohair@425 124 AC_DEFUN([BDEPS_CHECK_MODULE],
ohair@425 125 [
ihse@839 126 define([LIST_OF_BUILD_DEPENDENCIES],LIST_OF_BUILD_DEPENDENCIES[$2=$3'\n'])
ihse@839 127 if test "x$with_builddeps_server" != x || test "x$with_builddeps_conf" != x; then
ihse@839 128 # Source the builddeps file again, to make sure it uses the latest variables!
ihse@839 129 . $builddepsfile
ihse@839 130 # Look for a target and build machine specific resource!
ihse@839 131 eval resource=\${builddep_$2_BUILD_${rewritten_build_var}_TARGET_${rewritten_target_var}}
ihse@839 132 if test "x$resource" = x; then
ihse@839 133 # Ok, lets instead look for a target specific resource
ihse@839 134 eval resource=\${builddep_$2_TARGET_${rewritten_target_var}}
ohair@425 135 fi
ihse@839 136 if test "x$resource" = x; then
ihse@839 137 # Ok, lets instead look for a build specific resource
ihse@839 138 eval resource=\${builddep_$2_BUILD_${rewritten_build_var}}
ihse@839 139 fi
ihse@839 140 if test "x$resource" = x; then
ihse@839 141 # Ok, lets instead look for a generic resource
ihse@839 142 # (The $2 comes from M4 and not the shell, thus no need for eval here.)
ihse@839 143 resource=${builddep_$2}
ihse@839 144 fi
ihse@839 145 if test "x$resource" != x; then
ihse@839 146 AC_MSG_NOTICE([Using builddeps $resource for $2])
ihse@839 147 # If the resource in the builddeps.conf file is an existing directory,
ihse@839 148 # for example /java/linux/cups
ihse@839 149 if test -d ${resource}; then
ihse@839 150 depdir=${resource}
ihse@839 151 else
ihse@839 152 BDEPS_FETCH($2, $resource, $with_builddeps_server, $with_builddeps_dir, depdir)
ihse@839 153 fi
ihse@839 154 # Source the builddeps file again, because in the previous command, the depdir
ihse@839 155 # was updated to point at the current build dependency install directory.
ihse@839 156 . $builddepsfile
ihse@839 157 # Now extract variables from the builddeps.conf files.
ihse@839 158 theroot=${builddep_$2_ROOT}
ihse@839 159 thecflags=${builddep_$2_CFLAGS}
ihse@839 160 thelibs=${builddep_$2_LIBS}
ihse@839 161 if test "x$depdir" = x; then
ihse@839 162 AC_MSG_ERROR([Could not download build dependency $2])
ihse@839 163 fi
ihse@839 164 $1=$depdir
ihse@839 165 if test "x$theroot" != x; then
ihse@839 166 $1="$theroot"
ihse@839 167 fi
ihse@839 168 if test "x$thecflags" != x; then
ihse@839 169 $1_CFLAGS="$thecflags"
ihse@839 170 fi
ihse@839 171 if test "x$thelibs" != x; then
ihse@839 172 $1_LIBS="$thelibs"
ihse@839 173 fi
ihse@839 174 m4_default([$4], [:])
ihse@839 175 m4_ifvaln([$5], [else $5])
ihse@839 176 fi
ihse@839 177 m4_ifvaln([$5], [else $5])
ihse@839 178 fi
ohair@425 179 ])
ohair@425 180
ohair@425 181 AC_DEFUN([BDEPS_FETCH],
ohair@425 182 [
ihse@839 183 # $1 is for example mymodule
ihse@839 184 # $2 is for example libs/general/libmymod_1_2_3.zip
ihse@839 185 # $3 is for example ftp://mybuilddeps.myserver.com/builddeps
ihse@839 186 # $4 is for example /localhome/builddeps
ihse@839 187 # $5 is the name of the variable into which we store the depdir, eg MYMOD
ihse@839 188 # Will download ftp://mybuilddeps.myserver.com/builddeps/libs/general/libmymod_1_2_3.zip and
ihse@839 189 # unzip into the directory: /localhome/builddeps/libmymod_1_2_3
ihse@839 190 filename=`basename $2`
ihse@839 191 filebase=`echo $filename | sed 's/\.[[^\.]]*$//'`
ihse@839 192 filebase=${filename%%.*}
ihse@839 193 extension=${filename#*.}
ihse@839 194 installdir=$4/$filebase
ihse@839 195 if test ! -f $installdir/$filename.unpacked; then
ihse@839 196 AC_MSG_NOTICE([Downloading build dependency $1 from $3/$2 and installing into $installdir])
ihse@839 197 if test ! -d $installdir; then
ihse@839 198 mkdir -p $installdir
ohair@425 199 fi
ihse@839 200 if test ! -d $installdir; then
ihse@839 201 AC_MSG_ERROR([Could not create directory $installdir])
ohair@425 202 fi
ihse@839 203 tmpfile=`mktemp $installdir/$1.XXXXXXXXX`
ihse@839 204 touch $tmpfile
ihse@839 205 if test ! -f $tmpfile; then
ihse@839 206 AC_MSG_ERROR([Could not create files in directory $installdir])
ihse@839 207 fi
ihse@839 208 BDEPS_FTPGET([$3/$2] , [$tmpfile])
ihse@839 209 mv $tmpfile $installdir/$filename
ihse@839 210 if test ! -s $installdir/$filename; then
ihse@839 211 AC_MSG_ERROR([Could not download $3/$2])
ihse@839 212 fi
ihse@839 213 case "$extension" in
ihse@839 214 zip) echo "Unzipping $installdir/$filename..."
ihse@839 215 (cd $installdir ; rm -f $installdir/$filename.unpacked ; $BDEPS_UNZIP $installdir/$filename > /dev/null && touch $installdir/$filename.unpacked)
ihse@839 216 ;;
ihse@839 217 tar.gz) echo "Untaring $installdir/$filename..."
ihse@839 218 (cd $installdir ; rm -f $installdir/$filename.unpacked ; tar xzf $installdir/$filename && touch $installdir/$filename.unpacked)
ihse@839 219 ;;
ihse@839 220 tgz) echo "Untaring $installdir/$filename..."
ihse@839 221 (cd $installdir ; rm -f $installdir/$filename.unpacked ; tar xzf $installdir/$filename && touch $installdir/$filename.unpacked)
ihse@839 222 ;;
ihse@839 223 *) AC_MSG_ERROR([Cannot handle build depency archive with extension $extension])
ihse@839 224 ;;
ihse@839 225 esac
ihse@839 226 fi
ihse@839 227 if test -f $installdir/$filename.unpacked; then
ihse@839 228 $5=$installdir
ihse@839 229 fi
ohair@425 230 ])
erikj@458 231
erikj@458 232 AC_DEFUN_ONCE([BDEPS_CONFIGURE_BUILDDEPS],
erikj@458 233 [
ihse@839 234 AC_ARG_WITH(builddeps-conf, [AS_HELP_STRING([--with-builddeps-conf],
ihse@839 235 [use this configuration file for the builddeps])])
erikj@458 236
ihse@839 237 AC_ARG_WITH(builddeps-server, [AS_HELP_STRING([--with-builddeps-server],
ihse@839 238 [download and use build dependencies from this server url])])
erikj@458 239
ihse@839 240 AC_ARG_WITH(builddeps-dir, [AS_HELP_STRING([--with-builddeps-dir],
ihse@839 241 [store downloaded build dependencies here @<:@/localhome/builddeps@:>@])],
ihse@839 242 [],
ihse@839 243 [with_builddeps_dir=/localhome/builddeps])
erikj@458 244
ihse@839 245 AC_ARG_WITH(builddeps-group, [AS_HELP_STRING([--with-builddeps-group],
ihse@839 246 [chgrp the downloaded build dependencies to this group])])
erikj@458 247 ])

mercurial