source: CLFS/master.sh@ eba62c0

experimental
Last change on this file since eba62c0 was eba62c0, checked in by George Boudreau <georgeb@…>, 19 years ago

CLFS/master.sh, corrected a udev-rules oversight..

  • Property mode set to 100755
File size: 35.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 -v \$(MOUNT_PT)/tools && \\
24 rm -fv /tools && \\
25 ln -sv \$(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
32024-creatingcrossdir: 023-creatingtoolsdir
33 @mkdir -v \$(MOUNT_PT)/cross-tools && \\
34 rm -fv /cross-tools && \\
35 ln -sv \$(MOUNT_PT)/cross-tools /
36 @touch \$@
37
38025-addinguser: 024-creatingcrossdir
39 @\$(call echo_message, Building)
40 @if [ ! -d /home/lfs ]; then \\
41 groupadd lfs; \\
42 useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
43 else \\
44 touch user-lfs-exist; \\
45 fi;
46 @chown lfs \$(MOUNT_PT) && \\
47 chown lfs \$(MOUNT_PT)/tools && \\
48 chown lfs \$(MOUNT_PT)/cross-tools && \\
49 chown lfs \$(MOUNT_PT)/sources && \\
50 touch \$@
51
52026-settingenvironment: 025-addinguser
53 @\$(call echo_message, Building)
54 @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
55 mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
56 fi;
57 @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
58 mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
59 fi;
60 @echo "set +h" > /home/lfs/.bashrc && \\
61 echo "umask 022" >> /home/lfs/.bashrc && \\
62 echo "LFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
63 echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
64 echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
65 echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
66 echo "" >> /home/lfs/.bashrc && \\
67 echo "unset CFLAGS" >> /home/lfs/.bashrc && \\
68 echo "unset CXXFLAGS" >> /home/lfs/.bashrc && \\
69 echo "" >> /home/lfs/.bashrc && \\
70 echo "export LFS_HOST=\"${LFS_HOST}\"" >> /home/lfs/.bashrc && \\
71 echo "export LFS_TARGET=\"${TARGET}\"" >> /home/lfs/.bashrc && \\
72 echo "export LFS_TARGET32=\"${TARGET32}\"" >> /home/lfs/.bashrc && \\
73 echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc
74 @chown lfs:lfs /home/lfs/.bashrc && \\
75 touch envars && \\
76 touch \$@
77EOF
78) >> $MKFILE.tmp
79
80}
81
82
83
84#-----------------------------#
85cross_tools_Makefiles() { #
86#-----------------------------#
87 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools${R_arrow}"
88
89 for file in cross-tools/* ; do
90 # Keep the script file name
91 this_script=`basename $file`
92 #
93 # Skip this script...
94 case $this_script in
95 *cflags* | *variables* ) # work done in host_prep_Makefiles
96 continue; ;;
97 *) ;;
98 esac
99 #
100 # Set the dependency for the first target.
101 if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
102
103 # First append each name of the script files to a list (this will become
104 # the names of the targets in the Makefile
105 cross_tools="$cross_tools $this_script"
106
107 # Grab the name of the target (minus the -headers or -cross in the case of gcc
108 # and binutils in chapter 5)
109 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
110 -e 's@-static@@' \
111 -e 's@-final@@' \
112 -e 's@-headers@@' \
113 -e 's@-64@@' \
114 -e 's@-n32@@'`
115 # Adjust 'name' and patch a few scripts on the fly..
116 case $name in
117 linux-libc) name=linux-libc-headers ;;
118 esac
119 #
120 # Find the version of the command files, if it corresponds with the building of a specific package
121 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
122
123
124 #--------------------------------------------------------------------#
125 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
126 #--------------------------------------------------------------------#
127 #
128 # Drop in the name of the target on a new line, and the previous target
129 # as a dependency. Also call the echo_message function.
130 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
131 #
132 # If $vrs isn't empty, we've got a package...
133 #
134 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*" && echo -e '\ttrue' >> $MKFILE.tmp
135 #
136 wrt_run_as_lfs "${this_script}" "${file}"
137 #
138 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
139 #
140 # Include a touch of the target name so make can check if it's already been made.
141 echo -e '\t@touch $@' >> $MKFILE.tmp
142 #
143 #--------------------------------------------------------------------#
144 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
145 #--------------------------------------------------------------------#
146 #
147 # Keep the script file name for Makefile dependencies.
148 PREV=$this_script
149
150 done # for file in ....
151}
152
153
154#-----------------------------#
155temptools_Makefiles() { #
156#-----------------------------#
157 echo "${tab_}${GREEN}Processing... ${L_arrow}temp system${R_arrow}"
158
159 for file in temp-system/* ; do
160 # Keep the script file name
161 this_script=`basename $file`
162 #
163 # First append each name of the script files to a list (this will become
164 # the names of the targets in the Makefile
165 temptools="$temptools $this_script"
166
167 #
168 # Grab the name of the target, strip id number, XXX-script
169 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
170 #
171 # Find the version of the command files, if it corresponds with the building of a specific package
172 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
173
174
175 #--------------------------------------------------------------------#
176 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
177 #--------------------------------------------------------------------#
178 #
179 # Drop in the name of the target on a new line, and the previous target
180 # as a dependency. Also call the echo_message function.
181 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
182 #
183 # If $vrs isn't empty, we've got a package...
184 # Insert instructions for unpacking the package and to set the PKGDIR variable.
185 #
186 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*" && echo -e '\ttrue' >> $MKFILE.tmp
187 #
188 wrt_run_as_lfs "${this_script}" "${file}"
189 #
190 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
191 #
192 # Include a touch of the target name so make can check if it's already been made.
193 echo -e '\t@touch $@' >> $MKFILE.tmp
194 #
195 #--------------------------------------------------------------------#
196 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
197 #--------------------------------------------------------------------#
198 #
199 # Keep the script file name for Makefile dependencies.
200 PREV=$this_script
201 done # for file in ....
202}
203
204
205#-----------------------------#
206boot_Makefiles() { #
207#-----------------------------#
208 echo "${tab_}${GREEN}Processing... ${L_arrow}boot${R_arrow}"
209
210 for file in boot/* ; do
211 # Keep the script file name
212 this_script=`basename $file`
213
214 # A little housekeeping on the scripts
215 case $this_script in
216 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
217 *whatnext*) continue ;;
218 *kernel) # if there is no kernel config file do not build the kernel
219 [[ -z $CONFIG ]] && continue
220 # Copy the config file to /sources with a standardized name
221 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
222 ;;
223 esac
224 #
225 # First append each name of the script files to a list (this will become
226 # the names of the targets in the Makefile
227 boottools="$boottools $this_script"
228 #
229 # Grab the name of the target, strip id number and misc words.
230 case $this_script in
231 *kernel) name=linux ;;
232 *bootscripts) name="bootscripts-cross-lfs" ;;
233 *grub-build) name=grub ;;
234 *-aboot-build) name=aboot ;;
235 *yaboot-build) name=yaboot ;;
236 *colo-build) name=colo ;;
237 *silo-build) name=silo ;;
238 *arcload-build) name=arcload ;;
239 *lilo-build) name=lilo ;;
240 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
241 esac
242
243 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
244
245 #--------------------------------------------------------------------#
246 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
247 #--------------------------------------------------------------------#
248 #
249 # Drop in the name of the target on a new line, and the previous target
250 # as a dependency. Also call the echo_message function.
251 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
252 #
253 # If $vrs isn't empty, we've got a package...
254 # Insert instructions for unpacking the package and changing directories
255 #
256 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
257 #
258 # Select a script execution method
259 case $this_script in
260 *changingowner*) wrt_run_as_root "${this_script}" "${file}" ;;
261 *devices*) wrt_run_as_root "${this_script}" "${file}" ;;
262 *fstab*) if [[ -n "$FSTAB" ]]; then
263 wrt_copy_fstab "${this_script}"
264 else
265 wrt_run_as_lfs "${this_script}" "${file}"
266 fi
267 ;;
268 *) wrt_run_as_lfs "${this_script}" "${file}" ;;
269 esac
270 #
271 # Housekeeping...remove any build directory(ies) except if the package build fails.
272 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
273 #
274 # Include a touch of the target name so make can check if it's already been made.
275 echo -e '\t@touch $@' >> $MKFILE.tmp
276 #
277 #--------------------------------------------------------------------#
278 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
279 #--------------------------------------------------------------------#
280 #
281 # Keep the script file name for Makefile dependencies.
282 PREV=$this_script
283
284 done
285 # This will force the Makefile to exit and not allow it to be restarted with
286 # the command <make>, The user will have to issue the cmd <make chapterXX>
287 echo -e "\t@\$(call echo_boot_finished,$VERSION) && \\" >> $MKFILE.tmp
288 echo -e "\tfalse" >> $MKFILE.tmp
289}
290
291
292#-----------------------------#
293chroot_Makefiles() { #
294#-----------------------------#
295 echo "${tab_}${GREEN}Processing... ${L_arrow}chroot${R_arrow}"
296
297 for file in chroot/* ; do
298 # Keep the script file name
299 this_script=`basename $file`
300 #
301 # Skipping scripts is done now and not included in the build tree.
302 case $this_script in
303 *chroot*) continue ;;
304 esac
305
306 #
307 # First append each name of the script files to a list (this will become
308 # the names of the targets in the Makefile
309 chroottools="$chroottools $this_script"
310
311 # Grab the name of the target, strip id number, XXX-script
312 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
313 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
314
315 #--------------------------------------------------------------------#
316 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
317 #--------------------------------------------------------------------#
318 #
319 # Drop in the name of the target on a new line, and the previous target
320 # as a dependency. Also call the echo_message function.
321 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
322 #
323 # If $vrs isn't empty, we've got a package...
324 # Insert instructions for unpacking the package and changing directories
325 #
326 if [ "$vrs" != "" ] ; then
327 case $this_script in
328 *util-linux) wrt_unpack "$name-$vrs.tar.*"
329 echo -e '\ttrue' >> $MKFILE.tmp
330 ;;
331 *) wrt_unpack2 "$name-$vrs.tar.*"
332 ;;
333 esac
334 fi
335 #
336 # Select a script execution method
337 case $this_script in
338 *kernfs) wrt_run_as_root "${this_script}" "${file}" ;;
339 *util-linux) wrt_run_as_lfs "${this_script}" "${file}" ;;
340 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
341 esac
342 #
343 # Housekeeping...remove the build directory(ies), except if the package build fails.
344 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
345 #
346 # Include a touch of the target name so make can check if it's already been made.
347 echo -e '\t@touch $@' >> $MKFILE.tmp
348 #
349 #--------------------------------------------------------------------#
350 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
351 #--------------------------------------------------------------------#
352 #
353 # Keep the script file name for Makefile dependencies.
354 PREV=$this_script
355
356 done # for file in...
357}
358
359
360#-----------------------------#
361testsuite_tools_Makefiles() { #
362#-----------------------------#
363 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools${R_arrow}"
364
365 for file in testsuite-tools/* ; do
366 # Keep the script file name
367 this_script=`basename $file`
368
369 # First append each name of the script files to a list (this will become
370 # the names of the targets in the Makefile
371 testsuitetools="$testsuitetools $this_script"
372
373 # Grab the name of the target, strip id number, XXX-script
374 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
375 -e 's@-64bit@@' \
376 -e 's@-64@@' \
377 -e 's@64@@' \
378 -e 's@n32@@'`
379
380 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
381
382 #--------------------------------------------------------------------#
383 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
384 #--------------------------------------------------------------------#
385 #
386 # Drop in the name of the target on a new line, and the previous target
387 # as a dependency. Also call the echo_message function.
388 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
389 #
390 case $name in
391 tcl) wrt_unpack2 "$name$vrs-src.tar.*" ;;
392 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
393 esac
394 #
395 wrt_run_as_chroot1 "${this_script}" "${file}"
396 #
397 wrt_remove_build_dirs "${name}"
398 #
399 # Include a touch of the target name so make can check if it's already been made.
400 echo -e '\t@touch $@' >> $MKFILE.tmp
401 #
402 #--------------------------------------------------------------------#
403 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
404 #--------------------------------------------------------------------#
405 #
406 # Keep the script file name for Makefile dependencies.
407 PREV=$this_script
408
409 done
410}
411
412
413#--------------------------------#
414bm_testsuite_tools_Makefiles() { #
415#--------------------------------#
416 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools${R_arrow}"
417
418 for file in testsuite-tools/* ; do
419 # Keep the script file name
420 this_script=`basename $file`
421
422 # First append each name of the script files to a list (this will become
423 # the names of the targets in the Makefile
424 testsuitetools="$testsuitetools $this_script"
425
426 # Grab the name of the target, strip id number, XXX-script
427 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
428 -e 's@-64bit@@' \
429 -e 's@-64@@' \
430 -e 's@64@@' \
431 -e 's@n32@@'`
432
433 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
434
435 #--------------------------------------------------------------------#
436 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
437 #--------------------------------------------------------------------#
438 #
439 # Drop in the name of the target on a new line, and the previous target
440 # as a dependency. Also call the echo_message function.
441 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
442 #
443 case $name in
444 tcl) wrt_unpack3 "$name$vrs-src.tar.*" ;;
445 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
446 esac
447 #
448 wrt_run_as_root2 "${this_script}" "${file}"
449 #
450 wrt_remove_build_dirs2 "${name}"
451 #
452 # Include a touch of the target name so make can check if it's already been made.
453 echo -e '\t@touch $@' >> $MKFILE.tmp
454 #
455 #--------------------------------------------------------------------#
456 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
457 #--------------------------------------------------------------------#
458 #
459 # Keep the script file name for Makefile dependencies.
460 PREV=$this_script
461
462 done
463}
464
465
466#-----------------------------#
467final_system_Makefiles() { #
468#-----------------------------#
469 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system${R_arrow}"
470
471 for file in final-system/* ; do
472 # Keep the script file name
473 this_script=`basename $file`
474
475 # Test if the stripping phase must be skipped
476 case $this_script in
477 *stripping*) [[ "$STRIP" = "0" ]] && continue
478 ;;
479 esac
480
481 # First append each name of the script files to a list (this will become
482 # the names of the targets in the Makefile
483 basicsystem="$basicsystem $this_script"
484
485 # Grab the name of the target, strip id number, XXX-script
486 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
487 -e 's@temp-@@' \
488 -e 's@-64bit@@' \
489 -e 's@-64@@' \
490 -e 's@64@@' \
491 -e 's@n32@@'`
492
493 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
494
495 #--------------------------------------------------------------------#
496 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
497 #--------------------------------------------------------------------#
498 #
499 # Drop in the name of the target on a new line, and the previous target
500 # as a dependency. Also call the echo_message function.
501 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
502
503 # If $vrs isn't empty, we've got a package...
504 if [ "$vrs" != "" ] ; then
505 case $name in
506 temp-perl) wrt_unpack2 "perl-$vrs.tar.*" ;;
507 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
508 esac
509 fi
510 #
511 wrt_run_as_chroot1 "${this_script}" "${file}"
512 #
513 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
514 #
515 # Include a touch of the target name so make can check if it's already been made.
516 echo -e '\t@touch $@' >> $MKFILE.tmp
517 #
518 #--------------------------------------------------------------------#
519 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
520 #--------------------------------------------------------------------#
521 #
522 # Keep the script file name for Makefile dependencies.
523 PREV=$this_script
524
525 done # for file in final-system/* ...
526}
527
528
529#-----------------------------#
530bm_final_system_Makefiles() { #
531#-----------------------------#
532 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system${R_arrow}"
533
534 for file in final-system/* ; do
535 # Keep the script file name
536 this_script=`basename $file`
537
538 # Test if the stripping phase must be skipped
539 case $this_script in
540 *stripping*) [[ "$STRIP" = "0" ]] && continue
541 ;;
542 esac
543
544 # First append each name of the script files to a list (this will become
545 # the names of the targets in the Makefile
546 basicsystem="$basicsystem $this_script"
547
548 # Grab the name of the target, strip id number, XXX-script
549 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
550 -e 's@temp-@@' \
551 -e 's@-64bit@@' \
552 -e 's@-64@@' \
553 -e 's@64@@' \
554 -e 's@n32@@'`
555
556 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
557
558 #--------------------------------------------------------------------#
559 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
560 #--------------------------------------------------------------------#
561 #
562 # Drop in the name of the target on a new line, and the previous target
563 # as a dependency. Also call the echo_message function.
564 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
565
566 # If $vrs isn't empty, we've got a package...
567 if [ "$vrs" != "" ] ; then
568 case $name in
569 temp-perl) wrt_unpack3 "perl-$vrs.tar.*" ;;
570 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
571 esac
572 fi
573 #
574 wrt_run_as_root2 "${this_script}" "${file}"
575 #
576 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
577 #
578 # Include a touch of the target name so make can check if it's already been made.
579 echo -e '\t@touch $@' >> $MKFILE.tmp
580 #
581 #--------------------------------------------------------------------#
582 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
583 #--------------------------------------------------------------------#
584 #
585 # Keep the script file name for Makefile dependencies.
586 PREV=$this_script
587
588 done # for file in final-system/* ...
589}
590
591
592#-----------------------------#
593bootscripts_Makefiles() { #
594#-----------------------------#
595 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts${R_arrow}"
596
597 for file in bootscripts/* ; do
598 # Keep the script file name
599 this_script=`basename $file`
600
601 case $this_script in
602 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
603 *console*) continue ;; # Use the files that came with the bootscripts
604 *) ;;
605 esac
606
607 # First append each name of the script files to a list (this will become
608 # the names of the targets in the Makefile
609 bootscripttools="$bootscripttools $this_script"
610
611 # Grab the name of the target, strip id number, XXX-script
612 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
613 -e 's@-64bit@@' \
614 -e 's@-64@@' \
615 -e 's@64@@' \
616 -e 's@n32@@'`
617 case $name in
618 *bootscripts*) name=bootscripts-cross-lfs ;;
619 *udev-rules) name=udev-cross-lfs ;;
620 esac
621 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
622
623 #--------------------------------------------------------------------#
624 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
625 #--------------------------------------------------------------------#
626 #
627 # Drop in the name of the target on a new line, and the previous target
628 # as a dependency. Also call the echo_message function.
629 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
630 #
631 # If $vrs isn't empty, we've got a package...
632 #
633 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
634 #
635 wrt_run_as_chroot1 "${this_script}" "${file}"
636 #
637 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
638 #
639 # Include a touch of the target name so make can check if it's already been made.
640 echo -e '\t@touch $@' >> $MKFILE.tmp
641 #
642 #--------------------------------------------------------------------#
643 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
644 #--------------------------------------------------------------------#
645 #
646 # Keep the script file name for Makefile dependencies.
647 PREV=$this_script
648
649 done # for file in bootscripts/* ...
650
651}
652
653#-----------------------------#
654bm_bootscripts_Makefiles() { #
655#-----------------------------#
656 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts${R_arrow}"
657
658 for file in bootscripts/* ; do
659 # Keep the script file name
660 this_script=`basename $file`
661
662 case $this_script in
663 *udev*) continue ;; # This is not a script but a commentary
664 *console*) continue ;; # Use the files that came with the bootscripts
665 *) ;;
666 esac
667
668 # First append each name of the script files to a list (this will become
669 # the names of the targets in the Makefile
670 bootscripttools="$bootscripttools $this_script"
671
672 # Grab the name of the target, strip id number, XXX-script
673 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
674 -e 's@-64bit@@' \
675 -e 's@-64@@' \
676 -e 's@64@@' \
677 -e 's@n32@@'`
678 case $name in
679 *bootscripts*) name=bootscripts-cross-lfs
680 ;;
681 esac
682 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
683
684 #--------------------------------------------------------------------#
685 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
686 #--------------------------------------------------------------------#
687 #
688 # Drop in the name of the target on a new line, and the previous target
689 # as a dependency. Also call the echo_message function.
690 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
691 #
692 # If $vrs isn't empty, we've got a package...
693 #
694 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
695 #
696 wrt_run_as_root2 "${this_script}" "${file}"
697 #
698 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
699 #
700 # Include a touch of the target name so make can check if it's already been made.
701 echo -e '\t@touch $@' >> $MKFILE.tmp
702 #
703 #--------------------------------------------------------------------#
704 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
705 #--------------------------------------------------------------------#
706 #
707 # Keep the script file name for Makefile dependencies.
708 PREV=$this_script
709
710 done # for file in bootscripts/* ...
711
712}
713
714
715
716#-----------------------------#
717bootable_Makefiles() { #
718#-----------------------------#
719 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable${R_arrow}"
720
721 for file in bootable/* ; do
722 # Keep the script file name
723 this_script=`basename $file`
724
725 # A little housekeeping on the scripts
726 case $this_script in
727 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
728 *kernel) # if there is no kernel config file do not build the kernel
729 [[ -z $CONFIG ]] && continue
730 # Copy the config file to /sources with a standardized name
731 cp $CONFIG $BUILDDIR/sources/kernel-config
732 ;;
733 esac
734 #
735 # First append each name of the script files to a list (this will become
736 # the names of the targets in the Makefile
737 bootabletools="$bootabletools $this_script"
738 #
739 # Grab the name of the target, strip id number and misc words.
740 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
741 case $this_script in
742 *kernel*) name=linux
743 ;;
744 esac
745 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
746
747 #--------------------------------------------------------------------#
748 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
749 #--------------------------------------------------------------------#
750 #
751 # Drop in the name of the target on a new line, and the previous target
752 # as a dependency. Also call the echo_message function.
753 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
754 #
755 # If $vrs isn't empty, we've got a package...
756 # Insert instructions for unpacking the package and changing directories
757 #
758 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
759 #
760 # Select a script execution method
761 case $this_script in
762 *fstab*) if [[ -n "$FSTAB" ]]; then
763 wrt_copy_fstab "${this_script}"
764 else
765 wrt_run_as_chroot1 "${this_script}" "${file}"
766 fi
767 ;;
768 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
769 esac
770 #
771 # Housekeeping...remove any build directory(ies) except if the package build fails.
772 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
773 #
774 # Include a touch of the target name so make can check if it's already been made.
775 echo -e '\t@touch $@' >> $MKFILE.tmp
776 #
777 #--------------------------------------------------------------------#
778 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
779 #--------------------------------------------------------------------#
780 #
781 # Keep the script file name for Makefile dependencies.
782 PREV=$this_script
783
784 done
785
786}
787
788
789
790#-----------------------------#
791bm_bootable_Makefiles() { #
792#-----------------------------#
793 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable${R_arrow}"
794
795 for file in bootable/* ; do
796 # Keep the script file name
797 this_script=`basename $file`
798
799 # A little housekeeping on the scripts
800 case $this_script in
801 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
802 *kernel) # if there is no kernel config file do not build the kernel
803 [[ -z $CONFIG ]] && continue
804 # Copy the named config file to /sources with a standardized name
805 cp $CONFIG $BUILDDIR/sources/kernel-config
806 ;;
807 esac
808 #
809 # First append each name of the script files to a list (this will become
810 # the names of the targets in the Makefile
811 bootabletools="$bootabletools $this_script"
812 #
813 # Grab the name of the target, strip id number and misc words.
814 case $this_script in
815 *kernel) name=linux
816 ;;
817 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
818 esac
819
820 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
821
822 #--------------------------------------------------------------------#
823 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
824 #--------------------------------------------------------------------#
825 #
826 # Drop in the name of the target on a new line, and the previous target
827 # as a dependency. Also call the echo_message function.
828 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
829 #
830 # If $vrs isn't empty, we've got a package...
831 # Insert instructions for unpacking the package and changing directories
832 #
833 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
834 #
835 # Select a script execution method
836 case $this_script in
837 *fstab*) if [[ -n "$FSTAB" ]]; then
838 # Minimal boot mode has no access to original file, store in /sources
839 cp $FSTAB $BUILDDIR/sources/fstab
840 wrt_copy_fstab2 "${this_script}"
841 else
842 wrt_run_as_root2 "${this_script}" "${file}"
843 fi
844 ;;
845 *) wrt_run_as_root2 "${this_script}" "${file}" ;;
846 esac
847 #
848 # Housekeeping...remove any build directory(ies) except if the package build fails.
849 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
850 #
851 # Include a touch of the target name so make can check if it's already been made.
852 echo -e '\t@touch $@' >> $MKFILE.tmp
853 #
854 #--------------------------------------------------------------------#
855 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
856 #--------------------------------------------------------------------#
857 #
858 # Keep the script file name for Makefile dependencies.
859 PREV=$this_script
860
861 done
862
863}
864
865
866
867#-----------------------------#
868the_end_Makefiles() { #
869#-----------------------------#
870 echo "${tab_}${GREEN}Processing... ${L_arrow}THE END${R_arrow}"
871}
872
873
874#-----------------------------#
875build_Makefile() { # Construct a Makefile from the book scripts
876#-----------------------------#
877 echo "Creating Makefile... ${BOLD}START${OFF}"
878
879 cd $JHALFSDIR/${PROGNAME}-commands
880 # Start with a clean Makefile.tmp file
881 >$MKFILE.tmp
882
883 host_prep_Makefiles
884 cross_tools_Makefiles
885 temptools_Makefiles
886 if [[ $METHOD = "chroot" ]]; then
887 chroot_Makefiles
888 if [[ $TOOLCHAINTEST = "1" ]]; then
889 testsuite_tools_Makefiles
890 fi
891 final_system_Makefiles
892 bootscripts_Makefiles
893 bootable_Makefiles
894 else
895 boot_Makefiles # This phase must die at the end of its run..
896 if [[ $TOOLCHAINTEST = "1" ]]; then
897 bm_testsuite_tools_Makefiles
898 fi
899 bm_final_system_Makefiles
900 bm_bootscripts_Makefiles
901 bm_bootable_Makefiles
902 fi
903# the_end_Makefiles
904
905
906 # Add a header, some variables and include the function file
907 # to the top of the real Makefile.
908(
909 cat << EOF
910$HEADER
911
912SRC= /sources
913MOUNT_PT= $BUILDDIR
914
915include makefile-functions
916
917EOF
918) > $MKFILE
919
920 # Add chroot commands
921 if [ "$METHOD" = "chroot" ] ; then
922 chroot=`cat chroot/*chroot* | sed -e '/#!\/tools\/bin\/bash/d' \
923 -e '/^export/d' \
924 -e '/^logout/d' \
925 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
926 -e 's|\\$|&&|g' \
927 -e 's|exit||g' \
928 -e 's|$| -c|' \
929 -e 's|"$$LFS"|$(MOUNT_PT)|'\
930 -e 's|set -e||'`
931 echo -e "CHROOT1= $chroot\n" >> $MKFILE
932 fi
933
934 # Drop in the main target 'all:' and the chapter targets with each sub-target
935 # as a dependency.
936(
937 cat << EOF
938all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8
939 @\$(call echo_finished,$VERSION)
940
941chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment
942
943chapter3: chapter2 $cross_tools
944
945chapter4: chapter3 $temptools
946
947chapter5: chapter4 $chroottools $boottools
948
949chapter6: chapter5 $basicsystem
950
951chapter7: chapter6 $bootscripttools
952
953chapter8: chapter7 $bootabletools
954
955clean-all: clean
956 rm -rf ./{${PROGNAME}-commands,logs,Makefile,dump-clfs-scripts.xsl,functions,packages,patches}
957
958clean: clean-chapter4 clean-chapter3 clean-chapter2
959
960clean-chapter2:
961 -if [ ! -f user-lfs-exist ]; then \\
962 userdel lfs; \\
963 rm -rf /home/lfs; \\
964 fi;
965 rm -rf \$(MOUNT_PT)/tools
966 rm -f /tools
967 rm -rf \$(MOUNT_PT)/cross-tools
968 rm -f /cross-tools
969 rm -f envars user-lfs-exist
970 rm -f 02* logs/02*.log
971
972clean-chapter3:
973 rm -rf \$(MOUNT_PT)/tools/*
974 rm -f $cross_tools restore-lfs-env sources-dir
975 cd logs && rm -f $cross_tools && cd ..
976
977clean-chapter4:
978 -umount \$(MOUNT_PT)/sys
979 -umount \$(MOUNT_PT)/proc
980 -umount \$(MOUNT_PT)/dev/shm
981 -umount \$(MOUNT_PT)/dev/pts
982 -umount \$(MOUNT_PT)/dev
983 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
984 rm -f $temptools
985 cd logs && rm -f $temptools && cd ..
986
987
988restore-lfs-env:
989 @\$(call echo_message, Building)
990 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
991 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
992 fi;
993 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
994 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
995 fi;
996 @chown lfs:lfs /home/lfs/.bash* && \\
997 touch \$@
998
999EOF
1000) >> $MKFILE
1001
1002
1003 # Bring over the items from the Makefile.tmp
1004 cat $MKFILE.tmp >> $MKFILE
1005 rm $MKFILE.tmp
1006 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1007
1008}
1009
Note: See TracBrowser for help on using the repository browser.