.in with source files expect source code format for distdefs.
[autodist.git] / apps / autodist / autodist.in
index 099b9abd3a4323ebc948a312b54bc7ca7ebdf782..9740828591bfd6c3eaf25c156dc8695227db0c9a 100755 (executable)
@@ -474,18 +474,6 @@ ad_process_ads()
   do
     fname=`echo $i | sed s/\.ad//`
 
-    # Header
-  cat > $fname <<EOF
-# Automatically generated by Autodist $ver.  Do not edit.
-# To make changes edit the $i file in the source tree.
-
-# Source: $i
-# Generated: `date` by `whoami`
-# Distribution: $distribution
-# License: $license
-
-EOF
-
     # Run the distribution processing for this file
     ad_debug "Processing $i to be $fname"
     ad_process_file $i $fname
@@ -700,16 +688,29 @@ ad_process_tree()
 {
   ad_debug ">ad_process_tree: $1"
 
-  # We take all files, other than *.ad, including source files, in case
-  # they use the non-C-compiler-friendly format of distdefs, which is
-  # possible.
-
-  files=`find $am_distdir \! -name \*\.ad`
+  # Take files, except source and .ad files.
+  files=`find $am_distdir \! -name \*\.ad \( \
+       \! -name \*\.[cC] -a \
+       \! -name \*\.[cC][cCpP] -a \
+       \! -name \*\.[cC][xX][xX] -a \
+       \! -name \*\.[cC][pP][pP] -a \
+       \! -name \*\.[cC]++ -a \
+       \! -name \*\.m -a \
+       \! -name \*\.[hH] -a \
+       \! -name \*\.hh -a \
+       \! -name \*\.[cC]\.in -a \
+       \! -name \*\.[cC][cCpP]\.in -a \
+       \! -name \*\.[cC][xX][xX]\.in -a \
+       \! -name \*\.[cC][pP][pP]\.in -a \
+       \! -name \*\.[cC]++\.in -a \
+       \! -name \*\.m\.in -a \
+       \! -name \*\.[hH]\.in -a \
+       \! -name \*\.hh\.in \)`
   files=`echo $files | sed 's/$am_distdir//'`
 
   # Take away noprocess list
   if test -f autodist.noprocess; then
-    files=`echo $files | sh autodist.noprocess` || exit 1
+    files=`echo $files" " | sh autodist.noprocess` || exit 1
   fi
 
   for ff in $files
@@ -749,11 +750,19 @@ ad_process_source_tree()
        -name \*\.[cC]++ -o \
        -name \*\.m -o \
        -name \*\.[hH] -o \
-       -name \*\.hh \)`
+       -name \*\.hh -o \
+       -name \*\.[cC]\.in -o \
+       -name \*\.[cC][cCpP]\.in -o \
+       -name \*\.[cC][xX][xX]\.in -o \
+       -name \*\.[cC][pP][pP]\.in -o \
+       -name \*\.[cC]++\.in -o \
+       -name \*\.m\.in -o \
+       -name \*\.[hH]\.in -o \
+       -name \*\.hh\.in \)`
 
   # Take away noprocess list
   if test -f autodist.noprocess; then
-    files=`echo $files | sh autodist.noprocess` || exit 1
+    files=`echo $files" " | sh autodist.noprocess` || exit 1
   fi
 
   for ff in $files
@@ -1077,6 +1086,16 @@ ad_parse_distribution()
   ad_debug "licenseh: $licenseh"
 
   if test x$2 = xfalse; then
+    # Take rest of the stuff from top distribution
+
+    # We take precedence on defined and undefined distdefs.  Remove
+    # undefined distdefs if we have defined them.
+    for d in $defs
+    do
+      ad_debug "defining undefined $d distdef"
+      undistdefs=`echo $undistdefs | sed s/$d//g`
+    done
+
     # Get distribution name
     dname=`sed 's/^[   ]*//' < $distdir/$1 | grep -v "^#" \
       | grep "name " | cut -d' ' -f2-`
@@ -1158,7 +1177,7 @@ ad_process_distdefs()
   for i in $undistdefs
   do
     ad_debug "undefining $i distdef"
-    distdefs=`echo $distdefs | sed s/$i//`
+    distdefs=`echo $distdefs | sed s/$i//g`
   done
 
   rm -f autodist.tmp.defs
@@ -1241,14 +1260,17 @@ ad_process_noprocess()
 
   ad_debug ">ad_process_noprocess"
 
+  cur=`pwd`
+  cd $am_distdir || exit 1
   for i in $noprocess
   do
     # Escape
     ie=`echo $i | sed 's/\\//\\\\\//g'` || exit 1
 
-    n="$n -e 's/$am_distdir\\/$ie//'"
+    n="$n -e 's/$am_distdir\\/$ie //'"
     np=true
   done
+  cd $cur || exit 1
 
   rm -f autodist.noprocess
   if test x$np = xtrue; then
@@ -1560,7 +1582,10 @@ while test $# -gt 0; do
     fi
     ad_process_distdefs
     echo "Distdefs:" 1>&2;
-    echo "${distdefs}";
+    for i in $distdefs
+    do
+      echo "$i";
+    done
     exit 0;;
 
   -i | --init)