common/autoconf/builddeps.m4

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

mercurial