source: CLFS/master.sh@ 9d9ecf7

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 9d9ecf7 was 9d9ecf7, checked in by George Boudreau <georgeb@…>, 18 years ago

CLFS, had to use a ..small ugly.. (tm) to deal with the linux-headers-xxxx naming scheme

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