source: CLFS/master.sh@ ffd482f

experimental
Last change on this file since ffd482f was 64cc345, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Removed a duplicate function.

  • Property mode set to 100755
File size: 37.8 KB
RevLine 
[0170229]1#!/bin/sh
[1ce084e]2# $Id$
[0170229]3
4###################################
5### FUNCTIONS ###
6###################################
7
8
9
10#----------------------------#
[fcaf131]11host_prep_Makefiles() { # Initialization of the system
[0170229]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 #
[c3c4e1d]134 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*" && echo -e '\ttrue' >> $MKFILE.tmp
[0170229]135 #
[64cc345]136 wrt_run_as_su "${this_script}" "${file}"
[0170229]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 #
[c3c4e1d]186 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*" && echo -e '\ttrue' >> $MKFILE.tmp
[0170229]187 #
[64cc345]188 wrt_run_as_su "${this_script}" "${file}"
[0170229]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
[6d3564b]216 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
[0170229]217 *whatnext*) continue ;;
[0271c0c]218 *kernel) # if there is no kernel config file do not build the kernel
[4845f38]219 [[ -z $CONFIG ]] && continue
[0271c0c]220 # Copy the config file to /sources with a standardized name
[6eef5ef]221 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
[0170229]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
[6d3564b]231 *kernel) name=linux ;;
[fcaf131]232 *bootscripts) name="bootscripts-cross-lfs" ;;
[9dc8222]233 *udev-rules) name="udev-cross-lfs" ;;
[6d3564b]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 ;;
[0170229]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 #
[9dc8222]257 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*" && echo -e '\ttrue' >> $MKFILE.tmp
[0170229]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
[64cc345]266 wrt_run_as_su "${this_script}" "${file}"
[0170229]267 fi
268 ;;
[64cc345]269 *) wrt_run_as_su "${this_script}" "${file}" ;;
[0170229]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.
[fd5cb46]299 case $this_script in
300 *chroot*) continue ;;
301 esac
[0170229]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
[c3c4e1d]325 *util-linux) wrt_unpack "$name-$vrs.tar.*"
[7d018d1]326 echo -e '\ttrue' >> $MKFILE.tmp
327 ;;
328 *) wrt_unpack2 "$name-$vrs.tar.*"
329 ;;
[0170229]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}" ;;
[64cc345]336 *util-linux) wrt_run_as_su "${this_script}" "${file}" ;;
[0170229]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#-----------------------------#
[afd0232]360 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools${R_arrow}"
[0170229]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
[c3c4e1d]388 tcl) wrt_unpack2 "$name$vrs-src.tar.*" ;;
389 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
[0170229]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#--------------------------------#
[afd0232]413 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools${R_arrow}"
[0170229]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
[39d4d5c]421 PREV=
[0170229]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
[c3c4e1d]442 tcl) wrt_unpack3 "$name$vrs-src.tar.*" ;;
443 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
[0170229]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#-----------------------------#
[afd0232]467 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system${R_arrow}"
[0170229]468
469 for file in final-system/* ; do
470 # Keep the script file name
471 this_script=`basename $file`
472
[3fcd63e]473 # Test if the stripping phase must be skipped
[fd5cb46]474 case $this_script in
475 *stripping*) [[ "$STRIP" = "0" ]] && continue
476 ;;
477 esac
[3fcd63e]478
[0170229]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#-----------------------------#
[afd0232]530 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system${R_arrow}"
[0170229]531
[39d4d5c]532 # The makesys phase was initiated in bm_testsuite_tools_makefile
533 [[ "$TEST" = 0 ]] && PREV=""
534
[0170229]535 for file in final-system/* ; do
536 # Keep the script file name
537 this_script=`basename $file`
538
[3fcd63e]539 # Test if the stripping phase must be skipped
[64cc345]540 case $this_script in
[fd5cb46]541 *stripping*) [[ "$STRIP" = "0" ]] && continue
542 ;;
543 esac
[0170229]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
[c3c4e1d]570 temp-perl) wrt_unpack3 "perl-$vrs.tar.*" ;;
571 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
[0170229]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#-----------------------------#
[afd0232]596 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts${R_arrow}"
[0170229]597
598 for file in bootscripts/* ; do
599 # Keep the script file name
600 this_script=`basename $file`
601
602 case $this_script in
[eba62c0]603 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
[0170229]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@@'`
[fd5cb46]618 case $name in
[eba62c0]619 *bootscripts*) name=bootscripts-cross-lfs ;;
620 *udev-rules) name=udev-cross-lfs ;;
[fd5cb46]621 esac
[0170229]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#-----------------------------#
[afd0232]657 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts${R_arrow}"
[0170229]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@@'`
[fd5cb46]679 case $name in
680 *bootscripts*) name=bootscripts-cross-lfs
681 ;;
682 esac
[0170229]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 #
[c3c4e1d]695 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
[0170229]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#-----------------------------#
[afd0232]720 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable${R_arrow}"
[0170229]721
722 for file in bootable/* ; 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
[6d3564b]728 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
[87b93b4]729 *kernel) # if there is no kernel config file do not build the kernel
[4845f38]730 [[ -z $CONFIG ]] && continue
[0271c0c]731 # Copy the config file to /sources with a standardized name
[1917cad]732 cp $CONFIG $BUILDDIR/sources/kernel-config
[87b93b4]733 ;;
[0170229]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@@' `
[fd5cb46]742 case $this_script in
743 *kernel*) name=linux
744 ;;
745 esac
[0170229]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 #
[b88d581]759 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
[0170229]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
[fcaf131]766 wrt_run_as_chroot1 "${this_script}" "${file}"
[0170229]767 fi
768 ;;
[fcaf131]769 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
[0170229]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#-----------------------------#
[afd0232]794 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable${R_arrow}"
[0170229]795
796 for file in bootable/* ; 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
[6d3564b]802 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
[b83baf6]803 *kernel) # if there is no kernel config file do not build the kernel
[4845f38]804 [[ -z $CONFIG ]] && continue
[0271c0c]805 # Copy the named config file to /sources with a standardized name
[62033d2]806 cp $CONFIG $BUILDDIR/sources/kernel-config
[0170229]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 #
[c3c4e1d]834 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
[0170229]835 #
836 # Select a script execution method
837 case $this_script in
838 *fstab*) if [[ -n "$FSTAB" ]]; then
[a9490ab]839 # Minimal boot mode has no access to original file, store in /sources
840 cp $FSTAB $BUILDDIR/sources/fstab
[0170229]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
868#-----------------------------#
869the_end_Makefiles() { #
870#-----------------------------#
871 echo "${tab_}${GREEN}Processing... ${L_arrow}THE END${R_arrow}"
872}
873
874
875#-----------------------------#
876build_Makefile() { # Construct a Makefile from the book scripts
877#-----------------------------#
878 echo "Creating Makefile... ${BOLD}START${OFF}"
879
880 cd $JHALFSDIR/${PROGNAME}-commands
881 # Start with a clean Makefile.tmp file
882 >$MKFILE.tmp
883
884 host_prep_Makefiles
[d43a271]885 cross_tools_Makefiles # $cross_tools
886 temptools_Makefiles # $temptools
[afd0232]887 if [[ $METHOD = "chroot" ]]; then
[d43a271]888 chroot_Makefiles # $chroottools
[fa06e8e]889 if [[ ! $TEST = "0" ]]; then
[d43a271]890 testsuite_tools_Makefiles # $testsuitetools
[0170229]891 fi
[d43a271]892 final_system_Makefiles # $basicsystem
893 bootscripts_Makefiles # $bootscripttools
894 bootable_Makefiles # $bootabletools
[0170229]895 else
[d43a271]896 boot_Makefiles # $boottools
[fa06e8e]897 if [[ ! $TEST = "0" ]]; then
[d43a271]898 bm_testsuite_tools_Makefiles # $testsuitetools
[0170229]899 fi
[d43a271]900 bm_final_system_Makefiles # $basicsystem
901 bm_bootscripts_Makefiles # $bootscipttools
902 bm_bootable_Makefiles # $bootabletoosl
[0170229]903 fi
[39d4d5c]904# the_end_Makefiles
[0170229]905
906
907 # Add a header, some variables and include the function file
908 # to the top of the real Makefile.
909(
910 cat << EOF
911$HEADER
912
913SRC= /sources
914MOUNT_PT= $BUILDDIR
915
916include makefile-functions
917
918EOF
919) > $MKFILE
920
921 # Add chroot commands
[e676ffa]922 if [ "$METHOD" = "chroot" ] ; then
923 chroot=`cat chroot/*chroot* | sed -e '/#!\/tools\/bin\/bash/d' \
[0170229]924 -e '/^export/d' \
925 -e '/^logout/d' \
926 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
927 -e 's|\\$|&&|g' \
928 -e 's|exit||g' \
929 -e 's|$| -c|' \
930 -e 's|"$$LFS"|$(MOUNT_PT)|'\
931 -e 's|set -e||'`
[e676ffa]932 echo -e "CHROOT1= $chroot\n" >> $MKFILE
933 fi
[0170229]934
935 # Drop in the main target 'all:' and the chapter targets with each sub-target
936 # as a dependency.
[39d4d5c]937if [[ "${METHOD}" = "chroot" ]]; then
[0170229]938(
939 cat << EOF
940all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8
941 @\$(call echo_finished,$VERSION)
942
943chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment
944
945chapter3: chapter2 $cross_tools
946
947chapter4: chapter3 $temptools
948
[d43a271]949chapter5: chapter4 $chroottools $testsuitetools
[0170229]950
951chapter6: chapter5 $basicsystem
952
953chapter7: chapter6 $bootscripttools
954
955chapter8: chapter7 $bootabletools
956
957clean-all: clean
[39d4d5c]958 rm -rf ./{${PROGNAME}-commands,logs,${PROGNAME}-Makefile,clfs.xsl,makefile-functions,packages,patches}
[0170229]959
960clean: clean-chapter4 clean-chapter3 clean-chapter2
961
962clean-chapter2:
963 -if [ ! -f user-lfs-exist ]; then \\
964 userdel lfs; \\
965 rm -rf /home/lfs; \\
966 fi;
967 rm -rf \$(MOUNT_PT)/tools
968 rm -f /tools
969 rm -rf \$(MOUNT_PT)/cross-tools
970 rm -f /cross-tools
971 rm -f envars user-lfs-exist
972 rm -f 02* logs/02*.log
973
974clean-chapter3:
975 rm -rf \$(MOUNT_PT)/tools/*
976 rm -f $cross_tools restore-lfs-env sources-dir
977 cd logs && rm -f $cross_tools && cd ..
978
979clean-chapter4:
980 -umount \$(MOUNT_PT)/sys
981 -umount \$(MOUNT_PT)/proc
982 -umount \$(MOUNT_PT)/dev/shm
983 -umount \$(MOUNT_PT)/dev/pts
984 -umount \$(MOUNT_PT)/dev
985 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
986 rm -f $temptools
987 cd logs && rm -f $temptools && cd ..
988
989
990restore-lfs-env:
991 @\$(call echo_message, Building)
992 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
993 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
994 fi;
995 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
996 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
997 fi;
998 @chown lfs:lfs /home/lfs/.bash* && \\
999 touch \$@
1000
1001EOF
1002) >> $MKFILE
[39d4d5c]1003fi
1004
1005
1006if [[ "${METHOD}" = "boot" ]]; then
1007(
1008 cat << EOF
[64cc345]1009
[39d4d5c]1010all: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment \
1011 $cross_tools \
1012 $temptools \
1013 $chroottools \
1014 $boottools
1015 @\$(call echo_boot_finished,$VERSION)
1016
1017makeboot: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment \
1018 $cross_tools\
1019 $temptools \
1020 $chroottools \
1021 $boottools
1022 @\$(call echo_boot_finished,$VERSION)
1023
[d43a271]1024makesys: $testsuitetools $basicsystem $bootscripttools $bootabletools
[39d4d5c]1025 @\$(call echo_finished,$VERSION)
1026
1027
1028clean-all: clean
1029 rm -rf ./{${PROGNAME}-commands,logs,${PROGNAME}-Makefile,clfs.xsl,makefile-functions,packages,patches}
1030
1031clean: clean-makesys clean-makeboot clean-jhalfs
1032
1033clean-jhalfs:
1034 -if [ ! -f user-lfs-exist ]; then \\
1035 userdel lfs; \\
1036 rm -rf /home/lfs; \\
1037 fi;
1038 rm -rf \$(MOUNT_PT)/tools
1039 rm -f /tools
1040 rm -rf \$(MOUNT_PT)/cross-tools
1041 rm -f /cross-tools
1042 rm -f envars user-lfs-exist
1043 rm -f 02* logs/02*.log
[0170229]1044
[39d4d5c]1045clean-makeboot:
1046 rm -rf /tools/*
[64cc345]1047 rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools
[39d4d5c]1048 rm -f restore-lfs-env sources-dir
1049 cd logs && rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools && cd ..
1050
1051clean-makesys:
1052 -umount \$(MOUNT_PT)/sys
1053 -umount \$(MOUNT_PT)/proc
1054 -umount \$(MOUNT_PT)/dev/shm
1055 -umount \$(MOUNT_PT)/dev/pts
1056 -umount \$(MOUNT_PT)/dev
1057 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
1058 rm -f $basicsystem
1059 rm -f $bootscripttools
1060 rm -f $bootabletools
1061 cd logs && rm -f $basicsystem && rm -f $bootscripttools && rm -f $bootabletools && cd ..
1062
1063
1064restore-lfs-env:
1065 @\$(call echo_message, Building)
1066 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
1067 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
1068 fi;
1069 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
1070 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
1071 fi;
1072 @chown lfs:lfs /home/lfs/.bash* && \\
1073 touch \$@
1074
1075EOF
1076) >> $MKFILE
1077fi
[0170229]1078
1079 # Bring over the items from the Makefile.tmp
1080 cat $MKFILE.tmp >> $MKFILE
1081 rm $MKFILE.tmp
1082 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1083
1084}
1085
Note: See TracBrowser for help on using the repository browser.