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