Index: CLFS/master.sh
===================================================================
--- CLFS/master.sh	(revision 3e1c0e2a0d373172a73bed5fc269b0cdb29399c5)
+++ CLFS/master.sh	(revision b12abe15b619daa7c3cf85beda5dcd9fc9fc1057)
@@ -462,19 +462,39 @@
 final_system_Makefiles() {    #
 #-----------------------------#
-  echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system${R_arrow}"
-
-  for file in final-system/* ; do
+  # Set envars and scripts for iteration targets
+  LOGS="" # Start with an empty global LOGS envar
+  if [[ -z "$1" ]] ; then
+    local N=""
+  else
+    local N=-build_$1
+    local basicsystem=""
+    mkdir final-system$N
+    cp final-system/* final-system$N
+    for script in final-system$N/* ; do
+      # Overwrite existing symlinks, files, and dirs
+      sed -e 's/ln -sv/&f/g' \
+          -e 's/mv -v/&f/g' \
+          -e 's/mkdir -v/&p/g' -i ${script}
+    done
+    # Remove Bzip2 binaries before make install
+    sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
+    # Fix how Module-Init-Tools do the install target
+    sed -e 's@make install@make INSTALL=install install@' -i final-system$N/*-module-init-tools
+    # Delete *old Readline libraries just after make install
+    sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
+  fi
+
+  echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N${R_arrow}"
+
+  for file in final-system$N/* ; do
     # Keep the script file name
     this_script=`basename $file`
 
-    # Test if the stripping phase must be skipped
-    case $this_script in
-      *stripping*) [[ "$STRIP" = "0" ]] && continue
-       ;;
-    esac
-
-    # First append each name of the script files to a list (this will become
-    # the names of the targets in the Makefile
-    basicsystem="$basicsystem $this_script"
+    # Test if the stripping phase must be skipped.
+    # Skip alsp temp-perl for iterative runs
+    case $this_script in
+      *stripping*) [[ "$STRIP" = "0" ]] && continue ;;
+      *temp-perl*) [[ -n "$N" ]] && continue ;;
+    esac
 
     # Grab the name of the target, strip id number, XXX-script
@@ -486,5 +506,23 @@
                                   -e 's@n32@@'`
 
+    # Find the version of the command files, if it corresponds with the building of
+    # a specific package. We need this here to can skip scripts not needed for
+    # iterations rebuilds
     vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
+
+    if [[ "$vrs" = "" ]] && [[ -n "$N" ]] ; then
+      case "${this_script}" in
+        *stripping*) ;;
+        *)  continue ;;
+      esac
+    fi
+
+    # Append each name of the script files to a list (this will become
+    # the names of the targets in the Makefile
+    basicsystem="$basicsystem ${this_script}${N}"
+
+    # Append each name of the script files to a list (this will become
+    # the names of the logs to be moved for each iteration)
+    LOGS="$LOGS ${this_script}"
 
     #--------------------------------------------------------------------#
@@ -494,12 +532,10 @@
     # Drop in the name of the target on a new line, and the previous target
     # as a dependency. Also call the echo_message function.
-    wrt_target "${this_script}" "$PREV"
+    wrt_target "${this_script}${N}" "$PREV"
 
     # If $vrs isn't empty, we've got a package...
     if [ "$vrs" != "" ] ; then
-      case $name in
-        temp-perl) wrt_unpack2 "perl-$vrs.tar.*"    ;;
-        *)         wrt_unpack2 "$name-$vrs.tar.*"   ;;
-      esac
+      FILE="$name-$vrs.tar.*"
+      wrt_unpack2 "$FILE"
     fi
     #
@@ -516,6 +552,7 @@
     #
     # Keep the script file name for Makefile dependencies.
-    PREV=$this_script
-
+    PREV=${this_script}${N}
+    # Set system_build envar for iteration targets
+    system_build=$basicsystem
   done  # for file in final-system/* ...
 }
@@ -525,22 +562,41 @@
 bm_final_system_Makefiles() { #
 #-----------------------------#
-  echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system${R_arrow}"
-
-  # The makesys phase was initiated in bm_testsuite_tools_makefile
-  [[ "$TEST" = 0 ]] && PREV=""
-
-  for file in final-system/* ; do
+  # Set envars and scripts for iteration targets
+  LOGS="" # Start with an empty global LOGS envar
+  if [[ -z "$1" ]] ; then
+    local N=""
+    # The makesys phase was initiated in bm_testsuite_tools_makefile
+    [[ "$TEST" = 0 ]] && PREV=""
+  else
+    local N=-build_$1
+    local basicsystem=""
+    mkdir final-system$N
+    cp final-system/* final-system$N
+    for script in final-system$N/* ; do
+      # Overwrite existing symlinks, files, and dirs
+      sed -e 's/ln -sv/&f/g' \
+          -e 's/mv -v/&f/g' \
+          -e 's/mkdir -v/&p/g' -i ${script}
+    done
+    # Remove Bzip2 binaries before make install
+    sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
+    # Fix how Module-Init-Tools do the install target
+    sed -e 's@make install@make INSTALL=install install@' -i final-system$N/*-module-init-tools
+    # Delete *old Readline libraries just after make install
+    sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
+  fi
+
+  echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N${R_arrow}"
+
+  for file in final-system$N/* ; do
     # Keep the script file name
     this_script=`basename $file`
 
     # Test if the stripping phase must be skipped
-    case $this_script in
-      *stripping*) [[ "$STRIP" = "0" ]] && continue
-       ;;
-    esac
-
-    # First append each name of the script files to a list (this will become
-    # the names of the targets in the Makefile
-    basicsystem="$basicsystem $this_script"
+    # Skip alsp temp-perl for iterative runs
+    case $this_script in
+      *stripping*) [[ "$STRIP" = "0" ]] && continue ;;
+      *temp-perl*) [[ -n "$N" ]] && continue ;;
+    esac
 
     # Grab the name of the target, strip id number, XXX-script
@@ -552,5 +608,23 @@
                                   -e 's@n32@@'`
 
+    # Find the version of the command files, if it corresponds with the building of
+    # a specific package. We need this here to can skip scripts not needed for
+    # iterations rebuilds
     vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
+
+    if [[ "$vrs" = "" ]] && [[ -n "$N" ]] ; then
+      case "${this_script}" in
+        *stripping*) ;;
+        *)  continue ;;
+      esac
+    fi
+
+    # Append each name of the script files to a list (this will become
+    # the names of the targets in the Makefile
+    basicsystem="$basicsystem ${this_script}${N}"
+
+    # Append each name of the script files to a list (this will become
+    # the names of the logs to be moved for each iteration)
+    LOGS="$LOGS ${this_script}"
 
     #--------------------------------------------------------------------#
@@ -560,12 +634,10 @@
     # Drop in the name of the target on a new line, and the previous target
     # as a dependency. Also call the echo_message function.
-    wrt_target "${this_script}" "$PREV"
+    wrt_target "${this_script}${N}" "$PREV"
 
     # If $vrs isn't empty, we've got a package...
     if [ "$vrs" != "" ] ; then
-      case $name in
-        temp-perl) wrt_unpack3 "perl-$vrs.tar.*"    ;;
-        *)         wrt_unpack3 "$name-$vrs.tar.*"   ;;
-      esac
+      FILE="$name-$vrs.tar.*"
+      wrt_unpack3 "$FILE"
     fi
     #
@@ -582,6 +654,7 @@
     #
     # Keep the script file name for Makefile dependencies.
-    PREV=$this_script
-
+    PREV=${this_script}${N}
+    # Set system_build envar for iteration targets
+    system_build=$basicsystem
   done  # for file in final-system/* ...
 }
@@ -886,4 +959,6 @@
     fi
     final_system_Makefiles         # $basicsystem
+    # Add the iterations targets, if needed
+    [[ "$COMPARE" != "0" ]] && wrt_compare_targets
     bootscripts_Makefiles          # $bootscripttools
     bootable_Makefiles             # $bootabletools
@@ -894,4 +969,6 @@
     fi
     bm_final_system_Makefiles      # $basicsystem
+    # Add the iterations targets, if needed
+    [[ "$COMPARE" != "0" ]] && wrt_compare_targets
     bm_bootscripts_Makefiles       # $bootscipttools
     bm_bootable_Makefiles          # $bootabletoosl
