source: CLFS/master.sh@ c7c5a53

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

Using wrt_target function and simplified all target in CLFS module.

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