Added function to create iteration-N Makefile targets.

This commit is contained in:
Manuel Canales Esparcia 2006-04-08 16:30:12 +00:00
parent 2f0a537a8c
commit bfbd9275aa
2 changed files with 67 additions and 0 deletions

View file

@ -219,6 +219,9 @@ chapter789_Makefiles() {
#----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8/9${R_arrow}"
# Reset $PREV for ICA runs
[[ "$RUN_ICA" != "0" ]] && PREV=iteration-last
for file in chapter0{7,8,9}/* ; do
# Keep the script file name
this_script=`basename $file`

View file

@ -2,6 +2,14 @@
#----------------------------------#
wrt_ica_targets() { #
#----------------------------------#
local ICA_rebuild=$1
wrt_ica_rebuild "$ICA_rebuild"
wrt_iterations "$ICA_rebuild"
}
#----------------------------------#
wrt_ica_rebuild() { #
#----------------------------------#
local ICA_rebuild=$1
(
@ -12,6 +20,62 @@ EOF
) >> $MKFILE
}
#----------------------------------#
wrt_iterations() { #
#----------------------------------#
local ICA_rebuild=$1
for ((N=1; N <= ITERATIONS ; N++)) ; do # Double parentheses,
# and "ITERATIONS" with no "$".
ITERATION=iteration-$N
if [ "$N" = "1" ] ; then
(
cat << EOF
$ITERATION: chapter06
@do_ica_prep
@pushd logs && \\
mkdir $ITERATION && \\
mv $ICA_rebuild $ITERATION && \\
popd
@rm -f $ICA_rebuild
@touch \$@
EOF
) >> $MKFILE
PREV=$ITERATION
elif [ "$N" = "$ITERATIONS" ] ; then
(
cat << EOF
iteration-last: $PREV ICA_rebuild
@do_ica_prep
@pushd logs && \\
mkdir iteration-last && \\
cp $ICA_rebuild iteration-last && \\
popd
@do_ica_work
@touch \$@
EOF
) >> $MKFILE
else
(
cat << EOF
$ITERATION: $PREV ICA_rebuild
@do_ica_prep
@pushd logs && \\
mkdir $ITERATION && \\
mv $ICA_rebuild $ITERATION && \\
popd
@rm -f $ICA_rebuild
@touch \$@
EOF
) >> $MKFILE
PREV=$ITERATION
fi
done
}
# Acknowledgment:
# The following code is a modified version of an original work written by
# Greg Schafer for the "DIY Linux" project and is included here with his