Mercurial > hg > octave-nkf > gnulib-hg
comparison gnulib-tool @ 7213:0f2957c42e86
Save the --local-dir value in the cache file.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 28 Aug 2006 15:14:35 +0000 |
parents | 232ee448d272 |
children | eb43edab28c3 |
comparison
equal
deleted
inserted
replaced
7212:232ee448d272 | 7213:0f2957c42e86 |
---|---|
20 # This program is meant for authors or maintainers which want to import | 20 # This program is meant for authors or maintainers which want to import |
21 # modules from gnulib into their packages. | 21 # modules from gnulib into their packages. |
22 | 22 |
23 progname=$0 | 23 progname=$0 |
24 package=gnulib | 24 package=gnulib |
25 cvsdatestamp='$Date: 2006-08-28 15:12:52 $' | 25 cvsdatestamp='$Date: 2006-08-28 15:14:35 $' |
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'` | 26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'` |
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'` | 27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'` |
28 | 28 |
29 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH. | 29 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH. |
30 AUTOCONFPATH= | 30 AUTOCONFPATH= |
247 rm -f "$2" | 247 rm -f "$2" |
248 ln -s "$1" "$2" | 248 ln -s "$1" "$2" |
249 fi | 249 fi |
250 } | 250 } |
251 | 251 |
252 # func_relativize DIR1 DIR2 | |
253 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2. | |
254 # Input: | |
255 # - DIR1 relative pathname, relative to the current directory | |
256 # - DIR2 relative pathname, relative to the current directory | |
257 # Output: | |
258 # - reldir relative pathname of DIR2, relative to DIR1 | |
259 func_relativize () | |
260 { | |
261 dir0=`pwd` | |
262 dir1="$1" | |
263 dir2="$2" | |
264 sed_first='s,^\([^/]*\)/.*$,\1,' | |
265 sed_rest='s,^[^/]*/*,,' | |
266 sed_last='s,^.*/\([^/]*\)$,\1,' | |
267 sed_butlast='s,/*[^/]*$,,' | |
268 while test -n "$dir1"; do | |
269 first=`echo "$dir1" | sed -e "$sed_first"` | |
270 if test "$first" != "."; then | |
271 if test "$first" = ".."; then | |
272 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2" | |
273 dir0=`echo "$dir0" | sed -e "$sed_butlast"` | |
274 else | |
275 first2=`echo "$dir2" | sed -e "$sed_first"` | |
276 if test "$first2" = "$first"; then | |
277 dir2=`echo "$dir2" | sed -e "$sed_rest"` | |
278 else | |
279 dir2="../$dir2" | |
280 fi | |
281 dir0="$dir0"/"$first" | |
282 fi | |
283 fi | |
284 dir1=`echo "$dir1" | sed -e "$sed_rest"` | |
285 done | |
286 reldir="$dir2" | |
287 } | |
288 | |
289 # func_relconcat DIR1 DIR2 | |
290 # computes a relative pathname DIR1/DIR2, with obvious simplifications. | |
291 # Input: | |
292 # - DIR1 relative pathname, relative to the current directory | |
293 # - DIR2 relative pathname, relative to DIR1 | |
294 # Output: | |
295 # - relconcat DIR1/DIR2, relative to the current directory | |
296 func_relconcat () | |
297 { | |
298 dir1="$1" | |
299 dir2="$2" | |
300 sed_first='s,^\([^/]*\)/.*$,\1,' | |
301 sed_rest='s,^[^/]*/*,,' | |
302 sed_last='s,^.*/\([^/]*\)$,\1,' | |
303 sed_butlast='s,/*[^/]*$,,' | |
304 while true; do | |
305 first=`echo "$dir2" | sed -e "$sed_first"` | |
306 if test "$first" = "."; then | |
307 dir2=`echo "$dir2" | sed -e "$sed_rest"` | |
308 if test -z "$dir2"; then | |
309 relconcat="$dir1" | |
310 break | |
311 fi | |
312 else | |
313 last=`echo "$dir1" | sed -e "$sed_last"` | |
314 while test "$last" = "."; do | |
315 dir1=`echo "$dir1" | sed -e "$sed_butlast"` | |
316 last=`echo "$dir1" | sed -e "$sed_last"` | |
317 done | |
318 if test -z "$dir1"; then | |
319 relconcat="$dir2" | |
320 break | |
321 fi | |
322 if test "$first" = ".."; then | |
323 if test "$last" = ".."; then | |
324 relconcat="$dir1/$dir2" | |
325 break | |
326 fi | |
327 dir1=`echo "$dir1" | sed -e "$sed_butlast"` | |
328 dir2=`echo "$dir2" | sed -e "$sed_rest"` | |
329 if test -z "$dir1"; then | |
330 relconcat="$dir2" | |
331 break | |
332 fi | |
333 if test -z "$dir2"; then | |
334 relconcat="$dir1" | |
335 break | |
336 fi | |
337 else | |
338 relconcat="$dir1/$dir2" | |
339 break | |
340 fi | |
341 fi | |
342 done | |
343 } | |
344 | |
252 # Command-line option processing. | 345 # Command-line option processing. |
253 # Removes the OPTIONS from the arguments. Sets the variables: | 346 # Removes the OPTIONS from the arguments. Sets the variables: |
254 # - mode list or import or create-testdir or create-megatestdir | 347 # - mode list or import or create-testdir or create-megatestdir |
255 # - destdir from --dir | 348 # - destdir from --dir |
256 # - libname, supplied_libname from --lib | 349 # - libname, supplied_libname from --lib |
466 echo "Try 'gnulib-tool --help' for more information." 1>&2 | 559 echo "Try 'gnulib-tool --help' for more information." 1>&2 |
467 echo "If you really want to modify the gnulib configuration of your project," 1>&2 | 560 echo "If you really want to modify the gnulib configuration of your project," 1>&2 |
468 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2 | 561 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2 |
469 exit 1 | 562 exit 1 |
470 fi | 563 fi |
471 if test -n "$supplied_libname" || test -n "$sourcebase" || test -n "$m4base" \ | 564 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \ |
565 || test -n "$sourcebase" || test -n "$m4base" \ | |
472 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \ | 566 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \ |
473 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \ | 567 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \ |
474 || test -n "$macro_prefix"; then | 568 || test -n "$macro_prefix"; then |
475 echo "gnulib-tool: invalid options for 'update' mode" 1>&2 | 569 echo "gnulib-tool: invalid options for 'update' mode" 1>&2 |
476 echo "Try 'gnulib-tool --help' for more information." 1>&2 | 570 echo "Try 'gnulib-tool --help' for more information." 1>&2 |
531 esac | 625 esac |
532 | 626 |
533 # Remove trailing slashes from the directory names. This is necessary for | 627 # Remove trailing slashes from the directory names. This is necessary for |
534 # m4base (to avoid an error in func_import) and optional for the others. | 628 # m4base (to avoid an error in func_import) and optional for the others. |
535 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,' | 629 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,' |
630 case "$local_gnulib_dir" in | |
631 */ ) sourcebase=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;; | |
632 esac | |
536 case "$sourcebase" in | 633 case "$sourcebase" in |
537 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;; | 634 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;; |
538 esac | 635 esac |
539 case "$m4base" in | 636 case "$m4base" in |
540 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;; | 637 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;; |
1076 # - doit : if actions shall be executed, false if only to be printed | 1173 # - doit : if actions shall be executed, false if only to be printed |
1077 # - symbolic true if files should be symlinked, copied otherwise | 1174 # - symbolic true if files should be symlinked, copied otherwise |
1078 func_import () | 1175 func_import () |
1079 { | 1176 { |
1080 # Get the cached settings. | 1177 # Get the cached settings. |
1178 cached_local_gnulib_dir= | |
1081 cached_specified_modules= | 1179 cached_specified_modules= |
1082 cached_avoidlist= | 1180 cached_avoidlist= |
1083 cached_sourcebase= | 1181 cached_sourcebase= |
1084 cached_m4base= | 1182 cached_m4base= |
1085 cached_docbase= | 1183 cached_docbase= |
1093 cached_libtool=false | 1191 cached_libtool=false |
1094 my_sed_traces=' | 1192 my_sed_traces=' |
1095 s,#.*$,, | 1193 s,#.*$,, |
1096 s,^dnl .*$,, | 1194 s,^dnl .*$,, |
1097 s, dnl .*$,, | 1195 s, dnl .*$,, |
1196 /gl_LOCAL_DIR(/ { | |
1197 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p | |
1198 } | |
1098 /gl_MODULES(/ { | 1199 /gl_MODULES(/ { |
1099 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p | 1200 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p |
1100 } | 1201 } |
1101 /gl_AVOID(/ { | 1202 /gl_AVOID(/ { |
1102 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p | 1203 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p |
1151 # Merge the cached settings with the specified ones. | 1252 # Merge the cached settings with the specified ones. |
1152 # The m4base must be the same as expected from the pathname. | 1253 # The m4base must be the same as expected from the pathname. |
1153 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then | 1254 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then |
1154 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])" | 1255 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])" |
1155 fi | 1256 fi |
1257 # The local_gnulib_dir defaults to the cached one. Recall that the cached one | |
1258 # is relative to $destdir, whereas the one we use is relative to . or absolute. | |
1259 if test -z "$local_gnulib_dir"; then | |
1260 if test -n "$cached_local_gnulib_dir"; then | |
1261 case "$destdir" in | |
1262 /*) | |
1263 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;; | |
1264 *) | |
1265 case "$cached_local_gnulib_dir" in | |
1266 /*) | |
1267 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;; | |
1268 *) | |
1269 func_relconcat "$destdir" "$cached_local_gnulib_dir" | |
1270 local_gnulib_dir="$relconcat" ;; | |
1271 esac ;; | |
1272 esac | |
1273 fi | |
1274 fi | |
1156 # Append the cached and the specified module names. So that | 1275 # Append the cached and the specified module names. So that |
1157 # "gnulib-tool --import foo" means to add the module foo. | 1276 # "gnulib-tool --import foo" means to add the module foo. |
1158 specified_modules="$cached_specified_modules $1" | 1277 specified_modules="$cached_specified_modules $1" |
1159 # Append the cached and the specified avoidlist. This is probably better | 1278 # Append the cached and the specified avoidlist. This is probably better |
1160 # than dropping the cached one when --avoid is specified at least once. | 1279 # than dropping the cached one when --avoid is specified at least once. |
1452 done | 1571 done |
1453 | 1572 |
1454 # Command-line invocation printed in a comment in generated gnulib-cache.m4. | 1573 # Command-line invocation printed in a comment in generated gnulib-cache.m4. |
1455 actioncmd="gnulib-tool --import" | 1574 actioncmd="gnulib-tool --import" |
1456 actioncmd="$actioncmd --dir=$destdir" | 1575 actioncmd="$actioncmd --dir=$destdir" |
1576 if test -n "$local_gnulib_dir"; then | |
1577 actioncmd="$actioncmd --local-dir=$local_gnulib_dir" | |
1578 fi | |
1457 actioncmd="$actioncmd --lib=$libname" | 1579 actioncmd="$actioncmd --lib=$libname" |
1458 actioncmd="$actioncmd --source-base=$sourcebase" | 1580 actioncmd="$actioncmd --source-base=$sourcebase" |
1459 actioncmd="$actioncmd --m4-base=$m4base" | 1581 actioncmd="$actioncmd --m4-base=$m4base" |
1460 actioncmd="$actioncmd --doc-base=$docbase" | 1582 actioncmd="$actioncmd --doc-base=$docbase" |
1461 actioncmd="$actioncmd --aux-dir=$auxdir" | 1583 actioncmd="$actioncmd --aux-dir=$auxdir" |
1512 echo | 1634 echo |
1513 echo "# Specification in the form of a command-line invocation:" | 1635 echo "# Specification in the form of a command-line invocation:" |
1514 echo "# $actioncmd" | 1636 echo "# $actioncmd" |
1515 echo | 1637 echo |
1516 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:" | 1638 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:" |
1639 # Store the local_gnulib_dir relative to destdir. | |
1640 case "$local_gnulib_dir" in | |
1641 "" | /*) | |
1642 relative_local_gnulib_dir="$local_gnulib_dir" ;; | |
1643 * ) | |
1644 case "$destdir" in | |
1645 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;; | |
1646 *) | |
1647 # destdir, local_gnulib_dir are both relative. | |
1648 func_relativize "$destdir" "$local_gnulib_dir" | |
1649 relative_local_gnulib_dir="$reldir" ;; | |
1650 esac ;; | |
1651 esac | |
1652 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])" | |
1517 echo "gl_MODULES(["`echo $specified_modules`"])" | 1653 echo "gl_MODULES(["`echo $specified_modules`"])" |
1518 echo "gl_AVOID([$avoidlist])" | 1654 echo "gl_AVOID([$avoidlist])" |
1519 echo "gl_SOURCE_BASE([$sourcebase])" | 1655 echo "gl_SOURCE_BASE([$sourcebase])" |
1520 echo "gl_M4_BASE([$m4base])" | 1656 echo "gl_M4_BASE([$m4base])" |
1521 echo "gl_DOC_BASE([$docbase])" | 1657 echo "gl_DOC_BASE([$docbase])" |