X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Fautodist%2Fautodist.in;h=72a86a1c25f66f1ba8b9d81cf4e174670968b16a;hb=5eb5e7e513f84a0e41b8ccb8200a996d21863bfa;hp=12c9cabcaa0640d89c6c315c0cd046d0855884dc;hpb=38fa23dd69a23d3e1b3367f027c002f29851c949;p=autodist.git diff --git a/apps/autodist/autodist.in b/apps/autodist/autodist.in index 12c9cab..72a86a1 100755 --- a/apps/autodist/autodist.in +++ b/apps/autodist/autodist.in @@ -129,6 +129,7 @@ licenseh= # Whether to output ad_debug information debug=false +nolog=false # Autodist version ver=@VERSION@ @@ -210,7 +211,9 @@ EOF # ad_log() { - echo "$1" >&5 + if test x$nolog = xfalse; then + echo "$1" >&5 + fi } # @@ -369,7 +372,7 @@ ad_make_configure_ac() 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 @@ -405,8 +408,8 @@ EOF 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 @@ -415,15 +418,18 @@ EOF # 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 @@ -468,40 +474,71 @@ ad_make_makefile_ams() 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" +} - # Header for the Makefile.am - cat > $fname.am < +# +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 <> $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 < +# Arguments: ad_dist_includes # ad_dist_includes() { @@ -560,9 +597,11 @@ 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 @@ -613,7 +652,9 @@ ad_dist_includes() 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 @@ -632,10 +673,10 @@ ad_dist_includes() if test '!' -d $am_distdir/$d && test "$ds" != "$d"; then mkdir -p $am_distdir/$d || exit 1 fi -echo $d -echo $ds - 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 @@ -653,7 +694,9 @@ echo $ds 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 @@ -712,7 +755,10 @@ echo $ds src= dst= done - ad_log "" + + if test x$3 = xtrue; then + ad_log "" + fi set +f @@ -729,23 +775,33 @@ echo $ds # # The path may be file, directory or regular expression. # -# Arguments: ad_dist_includes +# Arguments: ad_dist_includes # 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 " $1" + 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" } @@ -764,7 +820,7 @@ ad_process_tree() 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 \ @@ -783,11 +839,6 @@ ad_process_tree() \! -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 @@ -817,7 +868,7 @@ ad_process_source_tree() # 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 \( \ + files=`find $am_distdir -type f \! -name \*\.ad \( \ -name \*\.[cC] -o \ -name \*\.[cC][cCpP] -o \ -name \*\.[cC][xX][xX] -o \ @@ -835,11 +886,6 @@ ad_process_source_tree() -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 @@ -852,6 +898,23 @@ ad_process_source_tree() ad_debug "Ending processing source files: $1" } +# +# Removes Autodist dependencies, as they cannot be delivered to distribution. +# +# Arguments: ad_remove_dependencies +# +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. @@ -878,7 +941,7 @@ ad_makedist_makesane() 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 @@ -906,8 +969,8 @@ ad_makedist() 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 @@ -930,6 +993,7 @@ ad_makedist() 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 @@ -952,10 +1016,10 @@ ad_makedist() ad_run_dist_hooks "$pre_p_dist_hooks" # 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 @@ -963,11 +1027,15 @@ ad_makedist() 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:" @@ -981,6 +1049,11 @@ ad_makedist() 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" @@ -1017,7 +1090,6 @@ ad_makedist() # Cleanup rm -rf $am_distdir - rm -f autodist.noprocess ad_log "Distribution created successfully." @@ -1353,39 +1425,67 @@ ad_process_license_header() # # 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 +# If 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" } @@ -1417,8 +1517,6 @@ ad_process_file() 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` @@ -1530,8 +1628,6 @@ ad_process_source_file() 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` @@ -1616,6 +1712,32 @@ ad_process_source_file() ad_debug "Ending processing source file: $1 $2" } +# +# Processes a non-source file. This is the -p, --process option. +# +# Arguments: ad_process +# +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 # @@ -1626,7 +1748,7 @@ ad_run_hooks() ad_debug "Running hooks: $1" ad_log "" - ad_log "Running hooks:" + ad_log "Hooks executed:" ad_log "--------------" for i in $1 @@ -1652,8 +1774,8 @@ 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 @@ -1689,6 +1811,8 @@ Operation modes: -s, --distdefs [] print distribution defines of , then exit -i, --init initialize Autodist environment, create default distribution directory and distribution, then exit + -p, --process process Makefile.ad file into for + distribution, the exit -m, --makedist create and package distribution --gzip create package compressed with gzip (default) --bzip2 create also package compressed with bzip2 @@ -1731,6 +1855,15 @@ while test $# -gt 0; do 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;; @@ -1801,14 +1934,18 @@ if test $# != 0; then 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"