[877cc6a] | 1 | #!/bin/sh
|
---|
| 2 | set -e # Enable error trapping
|
---|
| 3 |
|
---|
| 4 | # $Id$
|
---|
| 5 |
|
---|
| 6 | ###################################
|
---|
| 7 | ### FUNCTIONS ###
|
---|
| 8 | ###################################
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 | #----------------------------#
|
---|
| 12 | chapter3_Makefiles() { # Initialization of the system
|
---|
| 13 | #----------------------------#
|
---|
| 14 | local TARGET LOADER
|
---|
| 15 |
|
---|
| 16 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3${R_arrow}"
|
---|
| 17 |
|
---|
| 18 | # Define a few model dependant variables
|
---|
| 19 | if [[ ${MODEL} = "uclibc" ]]; then
|
---|
| 20 | TARGET="tools-linux-uclibc"; LOADER="ld-uClibc.so.0"
|
---|
| 21 | else
|
---|
| 22 | TARGET="tools-linux-gnu"; LOADER="ld-linux.so.2"
|
---|
| 23 | fi
|
---|
| 24 |
|
---|
| 25 | # NOTE: We use the lfs username and groupname also in HLFS
|
---|
| 26 | # If /home/lfs is already present in the host, we asume that the
|
---|
| 27 | # lfs user and group are also presents in the host, and a backup
|
---|
| 28 | # of their bash init files is made.
|
---|
| 29 | (
|
---|
| 30 | cat << EOF
|
---|
| 31 | 020-creatingtoolsdir:
|
---|
| 32 | @\$(call echo_message, Building)
|
---|
[e314f7e] | 33 | @mkdir \$(MOUNT_PT)/tools && \\
|
---|
| 34 | rm -f /tools && \\
|
---|
| 35 | ln -s \$(MOUNT_PT)/tools /
|
---|
[877cc6a] | 36 | @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
|
---|
| 37 | mkdir \$(MOUNT_PT)/sources; \\
|
---|
| 38 | fi;
|
---|
| 39 | @chmod a+wt \$(MOUNT_PT)/sources && \\
|
---|
| 40 | touch \$@
|
---|
| 41 |
|
---|
| 42 | 021-addinguser: 020-creatingtoolsdir
|
---|
| 43 | @\$(call echo_message, Building)
|
---|
| 44 | @if [ ! -d /home/lfs ]; then \\
|
---|
| 45 | groupadd lfs; \\
|
---|
| 46 | useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
|
---|
| 47 | else \\
|
---|
| 48 | touch user-lfs-exist; \\
|
---|
| 49 | fi;
|
---|
| 50 | @chown lfs \$(MOUNT_PT)/tools && \\
|
---|
| 51 | chown lfs \$(MOUNT_PT)/sources && \\
|
---|
| 52 | touch \$@
|
---|
| 53 |
|
---|
| 54 | 022-settingenvironment: 021-addinguser
|
---|
| 55 | @\$(call echo_message, Building)
|
---|
| 56 | @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
[e314f7e] | 57 | mv /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
---|
[877cc6a] | 58 | fi;
|
---|
| 59 | @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
[e314f7e] | 60 | mv /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
---|
[877cc6a] | 61 | fi;
|
---|
| 62 | @echo "set +h" > /home/lfs/.bashrc && \\
|
---|
| 63 | echo "umask 022" >> /home/lfs/.bashrc && \\
|
---|
| 64 | echo "HLFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
|
---|
| 65 | echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
---|
| 66 | echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
---|
| 67 | echo "export HLFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
---|
| 68 | echo "" >> /home/lfs/.bashrc && \\
|
---|
| 69 | echo "target=$(uname -m)-${TARGET}" >> /home/lfs/.bashrc && \\
|
---|
| 70 | echo "ldso=/tools/lib/${LOADER}" >> /home/lfs/.bashrc && \\
|
---|
| 71 | echo "export target ldso" >> /home/lfs/.bashrc && \\
|
---|
| 72 | echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
|
---|
| 73 | chown lfs:lfs /home/lfs/.bashrc && \\
|
---|
| 74 | touch envars && \\
|
---|
| 75 | touch \$@
|
---|
| 76 | EOF
|
---|
| 77 | ) >> $MKFILE.tmp
|
---|
| 78 |
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | #----------------------------#
|
---|
| 82 | chapter5_Makefiles() { # Bootstrap or temptools phase
|
---|
| 83 | #----------------------------#
|
---|
| 84 | local file
|
---|
| 85 | local this_script
|
---|
| 86 |
|
---|
| 87 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
|
---|
| 88 |
|
---|
| 89 | for file in chapter05/* ; do
|
---|
| 90 | # Keep the script file name
|
---|
| 91 | this_script=`basename $file`
|
---|
| 92 |
|
---|
| 93 | # Skip this script depending on jhalfs.conf flags set.
|
---|
| 94 | case $this_script in
|
---|
| 95 | # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
---|
| 96 | *tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
| 97 | *expect* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
| 98 | *dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
|
---|
| 99 | # Nothing interestin in this script
|
---|
| 100 | *introduction* ) continue ;;
|
---|
| 101 | # Test if the stripping phase must be skipped
|
---|
| 102 | *stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
---|
| 103 | *) ;;
|
---|
| 104 | esac
|
---|
| 105 |
|
---|
| 106 | # First append each name of the script files to a list (this will become
|
---|
| 107 | # the names of the targets in the Makefile
|
---|
| 108 | chapter5="$chapter5 $this_script"
|
---|
| 109 |
|
---|
| 110 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
| 111 | # and binutils in chapter 5)
|
---|
| 112 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-cross@@' -e 's@-headers@@'`
|
---|
| 113 |
|
---|
| 114 | # Adjust 'name'
|
---|
| 115 | case $name in
|
---|
| 116 | linux-libc) name=linux-libc-headers ;;
|
---|
| 117 | esac
|
---|
| 118 |
|
---|
| 119 | # Set the dependency for the first target.
|
---|
| 120 | if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 | #--------------------------------------------------------------------#
|
---|
| 124 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 125 | #--------------------------------------------------------------------#
|
---|
| 126 | #
|
---|
| 127 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 128 | # as a dependency. Also call the echo_message function.
|
---|
| 129 | wrt_target "$this_script" "$PREV"
|
---|
| 130 |
|
---|
| 131 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 132 | # a specific package
|
---|
| 133 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 134 | # If $vrs isn't empty, we've got a package...
|
---|
| 135 | if [ "$vrs" != "" ] ; then
|
---|
| 136 | # Deal with non-standard names
|
---|
| 137 | case $name in
|
---|
| 138 | tcl) FILE="$name$vrs-src.tar.*" ;;
|
---|
| 139 | uclibc) FILE="uClibc-$vrs.tar.*" ;;
|
---|
| 140 | gcc) FILE="gcc-core-$vrs.tar.*" ;;
|
---|
| 141 | *) FILE="$name-$vrs.tar.*" ;;
|
---|
| 142 | esac
|
---|
[1b65a84] | 143 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
[5842156] | 144 | case $this_script in
|
---|
[82eb8c1] | 145 | *binutils* )
|
---|
[a229600] | 146 | wrt_unpack "$FILE" 1 ;; # Do not delete an existing package directories
|
---|
| 147 | *)
|
---|
| 148 | wrt_unpack "$FILE" ;;
|
---|
[5842156] | 149 | esac
|
---|
[a229600] | 150 | # If the testsuites must be run, initialize the log file
|
---|
| 151 | [[ "$TEST" = "3" ]] && wrt_test_log "${this_script}"
|
---|
| 152 | # If using optimizations, write the instructions
|
---|
[1b65a84] | 153 | [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
| 154 | fi
|
---|
[877cc6a] | 155 |
|
---|
| 156 | case $this_script in
|
---|
| 157 | *binutils* ) # Dump the path to sources directory for later removal
|
---|
[15537d5] | 158 | (
|
---|
| 159 | cat << EOF
|
---|
[82eb8c1] | 160 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[15537d5] | 161 | echo "\$(MOUNT_PT)\$(SRC)/\$\$ROOT" >> sources-dir
|
---|
| 162 | EOF
|
---|
| 163 | ) >> $MKFILE.tmp
|
---|
[877cc6a] | 164 | ;;
|
---|
| 165 | *adjusting* ) # For the Adjusting phase we must to cd to the binutils-build directory.
|
---|
| 166 | echo -e '\t@echo "export PKGDIR=$(MOUNT_PT)$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
|
---|
| 167 | ;;
|
---|
| 168 | esac
|
---|
| 169 |
|
---|
| 170 | # Insert date and disk usage at the top of the log file, the script run
|
---|
| 171 | # and date and disk usage again at the bottom of the log file.
|
---|
| 172 | wrt_run_as_su "${this_script}" "${file}"
|
---|
| 173 |
|
---|
| 174 | # Remove the build directory(ies) except if the package build fails
|
---|
| 175 | # (so we can review config.cache, config.log, etc.)
|
---|
| 176 | # For Binutils the sources must be retained for some time.
|
---|
| 177 | if [ "$vrs" != "" ] ; then
|
---|
| 178 | case "${this_script}" in
|
---|
| 179 | *binutils*) : # do NOTHING
|
---|
| 180 | ;;
|
---|
| 181 | *) wrt_remove_build_dirs "$name"
|
---|
| 182 | ;;
|
---|
| 183 | esac
|
---|
| 184 | fi
|
---|
| 185 |
|
---|
| 186 | # Remove the Binutils pass 1 sources after a successful Adjusting phase.
|
---|
| 187 | case "${this_script}" in
|
---|
| 188 | *adjusting*)
|
---|
| 189 | (
|
---|
| 190 | cat << EOF
|
---|
| 191 | @rm -r \`cat sources-dir\` && \\
|
---|
| 192 | rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
|
---|
| 193 | rm sources-dir
|
---|
| 194 | EOF
|
---|
| 195 | ) >> $MKFILE.tmp
|
---|
| 196 | ;;
|
---|
| 197 | esac
|
---|
| 198 |
|
---|
| 199 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 200 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
| 201 | #
|
---|
| 202 | #--------------------------------------------------------------------#
|
---|
| 203 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 204 | #--------------------------------------------------------------------#
|
---|
| 205 |
|
---|
| 206 | # Keep the script file name for Makefile dependencies.
|
---|
| 207 | PREV=$this_script
|
---|
| 208 | done # end for file in chapter05/*
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 |
|
---|
| 212 | #----------------------------#
|
---|
| 213 | chapter6_Makefiles() { # sysroot or chroot build phase
|
---|
| 214 | #----------------------------#
|
---|
| 215 | local TARGET LOADER
|
---|
| 216 | local file
|
---|
| 217 | local this_script
|
---|
[45f82718] | 218 | # Set envars and scripts for iteration targets
|
---|
| 219 | LOGS="" # Start with an empty global LOGS envar
|
---|
| 220 | if [[ -z "$1" ]] ; then
|
---|
| 221 | local N=""
|
---|
| 222 | else
|
---|
| 223 | local N=-build_$1
|
---|
| 224 | local chapter6=""
|
---|
| 225 | mkdir chapter06$N
|
---|
| 226 | cp chapter06/* chapter06$N
|
---|
| 227 | for script in chapter06$N/* ; do
|
---|
| 228 | # Overwrite existing symlinks, files, and dirs
|
---|
| 229 | sed -e 's/ln -s /ln -sf /g' \
|
---|
| 230 | -e 's/^mv /&-f/g' -i ${script}
|
---|
| 231 | done
|
---|
| 232 | # Remove Bzip2 binaries before make install
|
---|
| 233 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2
|
---|
| 234 | # Fix how Module-Init-Tools do the install target
|
---|
| 235 | sed -e 's@make install@make INSTALL=install install@' -i chapter06$N/*-module-init-tools
|
---|
| 236 | # Delete *old Readline libraries just after make install
|
---|
| 237 | sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i chapter06$N/*-readline
|
---|
| 238 | # Don't readd already existing groups
|
---|
| 239 | sed -e '/groupadd/d' -i chapter06$N/*-udev
|
---|
| 240 | fi
|
---|
[877cc6a] | 241 |
|
---|
[45f82718] | 242 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
|
---|
[877cc6a] | 243 | #
|
---|
| 244 | # Set these definitions early and only once
|
---|
| 245 | #
|
---|
| 246 | if [[ ${MODEL} = "uclibc" ]]; then
|
---|
| 247 | TARGET="pc-linux-uclibc"; LOADER="ld-uClibc.so.0"
|
---|
| 248 | else
|
---|
| 249 | TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
|
---|
| 250 | fi
|
---|
| 251 |
|
---|
[45f82718] | 252 | for file in chapter06$N/* ; do
|
---|
[877cc6a] | 253 | # Keep the script file name
|
---|
| 254 | this_script=`basename $file`
|
---|
| 255 |
|
---|
| 256 | # Skip this script depending on jhalfs.conf flags set.
|
---|
| 257 | case $this_script in
|
---|
| 258 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
| 259 | # dependencies and target creation.
|
---|
| 260 | *chroot* ) continue ;;
|
---|
| 261 | # Test if the stripping phase must be skipped
|
---|
| 262 | *-stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
|
---|
| 263 | esac
|
---|
| 264 |
|
---|
| 265 | # Grab the name of the target
|
---|
| 266 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
| 267 |
|
---|
[45f82718] | 268 | # Find the version of the command files, if it corresponds with the building of
|
---|
| 269 | # a specific package
|
---|
| 270 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 271 |
|
---|
| 272 | if [[ "$vrs" = "" ]] && [[ -n "$N" ]] ; then
|
---|
| 273 | case "${this_script}" in
|
---|
| 274 | *stripping*) ;;
|
---|
| 275 | *) continue ;;
|
---|
| 276 | esac
|
---|
| 277 | fi
|
---|
| 278 |
|
---|
| 279 | # Append each name of the script files to a list (this will become
|
---|
| 280 | # the names of the targets in the Makefile
|
---|
| 281 | chapter6="$chapter6 ${this_script}${N}"
|
---|
| 282 |
|
---|
| 283 | # Append each name of the script files to a list (this will become
|
---|
| 284 | # the names of the logs to be moved for each iteration)
|
---|
| 285 | LOGS="$LOGS ${this_script}"
|
---|
| 286 |
|
---|
[877cc6a] | 287 | #
|
---|
| 288 | # Sed replacement to fix some rm command that could fail.
|
---|
| 289 | # That should be fixed in the book sources.
|
---|
| 290 | #
|
---|
| 291 | case $name in
|
---|
| 292 | glibc)
|
---|
[45f82718] | 293 | sed 's/rm /rm -f /' -i chapter06$N/$this_script
|
---|
[877cc6a] | 294 | ;;
|
---|
| 295 | gcc)
|
---|
[45f82718] | 296 | sed 's/rm /rm -f /' -i chapter06$N/$this_script
|
---|
[877cc6a] | 297 | ;;
|
---|
| 298 | esac
|
---|
| 299 |
|
---|
| 300 | #--------------------------------------------------------------------#
|
---|
| 301 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 302 | #--------------------------------------------------------------------#
|
---|
| 303 | #
|
---|
| 304 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 305 | # as a dependency. Also call the echo_message function.
|
---|
[45f82718] | 306 | wrt_target "${this_script}${N}" "$PREV"
|
---|
[877cc6a] | 307 |
|
---|
| 308 | # If $vrs isn't empty, we've got a package...
|
---|
| 309 | # Insert instructions for unpacking the package and changing directories
|
---|
| 310 | if [ "$vrs" != "" ] ; then
|
---|
| 311 | # Deal with non-standard names
|
---|
| 312 | case $name in
|
---|
| 313 | tcl) FILE="$name$vrs-src.tar.*" ;;
|
---|
| 314 | uclibc) FILE="uClibc-$vrs.tar.*" ;;
|
---|
| 315 | gcc) FILE="gcc-core-$vrs.tar.*" ;;
|
---|
| 316 | *) FILE="$name-$vrs.tar.*" ;;
|
---|
| 317 | esac
|
---|
| 318 | wrt_unpack2 "$FILE"
|
---|
| 319 | wrt_target_vars
|
---|
[a229600] | 320 | # If the testsuites must be run, initialize the log file
|
---|
| 321 | case $name in
|
---|
| 322 | binutils | gcc | glibc )
|
---|
| 323 | [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
|
---|
| 324 | ;;
|
---|
| 325 | * )
|
---|
| 326 | [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
|
---|
| 327 | ;;
|
---|
| 328 | esac
|
---|
| 329 | # If using optimizations, write the instructions
|
---|
[1b65a84] | 330 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
[877cc6a] | 331 | fi
|
---|
| 332 |
|
---|
| 333 | case $this_script in
|
---|
| 334 | *readjusting*) # For the Re-Adjusting phase we must to cd to the binutils-build directory.
|
---|
| 335 | echo -e '\t@echo "export PKGDIR=$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
|
---|
| 336 | ;;
|
---|
| 337 | esac
|
---|
| 338 |
|
---|
| 339 | # In the mount of kernel filesystems we need to set LFS and not to use chroot.
|
---|
| 340 | case "${this_script}" in
|
---|
| 341 | *kernfs*)
|
---|
| 342 | wrt_run_as_root "${this_script}" "${file}"
|
---|
| 343 | ;;
|
---|
| 344 | *) # The rest of Chapter06
|
---|
| 345 | wrt_run_as_chroot1 "${this_script}" "${file}"
|
---|
| 346 | ;;
|
---|
| 347 | esac
|
---|
| 348 | #
|
---|
| 349 | # Remove the build directory(ies) except if the package build fails.
|
---|
| 350 | if [ "$vrs" != "" ] ; then
|
---|
| 351 | wrt_remove_build_dirs "$name"
|
---|
| 352 | fi
|
---|
| 353 | #
|
---|
| 354 | # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
|
---|
| 355 | case "${this_script}" in
|
---|
| 356 | *readjusting*)
|
---|
| 357 | (
|
---|
| 358 | cat << EOF
|
---|
| 359 | @rm -r \`cat sources-dir\` && \\
|
---|
| 360 | rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
|
---|
| 361 | rm sources-dir
|
---|
| 362 | EOF
|
---|
| 363 | ) >> $MKFILE.tmp
|
---|
| 364 | ;;
|
---|
| 365 | esac
|
---|
| 366 |
|
---|
| 367 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 368 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
| 369 | #
|
---|
| 370 | #--------------------------------------------------------------------#
|
---|
| 371 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 372 | #--------------------------------------------------------------------#
|
---|
| 373 |
|
---|
| 374 | # Keep the script file name for Makefile dependencies.
|
---|
[45f82718] | 375 | PREV=${this_script}${N}
|
---|
| 376 | # Set system_build envar for iteration targets
|
---|
| 377 | system_build=$chapter6
|
---|
[877cc6a] | 378 | done # end for file in chapter06/*
|
---|
| 379 |
|
---|
| 380 | }
|
---|
| 381 |
|
---|
| 382 | #----------------------------#
|
---|
| 383 | chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
|
---|
| 384 | #----------------------------#
|
---|
| 385 | local file
|
---|
| 386 | local this_script
|
---|
| 387 |
|
---|
| 388 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7${R_arrow}"
|
---|
| 389 | for file in chapter07/*; do
|
---|
| 390 | # Keep the script file name
|
---|
| 391 | this_script=`basename $file`
|
---|
| 392 |
|
---|
| 393 | # Grub must be configured manually.
|
---|
| 394 | # The filesystems can't be unmounted via Makefile and the user
|
---|
| 395 | # should enter the chroot environment to create the root
|
---|
| 396 | # password, edit several files and setup Grub.
|
---|
| 397 | case $this_script in
|
---|
| 398 | *usage) continue ;; # Contains example commands
|
---|
| 399 | *grub) continue ;;
|
---|
| 400 | *reboot) continue ;;
|
---|
| 401 | *console) continue ;; # Use the file generated by lfs-bootscripts
|
---|
| 402 |
|
---|
| 403 | *kernel)
|
---|
| 404 | # If no .config file is supplied, the kernel build is skipped
|
---|
| 405 | [[ -z $CONFIG ]] && continue
|
---|
| 406 | cp $CONFIG $BUILDDIR/sources/kernel-config
|
---|
| 407 | ;;
|
---|
| 408 | esac
|
---|
| 409 |
|
---|
| 410 | # First append then name of the script file to a list (this will become
|
---|
| 411 | # the names of the targets in the Makefile
|
---|
| 412 | chapter7="$chapter7 $this_script"
|
---|
| 413 |
|
---|
| 414 | #--------------------------------------------------------------------#
|
---|
| 415 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 416 | #--------------------------------------------------------------------#
|
---|
| 417 | #
|
---|
| 418 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 419 | # as a dependency. Also call the echo_message function.
|
---|
| 420 | wrt_target "$this_script" "$PREV"
|
---|
| 421 |
|
---|
| 422 | case "${this_script}" in
|
---|
| 423 | *bootscripts*)
|
---|
| 424 | vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 425 | FILE="lfs-bootscripts-$vrs.tar.*"
|
---|
| 426 | wrt_unpack2 "$FILE"
|
---|
| 427 | vrs=`grep "^blfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
| 428 | echo -e "\t@echo \"\$(MOUNT_PT)\$(SRC)/blfs-bootscripts-$vrs\" >> sources-dir" >> $MKFILE.tmp
|
---|
| 429 | ;;
|
---|
| 430 | esac
|
---|
| 431 |
|
---|
| 432 | case "${this_script}" in
|
---|
| 433 | *fstab*) # Check if we have a real /etc/fstab file
|
---|
| 434 | if [[ -n "$FSTAB" ]] ; then
|
---|
| 435 | wrt_copy_fstab "$this_script"
|
---|
| 436 | else # Initialize the log and run the script
|
---|
| 437 | wrt_run_as_chroot2 "${this_script}" "${file}"
|
---|
| 438 | fi
|
---|
| 439 | ;;
|
---|
| 440 | *) # All other scripts
|
---|
| 441 | wrt_run_as_chroot2 "${this_script}" "${file}"
|
---|
| 442 | ;;
|
---|
| 443 | esac
|
---|
| 444 |
|
---|
| 445 | # Remove the build directory except if the package build fails.
|
---|
| 446 | case "${this_script}" in
|
---|
| 447 | *bootscripts*)
|
---|
| 448 | (
|
---|
| 449 | cat << EOF
|
---|
[82eb8c1] | 450 | @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
[877cc6a] | 451 | rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
| 452 | @rm -r \`cat sources-dir\` && \\
|
---|
| 453 | rm sources-dir
|
---|
| 454 | EOF
|
---|
| 455 | ) >> $MKFILE.tmp
|
---|
| 456 | ;;
|
---|
| 457 | esac
|
---|
| 458 |
|
---|
| 459 | # Include a touch of the target name so make can check if it's already been made.
|
---|
| 460 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
| 461 | #
|
---|
| 462 | #--------------------------------------------------------------------#
|
---|
| 463 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 464 | #--------------------------------------------------------------------#
|
---|
| 465 |
|
---|
| 466 | # Keep the script file name for Makefile dependencies.
|
---|
| 467 | PREV=$this_script
|
---|
| 468 | done # for file in chapter07/*
|
---|
[453bef0] | 469 |
|
---|
| 470 | # Add SBU-disk_usage report target if required
|
---|
| 471 | if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
|
---|
[877cc6a] | 472 | }
|
---|
| 473 |
|
---|
| 474 |
|
---|
| 475 | #----------------------------#
|
---|
| 476 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
| 477 | #----------------------------#
|
---|
[c7c5a53] | 478 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
[877cc6a] | 479 |
|
---|
| 480 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 481 | # Start with a clean Makefile.tmp file
|
---|
| 482 | >$MKFILE.tmp
|
---|
| 483 |
|
---|
| 484 | chapter3_Makefiles
|
---|
| 485 | chapter5_Makefiles
|
---|
| 486 | chapter6_Makefiles
|
---|
[45f82718] | 487 | # Add the iterations targets, if needed
|
---|
| 488 | [[ "$COMPARE" != "0" ]] && wrt_compare_targets
|
---|
[877cc6a] | 489 | chapter7_Makefiles
|
---|
| 490 |
|
---|
| 491 | # Add a header, some variables and include the function file
|
---|
| 492 | # to the top of the real Makefile.
|
---|
| 493 | (
|
---|
| 494 | cat << EOF
|
---|
| 495 | $HEADER
|
---|
| 496 |
|
---|
| 497 | SRC= /sources
|
---|
| 498 | MOUNT_PT= $BUILDDIR
|
---|
[82eb8c1] | 499 | PKG_LST= $PKG_LST
|
---|
[877cc6a] | 500 |
|
---|
| 501 | include makefile-functions
|
---|
| 502 |
|
---|
| 503 | EOF
|
---|
| 504 | ) > $MKFILE
|
---|
| 505 |
|
---|
| 506 |
|
---|
| 507 | # Add chroot commands
|
---|
| 508 | i=1
|
---|
| 509 | for file in chapter06/*chroot* ; do
|
---|
| 510 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
|
---|
| 511 | -e '/^export/d' \
|
---|
| 512 | -e '/^logout/d' \
|
---|
| 513 | -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
|
---|
| 514 | -e 's|\\$|&&|g' \
|
---|
| 515 | -e 's|exit||g' \
|
---|
| 516 | -e 's|$| -c|' \
|
---|
| 517 | -e 's|"$$HLFS"|$(MOUNT_PT)|'\
|
---|
| 518 | -e 's|set -e||'`
|
---|
| 519 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
| 520 | i=`expr $i + 1`
|
---|
| 521 | done
|
---|
| 522 |
|
---|
| 523 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 524 | # as a dependency.
|
---|
| 525 | (
|
---|
| 526 | cat << EOF
|
---|
[c8f9cd8] | 527 | all: chapter3 chapter5 chapter6 chapter7 do-housekeeping
|
---|
[877cc6a] | 528 | @\$(call echo_finished,$VERSION)
|
---|
| 529 |
|
---|
| 530 | chapter3: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
---|
| 531 |
|
---|
| 532 | chapter5: chapter3 $chapter5 restore-lfs-env
|
---|
| 533 |
|
---|
| 534 | chapter6: chapter5 $chapter6
|
---|
| 535 |
|
---|
| 536 | chapter7: chapter6 $chapter7
|
---|
| 537 |
|
---|
| 538 | clean-all: clean
|
---|
| 539 | rm -rf ./{hlfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
|
---|
| 540 |
|
---|
| 541 | clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter3
|
---|
| 542 |
|
---|
| 543 | clean-chapter3:
|
---|
| 544 | -if [ ! -f user-lfs-exist ]; then \\
|
---|
| 545 | userdel lfs; \\
|
---|
| 546 | rm -rf /home/lfs; \\
|
---|
| 547 | fi;
|
---|
| 548 | rm -rf \$(MOUNT_PT)/tools
|
---|
| 549 | rm -f /tools
|
---|
| 550 | rm -f envars user-lfs-exist
|
---|
| 551 | rm -f 02* logs/02*.log
|
---|
| 552 |
|
---|
| 553 | clean-chapter5:
|
---|
| 554 | rm -rf \$(MOUNT_PT)/tools/*
|
---|
| 555 | rm -f $chapter5 restore-lfs-env sources-dir
|
---|
| 556 | cd logs && rm -f $chapter5 && cd ..
|
---|
| 557 |
|
---|
| 558 | clean-chapter6:
|
---|
| 559 | -umount \$(MOUNT_PT)/sys
|
---|
| 560 | -umount \$(MOUNT_PT)/proc
|
---|
| 561 | -umount \$(MOUNT_PT)/dev/shm
|
---|
| 562 | -umount \$(MOUNT_PT)/dev/pts
|
---|
| 563 | -umount \$(MOUNT_PT)/dev
|
---|
| 564 | rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
---|
| 565 | rm -f $chapter6
|
---|
| 566 | cd logs && rm -f $chapter6 && cd ..
|
---|
| 567 |
|
---|
| 568 | clean-chapter7:
|
---|
| 569 | rm -f $chapter7
|
---|
| 570 | cd logs && rm -f $chapter7 && cd ..
|
---|
| 571 |
|
---|
| 572 | restore-lfs-env:
|
---|
| 573 | @\$(call echo_message, Building)
|
---|
| 574 | @if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
[e314f7e] | 575 | mv -f /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
|
---|
[877cc6a] | 576 | fi;
|
---|
| 577 | @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
[e314f7e] | 578 | mv /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
|
---|
[877cc6a] | 579 | fi;
|
---|
| 580 | @chown lfs:lfs /home/lfs/.bash* && \\
|
---|
| 581 | touch \$@
|
---|
| 582 |
|
---|
[7d9a82d] | 583 | do-housekeeping:
|
---|
| 584 | -umount \$(MOUNT_PT)/dev/pts
|
---|
| 585 | -umount \$(MOUNT_PT)/dev/shm
|
---|
| 586 | -umount \$(MOUNT_PT)/dev
|
---|
| 587 | -umount \$(MOUNT_PT)/sys
|
---|
| 588 | -umount \$(MOUNT_PT)/proc
|
---|
| 589 | -if [ ! -f user-lfs-exist ]; then \\
|
---|
| 590 | userdel lfs; \\
|
---|
| 591 | rm -rf /home/lfs; \\
|
---|
| 592 | fi;
|
---|
[a858a78] | 593 |
|
---|
[877cc6a] | 594 | EOF
|
---|
| 595 | ) >> $MKFILE
|
---|
| 596 |
|
---|
| 597 | # Bring over the items from the Makefile.tmp
|
---|
| 598 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 599 | rm $MKFILE.tmp
|
---|
[c7c5a53] | 600 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 601 |
|
---|
[877cc6a] | 602 | }
|
---|