Added AD_ENABLE_DEPENDENCIES to support Autodist dependencies in
authorPekka Riikonen <priikone@silcnet.org>
Sun, 1 May 2005 15:06:09 +0000 (15:06 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 1 May 2005 15:06:09 +0000 (15:06 +0000)
makefiles.
Added -p option.

apps/autodist/CHANGES
apps/autodist/autodist.in
apps/autodist/doc/autodist.1.in
apps/autodist/doc/autodist.texi
apps/autodist/tests/autodist7.test [new file with mode: 0755]

index 28e853bf586d7133cc2ad9665011a928d286fb6b..959fe07e0d5920861eba13a915d2eb2fce08a7c5 100644 (file)
@@ -1,3 +1,11 @@
+Sun May  1 12:31:55 EEST 2005 Pekka Riikonen <priikone@silcnet.org>
+
+       * Added AD_ENABLE_DEPENDENCIES macro to enable Autodist
+         dependencies in makefiles.
+
+       * Added -p option to Autodist.  It can be used to a process file
+         from the command line.
+
 Sat Apr 30 17:49:05 EEST 2005 Pekka Riikonen <priikone@silcnet.org>
 
        * The 'noprocess' directive now works recursively with
 Sat Apr 30 17:49:05 EEST 2005 Pekka Riikonen <priikone@silcnet.org>
 
        * The 'noprocess' directive now works recursively with
index f45ac7ccb337fc19d1e715f7b632f83d6416e5b9..c18051dd3a6c7eb39aa038cea7e55dc368a3dd57 100755 (executable)
@@ -129,6 +129,7 @@ licenseh=
 
 # Whether to output ad_debug information
 debug=false
 
 # Whether to output ad_debug information
 debug=false
+nolog=false
 
 # Autodist version
 ver=@VERSION@
 
 # Autodist version
 ver=@VERSION@
@@ -210,7 +211,9 @@ EOF
 #
 ad_log()
 {
 #
 ad_log()
 {
-  echo "$1" >&5
+  if test x$nolog = xfalse; then
+    echo "$1" >&5
+  fi
 }
 
 #
 }
 
 #
@@ -405,8 +408,8 @@ EOF
 
   ad_debug "creating configure.ac"
   if test -f configure.ad.cfs; then
 
   ad_debug "creating configure.ac"
   if test -f configure.ad.cfs; then
-    sed '/AD_INCLUDE_CONFIGURE/ r configure.ad.cfs' $1 > $fname.tmp
-    sed -e "/AD_INCLUDE_CONFIGURE/s///" $fname.tmp >> $fname
+    sed '/^AD_INCLUDE_CONFIGURE/ r configure.ad.cfs' $1 > $fname.tmp
+    sed -e "/^AD_INCLUDE_CONFIGURE/d" $fname.tmp >> $fname
     rm -f configure.ad.cfs $fname.tmp
   else
     cat $1 >> $fname
     rm -f configure.ad.cfs $fname.tmp
   else
     cat $1 >> $fname
@@ -415,15 +418,18 @@ EOF
   # Process AD_INIT
   sed -e "/AD_INIT/s//AC_INIT([$distribution], [$dist_version], [$bug_report], [$package])/" $fname > $fname.tmp
 
   # Process AD_INIT
   sed -e "/AD_INIT/s//AC_INIT([$distribution], [$dist_version], [$bug_report], [$package])/" $fname > $fname.tmp
 
+  # Remove AD_ENABLE_DEPENDENCIES
+  sed -e "/^AD_ENABLE_DEPENDENCIES/d" $fname.tmp > $fname
+
   # Process for distribution
   # Process for distribution
-  rm -f $fname
-  ad_process_file $fname.tmp $fname false
+  rm -f $fname.tmp
+  ad_process_file $fname $fname.tmp false
 
   # Remove any trailing backslashes
 
   # Remove any trailing backslashes
-  if test -f "$fname"; then
-    sed -e :a -e '/\\$/N; s/[  ]*\\\n//; ta' < $fname > configure.ac
+  if test -f "$fname.tmp"; then
+    sed -e :a -e '/\\$/N; s/[  ]*\\\n//; ta' < $fname.tmp > configure.ac
   else
   else
-    cp -p $fname.tmp configure.ac
+    cp -p $fname configure.ac
   fi
   rm -f $fname $fname.tmp
 
   fi
   rm -f $fname $fname.tmp
 
@@ -473,35 +479,66 @@ ad_make_makefile_ams()
   do
     ad_log "  $ff"
     fname=`echo $ff | sed s/\.ad//`
   do
     ad_log "  $ff"
     fname=`echo $ff | sed s/\.ad//`
+    ad_make_makefile_am $ff $fname.am
+  done
+  ad_log ""
+
+  ad_debug "Ending creating Makefile.am files"
+}
 
 
-    # Header for the Makefile.am
-  cat > $fname.am <<EOF
+#
+# Creates Makefile.am file from the Makefile.ad file.
+#
+# Arguments: ad_make_makefile_am <src> <dst>
+#
+ad_make_makefile_am()
+{
+  local am_deps=false
+  local f=$1
+  local fname=$2
+
+  # Enable dependencies if requested
+  dc=`sed 's/^[        ]*//' < configure.ad | grep -v "^#" \
+    | grep "AD_ENABLE_DEPENDENCIES"`
+  if test "$dc" = "AD_ENABLE_DEPENDENCIES"; then
+    am_deps=true
+  fi
+
+  # Header for the Makefile.am
+  cat > $fname <<EOF
 # Automatically generated by Autodist $ver from Makefile.ad.  Do not edit.
 # Automatically generated by Autodist $ver from Makefile.ad.  Do not edit.
-# To make changes edit the $ff file in the source tree.
+# To make changes edit the $f file in the source tree.
 
 
-# Source: $ff
+# Source: $f
 # Generated: `date` by `whoami`
 # Distribution: $distribution
 # License: $license
 
 EOF
 
 # Generated: `date` by `whoami`
 # Distribution: $distribution
 # License: $license
 
 EOF
 
-    # Run the distribution processing for this Makefile.ad
-    ad_debug "Processing $ff to be $fname.am"
-    ad_process_file $ff $fname.tmp false
+  # Run the distribution processing for this Makefile.ad
+  ad_debug "Processing $f to be $fname"
+  ad_process_file $f $fname.tmp false
 
 
-    # Remove any trailing backslashes
-    if test -f "$fname.tmp"; then
-      sed -e :a -e '/\\$/N; s/[        ]*\\\n//; ta' < $fname.tmp >> $fname.am
-    else
-      cat $ff >> $fname.am
-    fi
+  # Remove any trailing backslashes
+  if test -f "$fname.tmp"; then
+    sed -e :a -e '/\\$/N; s/[  ]*\\\n//; ta' < $fname.tmp >> $fname
+  else
+    cat $f >> $fname
+  fi
 
 
-    rm -f $fname.tmp
-  done
-  ad_log ""
+  # Enable dependencies if requested
+  if test x$am_deps = xtrue; then
+    cat >> $fname <<EOF
 
 
-  ad_debug "Ending creating Makefile.am files"
+# S_AD_ENABLE_DEPENDENCIES
+\$(srcdir)/Makefile.am: Makefile.ad
+       cd \$(top_srcdir) && autodist -p \$(subdir)/Makefile.ad \$(subdir)/Makefile.am && cd \$(subdir)
+# E_AD_ENABLE_DEPENDENCIES
+EOF
+  fi
+
+  rm -f $fname.tmp
 }
 
 #
 }
 
 #
@@ -861,6 +898,23 @@ ad_process_source_tree()
   ad_debug "Ending processing source files: $1"
 }
 
   ad_debug "Ending processing source files: $1"
 }
 
+#
+# Removes Autodist dependencies, as they cannot be delivered to distribution.
+#
+# Arguments: ad_remove_dependencies <distdir>
+#
+ad_remove_dependencies()
+{
+  ad_debug "Removing dependencies"
+
+  ams=`find $1 -type f -name Makefile\.\*`
+  for i in $ams
+  do
+    sed -e "/^# S_AD_ENABLE_DEPENDENCIES/,/^# E_AD_ENABLE_DEPENDENCIES/d" $i > $i.tmp
+    mv $i.tmp $i
+  done
+}
+
 #
 # Makes distribution sane, ala modtimes.  Since we modify the distribution
 # we need to make it sane after that.
 #
 # Makes distribution sane, ala modtimes.  Since we modify the distribution
 # we need to make it sane after that.
@@ -977,6 +1031,9 @@ ad_makedist()
     cp -p $license $am_distdir/COPYING || exit 1
   fi
 
     cp -p $license $am_distdir/COPYING || exit 1
   fi
 
+  # Remove dependencies
+  ad_remove_dependencies $am_distdir
+
   # Process noprocesses, first pass
   ad_process_noprocess true
 
   # Process noprocesses, first pass
   ad_process_noprocess true
 
@@ -1460,8 +1517,6 @@ ad_process_file()
     ad_process_license_header $f $1
   fi
 
     ad_process_license_header $f $1
   fi
 
-  ad_debug "Getting #ifdef's and #ifndef's"
-
   # Get defined distribution defines
   defs=`awk "/^#ifdef "$DP"_DIST_|^#else "$DP"_DIST_/ { print; }" \
     $1 |cut -d'*' -f2 |cut -d' ' -f2 | sort | uniq`
   # Get defined distribution defines
   defs=`awk "/^#ifdef "$DP"_DIST_|^#else "$DP"_DIST_/ { print; }" \
     $1 |cut -d'*' -f2 |cut -d' ' -f2 | sort | uniq`
@@ -1573,8 +1628,6 @@ ad_process_source_file()
     ad_process_license_header $f $1
   fi
 
     ad_process_license_header $f $1
   fi
 
-  ad_debug "Getting #ifdef's and #ifndef's"
-
   # Get defined distribution defines
   defs=`awk '/^#ifdef SILC_DIST_|^#else \/\* SILC_DIST_/ { print; }' \
     $1 |cut -d'*' -f2 |cut -d' ' -f2 | sort | uniq`
   # Get defined distribution defines
   defs=`awk '/^#ifdef SILC_DIST_|^#else \/\* SILC_DIST_/ { print; }' \
     $1 |cut -d'*' -f2 |cut -d' ' -f2 | sort | uniq`
@@ -1659,6 +1712,32 @@ ad_process_source_file()
   ad_debug "Ending processing source file: $1 $2"
 }
 
   ad_debug "Ending processing source file: $1 $2"
 }
 
+#
+# Processes a non-source file.  This is the -p, --process option.
+#
+# Arguments: ad_process <src> <dst>
+#
+ad_process()
+{
+  ad_debug "Starting process: $1 $2"
+
+  nolog=true
+
+  if test '!' -f autodist.dist; then
+    ad_fatal "Autodist has not been run yet to prepare source tree"
+  fi
+
+  # Parse distribution
+  distribution=`grep "dist:" < autodist.dist | cut -d: -f2` || exit 1
+  ad_parse_distribution $distribution false
+  ad_process_distdefs
+
+  # Process file
+  ad_make_makefile_am $1 $2
+
+  ad_debug "Ending process: $1 $2"
+}
+
 #
 # Run hooks
 #
 #
 # Run hooks
 #
@@ -1732,6 +1811,8 @@ Operation modes:
   -s, --distdefs [<dist>]   print distribution defines of <dist>, then exit
   -i, --init                initialize Autodist environment, create default
                             distribution directory and distribution, then exit
   -s, --distdefs [<dist>]   print distribution defines of <dist>, then exit
   -i, --init                initialize Autodist environment, create default
                             distribution directory and distribution, then exit
+  -p, --process <src> <dst> process file <src> into <dst> for distribution,
+                            only non-source files can be processed with -p
   -m, --makedist            create and package distribution
       --gzip                create package compressed with gzip (default)
       --bzip2               create also package compressed with bzip2
   -m, --makedist            create and package distribution
       --gzip                create package compressed with gzip (default)
       --bzip2               create also package compressed with bzip2
@@ -1774,6 +1855,15 @@ while test $# -gt 0; do
     ad_initialize;
     exit 0;;
 
     ad_initialize;
     exit 0;;
 
+  -p | --process)
+    shift;
+    if test $# -eq 2; then
+      ad_process $1 $2
+    else
+      echo "${usage}" 1>&2;
+    fi
+    exit 0;;
+
   -m | --makedist)
     ad_makedist
     exit 0;;
   -m | --makedist)
     ad_makedist
     exit 0;;
index 333ccb347dca478c696e80884a4137478de8d9b6..309e28d05958758fc8f69bfdb0a804e32233f04d 100644 (file)
@@ -57,6 +57,11 @@ directory 'distdir', 'autodist.conf' configuration file and the
 default distribution 'default', then exits.
 .PP
 .TP
 default distribution 'default', then exits.
 .PP
 .TP
+\fB\-p\fR, \fB\-\-process\fR \fB<src>\fR \fB<dst>\fR
+Process file <src> into <dst> for distribution, only non-source files can 
+be processed with -p.
+.PP
+.TP
 \fB\-m\fR, \fB\-\-makedist\fR
 Creates and packages distribution
 .PP
 \fB\-m\fR, \fB\-\-makedist\fR
 Creates and packages distribution
 .PP
index 5167b7327c3b3d98eb5b1f9b9c2af45638044b81..c167a0eb10fb9afae2c929ffe84c3b1345762bd0 100644 (file)
@@ -1020,7 +1020,22 @@ macro 'AC_OUTPUT'.  This macro has no arguments.
 Note that, the 'configure.ad' fragments are not real full featured
 configure scripts.  They must not use 'AD_INIT', 'AD_INCLUDE_CONFIGURE',
 'AC_INIT' or any other initialization macros.
 Note that, the 'configure.ad' fragments are not real full featured
 configure scripts.  They must not use 'AD_INIT', 'AD_INCLUDE_CONFIGURE',
 'AC_INIT' or any other initialization macros.
+@end defmac
+
+
+@defmac AD_ENABLE_DEPENDENCIES
 
 
+This macro is used to enable Autodist dependencies in 'Makefile.ad' files.  
+If this macro is used, then after editing 'Makefile.ad' file running 
+Autodist manually is not required, but it is run automatically when the 
+source is compiled with 'make'.  This macro has no arguments.
+
+Note that, the dependencies are enabled only in the prepared source tree.  
+Depedencies are not delivered to distribution, as they would require the 
+presence of 'Makefile.ad' files, which are not delivered to distribution. 
+
+Current Autodist version does not support dependencies in 'configure.ad' 
+files, only in 'Makefile.ad' files.
 @end defmac
 
 @menu
 @end defmac
 
 @menu
@@ -1312,6 +1327,11 @@ Initializes Autodist environment.  Creates the default distribution
 directory 'distdir', 'autodist.conf' configuration file and the
 default distribution 'default', then exits.
 
 directory 'distdir', 'autodist.conf' configuration file and the
 default distribution 'default', then exits.
 
+@item -p
+@itemx --process <src> <dst>
+process file <src> into <dst> for distribution, only non-source files can 
+be processed with -p.
+
 @item -m
 @itemx --makedist
 Creates and packages distribution
 @item -m
 @itemx --makedist
 Creates and packages distribution
diff --git a/apps/autodist/tests/autodist7.test b/apps/autodist/tests/autodist7.test
new file mode 100755 (executable)
index 0000000..00c8c79
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+AUTODIST=../../autodist
+
+rm -rf test
+mkdir test
+
+cd test || exit 1
+
+chmod +x $AUTODIST || exit 1
+
+cat << EOF > configure.ad
+AD_INIT
+AD_ENABLE_DEPENDENCIES
+#ifdef _DIST_DEFAULT
+AC_CANONICAL_BUILD
+AM_INIT_AUTOMAKE
+AC_PREREQ(2.52)
+AC_CONFIG_HEADERS(config.h)
+AC_CONFIG_FILES(
+Makefile
+)
+AC_OUTPUT
+echo configure.ad ok
+#else !_DIST_DEFAULT
+echo "ERROR"
+exit 1
+#endif _DIST_DEFAULT
+EOF
+
+cat << EOF > Makefile.ad
+SUBDIRS=       \\
+#ifdef _DIST_NODEF
+       nodef   \\
+       poa     \\
+       paa     \\
+#endif _DIST_NODEF
+       .       \\
+       .       \\
+       .       \\
+       .       \\
+
+EOF
+
+rm -rf distdir subdir
+mkdir -p subdir || exit 1
+
+$AUTODIST -i || exit 1
+if test '!' -d distdir; then
+  echo "error: distdir/ does no exist"
+  exit 1
+fi 
+
+cp -p ../../default distdir || exit 1
+cp -p ../../autodist.conf distdir || exit 1
+
+touch README NEWS AUTHORS ChangeLog
+
+$AUTODIST || exit 1
+
+./configure || exit 1
+make || exit 1
+echo make ok
+
+echo test ok
+
+# Cleanup
+rm -rf subdir distdir
+