source: CLFS/master.sh@ 37ac06a

experimental
Last change on this file since 37ac06a was 966cb20, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Merged r2771 from trunk.

  • Property mode set to 100755
File size: 41.9 KB
Line 
1#!/bin/sh
2# $Id$
3
4###################################
5### FUNCTIONS ###
6###################################
7
8
9
10#----------------------------#
11host_prep_Makefiles() { # Initialization of the system
12#----------------------------#
13 local LFS_HOST
14
15 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files${R_arrow}"
16
17 # defined here, only for ease of reading
18 LFS_HOST="`echo ${MACHTYPE} | sed -e 's/unknown/cross/g' -e 's/-pc-/-cross-/g'`"
19(
20cat << EOF
21023-creatingtoolsdir:
22 @\$(call echo_message, Building)
23 @mkdir \$(MOUNT_PT)/tools && \\
24 rm -f /tools && \\
25 ln -s \$(MOUNT_PT)/tools /
26 @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
27 mkdir \$(MOUNT_PT)/sources; \\
28 fi;
29 @chmod a+wt \$(MOUNT_PT)/sources && \\
30 touch \$@ && \\
31 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
32 echo --------------------------------------------------------------------------------\$(WHITE)
33
34024-creatingcrossdir: 023-creatingtoolsdir
35 @mkdir -v \$(MOUNT_PT)/cross-tools && \\
36 rm -f /cross-tools && \\
37 ln -s \$(MOUNT_PT)/cross-tools /
38 @touch \$@ && \\
39 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
40 echo --------------------------------------------------------------------------------\$(WHITE)
41
42025-addinguser: 024-creatingcrossdir
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) && \\
51 chown lfs \$(MOUNT_PT)/tools && \\
52 chown lfs \$(MOUNT_PT)/cross-tools && \\
53 chown lfs \$(MOUNT_PT)/sources && \\
54 touch \$@ && \\
55 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
56 echo --------------------------------------------------------------------------------\$(WHITE)
57
58026-settingenvironment: 025-addinguser
59 @\$(call echo_message, Building)
60 @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
61 mv /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
62 fi;
63 @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
64 mv /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
65 fi;
66 @echo "set +h" > /home/lfs/.bashrc && \\
67 echo "umask 022" >> /home/lfs/.bashrc && \\
68 echo "LFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
69 echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
70 echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
71 echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
72 echo "" >> /home/lfs/.bashrc && \\
73 echo "unset CFLAGS" >> /home/lfs/.bashrc && \\
74 echo "unset CXXFLAGS" >> /home/lfs/.bashrc && \\
75 echo "" >> /home/lfs/.bashrc && \\
76 echo "export LFS_HOST=\"${LFS_HOST}\"" >> /home/lfs/.bashrc && \\
77 echo "export LFS_TARGET=\"${TARGET}\"" >> /home/lfs/.bashrc && \\
78 echo "export LFS_TARGET32=\"${TARGET32}\"" >> /home/lfs/.bashrc && \\
79 echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc
80 @chown lfs:lfs /home/lfs/.bashrc && \\
81 touch envars && \\
82 touch \$@ && \\
83 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
84 echo --------------------------------------------------------------------------------\$(WHITE)
85EOF
86) >> $MKFILE.tmp
87
88}
89
90
91
92#-----------------------------#
93cross_tools_Makefiles() { #
94#-----------------------------#
95 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools${R_arrow}"
96
97 for file in cross-tools/* ; do
98 # Keep the script file name
99 this_script=`basename $file`
100 #
101 # Skip this script...
102 case $this_script in
103 *cflags* | *variables* ) # work done in host_prep_Makefiles
104 continue; ;;
105 *) ;;
106 esac
107 #
108 # Set the dependency for the first target.
109 if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
110
111 # First append each name of the script files to a list (this will become
112 # the names of the targets in the Makefile
113 cross_tools="$cross_tools $this_script"
114
115 # Grab the name of the target (minus the -headers or -cross in the case of gcc
116 # and binutils in chapter 5)
117 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
118 -e 's@-static@@' \
119 -e 's@-final@@' \
120 -e 's@-headers@@' \
121 -e 's@-64@@' \
122 -e 's@-n32@@'`
123 # Adjust 'name' and patch a few scripts on the fly..
124 case $name in
125 linux-libc) name=linux-libc-headers ;;
126 esac
127 #
128 # Find the version of the command files, if it corresponds with the building of a specific package
129 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
130
131
132 #--------------------------------------------------------------------#
133 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
134 #--------------------------------------------------------------------#
135 #
136 # Drop in the name of the target on a new line, and the previous target
137 # as a dependency. Also call the echo_message function.
138 wrt_target "${this_script}" "$PREV"
139 #
140 # If $vrs isn't empty, we've got a package...
141 #
142 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
143 #
144 wrt_run_as_su "${this_script}" "${file}"
145 #
146 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
147 #
148 # Include a touch of the target name so make can check if it's already been made.
149 wrt_touch
150 #
151 #--------------------------------------------------------------------#
152 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
153 #--------------------------------------------------------------------#
154 #
155 # Keep the script file name for Makefile dependencies.
156 PREV=$this_script
157
158 done # for file in ....
159}
160
161
162#-----------------------------#
163temptools_Makefiles() { #
164#-----------------------------#
165 echo "${tab_}${GREEN}Processing... ${L_arrow}temp system${R_arrow}"
166
167 for file in temp-system/* ; do
168 # Keep the script file name
169 this_script=`basename $file`
170 #
171 # First append each name of the script files to a list (this will become
172 # the names of the targets in the Makefile
173 temptools="$temptools $this_script"
174
175 #
176 # Grab the name of the target, strip id number, XXX-script
177 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
178 #
179 # Find the version of the command files, if it corresponds with the building of a specific package
180 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
181
182
183 #--------------------------------------------------------------------#
184 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
185 #--------------------------------------------------------------------#
186 #
187 # Drop in the name of the target on a new line, and the previous target
188 # as a dependency. Also call the echo_message function.
189 wrt_target "${this_script}" "$PREV"
190 #
191 # If $vrs isn't empty, we've got a package...
192 # Insert instructions for unpacking the package and to set the PKGDIR variable.
193 #
194 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
195 [[ "$vrs" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
196 #
197 wrt_run_as_su "${this_script}" "${file}"
198 #
199 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
200 #
201 # Include a touch of the target name so make can check if it's already been made.
202 wrt_touch
203 #
204 #--------------------------------------------------------------------#
205 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
206 #--------------------------------------------------------------------#
207 #
208 # Keep the script file name for Makefile dependencies.
209 PREV=$this_script
210 done # for file in ....
211}
212
213
214#-----------------------------#
215boot_Makefiles() { #
216#-----------------------------#
217 echo "${tab_}${GREEN}Processing... ${L_arrow}boot${R_arrow}"
218
219 for file in boot/* ; do
220 # Keep the script file name
221 this_script=`basename $file`
222
223 # A little housekeeping on the scripts
224 case $this_script in
225 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
226 *whatnext*) continue ;;
227 *kernel) # if there is no kernel config file do not build the kernel
228 [[ -z $CONFIG ]] && continue
229 # Copy the config file to /sources with a standardized name
230 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
231 ;;
232 esac
233 #
234 # First append each name of the script files to a list (this will become
235 # the names of the targets in the Makefile
236 boottools="$boottools $this_script"
237 #
238 # Grab the name of the target, strip id number and misc words.
239 case $this_script in
240 *kernel) name=linux ;;
241 *bootscripts) name="bootscripts-cross-lfs" ;;
242 *udev-rules) name="udev-cross-lfs" ;;
243 *grub-build) name=grub ;;
244 *-aboot-build) name=aboot ;;
245 *yaboot-build) name=yaboot ;;
246 *colo-build) name=colo ;;
247 *silo-build) name=silo ;;
248 *arcload-build) name=arcload ;;
249 *lilo-build) name=lilo ;;
250 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
251 esac
252
253 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
254
255 #--------------------------------------------------------------------#
256 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
257 #--------------------------------------------------------------------#
258 #
259 # Drop in the name of the target on a new line, and the previous target
260 # as a dependency. Also call the echo_message function.
261 wrt_target "${this_script}" "$PREV"
262 #
263 # If $vrs isn't empty, we've got a package...
264 # Insert instructions for unpacking the package and changing directories
265 #
266 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
267 [[ "$vrs" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
268 #
269 # Select a script execution method
270 case $this_script in
271 *changingowner*) wrt_run_as_root "${this_script}" "${file}" ;;
272 *devices*) wrt_run_as_root "${this_script}" "${file}" ;;
273 *fstab*) if [[ -n "$FSTAB" ]]; then
274 wrt_copy_fstab "${this_script}"
275 else
276 wrt_run_as_su "${this_script}" "${file}"
277 fi
278 ;;
279 *) wrt_run_as_su "${this_script}" "${file}" ;;
280 esac
281 #
282 # Housekeeping...remove any build directory(ies) except if the package build fails.
283 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
284 #
285 # Include a touch of the target name so make can check if it's already been made.
286 wrt_touch
287 #
288 #--------------------------------------------------------------------#
289 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
290 #--------------------------------------------------------------------#
291 #
292 # Keep the script file name for Makefile dependencies.
293 PREV=$this_script
294
295 done
296}
297
298
299#-----------------------------#
300chroot_Makefiles() { #
301#-----------------------------#
302 echo "${tab_}${GREEN}Processing... ${L_arrow}chroot${R_arrow}"
303
304 for file in chroot/* ; do
305 # Keep the script file name
306 this_script=`basename $file`
307 #
308 # Skipping scripts is done now and not included in the build tree.
309 case $this_script in
310 *chroot*) continue ;;
311 esac
312
313 #
314 # First append each name of the script files to a list (this will become
315 # the names of the targets in the Makefile
316 chroottools="$chroottools $this_script"
317
318 # Grab the name of the target, strip id number, XXX-script
319 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
320 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
321
322 #--------------------------------------------------------------------#
323 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
324 #--------------------------------------------------------------------#
325 #
326 # Drop in the name of the target on a new line, and the previous target
327 # as a dependency. Also call the echo_message function.
328 wrt_target "${this_script}" "$PREV"
329 #
330 # If $vrs isn't empty, we've got a package...
331 # Insert instructions for unpacking the package and changing directories
332 #
333 if [ "$vrs" != "" ] ; then
334 case $this_script in
335 *util-linux) wrt_unpack "$name-$vrs.tar.*" ;;
336 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
337 esac
338 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
339 fi
340 #
341 # Select a script execution method
342 case $this_script in
343 *kernfs) wrt_run_as_root "${this_script}" "${file}" ;;
344 *util-linux) wrt_run_as_su "${this_script}" "${file}" ;;
345 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
346 esac
347 #
348 # Housekeeping...remove the build directory(ies), except if the package build fails.
349 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
350 #
351 # Include a touch of the target name so make can check if it's already been made.
352 wrt_touch
353 #
354 #--------------------------------------------------------------------#
355 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
356 #--------------------------------------------------------------------#
357 #
358 # Keep the script file name for Makefile dependencies.
359 PREV=$this_script
360
361 done # for file in...
362}
363
364
365#-----------------------------#
366testsuite_tools_Makefiles() { #
367#-----------------------------#
368 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools${R_arrow}"
369
370 for file in testsuite-tools/* ; do
371 # Keep the script file name
372 this_script=`basename $file`
373
374 # First append each name of the script files to a list (this will become
375 # the names of the targets in the Makefile
376 testsuitetools="$testsuitetools $this_script"
377
378 # Grab the name of the target, strip id number, XXX-script
379 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
380 -e 's@-64bit@@' \
381 -e 's@-64@@' \
382 -e 's@64@@' \
383 -e 's@n32@@'`
384
385 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
386
387 #--------------------------------------------------------------------#
388 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
389 #--------------------------------------------------------------------#
390 #
391 # Drop in the name of the target on a new line, and the previous target
392 # as a dependency. Also call the echo_message function.
393 wrt_target "${this_script}" "$PREV"
394 #
395 case $name in
396 tcl) wrt_unpack2 "$name$vrs-src.tar.*" ;;
397 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
398 esac
399 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
400 #
401 wrt_run_as_chroot1 "${this_script}" "${file}"
402 #
403 wrt_remove_build_dirs "${name}"
404 #
405 # Include a touch of the target name so make can check if it's already been made.
406 wrt_touch
407 #
408 #--------------------------------------------------------------------#
409 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
410 #--------------------------------------------------------------------#
411 #
412 # Keep the script file name for Makefile dependencies.
413 PREV=$this_script
414
415 done
416}
417
418
419#--------------------------------#
420bm_testsuite_tools_Makefiles() { #
421#--------------------------------#
422 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools${R_arrow}"
423
424 for file in testsuite-tools/* ; do
425 # Keep the script file name
426 this_script=`basename $file`
427
428 # First append each name of the script files to a list (this will become
429 # the names of the targets in the Makefile
430 PREV=
431 testsuitetools="$testsuitetools $this_script"
432
433 # Grab the name of the target, strip id number, XXX-script
434 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
435 -e 's@-64bit@@' \
436 -e 's@-64@@' \
437 -e 's@64@@' \
438 -e 's@n32@@'`
439
440 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
441
442 #--------------------------------------------------------------------#
443 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
444 #--------------------------------------------------------------------#
445 #
446 # Drop in the name of the target on a new line, and the previous target
447 # as a dependency. Also call the echo_message function.
448 wrt_target "${this_script}" "$PREV"
449 #
450 case $name in
451 tcl) wrt_unpack3 "$name$vrs-src.tar.*" ;;
452 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
453 esac
454 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
455 #
456 wrt_run_as_root2 "${this_script}" "${file}"
457 #
458 wrt_remove_build_dirs2 "${name}"
459 #
460 # Include a touch of the target name so make can check if it's already been made.
461 wrt_touch
462 #
463 #--------------------------------------------------------------------#
464 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
465 #--------------------------------------------------------------------#
466 #
467 # Keep the script file name for Makefile dependencies.
468 PREV=$this_script
469
470 done
471}
472
473
474#-----------------------------#
475final_system_Makefiles() { #
476#-----------------------------#
477 # Set envars and scripts for iteration targets
478 LOGS="" # Start with an empty global LOGS envar
479 if [[ -z "$1" ]] ; then
480 local N=""
481 else
482 local N=-build_$1
483 local basicsystem=""
484 mkdir final-system$N
485 cp final-system/* final-system$N
486 for script in final-system$N/* ; do
487 # Overwrite existing symlinks, files, and dirs
488 sed -e 's/ln -sv/&f/g' \
489 -e 's/mv -v/&f/g' \
490 -e 's/mkdir -v/&p/g' -i ${script}
491 done
492 # Remove Bzip2 binaries before make install
493 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
494 # Delete *old Readline libraries just after make install
495 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
496 fi
497
498 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N${R_arrow}"
499
500 for file in final-system$N/* ; do
501 # Keep the script file name
502 this_script=`basename $file`
503
504 # Test if the stripping phase must be skipped.
505 # Skip alsp temp-perl for iterative runs
506 case $this_script in
507 *stripping*) [[ "$STRIP" = "0" ]] && continue ;;
508 *temp-perl*) [[ -n "$N" ]] && continue ;;
509 esac
510
511 # Grab the name of the target, strip id number, XXX-script
512 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
513 -e 's@temp-@@' \
514 -e 's@-64bit@@' \
515 -e 's@-64@@' \
516 -e 's@64@@' \
517 -e 's@n32@@'`
518
519 # Find the version of the command files, if it corresponds with the building of
520 # a specific package. We need this here to can skip scripts not needed for
521 # iterations rebuilds
522 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
523
524 if [[ "$vrs" = "" ]] && [[ -n "$N" ]] ; then
525 case "${this_script}" in
526 *stripping*) ;;
527 *) continue ;;
528 esac
529 fi
530
531 # Append each name of the script files to a list (this will become
532 # the names of the targets in the Makefile
533 basicsystem="$basicsystem ${this_script}${N}"
534
535 # Append each name of the script files to a list (this will become
536 # the names of the logs to be moved for each iteration)
537 LOGS="$LOGS ${this_script}"
538
539 #--------------------------------------------------------------------#
540 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
541 #--------------------------------------------------------------------#
542 #
543 # Drop in the name of the target on a new line, and the previous target
544 # as a dependency. Also call the echo_message function.
545 wrt_target "${this_script}${N}" "$PREV"
546
547 # If $vrs isn't empty, we've got a package...
548 if [ "$vrs" != "" ] ; then
549 FILE="$name-$vrs.tar.*"
550 wrt_unpack2 "$FILE"
551 # If the testsuites must be run, initialize the log file
552 case $name in
553 binutils | gcc | glibc )
554 [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
555 ;;
556 * )
557 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
558 ;;
559 esac
560 # If using optimizations, write the instructions
561 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
562 fi
563 #
564 wrt_run_as_chroot1 "${this_script}" "${file}"
565 #
566 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
567 #
568 # Include a touch of the target name so make can check if it's already been made.
569 wrt_touch
570 #
571 #--------------------------------------------------------------------#
572 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
573 #--------------------------------------------------------------------#
574 #
575 # Keep the script file name for Makefile dependencies.
576 PREV=${this_script}${N}
577 # Set system_build envar for iteration targets
578 system_build=$basicsystem
579 done # for file in final-system/* ...
580}
581
582
583#-----------------------------#
584bm_final_system_Makefiles() { #
585#-----------------------------#
586 # Set envars and scripts for iteration targets
587 LOGS="" # Start with an empty global LOGS envar
588 if [[ -z "$1" ]] ; then
589 local N=""
590 # The makesys phase was initiated in bm_testsuite_tools_makefile
591 [[ "$TEST" = 0 ]] && PREV=""
592 else
593 local N=-build_$1
594 local basicsystem=""
595 mkdir final-system$N
596 cp final-system/* final-system$N
597 for script in final-system$N/* ; do
598 # Overwrite existing symlinks, files, and dirs
599 sed -e 's/ln -sv/&f/g' \
600 -e 's/mv -v/&f/g' \
601 -e 's/mkdir -v/&p/g' -i ${script}
602 done
603 # Remove Bzip2 binaries before make install
604 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
605 # Delete *old Readline libraries just after make install
606 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
607 fi
608
609 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N${R_arrow}"
610
611 for file in final-system$N/* ; do
612 # Keep the script file name
613 this_script=`basename $file`
614
615 # Test if the stripping phase must be skipped
616 # Skip alsp temp-perl for iterative runs
617 case $this_script in
618 *stripping*) [[ "$STRIP" = "0" ]] && continue ;;
619 *temp-perl*) [[ -n "$N" ]] && continue ;;
620 esac
621
622 # Grab the name of the target, strip id number, XXX-script
623 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
624 -e 's@temp-@@' \
625 -e 's@-64bit@@' \
626 -e 's@-64@@' \
627 -e 's@64@@' \
628 -e 's@n32@@'`
629
630 # Find the version of the command files, if it corresponds with the building of
631 # a specific package. We need this here to can skip scripts not needed for
632 # iterations rebuilds
633 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
634
635 if [[ "$vrs" = "" ]] && [[ -n "$N" ]] ; then
636 case "${this_script}" in
637 *stripping*) ;;
638 *) continue ;;
639 esac
640 fi
641
642 # Append each name of the script files to a list (this will become
643 # the names of the targets in the Makefile
644 basicsystem="$basicsystem ${this_script}${N}"
645
646 # Append each name of the script files to a list (this will become
647 # the names of the logs to be moved for each iteration)
648 LOGS="$LOGS ${this_script}"
649
650 #--------------------------------------------------------------------#
651 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
652 #--------------------------------------------------------------------#
653 #
654 # Drop in the name of the target on a new line, and the previous target
655 # as a dependency. Also call the echo_message function.
656 wrt_target "${this_script}${N}" "$PREV"
657
658 # If $vrs isn't empty, we've got a package...
659 if [ "$vrs" != "" ] ; then
660 FILE="$name-$vrs.tar.*"
661 wrt_unpack3 "$FILE"
662 # If the testsuites must be run, initialize the log file
663 case $name in
664 binutils | gcc | glibc )
665 [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
666 ;;
667 * )
668 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
669 ;;
670 esac
671 # If using optimizations, write the instructions
672 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
673 fi
674 #
675 wrt_run_as_root2 "${this_script}" "${file}"
676 #
677 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
678 #
679 # Include a touch of the target name so make can check if it's already been made.
680 wrt_touch
681 #
682 #--------------------------------------------------------------------#
683 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
684 #--------------------------------------------------------------------#
685 #
686 # Keep the script file name for Makefile dependencies.
687 PREV=${this_script}${N}
688 # Set system_build envar for iteration targets
689 system_build=$basicsystem
690 done # for file in final-system/* ...
691}
692
693
694#-----------------------------#
695bootscripts_Makefiles() { #
696#-----------------------------#
697 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts${R_arrow}"
698
699 for file in bootscripts/* ; do
700 # Keep the script file name
701 this_script=`basename $file`
702
703 case $this_script in
704 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
705 *console*) continue ;; # Use the files that came with the bootscripts
706 *) ;;
707 esac
708
709 # First append each name of the script files to a list (this will become
710 # the names of the targets in the Makefile
711 bootscripttools="$bootscripttools $this_script"
712
713 # Grab the name of the target, strip id number, XXX-script
714 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
715 -e 's@-64bit@@' \
716 -e 's@-64@@' \
717 -e 's@64@@' \
718 -e 's@n32@@'`
719 case $name in
720 *bootscripts*) name=bootscripts-cross-lfs ;;
721 *udev-rules) name=udev-cross-lfs ;;
722 esac
723 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
724
725 #--------------------------------------------------------------------#
726 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
727 #--------------------------------------------------------------------#
728 #
729 # Drop in the name of the target on a new line, and the previous target
730 # as a dependency. Also call the echo_message function.
731 wrt_target "${this_script}" "$PREV"
732 #
733 # If $vrs isn't empty, we've got a package...
734 #
735 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
736 #
737 wrt_run_as_chroot1 "${this_script}" "${file}"
738 #
739 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
740 #
741 # Include a touch of the target name so make can check if it's already been made.
742 wrt_touch
743 #
744 #--------------------------------------------------------------------#
745 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
746 #--------------------------------------------------------------------#
747 #
748 # Keep the script file name for Makefile dependencies.
749 PREV=$this_script
750
751 done # for file in bootscripts/* ...
752
753}
754
755#-----------------------------#
756bm_bootscripts_Makefiles() { #
757#-----------------------------#
758 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts${R_arrow}"
759
760 for file in bootscripts/* ; do
761 # Keep the script file name
762 this_script=`basename $file`
763
764 case $this_script in
765 *udev*) continue ;; # This is not a script but a commentary
766 *console*) continue ;; # Use the files that came with the bootscripts
767 *) ;;
768 esac
769
770 # First append each name of the script files to a list (this will become
771 # the names of the targets in the Makefile
772 bootscripttools="$bootscripttools $this_script"
773
774 # Grab the name of the target, strip id number, XXX-script
775 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
776 -e 's@-64bit@@' \
777 -e 's@-64@@' \
778 -e 's@64@@' \
779 -e 's@n32@@'`
780 case $name in
781 *bootscripts*) name=bootscripts-cross-lfs
782 ;;
783 esac
784 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
785
786 #--------------------------------------------------------------------#
787 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
788 #--------------------------------------------------------------------#
789 #
790 # Drop in the name of the target on a new line, and the previous target
791 # as a dependency. Also call the echo_message function.
792 wrt_target "${this_script}" "$PREV"
793 #
794 # If $vrs isn't empty, we've got a package...
795 #
796 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
797 #
798 wrt_run_as_root2 "${this_script}" "${file}"
799 #
800 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
801 #
802 # Include a touch of the target name so make can check if it's already been made.
803 wrt_touch
804 #
805 #--------------------------------------------------------------------#
806 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
807 #--------------------------------------------------------------------#
808 #
809 # Keep the script file name for Makefile dependencies.
810 PREV=$this_script
811
812 done # for file in bootscripts/* ...
813
814}
815
816
817
818#-----------------------------#
819bootable_Makefiles() { #
820#-----------------------------#
821 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable${R_arrow}"
822
823 for file in {bootable,the-end}/* ; do
824 # Keep the script file name
825 this_script=`basename $file`
826
827 # A little housekeeping on the scripts
828 case $this_script in
829 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
830 *kernel) # if there is no kernel config file do not build the kernel
831 [[ -z $CONFIG ]] && continue
832 # Copy the config file to /sources with a standardized name
833 cp $CONFIG $BUILDDIR/sources/kernel-config
834 ;;
835 esac
836 #
837 # First append each name of the script files to a list (this will become
838 # the names of the targets in the Makefile
839 bootabletools="$bootabletools $this_script"
840 #
841 # Grab the name of the target, strip id number and misc words.
842 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
843 case $this_script in
844 *kernel*) name=linux
845 ;;
846 esac
847 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
848
849 #--------------------------------------------------------------------#
850 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
851 #--------------------------------------------------------------------#
852 #
853 # Drop in the name of the target on a new line, and the previous target
854 # as a dependency. Also call the echo_message function.
855 wrt_target "${this_script}" "$PREV"
856 #
857 # If $vrs isn't empty, we've got a package...
858 # Insert instructions for unpacking the package and changing directories
859 #
860 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
861 #
862 # Select a script execution method
863 case $this_script in
864 *fstab*) if [[ -n "$FSTAB" ]]; then
865 wrt_copy_fstab "${this_script}"
866 else
867 wrt_run_as_chroot1 "${this_script}" "${file}"
868 fi
869 ;;
870 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
871 esac
872 #
873 # Housekeeping...remove any build directory(ies) except if the package build fails.
874 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
875 #
876 # Include a touch of the target name so make can check if it's already been made.
877 wrt_touch
878 #
879 #--------------------------------------------------------------------#
880 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
881 #--------------------------------------------------------------------#
882 #
883 # Keep the script file name for Makefile dependencies.
884 PREV=$this_script
885
886 done
887
888 # Add SBU-disk_usage report target if required
889 if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
890
891}
892
893
894
895#-----------------------------#
896bm_bootable_Makefiles() { #
897#-----------------------------#
898 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable${R_arrow}"
899
900 for file in {bootable,the-end}/* ; do
901 # Keep the script file name
902 this_script=`basename $file`
903
904 # A little housekeeping on the scripts
905 case $this_script in
906 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
907 *kernel) # if there is no kernel config file do not build the kernel
908 [[ -z $CONFIG ]] && continue
909 # Copy the named config file to /sources with a standardized name
910 cp $CONFIG $BUILDDIR/sources/kernel-config
911 ;;
912 esac
913 #
914 # First append each name of the script files to a list (this will become
915 # the names of the targets in the Makefile
916 bootabletools="$bootabletools $this_script"
917 #
918 # Grab the name of the target, strip id number and misc words.
919 case $this_script in
920 *kernel) name=linux
921 ;;
922 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
923 esac
924
925 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
926
927 #--------------------------------------------------------------------#
928 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
929 #--------------------------------------------------------------------#
930 #
931 # Drop in the name of the target on a new line, and the previous target
932 # as a dependency. Also call the echo_message function.
933 wrt_target "${this_script}" "$PREV"
934 #
935 # If $vrs isn't empty, we've got a package...
936 # Insert instructions for unpacking the package and changing directories
937 #
938 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
939 #
940 # Select a script execution method
941 case $this_script in
942 *fstab*) if [[ -n "$FSTAB" ]]; then
943 # Minimal boot mode has no access to original file, store in /sources
944 cp $FSTAB $BUILDDIR/sources/fstab
945 wrt_copy_fstab2 "${this_script}"
946 else
947 wrt_run_as_root2 "${this_script}" "${file}"
948 fi
949 ;;
950 *) wrt_run_as_root2 "${this_script}" "${file}" ;;
951 esac
952 #
953 # Housekeeping...remove any build directory(ies) except if the package build fails.
954 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
955 #
956 # Include a touch of the target name so make can check if it's already been made.
957 wrt_touch
958 #
959 #--------------------------------------------------------------------#
960 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
961 #--------------------------------------------------------------------#
962 #
963 # Keep the script file name for Makefile dependencies.
964 PREV=$this_script
965
966 done
967
968 # Add SBU-disk_usage report target if required
969 if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
970
971}
972
973
974#-----------------------------#
975build_Makefile() { # Construct a Makefile from the book scripts
976#-----------------------------#
977 echo "Creating Makefile... ${BOLD}START${OFF}"
978
979 cd $JHALFSDIR/${PROGNAME}-commands
980 # Start with a clean Makefile.tmp file
981 >$MKFILE.tmp
982
983 host_prep_Makefiles
984 cross_tools_Makefiles # $cross_tools
985 temptools_Makefiles # $temptools
986 if [[ $METHOD = "chroot" ]]; then
987 chroot_Makefiles # $chroottools
988 if [[ ! $TEST = "0" ]]; then
989 testsuite_tools_Makefiles # $testsuitetools
990 fi
991 final_system_Makefiles # $basicsystem
992 # Add the iterations targets, if needed
993 [[ "$COMPARE" != "0" ]] && wrt_compare_targets
994 bootscripts_Makefiles # $bootscripttools
995 bootable_Makefiles # $bootabletools
996 else
997 boot_Makefiles # $boottools
998 if [[ ! $TEST = "0" ]]; then
999 bm_testsuite_tools_Makefiles # $testsuitetools
1000 fi
1001 bm_final_system_Makefiles # $basicsystem
1002 # Add the iterations targets, if needed
1003 [[ "$COMPARE" != "0" ]] && wrt_compare_targets
1004 bm_bootscripts_Makefiles # $bootscipttools
1005 bm_bootable_Makefiles # $bootabletoosl
1006 fi
1007# the_end_Makefiles
1008
1009
1010 # Add a header, some variables and include the function file
1011 # to the top of the real Makefile.
1012(
1013 cat << EOF
1014$HEADER
1015
1016SRC= /sources
1017MOUNT_PT= $BUILDDIR
1018PKG_LST= $PKG_LST
1019
1020include makefile-functions
1021
1022EOF
1023) > $MKFILE
1024
1025 # Add chroot commands
1026 if [ "$METHOD" = "chroot" ] ; then
1027 chroot=`cat chroot/*chroot* | sed -e '/#!\/tools\/bin\/bash/d' \
1028 -e '/^export/d' \
1029 -e '/^logout/d' \
1030 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
1031 -e 's|\\$|&&|g' \
1032 -e 's|exit||g' \
1033 -e 's|$| -c|' \
1034 -e 's|"$$LFS"|$(MOUNT_PT)|'\
1035 -e 's|set -e||'`
1036 echo -e "CHROOT1= $chroot\n" >> $MKFILE
1037 fi
1038
1039 # Drop in the main target 'all:' and the chapter targets with each sub-target
1040 # as a dependency.
1041if [[ "${METHOD}" = "chroot" ]]; then
1042(
1043 cat << EOF
1044all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8 do-housekeeping
1045 @\$(call echo_finished,$VERSION)
1046
1047chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment
1048
1049chapter3: chapter2 $cross_tools
1050
1051chapter4: chapter3 $temptools
1052
1053chapter5: chapter4 $chroottools $testsuitetools
1054
1055chapter6: chapter5 $basicsystem
1056
1057chapter7: chapter6 $bootscripttools
1058
1059chapter8: chapter7 $bootabletools
1060
1061clean-all: clean
1062 rm -rf ./{clfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
1063
1064clean: clean-chapter4 clean-chapter3 clean-chapter2
1065
1066clean-chapter2:
1067 -if [ ! -f user-lfs-exist ]; then \\
1068 userdel lfs; \\
1069 rm -rf /home/lfs; \\
1070 fi;
1071 rm -rf \$(MOUNT_PT)/tools
1072 rm -f /tools
1073 rm -rf \$(MOUNT_PT)/cross-tools
1074 rm -f /cross-tools
1075 rm -f envars user-lfs-exist
1076 rm -f 02* logs/02*.log
1077
1078clean-chapter3:
1079 rm -rf \$(MOUNT_PT)/tools/*
1080 rm -f $cross_tools restore-lfs-env sources-dir
1081 cd logs && rm -f $cross_tools && cd ..
1082
1083clean-chapter4:
1084 -umount \$(MOUNT_PT)/sys
1085 -umount \$(MOUNT_PT)/proc
1086 -umount \$(MOUNT_PT)/dev/shm
1087 -umount \$(MOUNT_PT)/dev/pts
1088 -umount \$(MOUNT_PT)/dev
1089 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
1090 rm -f $temptools
1091 cd logs && rm -f $temptools && cd ..
1092
1093
1094restore-lfs-env:
1095 @\$(call echo_message, Building)
1096 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
1097 mv -f /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
1098 fi;
1099 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
1100 mv /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
1101 fi;
1102 @chown lfs:lfs /home/lfs/.bash* && \\
1103 touch \$@ && \\
1104 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
1105 echo --------------------------------------------------------------------------------\$(WHITE)
1106
1107do-housekeeping:
1108 @-umount \$(MOUNT_PT)/dev/pts
1109 @-umount \$(MOUNT_PT)/dev/shm
1110 @-umount \$(MOUNT_PT)/dev
1111 @-umount \$(MOUNT_PT)/sys
1112 @-umount \$(MOUNT_PT)/proc
1113 @-if [ ! -f user-lfs-exist ]; then \\
1114 userdel lfs; \\
1115 rm -rf /home/lfs; \\
1116 fi;
1117
1118EOF
1119) >> $MKFILE
1120fi
1121
1122
1123if [[ "${METHOD}" = "boot" ]]; then
1124(
1125 cat << EOF
1126
1127all: makeboot
1128
1129makeboot: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment \
1130 $cross_tools\
1131 $temptools \
1132 $chroottools \
1133 $boottools
1134 @\$(call echo_boot_finished,$VERSION)
1135
1136makesys: $testsuitetools $basicsystem $bootscripttools $bootabletools
1137 @\$(call echo_finished,$VERSION)
1138
1139
1140clean-all: clean
1141 rm -rf ./{clfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
1142
1143clean: clean-makesys clean-makeboot clean-jhalfs
1144
1145clean-jhalfs:
1146 -if [ ! -f user-lfs-exist ]; then \\
1147 userdel lfs; \\
1148 rm -rf /home/lfs; \\
1149 fi;
1150 rm -rf \$(MOUNT_PT)/tools
1151 rm -f /tools
1152 rm -rf \$(MOUNT_PT)/cross-tools
1153 rm -f /cross-tools
1154 rm -f envars user-lfs-exist
1155 rm -f 02* logs/02*.log
1156
1157clean-makeboot:
1158 rm -rf /tools/*
1159 rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools
1160 rm -f restore-lfs-env sources-dir
1161 cd logs && rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools && cd ..
1162
1163clean-makesys:
1164 -umount \$(MOUNT_PT)/sys
1165 -umount \$(MOUNT_PT)/proc
1166 -umount \$(MOUNT_PT)/dev/shm
1167 -umount \$(MOUNT_PT)/dev/pts
1168 -umount \$(MOUNT_PT)/dev
1169 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
1170 rm -f $basicsystem
1171 rm -f $bootscripttools
1172 rm -f $bootabletools
1173 cd logs && rm -f $basicsystem && rm -f $bootscripttools && rm -f $bootabletools && cd ..
1174
1175
1176restore-lfs-env:
1177 @\$(call echo_message, Building)
1178 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
1179 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
1180 fi;
1181 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
1182 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
1183 fi;
1184 @chown lfs:lfs /home/lfs/.bash* && \\
1185 touch \$@ && \\
1186 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
1187 echo --------------------------------------------------------------------------------\$(WHITE)
1188
1189
1190EOF
1191) >> $MKFILE
1192fi
1193
1194 # Bring over the items from the Makefile.tmp
1195 cat $MKFILE.tmp >> $MKFILE
1196 rm $MKFILE.tmp
1197 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1198
1199}
1200
Note: See TracBrowser for help on using the repository browser.