source: CLFS/master.sh@ 775945f

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 775945f was 877cc6a, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Merged experimental branch to trunk.
Updated TODO.

  • Property mode set to 100755
File size: 37.6 KB
RevLine 
[877cc6a]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_su "${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_su "${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 *udev-rules) name="udev-cross-lfs" ;;
234 *grub-build) name=grub ;;
235 *-aboot-build) name=aboot ;;
236 *yaboot-build) name=yaboot ;;
237 *colo-build) name=colo ;;
238 *silo-build) name=silo ;;
239 *arcload-build) name=arcload ;;
240 *lilo-build) name=lilo ;;
241 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
242 esac
243
244 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
245
246 #--------------------------------------------------------------------#
247 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
248 #--------------------------------------------------------------------#
249 #
250 # Drop in the name of the target on a new line, and the previous target
251 # as a dependency. Also call the echo_message function.
252 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
253 #
254 # If $vrs isn't empty, we've got a package...
255 # Insert instructions for unpacking the package and changing directories
256 #
257 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*" && echo -e '\ttrue' >> $MKFILE.tmp
258 #
259 # Select a script execution method
260 case $this_script in
261 *changingowner*) wrt_run_as_root "${this_script}" "${file}" ;;
262 *devices*) wrt_run_as_root "${this_script}" "${file}" ;;
263 *fstab*) if [[ -n "$FSTAB" ]]; then
264 wrt_copy_fstab "${this_script}"
265 else
266 wrt_run_as_su "${this_script}" "${file}"
267 fi
268 ;;
269 *) wrt_run_as_su "${this_script}" "${file}" ;;
270 esac
271 #
272 # Housekeeping...remove any build directory(ies) except if the package build fails.
273 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
274 #
275 # Include a touch of the target name so make can check if it's already been made.
276 echo -e '\t@touch $@' >> $MKFILE.tmp
277 #
278 #--------------------------------------------------------------------#
279 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
280 #--------------------------------------------------------------------#
281 #
282 # Keep the script file name for Makefile dependencies.
283 PREV=$this_script
284
285 done
286}
287
288
289#-----------------------------#
290chroot_Makefiles() { #
291#-----------------------------#
292 echo "${tab_}${GREEN}Processing... ${L_arrow}chroot${R_arrow}"
293
294 for file in chroot/* ; do
295 # Keep the script file name
296 this_script=`basename $file`
297 #
298 # Skipping scripts is done now and not included in the build tree.
299 case $this_script in
300 *chroot*) continue ;;
301 esac
302
303 #
304 # First append each name of the script files to a list (this will become
305 # the names of the targets in the Makefile
306 chroottools="$chroottools $this_script"
307
308 # Grab the name of the target, strip id number, XXX-script
309 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
310 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
311
312 #--------------------------------------------------------------------#
313 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
314 #--------------------------------------------------------------------#
315 #
316 # Drop in the name of the target on a new line, and the previous target
317 # as a dependency. Also call the echo_message function.
318 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
319 #
320 # If $vrs isn't empty, we've got a package...
321 # Insert instructions for unpacking the package and changing directories
322 #
323 if [ "$vrs" != "" ] ; then
324 case $this_script in
325 *util-linux) wrt_unpack "$name-$vrs.tar.*"
326 echo -e '\ttrue' >> $MKFILE.tmp
327 ;;
328 *) wrt_unpack2 "$name-$vrs.tar.*"
329 ;;
330 esac
331 fi
332 #
333 # Select a script execution method
334 case $this_script in
335 *kernfs) wrt_run_as_root "${this_script}" "${file}" ;;
336 *util-linux) wrt_run_as_su "${this_script}" "${file}" ;;
337 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
338 esac
339 #
340 # Housekeeping...remove the build directory(ies), except if the package build fails.
341 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
342 #
343 # Include a touch of the target name so make can check if it's already been made.
344 echo -e '\t@touch $@' >> $MKFILE.tmp
345 #
346 #--------------------------------------------------------------------#
347 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
348 #--------------------------------------------------------------------#
349 #
350 # Keep the script file name for Makefile dependencies.
351 PREV=$this_script
352
353 done # for file in...
354}
355
356
357#-----------------------------#
358testsuite_tools_Makefiles() { #
359#-----------------------------#
360 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools${R_arrow}"
361
362 for file in testsuite-tools/* ; do
363 # Keep the script file name
364 this_script=`basename $file`
365
366 # First append each name of the script files to a list (this will become
367 # the names of the targets in the Makefile
368 testsuitetools="$testsuitetools $this_script"
369
370 # Grab the name of the target, strip id number, XXX-script
371 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
372 -e 's@-64bit@@' \
373 -e 's@-64@@' \
374 -e 's@64@@' \
375 -e 's@n32@@'`
376
377 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
378
379 #--------------------------------------------------------------------#
380 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
381 #--------------------------------------------------------------------#
382 #
383 # Drop in the name of the target on a new line, and the previous target
384 # as a dependency. Also call the echo_message function.
385 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
386 #
387 case $name in
388 tcl) wrt_unpack2 "$name$vrs-src.tar.*" ;;
389 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
390 esac
391 #
392 wrt_run_as_chroot1 "${this_script}" "${file}"
393 #
394 wrt_remove_build_dirs "${name}"
395 #
396 # Include a touch of the target name so make can check if it's already been made.
397 echo -e '\t@touch $@' >> $MKFILE.tmp
398 #
399 #--------------------------------------------------------------------#
400 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
401 #--------------------------------------------------------------------#
402 #
403 # Keep the script file name for Makefile dependencies.
404 PREV=$this_script
405
406 done
407}
408
409
410#--------------------------------#
411bm_testsuite_tools_Makefiles() { #
412#--------------------------------#
413 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools${R_arrow}"
414
415 for file in testsuite-tools/* ; do
416 # Keep the script file name
417 this_script=`basename $file`
418
419 # First append each name of the script files to a list (this will become
420 # the names of the targets in the Makefile
421 PREV=
422 testsuitetools="$testsuitetools $this_script"
423
424 # Grab the name of the target, strip id number, XXX-script
425 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
426 -e 's@-64bit@@' \
427 -e 's@-64@@' \
428 -e 's@64@@' \
429 -e 's@n32@@'`
430
431 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
432
433 #--------------------------------------------------------------------#
434 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
435 #--------------------------------------------------------------------#
436 #
437 # Drop in the name of the target on a new line, and the previous target
438 # as a dependency. Also call the echo_message function.
439 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
440 #
441 case $name in
442 tcl) wrt_unpack3 "$name$vrs-src.tar.*" ;;
443 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
444 esac
445 #
446 wrt_run_as_root2 "${this_script}" "${file}"
447 #
448 wrt_remove_build_dirs2 "${name}"
449 #
450 # Include a touch of the target name so make can check if it's already been made.
451 echo -e '\t@touch $@' >> $MKFILE.tmp
452 #
453 #--------------------------------------------------------------------#
454 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
455 #--------------------------------------------------------------------#
456 #
457 # Keep the script file name for Makefile dependencies.
458 PREV=$this_script
459
460 done
461}
462
463
464#-----------------------------#
465final_system_Makefiles() { #
466#-----------------------------#
467 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system${R_arrow}"
468
469 for file in final-system/* ; do
470 # Keep the script file name
471 this_script=`basename $file`
472
473 # Test if the stripping phase must be skipped
474 case $this_script in
475 *stripping*) [[ "$STRIP" = "0" ]] && continue
476 ;;
477 esac
478
479 # First append each name of the script files to a list (this will become
480 # the names of the targets in the Makefile
481 basicsystem="$basicsystem $this_script"
482
483 # Grab the name of the target, strip id number, XXX-script
484 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
485 -e 's@temp-@@' \
486 -e 's@-64bit@@' \
487 -e 's@-64@@' \
488 -e 's@64@@' \
489 -e 's@n32@@'`
490
491 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
492
493 #--------------------------------------------------------------------#
494 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
495 #--------------------------------------------------------------------#
496 #
497 # Drop in the name of the target on a new line, and the previous target
498 # as a dependency. Also call the echo_message function.
499 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
500
501 # If $vrs isn't empty, we've got a package...
502 if [ "$vrs" != "" ] ; then
503 case $name in
504 temp-perl) wrt_unpack2 "perl-$vrs.tar.*" ;;
505 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
506 esac
507 fi
508 #
509 wrt_run_as_chroot1 "${this_script}" "${file}"
510 #
511 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
512 #
513 # Include a touch of the target name so make can check if it's already been made.
514 echo -e '\t@touch $@' >> $MKFILE.tmp
515 #
516 #--------------------------------------------------------------------#
517 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
518 #--------------------------------------------------------------------#
519 #
520 # Keep the script file name for Makefile dependencies.
521 PREV=$this_script
522
523 done # for file in final-system/* ...
524}
525
526
527#-----------------------------#
528bm_final_system_Makefiles() { #
529#-----------------------------#
530 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system${R_arrow}"
531
532 # The makesys phase was initiated in bm_testsuite_tools_makefile
533 [[ "$TEST" = 0 ]] && PREV=""
534
535 for file in final-system/* ; do
536 # Keep the script file name
537 this_script=`basename $file`
538
539 # Test if the stripping phase must be skipped
540 case $this_script in
541 *stripping*) [[ "$STRIP" = "0" ]] && continue
542 ;;
543 esac
544
545 # First append each name of the script files to a list (this will become
546 # the names of the targets in the Makefile
547 basicsystem="$basicsystem $this_script"
548
549 # Grab the name of the target, strip id number, XXX-script
550 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
551 -e 's@temp-@@' \
552 -e 's@-64bit@@' \
553 -e 's@-64@@' \
554 -e 's@64@@' \
555 -e 's@n32@@'`
556
557 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
558
559 #--------------------------------------------------------------------#
560 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
561 #--------------------------------------------------------------------#
562 #
563 # Drop in the name of the target on a new line, and the previous target
564 # as a dependency. Also call the echo_message function.
565 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
566
567 # If $vrs isn't empty, we've got a package...
568 if [ "$vrs" != "" ] ; then
569 case $name in
570 temp-perl) wrt_unpack3 "perl-$vrs.tar.*" ;;
571 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
572 esac
573 fi
574 #
575 wrt_run_as_root2 "${this_script}" "${file}"
576 #
577 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
578 #
579 # Include a touch of the target name so make can check if it's already been made.
580 echo -e '\t@touch $@' >> $MKFILE.tmp
581 #
582 #--------------------------------------------------------------------#
583 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
584 #--------------------------------------------------------------------#
585 #
586 # Keep the script file name for Makefile dependencies.
587 PREV=$this_script
588
589 done # for file in final-system/* ...
590}
591
592
593#-----------------------------#
594bootscripts_Makefiles() { #
595#-----------------------------#
596 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts${R_arrow}"
597
598 for file in bootscripts/* ; do
599 # Keep the script file name
600 this_script=`basename $file`
601
602 case $this_script in
603 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
604 *console*) continue ;; # Use the files that came with the bootscripts
605 *) ;;
606 esac
607
608 # First append each name of the script files to a list (this will become
609 # the names of the targets in the Makefile
610 bootscripttools="$bootscripttools $this_script"
611
612 # Grab the name of the target, strip id number, XXX-script
613 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
614 -e 's@-64bit@@' \
615 -e 's@-64@@' \
616 -e 's@64@@' \
617 -e 's@n32@@'`
618 case $name in
619 *bootscripts*) name=bootscripts-cross-lfs ;;
620 *udev-rules) name=udev-cross-lfs ;;
621 esac
622 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
623
624 #--------------------------------------------------------------------#
625 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
626 #--------------------------------------------------------------------#
627 #
628 # Drop in the name of the target on a new line, and the previous target
629 # as a dependency. Also call the echo_message function.
630 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
631 #
632 # If $vrs isn't empty, we've got a package...
633 #
634 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
635 #
636 wrt_run_as_chroot1 "${this_script}" "${file}"
637 #
638 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
639 #
640 # Include a touch of the target name so make can check if it's already been made.
641 echo -e '\t@touch $@' >> $MKFILE.tmp
642 #
643 #--------------------------------------------------------------------#
644 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
645 #--------------------------------------------------------------------#
646 #
647 # Keep the script file name for Makefile dependencies.
648 PREV=$this_script
649
650 done # for file in bootscripts/* ...
651
652}
653
654#-----------------------------#
655bm_bootscripts_Makefiles() { #
656#-----------------------------#
657 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts${R_arrow}"
658
659 for file in bootscripts/* ; do
660 # Keep the script file name
661 this_script=`basename $file`
662
663 case $this_script in
664 *udev*) continue ;; # This is not a script but a commentary
665 *console*) continue ;; # Use the files that came with the bootscripts
666 *) ;;
667 esac
668
669 # First append each name of the script files to a list (this will become
670 # the names of the targets in the Makefile
671 bootscripttools="$bootscripttools $this_script"
672
673 # Grab the name of the target, strip id number, XXX-script
674 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
675 -e 's@-64bit@@' \
676 -e 's@-64@@' \
677 -e 's@64@@' \
678 -e 's@n32@@'`
679 case $name in
680 *bootscripts*) name=bootscripts-cross-lfs
681 ;;
682 esac
683 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
684
685 #--------------------------------------------------------------------#
686 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
687 #--------------------------------------------------------------------#
688 #
689 # Drop in the name of the target on a new line, and the previous target
690 # as a dependency. Also call the echo_message function.
691 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
692 #
693 # If $vrs isn't empty, we've got a package...
694 #
695 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
696 #
697 wrt_run_as_root2 "${this_script}" "${file}"
698 #
699 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
700 #
701 # Include a touch of the target name so make can check if it's already been made.
702 echo -e '\t@touch $@' >> $MKFILE.tmp
703 #
704 #--------------------------------------------------------------------#
705 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
706 #--------------------------------------------------------------------#
707 #
708 # Keep the script file name for Makefile dependencies.
709 PREV=$this_script
710
711 done # for file in bootscripts/* ...
712
713}
714
715
716
717#-----------------------------#
718bootable_Makefiles() { #
719#-----------------------------#
720 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable${R_arrow}"
721
722 for file in {bootable,the-end}/* ; do
723 # Keep the script file name
724 this_script=`basename $file`
725
726 # A little housekeeping on the scripts
727 case $this_script in
728 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
729 *kernel) # if there is no kernel config file do not build the kernel
730 [[ -z $CONFIG ]] && continue
731 # Copy the config file to /sources with a standardized name
732 cp $CONFIG $BUILDDIR/sources/kernel-config
733 ;;
734 esac
735 #
736 # First append each name of the script files to a list (this will become
737 # the names of the targets in the Makefile
738 bootabletools="$bootabletools $this_script"
739 #
740 # Grab the name of the target, strip id number and misc words.
741 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
742 case $this_script in
743 *kernel*) name=linux
744 ;;
745 esac
746 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
747
748 #--------------------------------------------------------------------#
749 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
750 #--------------------------------------------------------------------#
751 #
752 # Drop in the name of the target on a new line, and the previous target
753 # as a dependency. Also call the echo_message function.
754 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
755 #
756 # If $vrs isn't empty, we've got a package...
757 # Insert instructions for unpacking the package and changing directories
758 #
759 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
760 #
761 # Select a script execution method
762 case $this_script in
763 *fstab*) if [[ -n "$FSTAB" ]]; then
764 wrt_copy_fstab "${this_script}"
765 else
766 wrt_run_as_chroot1 "${this_script}" "${file}"
767 fi
768 ;;
769 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
770 esac
771 #
772 # Housekeeping...remove any build directory(ies) except if the package build fails.
773 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
774 #
775 # Include a touch of the target name so make can check if it's already been made.
776 echo -e '\t@touch $@' >> $MKFILE.tmp
777 #
778 #--------------------------------------------------------------------#
779 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
780 #--------------------------------------------------------------------#
781 #
782 # Keep the script file name for Makefile dependencies.
783 PREV=$this_script
784
785 done
786
787}
788
789
790
791#-----------------------------#
792bm_bootable_Makefiles() { #
793#-----------------------------#
794 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable${R_arrow}"
795
796 for file in {bootable,the-end}/* ; do
797 # Keep the script file name
798 this_script=`basename $file`
799
800 # A little housekeeping on the scripts
801 case $this_script in
802 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
803 *kernel) # if there is no kernel config file do not build the kernel
804 [[ -z $CONFIG ]] && continue
805 # Copy the named config file to /sources with a standardized name
806 cp $CONFIG $BUILDDIR/sources/kernel-config
807 ;;
808 esac
809 #
810 # First append each name of the script files to a list (this will become
811 # the names of the targets in the Makefile
812 bootabletools="$bootabletools $this_script"
813 #
814 # Grab the name of the target, strip id number and misc words.
815 case $this_script in
816 *kernel) name=linux
817 ;;
818 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
819 esac
820
821 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
822
823 #--------------------------------------------------------------------#
824 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
825 #--------------------------------------------------------------------#
826 #
827 # Drop in the name of the target on a new line, and the previous target
828 # as a dependency. Also call the echo_message function.
829 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
830 #
831 # If $vrs isn't empty, we've got a package...
832 # Insert instructions for unpacking the package and changing directories
833 #
834 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
835 #
836 # Select a script execution method
837 case $this_script in
838 *fstab*) if [[ -n "$FSTAB" ]]; then
839 # Minimal boot mode has no access to original file, store in /sources
840 cp $FSTAB $BUILDDIR/sources/fstab
841 wrt_copy_fstab2 "${this_script}"
842 else
843 wrt_run_as_root2 "${this_script}" "${file}"
844 fi
845 ;;
846 *) wrt_run_as_root2 "${this_script}" "${file}" ;;
847 esac
848 #
849 # Housekeeping...remove any build directory(ies) except if the package build fails.
850 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
851 #
852 # Include a touch of the target name so make can check if it's already been made.
853 echo -e '\t@touch $@' >> $MKFILE.tmp
854 #
855 #--------------------------------------------------------------------#
856 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
857 #--------------------------------------------------------------------#
858 #
859 # Keep the script file name for Makefile dependencies.
860 PREV=$this_script
861
862 done
863
864}
865
866
867#-----------------------------#
868build_Makefile() { # Construct a Makefile from the book scripts
869#-----------------------------#
870 echo "Creating Makefile... ${BOLD}START${OFF}"
871
872 cd $JHALFSDIR/${PROGNAME}-commands
873 # Start with a clean Makefile.tmp file
874 >$MKFILE.tmp
875
876 host_prep_Makefiles
877 cross_tools_Makefiles # $cross_tools
878 temptools_Makefiles # $temptools
879 if [[ $METHOD = "chroot" ]]; then
880 chroot_Makefiles # $chroottools
881 if [[ ! $TEST = "0" ]]; then
882 testsuite_tools_Makefiles # $testsuitetools
883 fi
884 final_system_Makefiles # $basicsystem
885 bootscripts_Makefiles # $bootscripttools
886 bootable_Makefiles # $bootabletools
887 else
888 boot_Makefiles # $boottools
889 if [[ ! $TEST = "0" ]]; then
890 bm_testsuite_tools_Makefiles # $testsuitetools
891 fi
892 bm_final_system_Makefiles # $basicsystem
893 bm_bootscripts_Makefiles # $bootscipttools
894 bm_bootable_Makefiles # $bootabletoosl
895 fi
896# the_end_Makefiles
897
898
899 # Add a header, some variables and include the function file
900 # to the top of the real Makefile.
901(
902 cat << EOF
903$HEADER
904
905SRC= /sources
906MOUNT_PT= $BUILDDIR
907
908include makefile-functions
909
910EOF
911) > $MKFILE
912
913 # Add chroot commands
914 if [ "$METHOD" = "chroot" ] ; then
915 chroot=`cat chroot/*chroot* | sed -e '/#!\/tools\/bin\/bash/d' \
916 -e '/^export/d' \
917 -e '/^logout/d' \
918 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
919 -e 's|\\$|&&|g' \
920 -e 's|exit||g' \
921 -e 's|$| -c|' \
922 -e 's|"$$LFS"|$(MOUNT_PT)|'\
923 -e 's|set -e||'`
924 echo -e "CHROOT1= $chroot\n" >> $MKFILE
925 fi
926
927 # Drop in the main target 'all:' and the chapter targets with each sub-target
928 # as a dependency.
929if [[ "${METHOD}" = "chroot" ]]; then
930(
931 cat << EOF
932all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8
933 @\$(call echo_finished,$VERSION)
934
935chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment
936
937chapter3: chapter2 $cross_tools
938
939chapter4: chapter3 $temptools
940
941chapter5: chapter4 $chroottools $testsuitetools
942
943chapter6: chapter5 $basicsystem
944
945chapter7: chapter6 $bootscripttools
946
947chapter8: chapter7 $bootabletools
948
949clean-all: clean
950 rm -rf ./{clfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
951
952clean: clean-chapter4 clean-chapter3 clean-chapter2
953
954clean-chapter2:
955 -if [ ! -f user-lfs-exist ]; then \\
956 userdel lfs; \\
957 rm -rf /home/lfs; \\
958 fi;
959 rm -rf \$(MOUNT_PT)/tools
960 rm -f /tools
961 rm -rf \$(MOUNT_PT)/cross-tools
962 rm -f /cross-tools
963 rm -f envars user-lfs-exist
964 rm -f 02* logs/02*.log
965
966clean-chapter3:
967 rm -rf \$(MOUNT_PT)/tools/*
968 rm -f $cross_tools restore-lfs-env sources-dir
969 cd logs && rm -f $cross_tools && cd ..
970
971clean-chapter4:
972 -umount \$(MOUNT_PT)/sys
973 -umount \$(MOUNT_PT)/proc
974 -umount \$(MOUNT_PT)/dev/shm
975 -umount \$(MOUNT_PT)/dev/pts
976 -umount \$(MOUNT_PT)/dev
977 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
978 rm -f $temptools
979 cd logs && rm -f $temptools && cd ..
980
981
982restore-lfs-env:
983 @\$(call echo_message, Building)
984 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
985 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
986 fi;
987 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
988 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
989 fi;
990 @chown lfs:lfs /home/lfs/.bash* && \\
991 touch \$@
992
993EOF
994) >> $MKFILE
995fi
996
997
998if [[ "${METHOD}" = "boot" ]]; then
999(
1000 cat << EOF
1001
1002all: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment \
1003 $cross_tools \
1004 $temptools \
1005 $chroottools \
1006 $boottools
1007 @\$(call echo_boot_finished,$VERSION)
1008
1009makeboot: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment \
1010 $cross_tools\
1011 $temptools \
1012 $chroottools \
1013 $boottools
1014 @\$(call echo_boot_finished,$VERSION)
1015
1016makesys: $testsuitetools $basicsystem $bootscripttools $bootabletools
1017 @\$(call echo_finished,$VERSION)
1018
1019
1020clean-all: clean
1021 rm -rf ./{clfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
1022
1023clean: clean-makesys clean-makeboot clean-jhalfs
1024
1025clean-jhalfs:
1026 -if [ ! -f user-lfs-exist ]; then \\
1027 userdel lfs; \\
1028 rm -rf /home/lfs; \\
1029 fi;
1030 rm -rf \$(MOUNT_PT)/tools
1031 rm -f /tools
1032 rm -rf \$(MOUNT_PT)/cross-tools
1033 rm -f /cross-tools
1034 rm -f envars user-lfs-exist
1035 rm -f 02* logs/02*.log
1036
1037clean-makeboot:
1038 rm -rf /tools/*
1039 rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools
1040 rm -f restore-lfs-env sources-dir
1041 cd logs && rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools && cd ..
1042
1043clean-makesys:
1044 -umount \$(MOUNT_PT)/sys
1045 -umount \$(MOUNT_PT)/proc
1046 -umount \$(MOUNT_PT)/dev/shm
1047 -umount \$(MOUNT_PT)/dev/pts
1048 -umount \$(MOUNT_PT)/dev
1049 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
1050 rm -f $basicsystem
1051 rm -f $bootscripttools
1052 rm -f $bootabletools
1053 cd logs && rm -f $basicsystem && rm -f $bootscripttools && rm -f $bootabletools && cd ..
1054
1055
1056restore-lfs-env:
1057 @\$(call echo_message, Building)
1058 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
1059 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
1060 fi;
1061 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
1062 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
1063 fi;
1064 @chown lfs:lfs /home/lfs/.bash* && \\
1065 touch \$@
1066
1067EOF
1068) >> $MKFILE
1069fi
1070
1071 # Bring over the items from the Makefile.tmp
1072 cat $MKFILE.tmp >> $MKFILE
1073 rm $MKFILE.tmp
1074 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1075
1076}
1077
Note: See TracBrowser for help on using the repository browser.