From bfbd9275aaa0feeb6514535eb37f93e85725ae67 Mon Sep 17 00:00:00 2001 From: Manuel Canales Esparcia Date: Sat, 8 Apr 2006 16:30:12 +0000 Subject: [PATCH] Added function to create iteration-N Makefile targets. --- LFS/master.sh | 3 +++ common/func_ICA.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/LFS/master.sh b/LFS/master.sh index a6cfec3..5b69916 100755 --- a/LFS/master.sh +++ b/LFS/master.sh @@ -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` diff --git a/common/func_ICA.sh b/common/func_ICA.sh index 6c5ae36..eea4453 100644 --- a/common/func_ICA.sh +++ b/common/func_ICA.sh @@ -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