updates.
[autodist.git] / apps / autodist / autodist.in
index 27e6c22247dc15ee1b04c3fd2a7ad71919c88bfa..00a7c95585758eb15c37a833aed072c34ef7c744 100755 (executable)
@@ -74,11 +74,13 @@ excludes=
 # All noprocesses
 noprocess=
 
-# All pre, post pre-dist and post-dist hooks
+# All hooks
 pre_hooks=
 post_hooks=
 pre_dist_hooks=
 post_dist_hooks=
+pre_p_dist_hooks=
+post_p_dist_hooks=
 
 # Distribution license and license header
 license=
@@ -212,9 +214,10 @@ ad_create_distdefs_h()
 #
 ad_make_configure()
 {
-  ad_debug ">ad_make_configure"
   local run_autoconf=false
 
+  ad_debug ">ad_make_configure"
+
   rm -f configure
 
   if test "$ACLOCAL"; then
@@ -268,13 +271,15 @@ ad_make_configure()
 #
 ad_make_configure_ac()
 {
+  local check
+
   ad_debug ">ad_make_configure_ac: $1"
 
   if test '!' -f $1; then
     ad_fatal "The configure file '$1' does not exist"
   fi
 
-  local check="`cat $1 | sed 's/^[     ]*//' | grep -v "^#" | grep -e "AD_INIT"`"
+  check="`cat $1 | sed 's/^[   ]*//' | grep -v "^#" | grep -e "AD_INIT"`"
   if test -z $check; then
     rm -f configure.ad.cfs
     rm -f $fname $fname.tmp
@@ -294,7 +299,7 @@ ad_make_configure_ac()
   done
 
   if test -f configure.ad.cfs; then
-    local check="`cat $1 | sed 's/^[   ]*//' | grep -v "^#" | grep -e "AD_INCLUDE_CONFIGURE"`"
+    check="`cat $1 | sed 's/^[         ]*//' | grep -v "^#" | grep -e "AD_INCLUDE_CONFIGURE"`"
     if test -z $check; then
       rm -f configure.ad.cfs
       ad_warning "configure.ad fragments found but 'AD_INCLUDE_CONFIGURE' is not set"
@@ -304,9 +309,9 @@ ad_make_configure_ac()
   # Header for configure.ac
   fname="configure.tmp.ac"
   echo "# Automatically generated by Autodist $ver.  Do not edit." > $fname
-  echo "# To make changes edit the $i file in the source tree." >> $fname
+  echo "# To make changes edit the configure.ad file in the source tree." >> $fname
   echo >> $fname
-  echo "# Source: $i" >> $fname
+  echo "# Source: configure.ad" >> $fname
   echo "# Generated: `date` by `whoami`" >> $fname
   echo "# Distribution: $distribution" >> $fname
   echo "# License: $license" >> $fname
@@ -453,13 +458,15 @@ ad_process_ads()
 #
 ad_dist_includes()
 {
+  local incs
+
   ad_debug ">ad_dist_includes: $1 $2"
 
   # By default do not expand pathnames
   set -f
 
   # Add : separator at the end
-  local incs="`echo "$1" | sed 's/$/ : /'`"
+  incs="`echo "$1" | sed 's/$/ : /'`"
 
   src=
   dst=
@@ -784,6 +791,9 @@ ad_makedist()
     ad_fatal "The '$distribution' distribution cannot be packaged"
   fi
 
+  # Run pre-dist-hooks
+  ad_run_dist_hooks "$pre_dist_hooks"
+
   # Create distribution directory
   ad_debug "Creating distribution directory $am_distdir"
   $MAKE distdir || exit 1
@@ -793,8 +803,8 @@ ad_makedist()
     ad_fatal "Distribution directory $am_distdir not created"
   fi
 
-  # Run pre-dist-hooks
-  ad_run_dist_hooks "$pre_dist_hooks"
+  # Run pre-process-dist-hooks
+  ad_run_dist_hooks "$pre_p_dist_hooks"
 
   # Run excludes
   ad_dist_excludes "$excludes"
@@ -818,8 +828,8 @@ ad_makedist()
   ad_debug "Process distribution tree"
   ad_process_tree $am_distdir
 
-  # Run post-dist-hooks
-  ad_run_dist_hooks "$post_dist_hooks"
+  # Run post-process_dist-hooks
+  ad_run_dist_hooks "$post_p_dist_hooks"
 
   # Make distribution sane
   ad_makedist_makesane
@@ -845,6 +855,9 @@ ad_makedist()
   fi
   rm -f $am_distdir.tar
 
+  # Run post-dist-hooks
+  ad_run_dist_hooks "$post_dist_hooks"
+
   # Cleanup
   rm -rf $am_distdir
   rm -f autodist.noprocess
@@ -912,6 +925,23 @@ ad_clear_options()
 #
 ad_parse_distribution()
 {
+  local inhs
+  local defs
+  local undefs
+  local incs
+  local excs
+  local nops
+  local opts
+  local dname
+  local dpname
+  local bugr
+  local prh
+  local poh
+  local prdh
+  local podh
+  local prpdh
+  local popdh
+
   ad_debug ">ad_parse_distribution: $1 $2"
 
   if test '!' -f $distdir/$1; then
@@ -919,11 +949,11 @@ ad_parse_distribution()
   fi
 
   # Get inherited
-  local inhs=`cat $distdir/$1 | sed 's/^[      ]*//' | grep -v "^#" \
+  inhs=`cat $distdir/$1 | sed 's/^[    ]*//' | grep -v "^#" \
     | grep "inherit " | cut -d' ' -f2 | sort | uniq`
 
   # Get distdefs
-  local defs=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  defs=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
    | grep "define " | cut -d' ' -f2 | sort | uniq`
 
   if test "$inhs" = "" && test "$defs" = ""; then
@@ -931,23 +961,23 @@ ad_parse_distribution()
   fi
 
   # Get undefined distdefs
-  local undefs=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  undefs=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
    | grep "undef " | cut -d' ' -f2 | sort | uniq`
 
   # Get includes
-  local incs=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  incs=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
     | grep "include " | sed 's/include / : /'`
 
   # Get excludes
-  local excs=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  excs=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
     | grep "exclude " | cut -d' ' -f2- | sort | uniq`
 
   # Get noprocesses
-  local nops=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  nops=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
     | grep "noprocess " | cut -d' ' -f2- | sort | uniq`
 
   # Get options
-  local opts=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  opts=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
     | grep "option " | cut -d' ' -f2- | sort | uniq`
 
   # Check options
@@ -994,7 +1024,7 @@ ad_parse_distribution()
 
   if test x$2 = xfalse; then
     # Get distribution name
-    local dname=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+    dname=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
       | grep "name " | cut -d' ' -f2-`
 
     if test "$dname"; then
@@ -1002,7 +1032,7 @@ ad_parse_distribution()
     fi
 
     # Get distribution package name (optional)
-    local dpname=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+    dpname=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
      | grep "package " | cut -d' ' -f2`
 
     if test "$dpname"; then
@@ -1012,7 +1042,7 @@ ad_parse_distribution()
     fi
 
     # Get Bug-report email address (optional)
-    local bugr=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+    bugr=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
      | grep "bug-report " | cut -d' ' -f2-`
 
     if test "$bugr"; then
@@ -1024,19 +1054,25 @@ ad_parse_distribution()
     ad_debug "bug-report=$bug_report"
 
     # Get hooks (optional)
-    local prh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+    prh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
      | grep "pre-hook " | cut -d' ' -f2-`
-    local poh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+    poh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
      | grep "post-hook " | cut -d' ' -f2-`
-    local prdh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+    prdh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
      | grep "pre-dist-hook " | sed 's/^[       ]*//' | cut -d' ' -f2-`
-    local podh=`cat $distdir/$1 | grep -v "^#" \
+    podh=`cat $distdir/$1 | grep -v "^#" \
      | grep "post-dist-hook " | sed 's/^[       ]*//' | cut -d' ' -f2-`
+    prpdh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+     | grep "pre-process-dist-hook " | sed 's/^[       ]*//' | cut -d' ' -f2-`
+    popdh=`cat $distdir/$1 | grep -v "^#" \
+     | grep "post-process-dist-hook " | sed 's/^[       ]*//' | cut -d' ' -f2-`
 
     pre_hooks="$pre_hooks $prh"
     post_hooks="$post_hooks $poh"
     pre_dist_hooks="$pre_dist_hooks $prdh"
     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"
 
     ad_handle_options "$options"
@@ -1147,11 +1183,11 @@ ad_process_license_header()
 #
 ad_process_noprocess()
 {
-  ad_debug ">ad_process_noprocess"
   local np=false
-
   local n="sed "
 
+  ad_debug ">ad_process_noprocess"
+
   for i in $noprocess
   do
     # Escape
@@ -1177,6 +1213,9 @@ ad_process_noprocess()
 ad_process_file()
 {
   local found=false
+  local f
+  local defs
+  local ndefs
 
   # Process only regular files
   if test '!' -f $1; then
@@ -1185,7 +1224,7 @@ ad_process_file()
 
   ad_debug ">ad_process_file: $1 $2"
 
-  local f="autodist.tmp.script"
+  f="autodist.tmp.script"
   rm -f $f
 
   # If license header is provided, replace the license header in the file.
@@ -1194,11 +1233,11 @@ ad_process_file()
   ad_debug "Getting #ifdef's and #ifndef's"
 
   # Get defined distribution defines
-  local defs=`awk "/^#ifdef "$DP"_DIST_|^#else "$DP"_DIST_/ { print; }" \
+  defs=`awk "/^#ifdef "$DP"_DIST_|^#else "$DP"_DIST_/ { print; }" \
     $1 |cut -d'*' -f2 |cut -d' ' -f2 | sort | uniq`
 
   # Get explicitly not-defined distribution defines
-  local ndefs=`awk "/^#ifndef "$DP"_DIST_|^#else !"$DP"_DIST_/ { print; }" \
+  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"
@@ -1279,6 +1318,9 @@ ad_process_file()
 ad_process_source_file()
 {
   local found=false
+  local f
+  local defs
+  local ndefs
 
   # Process only regular files
   if test '!' -f $1; then
@@ -1287,7 +1329,7 @@ ad_process_source_file()
 
   ad_debug ">ad_process_source_file: $1 $2"
 
-  local f="autodist.tmp.script"
+  f="autodist.tmp.script"
   rm -f $f
 
   # If license header is provided, replace the license header in the file.
@@ -1296,11 +1338,11 @@ ad_process_source_file()
   ad_debug "Getting #ifdef's and #ifndef's"
 
   # Get defined distribution defines
-  local defs=`awk '/^#ifdef SILC_DIST_|^#else \/\* SILC_DIST_/ { print; }' \
+  defs=`awk '/^#ifdef SILC_DIST_|^#else \/\* SILC_DIST_/ { print; }' \
     $1 |cut -d'*' -f2 |cut -d' ' -f2 | sort | uniq`
 
   # Get explicitly not-defined distribution defines
-  local ndefs=`awk '/^#ifndef SILC_DIST_|^#else \/\* \!SILC_DIST_/ { print; }' \
+  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"
@@ -1568,6 +1610,11 @@ ad_make_makefile_ams
 #
 ad_make_configure_ac ./configure.ad
 
+#
+# Process all files with .ad suffix for distribution processing
+#
+ad_process_ads
+
 #
 # Generate configure script
 #
@@ -1578,11 +1625,6 @@ ad_make_configure
 #
 ad_make_makefile_ins
 
-#
-# Process all files with .ad suffix for distribution processing
-#
-ad_process_ads
-
 #
 # Create autodist.dist
 #