#
# Author: Pekka Riikonen <priikone@silcnet.org>
#
-# Copyright (C) 2005 Pekka Riikonen
+# Copyright (C) 2005 - 2007 Pekka Riikonen
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# Whether to output ad_debug information
debug=false
+nolog=false
# Autodist version
ver=@VERSION@
#
ad_log()
{
- echo "$1" >&5
+ if test x$nolog = xfalse; then
+ echo "$1" >&5
+ fi
}
#
# Create default distdir
if test '!' -f $distdir; then
- mkdir -p $distdir
+ mkdir -p -- $distdir
fi
# Create Autodist configuration file
rm -f configure.ac configure.ad.cfs
- cfs=`find . -name configure\*\.ad`
+ cfs=`find . -type f -name configure\*\.ad`
for i in $cfs
do
if test "x$i" = "x$1"; 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
# Process AD_INIT
sed -e "/AD_INIT/s//AC_INIT([$distribution], [$dist_version], [$bug_report], [$package])/" $fname > $fname.tmp
+ # Remove AD_DISABLE_DEPENDENCIES
+ sed -e "/^AD_DISABLE_DEPENDENCIES/d" $fname.tmp > $fname
+
# 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
- 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
- cp -p $fname.tmp configure.ac
+ cp -p $fname configure.ac
fi
rm -f $fname $fname.tmp
ad_log "Following Makefile.ad files were processed into Makefile.am files:"
ad_log "------------------------------------------------------------------"
- files=`find . -name Makefile\.ad`
+ files=`find . -type f -name Makefile\.ad`
for ff in $files
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"
+}
+
+#
+# Creates Makefile.am file from the Makefile.ad file.
+#
+# Arguments: ad_make_makefile_am <src> <dst>
+#
+ad_make_makefile_am()
+{
+ local am_deps=true
+ local f=$1
+ local fname=$2
+
+ # Disable dependencies if requested
+ dc=`sed 's/^[ ]*//' < configure.ad | grep -v "^#" \
+ | grep "AD_DISABLE_DEPENDENCIES"`
+ if test "$dc" = "AD_DISABLE_DEPENDENCIES"; then
+ am_deps=false
+ fi
- # Header for the Makefile.am
- cat > $fname.am <<EOF
+ # Header for the Makefile.am
+ cat > $fname <<EOF
# 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
- # 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
+ # Get list of configure.ad's to get them into deps also
+ cfs=`find . -type f -name configure\*\.ad`
+ cfs=`echo $cfs | sed 's/\.\///g'`
- ad_debug "Ending creating Makefile.am files"
+ cat >> $fname <<EOF
+
+# S_AD_ENABLE_DEPENDENCIES
+\$(srcdir)/Makefile.am: Makefile.ad
+ cd \$(top_srcdir) && autodist -p makefile \$(subdir)/Makefile.ad \$(subdir)/Makefile.am && cd \$(subdir)
+\$(srcdir)/configure.ac: $cfs
+ cd \$(top_srcdir) && autodist -p configure \$(top_srcdir)/configure.ad && cd \$(subdir)
+# E_AD_ENABLE_DEPENDENCIES
+EOF
+ fi
+
+ rm -f $fname.tmp
}
#
ad_log "Following .ad files were processed:"
ad_log "-----------------------------------"
- files=`find . -name \*\.ad \! -name configure\*\.ad \! -name Makefile\.ad`
+ files=`find . -type f -name \*\.ad \! -name configure\*\.ad \! -name Makefile\.ad`
for i in $files
do
fname=`echo $i | sed s/\.ad//`
+ orig=$i
ad_debug "Processing $i to be $fname"
ad_log " $i into $fname"
+ rm -f $fname
+
# Run the distribution processing for this file
- ad_process_file $i $fname false
- if test -f $fname; then
- cp -p $i $fname || exit 1
- fi
+ ad_process_file $orig $fname false
+ if test '!' -f "$fname"; then
+ cp -p $orig $fname || exit 1
+ fi
done
ad_log ""
# source path. This, in effect, is a cp utility with ability to create
# directories if they do not exist.
#
-# Arguments: ad_dist_includes <includeslist> <recursive>
+# Arguments: ad_dist_includes <includeslist> <recursive> <log>
#
ad_dist_includes()
{
ad_debug "Starting running includes: $1 $2"
- ad_log ""
- ad_log "Following files and directories were included in distribution:"
- ad_log "--------------------------------------------------------------"
+ if test x$3 = xtrue; then
+ ad_log ""
+ ad_log "Following files and directories were included in distribution:"
+ ad_log "--------------------------------------------------------------"
+ fi
# By default do not expand pathnames
set -f
d=`echo $src | sed 's,/[^/]*$,,'`
if test "$d" != "$src" && test "$d" != "." && \
test '!' -d $am_distdir/$d; then
- mkdir -p $am_distdir/$d || exit 1
+ mkdir -p -- $am_distdir/$d || exit 1
fi
else
# Add to different location
d=`echo $dst | sed 's,/[^/]*$,,'`
if test "$d" != "$dst" && test "$d" != "." && \
test '!' -d $am_distdir/$d; then
- mkdir -p $am_distdir/$d || exit 1
+ mkdir -p -- $am_distdir/$d || exit 1
fi
fi
- ad_log " $src into $am_distdir/$d"
+ if test x$3 = xtrue; then
+ ad_log " $src into $am_distdir/$d"
+ fi
cp -p $src $am_distdir/$d || exit 1
elif test -d "$src"; then
d=""
fi
if test '!' -d $am_distdir/$d && test "$ds" != "$d"; then
- mkdir -p $am_distdir/$d || exit 1
+ mkdir -p -- $am_distdir/$d || exit 1
fi
- ad_log " $src into $am_distdir/$d"
+ if test x$3 = xtrue; then
+ ad_log " $src into $am_distdir/$d"
+ fi
cp -pR $src $am_distdir/$d || exit 1
else
# Add to different location
d=`echo $d | sed 's,/[^/]*$,,'`
fi
if test '!' -d $am_distdir/$d && test "$dst" != "$d"; then
- mkdir -p $am_distdir/$d || exit 1
+ mkdir -p -- $am_distdir/$d || exit 1
fi
- ad_log " $src into $am_distdir/$dst"
+ if test x$3 = xtrue; then
+ ad_log " $src into $am_distdir/$dst"
+ fi
cp -pR $src $am_distdir/$dst || exit 1
fi
src=
dst=
done
- ad_log ""
+
+ if test x$3 = xtrue; then
+ ad_log ""
+ fi
set +f
#
# The path may be file, directory or regular expression.
#
-# Arguments: ad_dist_includes <excludelist>
+# Arguments: ad_dist_includes <excludelist> <log>
#
ad_dist_excludes()
{
ad_debug "Starting running excludes: $1"
- ad_log ""
- ad_log "Following files and directories were excluded from distribution:"
- ad_log "----------------------------------------------------------------"
+ if test x$2 = xtrue; then
+ ad_log ""
+ ad_log "Following files and directories were excluded from distribution:"
+ ad_log "----------------------------------------------------------------"
+ fi
+ cur=`pwd`
+ cd $am_distdir || exit 1
for i in $1
do
ad_debug "Excluding $i"
- ad_log " $1"
- rm -rf $am_distdir/$i
+ if test x$2 = xtrue; then
+ ad_log " $i"
+ fi
+ rm -rf $i
done
- ad_log ""
+ cd $cur || exit 1
+
+ if test x$2 = xtrue; then
+ ad_log ""
+ fi
ad_debug "Ending running excludes: $1"
}
ad_debug "Starting processing non-source files: $1"
# Take files, except source and .ad files.
- files=`find $am_distdir \! -name \*\.ad \( \
+ files=`find $am_distdir -type f \! -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 \*\.mm -a \
+ \! -name \*\.M -a \
+ \! -name \*\.S -a \
\! -name \*\.[hH] -a \
\! -name \*\.hh -a \
\! -name \*\.[cC]\.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
- fi
-
for ff in $files
do
ad_process_file $ff $ff.tmp true
{
ad_debug "Starting processing source files: $1"
- # We take only C/C++ files since they use the C compiler friendly
- # version of distdefs. Other files are not assumed to use them.
- files=`find $am_distdir \! -name \*\.ad \( \
+ # We take only C/C++ (and other files that are run through traditional
+ # preprocessor) files since they use the C compiler friendly version
+ # of distdefs. Other files are not assumed to use them.
+ files=`find $am_distdir -type f \! -name \*\.ad \( \
-name \*\.[cC] -o \
-name \*\.[cC][cCpP] -o \
-name \*\.[cC][xX][xX] -o \
-name \*\.[cC][pP][pP] -o \
-name \*\.[cC]++ -o \
-name \*\.m -o \
+ -name \*\.mm -o \
+ -name \*\.M -o \
+ -name \*\.S -o \
-name \*\.[hH] -o \
-name \*\.hh -o \
-name \*\.[cC]\.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
- fi
-
for ff in $files
do
ad_process_source_file $ff $ff.tmp true
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.
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`
+ files=`find $am_distdir -type f -name Makefile\.in`
for i in $files
do
touch $i
ad_log_open "makedist.log"
ad_debug "Starting distribution creation"
- ad_log "Starting distribution creation"
- ad_log "------------------------------"
+ ad_log "Created distribution"
+ ad_log "--------------------"
ad_log ""
if test '!' -f autodist.dist; then
distribution=`grep "dist:" < autodist.dist | cut -d: -f2` || exit 1
dist_version=`grep "ver:" < autodist.dist | cut -d: -f2` || exit 1
am_distdir=`grep "distdir:" < autodist.dist | cut -d: -f2` || exit 1
+ params=`grep "params:" < autodist.dist | cut -d: -f2` || exit 1
ad_parse_distribution $distribution false
ad_log " Distribution: $distribution $dist_version"
ad_log " Destination directory: $am_distdir"
+ ad_log ""
ad_process_distdefs
if test x$opt_no_dist = xtrue; then
fi
# Run pre-dist-hooks
- ad_run_dist_hooks "$pre_dist_hooks"
+ ad_run_dist_hooks "$pre_dist_hooks" "$params"
# Create distribution directory
ad_debug "Creating distribution directory $am_distdir"
fi
# Run pre-process-dist-hooks
- ad_run_dist_hooks "$pre_p_dist_hooks"
+ ad_run_dist_hooks "$pre_p_dist_hooks" "$params"
# Run excludes
- ad_dist_excludes "$excludes"
+ ad_dist_excludes "$excludes" true
# Run includes
- ad_dist_includes "$includes"
+ ad_dist_includes "$includes" false true
# Include specific license file if specified
if test "$license" != ""; then
ad_log "License file in distribution:"
ad_log "-----------------------------"
ad_log " $license into $am_distdir/COPYING"
+ ad_log ""
cp -p $license $am_distdir/COPYING || exit 1
fi
- # Process noprocesses
- ad_process_noprocess
+ # Remove dependencies
+ ad_remove_dependencies $am_distdir
+
+ # Process noprocesses, first pass
+ ad_process_noprocess true
ad_log ""
ad_log "Following files were not re-licensed:"
ad_debug "Process distribution tree"
ad_process_tree $am_distdir
+ ad_log ""
+
+ # Process noprocesses, second pass
+ ad_process_noprocess false
+
# Run post-process_dist-hooks
- ad_run_dist_hooks "$post_p_dist_hooks"
+ ad_run_dist_hooks "$post_p_dist_hooks" "$params"
# Make distribution sane
ad_makedist_makesane
rm -f $am_distdir.tar
# Run post-dist-hooks
- ad_run_dist_hooks "$post_dist_hooks"
+ ad_run_dist_hooks "$post_dist_hooks" "$params"
# Cleanup
rm -rf $am_distdir
- rm -f autodist.noprocess
ad_log "Distribution created successfully."
ad_fatal "Distribution '$1' is not declared"
fi
+ # Get and enforce prereq version
+ prereq=`sed 's/^[ ]*//' < $distdir/$1 | grep -v "^#" \
+ | grep "prereq " | cut -d' ' -f2- | sort | uniq`
+ if test '!' -z $prereq; then
+ if test "$ver" \< "$prereq"; then
+ ad_fatal "Autodist $prereq or newer is required for distribution $1"
+ fi
+ fi
+
# Get inherited
inhs=`sed 's/^[ ]*//' < $distdir/$1 | grep -v "^#" \
| grep "inherit " | cut -d' ' -f2 | sort | uniq`
| grep "define " | cut -d' ' -f2 | sort | uniq`
if test "$inhs" = "" && test "$defs" = ""; then
- ad_fatal "Distribution '$1' does not define anything"
+ if test "$1" != "default"; then
+ ad_fatal "Distribution '$1' does not define anything"
+ fi
fi
# Get undefined distdefs
do
echo $i >>autodist.tmp.defs
done
- distdefs=`sort < autodist.tmp.defs | uniq`
+ if test -f autodist.tmp.defs; then
+ distdefs=`sort < autodist.tmp.defs | uniq`
+ fi
distdefs=`echo $distdefs`
rm -f autodist.tmp.defs
#
# Process specified noprocesses. This is called during makedist.
+# The noprocess first copies the noprocess files and dirs into a temp
+# directory, and then removes them from the distdir. This way they are
+# not processed by Autodist. After processing they are returned to their
+# correct locations from the temp dir. Dirty, yeah, but the way we do
+# this until better one comes along.
#
-# Arguments: ad_process_noprocess
+# Arguments: ad_process_noprocess <process>
+#
+# If <process> is true this excludes and if false this includes.
#
ad_process_noprocess()
{
- local np=false
- local n="sed "
-
ad_debug "Starting running noprocesses"
- ad_log ""
- ad_log "Autodist did not process the following files:"
- ad_log "---------------------------------------------"
+ set -f
cur=`pwd`
- cd $am_distdir || exit 1
- for i in $noprocess
- do
- ad_log " $i"
- # Escape
- ie=`echo $i | sed 's/\\//\\\\\//g'` || exit 1
-
- n="$n -e 's/$am_distdir\\/$ie //'"
- np=true
- done
- cd $cur || exit 1
+ if test x$1 = xtrue; then
+ ad_log ""
+ ad_log "Following files and directories were not processed:"
+ ad_log "---------------------------------------------------"
+
+ f="$cur/autodist__noprocess"
+ rm -rf $f
+ mkdir -p -- $f || exit 1
+
+ # First, include them to new location with correct directory structure.
+ old_am_distdir="$am_distdir"
+ cd $am_distdir || exit 1
+ am_distdir="$f"
+ nops=" $noprocess"
+ nops=`echo $nops | sed -e 's/ / : /g' -e 's/^/ : /'` || exit 1
+ ad_dist_includes "$nops" false false
+ am_distdir="$old_am_distdir"
+
+ # Then, remove from distdir (they are in temp dir now)
+ for i in $noprocess
+ do
+ ad_log " $i"
+ rm -rf $i
+ done
+ cd $cur || exit 1
- rm -f autodist.noprocess
- if test x$np = xtrue; then
- echo $n > autodist.noprocess || exit 1
+ ad_log ""
+ else
+ # Copy from the temp dir back to distdir
+ cd autodist__noprocess || exit 1
+ old_am_distdir="$am_distdir"
+ am_distdir="$cur/$old_am_distdir"
+ nops=" $noprocess"
+ nops=`echo $nops | sed -e 's/ / : /g' -e 's/^/ : /'` || exit 1
+
+ ad_dist_includes "$nops" false false
+
+ am_distdir="$old_am_distdir"
+ cd $cur || exit 1
+ rm -rf autodist__noprocess
fi
- ad_log ""
+
+ set +f
ad_debug "Ending running noprocesses"
}
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; }" \
+ defs=`awk "/^#ifdef ${DP}_DIST_|^#else ${DP}_DIST_/ { print; }" \
$1 |cut -d'*' -f2 |cut -d' ' -f2 | sort | uniq`
# Get explicitly not-defined distribution defines
- 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 in $1: $defs"
# This also handles the #ifdef's #else (ie. #ifndef) branch.
if test x$found = xfalse; then
ad_debug "ifdef $d will be excluded (it is NOT defined)"
- echo "/^#ifdef $d/,/^#else !$d|^#endif $d/ { next; }" >> $f
+ echo "/^#ifdef $d$/,/^#else !$d$|^#endif $d$/ { next; }" >> $f
else
- echo "/^#else !$d/,/^#endif $d/ { next; }" >> $f
+ echo "/^#else !$d$/,/^#endif $d$/ { next; }" >> $f
fi
done
# This also handles the #ifndef's #else (ie. #ifdef) branch.
if test x$found = xtrue; then
ad_debug "ifndef $d will be excluded (it IS defined)"
- echo "/^#ifndef $d/,/^#else $d|^#endif $d/ { next; }" >> $f
+ echo "/^#ifndef $d$/,/^#else $d$|^#endif $d$/ { next; }" >> $f
else
- echo "/^#else $d/,/^#endif $d/ { next; }" >> $f
+ echo "/^#else $d$/,/^#endif $d$/ { next; }" >> $f
fi
done
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; }' \
+ defs=`awk "/^#ifdef ${DP}_DIST_|^#else \/\* ${DP}_DIST_/ { print; }" \
$1 |cut -d'*' -f2 |cut -d' ' -f2 | sort | uniq`
# Get explicitly not-defined distribution defines
- ndefs=`awk '/^#ifndef SILC_DIST_|^#else \/\* \!SILC_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 in $1: $defs"
# This also handles the #ifdef's #else (ie. #ifndef) branch.
if test x$found = xfalse; then
ad_debug "ifdef $d will be excluded (it is NOT defined)"
- echo "/^#ifdef $d/,/^#else \/\* \!$d|^#endif \/\* $d/ { next; }" >> $f
+ echo "/^#ifdef $d$/,/^#else \/\* \!$d |^#endif \/\* $d / { next; }" >> $f
else
- echo "/^#else \/\* \!$d/,/^#endif \/\* $d/ { next; }" >> $f
+ echo "/^#else \/\* \!$d /,/^#endif \/\* $d / { next; }" >> $f
fi
done
# This also handles the #ifndef's #else (ie. #ifdef) branch.
if test x$found = xtrue; then
ad_debug "ifndef $d will be excluded (it IS defined)"
- echo "/^#ifndef $d/,/^#else \/\* $d|^#endif \/\* $d/ { next; }" >> $f
+ echo "/^#ifndef $d$/,/^#else \/\* $d |^#endif \/\* $d / { next; }" >> $f
else
- echo "/^#else \/\* $d/,/^#endif \/\* $d/ { next; }" >> $f
+ echo "/^#else \/\* $d /,/^#endif \/\* $d / { next; }" >> $f
fi
done
# Those distdef lines that remain in the file are removed to make
# the appearance prettier
- echo "/^#ifdef SILC_DIST_|^#endif \/\* SILC_DIST_|^#else \/\* SILC_DIST_|^#else \/\* \!SILC_DIST_|^#ifndef SILC_DIST_/ { next; }" >> $f
+ echo "/^#ifdef "$DP"_DIST_|^#endif \/\* "$DP"_DIST_|^#else \/\* "$DP"_DIST_|^#else \/\* \!"$DP"_DIST_|^#ifndef "$DP"_DIST_/ { next; }" >> $f
echo "{ print; }" >> $f
# Execute the script
ad_debug "Ending processing source file: $1 $2"
}
+#
+# Processes a file. This is the -p, --process option.
+#
+# Arguments: ad_process <type> <src> <dst>
+#
+ad_process()
+{
+ ad_debug "Starting process: $1 $2 $3"
+
+ 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
+ dist_version=`grep "ver:" < autodist.dist | cut -d: -f2` || exit 1
+ ad_parse_distribution $distribution false
+ ad_process_distdefs
+
+ # Process file
+ case "$1" in
+ makefile)
+ if test -z $3; then
+ ad_fatal "File type $1 requires <dst> argument"
+ fi
+ ad_make_makefile_am $2 $3
+ exit 0;;
+
+ configure)
+ ad_make_configure_ac $2
+ exit 0;;
+
+ non-source)
+ if test -z $3; then
+ ad_fatal "File type $1 requires <dst> argument"
+ fi
+ ad_process_file $2 $3 false
+ exit 0;;
+
+ source)
+ if test -z $3; then
+ ad_fatal "File type $1 requires <dst> argument"
+ fi
+ ad_process_source_file $2 $3 false
+ exit 0;;
+
+ *)
+ ad_fatal "Unknown file type: $1";
+ ;;
+ esac
+}
+
#
# Run hooks
#
-# Arguments: ad_run_hooks <hooks>
+# Arguments: ad_run_hooks <hooks> <params>
#
ad_run_hooks()
{
ad_debug "Running hooks: $1"
ad_log ""
- ad_log "Running hooks:"
+ ad_log "Hooks executed:"
ad_log "--------------"
for i in $1
if test '!' -f $i; then
ad_fatal "Hook script $i does not exist"
fi
- ad_log " sh $i \"$distribution\" \"$dist_version\" \"$package\""
- sh $i "$distribution" "$dist_version" "$package" || exit 1
+ ad_log " sh $i \"$distribution\" \"$dist_version\" \"$package\" \"$2\""
+ sh $i "$distribution" "$dist_version" "$package" "$2" || exit 1
done
ad_log ""
#
# Run dist hooks
#
-# Arguments: ad_run_dist_hooks <hooks>
+# Arguments: ad_run_dist_hooks <hooks> <params>
#
ad_run_dist_hooks()
{
ad_debug "Starting running distributions hooks: $1"
ad_log ""
- ad_log "Running distribution hooks:"
- ad_log "---------------------------"
+ ad_log "Distribution hooks executed:"
+ ad_log "----------------------------"
for i in $1
do
ad_fatal "Dist hook script $i does not exist"
fi
- ad_log " sh $i \"$distribution\" \"$dist_version\" \"$package\" \"$am_distdir\""
- sh $i "$distribution" "$dist_version" "$package" "$am_distdir" || exit 1
+ ad_log " sh $i \"$distribution\" \"$dist_version\" \"$package\" \"$am_distdir\" \"$2\""
+ sh $i "$distribution" "$dist_version" "$package" "$am_distdir" "$2" || exit 1
done
ad_log ""
###############################################################################
# Autodist code
-usage="Usage: autodist [options] [distribution] [version]"
+usage="Usage: autodist [OPTIONS] [DISTRIBUTION] [VERSION] [PARAMS]"
help="\
Autodist prepares source tree for configuration, compilation and
-distribution. Prepares the source tree from the \`autodist.ad'
-configuration file. Generates Automake.am files from Automake.ad
-files, configure.ac file from configure.ad file(s), generates the
-configure script by running Autoconf tool, and generates Makefile.in
-files by running Automake tool.
+distribution. Generates Automake.am files from Automake.ad files,
+configure.ac file from configure.ad file(s), generates the configure
+script by running Autoconf tool, and generates Makefile.in files by
+running Automake tool.
Operation modes:
-h, --help print this help, 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 <type> <src> [<dst>]
+ process file <src> into <dst> for distribution,
+ <type> is 'makefile', 'configure', 'non-source'
+ or 'source' and defines the type of <src>
-m, --makedist create and package distribution
--gzip create package compressed with gzip (default)
--bzip2 create also package compressed with bzip2
ad_initialize;
exit 0;;
+ -p | --process)
+ shift;
+ if test $# -ge 2; then
+ ad_process $1 $2 $3
+ else
+ echo "${usage}" 1>&2;
+ fi
+ exit 0;;
+
-m | --makedist)
ad_makedist
exit 0;;
echo "@PACKAGE@ (@PACKAGE_NAME@) $ver" 1>&2;
echo "Written by Pekka Riikonen" 1>&2;
echo 1>&2;
- echo "Copyright (C) 2004 - 2005 SILC Project" 1>&2;
+ echo "Copyright (C) 2004 - 2007 SILC Project" 1>&2;
echo "\
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " 1>&2;
distfile=$distribution
shift
fi
+
ad_parse_distribution $distribution false
-ad_log " Distribution: $distribution $dist_version"
-ad_process_distdefs
if test $# != 0; then
dist_version="${1}";
fi
+ad_log " Distribution: $distribution $dist_version"
+ad_log ""
+
+ad_process_distdefs
+
ad_debug "Preparing source tree for configuration and compilation..."
ad_debug "Preparing $distribution distribution version $dist_version"
#
if test "$DISTDEFS"; then
ad_create_distdefs_h
-else
- ad_fatal "DISTDEFS not defined in $distdir/autodist.conf"
+fi
+
+# Get extra parameters from command line
+if test $# != 0; then
+ shift
fi
#
# Run pre-hooks
#
-ad_run_hooks "$pre_hooks"
+ad_run_hooks "$pre_hooks" "$@"
#
# Generate the Makefile.am files from Makefile.ad files
echo "dist:$distfile" > autodist.dist
echo "ver:$dist_version" >> autodist.dist
echo "distdir:$package-$dist_version" >> autodist.dist
+echo "params:$@" >> autodist.dist
#
# Run post-hooks
#
-ad_run_hooks "$post_hooks"
+ad_run_hooks "$post_hooks" "$@"
ad_log "Source tree processed successfully."
ad_debug "Done, now run ./configure and make."