updates.
[autodist.git] / apps / autodist / autodist.in
index 26f91c582e4c177a35bde154fc7ae0735393ffaa..b16f696bf61307b3fd041dc9744bbbdd2a6ebeea 100755 (executable)
@@ -35,7 +35,7 @@
 
 # Be Bourne compatible
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-  # XXX We actually may not work on zsh
+  # Despite of this, we have managed to segfault some zsh's.
   emulate sh
   NULLCMD=:
   # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
@@ -101,7 +101,7 @@ distdefs=
 undistdefs=
 
 # All distribution options
-options=
+doptions=
 opt_template=false
 opt_no_dist=false
 opt_no_inherit=false
@@ -263,7 +263,11 @@ ad_make_configure()
 
   if test "$ACLOCAL"; then
     ad_debug "Running aclocal"
-    $ACLOCAL 1>/dev/null 2>/dev/null
+    if test x$debug = xtrue; then
+      $ACLOCAL
+    else
+      $ACLOCAL 1>/dev/null 2>/dev/null
+    fi
     if test $? != 0; then
       ad_fatal "aclocal failed"
     fi
@@ -376,7 +380,7 @@ ad_make_configure_ac()
 
   # Remove any trailing backslashes
   if test -f "$fname"; then
-    cat $fname | sed -e :a -e '/\\$/N; s/\\\n//; ta' > configure.ac
+    cat $fname | sed -e :a -e '/\\$/N; s/[     ]*\\\n//; ta' > configure.ac
   else
     cp -p $fname.tmp configure.ac
   fi
@@ -437,7 +441,7 @@ ad_make_makefile_ams()
 
     # Remove any trailing backslashes
     if test -f "$fname.tmp"; then
-      cat $fname.tmp | sed -e :a -e '/\\$/N; s/\\\n//; ta' >> $fname.am
+      cat $fname.tmp | sed -e :a -e '/\\$/N; s/[       ]*\\\n//; ta' >> $fname.am
     else
       cat $ff >> $fname.am
     fi
@@ -778,7 +782,7 @@ ad_makedist_makesane()
     ad_fatal "Makefile: No such file or directory"
   fi
 
-  configh=`grep "^CONFIG_HEADER" Makefile | cut -d= -f2 | sed 's/^[ \t]//'`
+  configh=`grep "^CONFIG_HEADER" Makefile | cut -d= -f2 | sed 's/^[    ]*//'`
   touch $am_distdir/$configh.in 1>/dev/null 2>/dev/null
 
   files=`find $am_distdir -name Makefile\.in`
@@ -822,11 +826,11 @@ ad_makedist()
   fi
 
   # Parse the requested distribution
-  distribution=`cat autodist.dist | grep "dist:" | cut -d: -f2`
-  dist_version=`cat autodist.dist | grep "ver:" | cut -d: -f2`
+  distribution=`cat autodist.dist | grep "dist:" | cut -d: -f2` || exit 1
+  dist_version=`cat autodist.dist | grep "ver:" | cut -d: -f2` || exit 1
+  am_distdir=`cat autodist.dist | grep "distdir:" | cut -d: -f2` || exit 1
   ad_parse_distribution $distribution false
   ad_process_distdefs
-  am_distdir="$package-$dist_version"
 
   if test x$opt_no_dist = xtrue; then
     ad_fatal "The '$distribution' distribution cannot be packaged"
@@ -1030,13 +1034,13 @@ ad_parse_distribution()
     ad_fatal "Template distribution '$1' cannot be prepared or packaged"
   fi
 
-  ad_debug "inherits=$inhs"
-  ad_debug "distdefs=$defs"
-  ad_debug "includes=$incs"
-  ad_debug "excludes=$excs"
-  ad_debug "noprocess=$nops"
-  ad_debug "undistdefs=$undefs"
-  ad_debug "options=$opts"
+  ad_debug "inherits$inhs"
+  ad_debug "distdefs$defs"
+  ad_debug "includes$incs"
+  ad_debug "excludes$excs"
+  ad_debug "noprocess$nops"
+  ad_debug "undistdefs$undefs"
+  ad_debug "options$opts"
 
   # Expand distdefs from inherited distributions
   for i in $inhs
@@ -1060,8 +1064,8 @@ ad_parse_distribution()
   licenseh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
     | grep "license-header " | sed 's/license-header / : /'`
 
-  ad_debug "license=$license"
-  ad_debug "licenseh=$licenseh"
+  ad_debug "license$license"
+  ad_debug "licenseh$licenseh"
 
   if test x$2 = xfalse; then
     # Get distribution name
@@ -1090,9 +1094,9 @@ ad_parse_distribution()
       bug_report=$bugr
     fi
 
-    ad_debug "distribution=$distribution"
-    ad_debug "package=$package"
-    ad_debug "bug-report=$bug_report"
+    ad_debug "distribution$distribution"
+    ad_debug "package$package"
+    ad_debug "bug-report$bug_report"
 
     # Get hooks (optional)
     prh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
@@ -1114,10 +1118,10 @@ ad_parse_distribution()
     post_dist_hooks="$post_dist_hooks $podh"
     pre_p_dist_hooks="$pre_p_dist_hooks $prpdh"
     post_p_dist_hooks="$post_p_dist_hooks $popdh"
-    options="$options $opts"
+    doptions="$doptions $opts"
 
-    ad_handle_options "$options"
-    ad_debug "options=$options"
+    ad_handle_options "$doptions"
+    ad_debug "options: $doptions"
   fi
 
   # Return to caller
@@ -1148,8 +1152,7 @@ ad_process_distdefs()
     distdefs=`echo $distdefs | sed s/$i//`
   done
 
-  rm -f autodist.tmp.defs autodist.pre.hooks autodist.post.hooks
-  rm -f autodist.pre.dist.hooks autodist.post.dist.hooks
+  rm -f autodist.tmp.defs
 
   # Remove duplicate distdefs
   for i in $distdefs
@@ -1281,8 +1284,8 @@ ad_process_file()
   ndefs=`awk "/^#ifndef "$DP"_DIST_|^#else !"$DP"_DIST_/ { print; }" \
     $1 |cut -d'*' -f2 |cut -d' ' -f2 | cut -d'!' -f2 | sort | uniq`
 
-  ad_debug "defs=$defs"
-  ad_debug "ndefs=$ndefs"
+  ad_debug "defs in $1: $defs"
+  ad_debug "ndefs in $1: $ndefs"
 
   # Create the script to include and exclude stuff in the file according
   # to the distribution defines
@@ -1386,7 +1389,8 @@ ad_process_source_file()
   ndefs=`awk '/^#ifndef SILC_DIST_|^#else \/\* \!SILC_DIST_/ { print; }' \
     $1 |cut -d'*' -f2 |cut -d' ' -f2 | cut -d'!' -f2 | sort | uniq`
 
-  ad_debug "defs=$defs ndefs=$ndefs"
+  ad_debug "defs in $1: $defs"
+  ad_debug "ndefs in $1: $ndefs"
 
   # Create the script to include and exclude stuff in the file according
   # to the distribution defines
@@ -1469,7 +1473,7 @@ ad_run_hooks()
     if test '!' -f $i; then
       ad_fatal "Hook script $i does not exist"
     fi
-    sh $i $distribution $dist_version $package || exit 1
+    sh $i "$distribution" "$dist_version" "$package" || exit 1
   done
 
   ad_debug "<ad_run_hooks: $1"
@@ -1489,7 +1493,7 @@ ad_run_dist_hooks()
     if test '!' -f $i; then
       ad_fatal "Dist hook script $i does not exist"
     fi
-    sh $i $distribution $dist_version $package $am_distdir || exit 1
+    sh $i "$distribution" "$dist_version" "$package" "$am_distdir" || exit 1
   done
 
   ad_debug "<ad_run_dist_hooks: $1"
@@ -1672,7 +1676,7 @@ ad_make_makefile_ins
 ad_debug "Creating autodist.dist"
 echo "dist:$distfile" > autodist.dist
 echo "ver:$dist_version" >> autodist.dist
-echo "$package-$dist_version" >> autodist.dist
+echo "distdir:$package-$dist_version" >> autodist.dist
 
 #
 # Run post-hooks