source: CLFS/master.sh@ 3fcd63e

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

Depured final system makefiles.

  • Property mode set to 100755
File size: 35.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 #
136 wrt_run_as_lfs "${this_script}" "${file}"
137 #
138 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
139 #
140 # Include a touch of the target name so make can check if it's already been made.
141 echo -e '\t@touch $@' >> $MKFILE.tmp
142 #
143 #--------------------------------------------------------------------#
144 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
145 #--------------------------------------------------------------------#
146 #
147 # Keep the script file name for Makefile dependencies.
148 PREV=$this_script
149
150 done # for file in ....
151}
152
153
154#-----------------------------#
155temptools_Makefiles() { #
156#-----------------------------#
157 echo "${tab_}${GREEN}Processing... ${L_arrow}temp system${R_arrow}"
158
159 for file in temp-system/* ; do
160 # Keep the script file name
161 this_script=`basename $file`
162 #
163 # First append each name of the script files to a list (this will become
164 # the names of the targets in the Makefile
165 temptools="$temptools $this_script"
166
167 #
168 # Grab the name of the target, strip id number, XXX-script
169 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
170 #
171 # Find the version of the command files, if it corresponds with the building of a specific package
172 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
173
174
175 #--------------------------------------------------------------------#
176 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
177 #--------------------------------------------------------------------#
178 #
179 # Drop in the name of the target on a new line, and the previous target
180 # as a dependency. Also call the echo_message function.
181 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
182 #
183 # If $vrs isn't empty, we've got a package...
184 # Insert instructions for unpacking the package and to set the PKGDIR variable.
185 #
[c3c4e1d]186 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*" && echo -e '\ttrue' >> $MKFILE.tmp
[0170229]187 #
188 wrt_run_as_lfs "${this_script}" "${file}"
189 #
190 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
191 #
192 # Include a touch of the target name so make can check if it's already been made.
193 echo -e '\t@touch $@' >> $MKFILE.tmp
194 #
195 #--------------------------------------------------------------------#
196 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
197 #--------------------------------------------------------------------#
198 #
199 # Keep the script file name for Makefile dependencies.
200 PREV=$this_script
201 done # for file in ....
202}
203
204
205#-----------------------------#
206boot_Makefiles() { #
207#-----------------------------#
208 echo "${tab_}${GREEN}Processing... ${L_arrow}boot${R_arrow}"
209
210 for file in boot/* ; do
211 # Keep the script file name
212 this_script=`basename $file`
213
214 # A little housekeeping on the scripts
215 case $this_script in
216 *grub*) continue ;;
217 *whatnext*) continue ;;
218 *settingenvironment*) sed 's@PS1=@set +h\nPS1=@' -i $file ;;
[0271c0c]219 *kernel) # if there is no kernel config file do not build the kernel
[4845f38]220 [[ -z $CONFIG ]] && continue
[0271c0c]221 # Copy the config file to /sources with a standardized name
[6eef5ef]222 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
[b83baf6]223# sed "s|make mrproper|make mrproper\ncp /sources/bootkernel-config .config|" -i $file
[0271c0c]224 # You cannot run menuconfig from within the makefile
[b83baf6]225# sed 's|menuconfig|oldconfig|' -i $file
[0271c0c]226 #If defined include the keymap in the kernel
[b83baf6]227# if [[ -n "$KEYMAP" ]]; then
228# sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file
229# else
230# sed '/loadkeys -m/d' -i $file
231# sed '/drivers\/char/d' -i $file
232# fi
[0170229]233 ;;
234 esac
235 #
236 # First append each name of the script files to a list (this will become
237 # the names of the targets in the Makefile
238 boottools="$boottools $this_script"
239 #
240 # Grab the name of the target, strip id number and misc words.
241 case $this_script in
242 *kernel) name=linux ;;
[fcaf131]243 *bootscripts) name="bootscripts-cross-lfs" ;;
[0170229]244 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
245 esac
246
247 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
248
249 #--------------------------------------------------------------------#
250 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
251 #--------------------------------------------------------------------#
252 #
253 # Drop in the name of the target on a new line, and the previous target
254 # as a dependency. Also call the echo_message function.
255 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
256 #
257 # If $vrs isn't empty, we've got a package...
258 # Insert instructions for unpacking the package and changing directories
259 #
[c3c4e1d]260 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
[0170229]261 #
262 # Select a script execution method
263 case $this_script in
264 *changingowner*) wrt_run_as_root "${this_script}" "${file}" ;;
265 *devices*) wrt_run_as_root "${this_script}" "${file}" ;;
266 *fstab*) if [[ -n "$FSTAB" ]]; then
267 wrt_copy_fstab "${this_script}"
268 else
269 wrt_run_as_lfs "${this_script}" "${file}"
270 fi
271 ;;
272 *) wrt_run_as_lfs "${this_script}" "${file}" ;;
273 esac
274 #
275 # Housekeeping...remove any build directory(ies) except if the package build fails.
276 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
277 #
278 # Include a touch of the target name so make can check if it's already been made.
279 echo -e '\t@touch $@' >> $MKFILE.tmp
280 #
281 #--------------------------------------------------------------------#
282 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
283 #--------------------------------------------------------------------#
284 #
285 # Keep the script file name for Makefile dependencies.
286 PREV=$this_script
287
288 done
289 # This will force the Makefile to exit and not allow it to be restarted with
290 # the command <make>, The user will have to issue the cmd <make chapterXX>
291 echo -e "\t@\$(call echo_boot_finished,$VERSION) && \\" >> $MKFILE.tmp
292 echo -e "\tfalse" >> $MKFILE.tmp
293}
294
295
296#-----------------------------#
297chroot_Makefiles() { #
298#-----------------------------#
299 echo "${tab_}${GREEN}Processing... ${L_arrow}chroot${R_arrow}"
300
301 for file in chroot/* ; do
302 # Keep the script file name
303 this_script=`basename $file`
304 #
305 # Skipping scripts is done now and not included in the build tree.
306 [[ `_IS_ $this_script chroot` ]] && continue
307
308 #
309 # First append each name of the script files to a list (this will become
310 # the names of the targets in the Makefile
311 chroottools="$chroottools $this_script"
312
313 #
314 # A little housekeeping on the script contents
315 case $this_script in
316 *kernfs*) sed '/exit/d' -i $file ;;
317 *pwdgroup*) sed '/exec/d' -i $file ;;
318 esac
319 #
320 # Grab the name of the target, strip id number, XXX-script
321 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
322 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
323
324 #--------------------------------------------------------------------#
325 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
326 #--------------------------------------------------------------------#
327 #
328 # Drop in the name of the target on a new line, and the previous target
329 # as a dependency. Also call the echo_message function.
330 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
331 #
332 # If $vrs isn't empty, we've got a package...
333 # Insert instructions for unpacking the package and changing directories
334 #
335 if [ "$vrs" != "" ] ; then
336 case $this_script in
[c3c4e1d]337 *util-linux) wrt_unpack "$name-$vrs.tar.*"
[7d018d1]338 echo -e '\ttrue' >> $MKFILE.tmp
339 ;;
340 *) wrt_unpack2 "$name-$vrs.tar.*"
341 ;;
[0170229]342 esac
343 fi
344 #
345 # Select a script execution method
346 case $this_script in
347 *kernfs) wrt_run_as_root "${this_script}" "${file}" ;;
348 *util-linux) wrt_run_as_lfs "${this_script}" "${file}" ;;
349 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
350 esac
351 #
352 # Housekeeping...remove the build directory(ies), except if the package build fails.
353 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
354 #
355 # Include a touch of the target name so make can check if it's already been made.
356 echo -e '\t@touch $@' >> $MKFILE.tmp
357 #
358 #--------------------------------------------------------------------#
359 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
360 #--------------------------------------------------------------------#
361 #
362 # Keep the script file name for Makefile dependencies.
363 PREV=$this_script
364
365 done # for file in...
366}
367
368
369#-----------------------------#
370testsuite_tools_Makefiles() { #
371#-----------------------------#
[afd0232]372 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools${R_arrow}"
[0170229]373
374 for file in testsuite-tools/* ; do
375 # Keep the script file name
376 this_script=`basename $file`
377
378 # First append each name of the script files to a list (this will become
379 # the names of the targets in the Makefile
380 testsuitetools="$testsuitetools $this_script"
381
382 # Grab the name of the target, strip id number, XXX-script
383 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
384 -e 's@-64bit@@' \
385 -e 's@-64@@' \
386 -e 's@64@@' \
387 -e 's@n32@@'`
388
389 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
390
391 #--------------------------------------------------------------------#
392 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
393 #--------------------------------------------------------------------#
394 #
395 # Drop in the name of the target on a new line, and the previous target
396 # as a dependency. Also call the echo_message function.
397 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
398 #
399 case $name in
[c3c4e1d]400 tcl) wrt_unpack2 "$name$vrs-src.tar.*" ;;
401 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
[0170229]402 esac
403 #
404 wrt_run_as_chroot1 "${this_script}" "${file}"
405 #
406 wrt_remove_build_dirs "${name}"
407 #
408 # Include a touch of the target name so make can check if it's already been made.
409 echo -e '\t@touch $@' >> $MKFILE.tmp
410 #
411 #--------------------------------------------------------------------#
412 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
413 #--------------------------------------------------------------------#
414 #
415 # Keep the script file name for Makefile dependencies.
416 PREV=$this_script
417
418 done
419}
420
421
422#--------------------------------#
423bm_testsuite_tools_Makefiles() { #
424#--------------------------------#
[afd0232]425 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools${R_arrow}"
[0170229]426
427 for file in testsuite-tools/* ; do
428 # Keep the script file name
429 this_script=`basename $file`
430
431 # First append each name of the script files to a list (this will become
432 # the names of the targets in the Makefile
433 testsuitetools="$testsuitetools $this_script"
434
435 # Grab the name of the target, strip id number, XXX-script
436 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
437 -e 's@-64bit@@' \
438 -e 's@-64@@' \
439 -e 's@64@@' \
440 -e 's@n32@@'`
441
442 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
443
444 #--------------------------------------------------------------------#
445 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
446 #--------------------------------------------------------------------#
447 #
448 # Drop in the name of the target on a new line, and the previous target
449 # as a dependency. Also call the echo_message function.
450 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
451 #
452 case $name in
[c3c4e1d]453 tcl) wrt_unpack3 "$name$vrs-src.tar.*" ;;
454 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
[0170229]455 esac
456 #
457 wrt_run_as_root2 "${this_script}" "${file}"
458 #
459 wrt_remove_build_dirs2 "${name}"
460 #
461 # Include a touch of the target name so make can check if it's already been made.
462 echo -e '\t@touch $@' >> $MKFILE.tmp
463 #
464 #--------------------------------------------------------------------#
465 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
466 #--------------------------------------------------------------------#
467 #
468 # Keep the script file name for Makefile dependencies.
469 PREV=$this_script
470
471 done
472}
473
474
475#-----------------------------#
476final_system_Makefiles() { #
477#-----------------------------#
[afd0232]478 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system${R_arrow}"
[0170229]479
480 for file in final-system/* ; do
481 # Keep the script file name
482 this_script=`basename $file`
483
[3fcd63e]484 # Test if the stripping phase must be skipped
485 if [ "$STRIP" = "0" ] && [[ `_IS_ ${this_script} stripping` ]] ; then
486 continue
487 fi
488
[0170229]489 # First append each name of the script files to a list (this will become
490 # the names of the targets in the Makefile
491 basicsystem="$basicsystem $this_script"
492
493 # Grab the name of the target, strip id number, XXX-script
494 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
495 -e 's@temp-@@' \
496 -e 's@-64bit@@' \
497 -e 's@-64@@' \
498 -e 's@64@@' \
499 -e 's@n32@@'`
500
501 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
502
503 #--------------------------------------------------------------------#
504 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
505 #--------------------------------------------------------------------#
506 #
507 # Drop in the name of the target on a new line, and the previous target
508 # as a dependency. Also call the echo_message function.
509 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
510
511 # If $vrs isn't empty, we've got a package...
512 if [ "$vrs" != "" ] ; then
513 case $name in
514 temp-perl) wrt_unpack2 "perl-$vrs.tar.*" ;;
515 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
516 esac
517 fi
518 #
519 wrt_run_as_chroot1 "${this_script}" "${file}"
520 #
521 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
522 #
523 # Include a touch of the target name so make can check if it's already been made.
524 echo -e '\t@touch $@' >> $MKFILE.tmp
525 #
526 #--------------------------------------------------------------------#
527 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
528 #--------------------------------------------------------------------#
529 #
530 # Keep the script file name for Makefile dependencies.
531 PREV=$this_script
532
533 done # for file in final-system/* ...
534}
535
536
537#-----------------------------#
538bm_final_system_Makefiles() { #
539#-----------------------------#
[afd0232]540 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system${R_arrow}"
[0170229]541
542 for file in final-system/* ; do
543 # Keep the script file name
544 this_script=`basename $file`
545
[3fcd63e]546 # Test if the stripping phase must be skipped
547 if [ "$STRIP" = "0" ] && [[ `_IS_ ${this_script} stripping` ]] ; then
548 continue
549 fi
[0170229]550
551 # First append each name of the script files to a list (this will become
552 # the names of the targets in the Makefile
553 basicsystem="$basicsystem $this_script"
554
555 # Grab the name of the target, strip id number, XXX-script
556 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
557 -e 's@temp-@@' \
558 -e 's@-64bit@@' \
559 -e 's@-64@@' \
560 -e 's@64@@' \
561 -e 's@n32@@'`
562
563 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
564
565 #--------------------------------------------------------------------#
566 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
567 #--------------------------------------------------------------------#
568 #
569 # Drop in the name of the target on a new line, and the previous target
570 # as a dependency. Also call the echo_message function.
571 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
572
573 # If $vrs isn't empty, we've got a package...
574 if [ "$vrs" != "" ] ; then
575 case $name in
[c3c4e1d]576 temp-perl) wrt_unpack3 "perl-$vrs.tar.*" ;;
577 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
[0170229]578 esac
579 fi
580 #
581 wrt_run_as_root2 "${this_script}" "${file}"
582 #
583 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
584 #
585 # Include a touch of the target name so make can check if it's already been made.
586 echo -e '\t@touch $@' >> $MKFILE.tmp
587 #
588 #--------------------------------------------------------------------#
589 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
590 #--------------------------------------------------------------------#
591 #
592 # Keep the script file name for Makefile dependencies.
593 PREV=$this_script
594
595 done # for file in final-system/* ...
596}
597
598
599#-----------------------------#
600bootscripts_Makefiles() { #
601#-----------------------------#
[afd0232]602 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts${R_arrow}"
[0170229]603
604 for file in bootscripts/* ; do
605 # Keep the script file name
606 this_script=`basename $file`
607
608 case $this_script in
609 *udev*) continue ;; # This is not a script but a commentary
610 *console*) continue ;; # Use the files that came with the bootscripts
611 *) ;;
612 esac
613
614 # First append each name of the script files to a list (this will become
615 # the names of the targets in the Makefile
616 bootscripttools="$bootscripttools $this_script"
617
618 # Grab the name of the target, strip id number, XXX-script
619 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
620 -e 's@-64bit@@' \
621 -e 's@-64@@' \
622 -e 's@64@@' \
623 -e 's@n32@@'`
[fcaf131]624 if [[ `_IS_ $name bootscripts` ]]; then name=bootscripts-cross-lfs; fi
[0170229]625
626 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
627
628 #--------------------------------------------------------------------#
629 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
630 #--------------------------------------------------------------------#
631 #
632 # Drop in the name of the target on a new line, and the previous target
633 # as a dependency. Also call the echo_message function.
634 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
635 #
636 # If $vrs isn't empty, we've got a package...
637 #
638 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
639 #
640 wrt_run_as_chroot1 "${this_script}" "${file}"
641 #
642 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
643 #
644 # Include a touch of the target name so make can check if it's already been made.
645 echo -e '\t@touch $@' >> $MKFILE.tmp
646 #
647 #--------------------------------------------------------------------#
648 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
649 #--------------------------------------------------------------------#
650 #
651 # Keep the script file name for Makefile dependencies.
652 PREV=$this_script
653
654 done # for file in bootscripts/* ...
655
656}
657
658#-----------------------------#
659bm_bootscripts_Makefiles() { #
660#-----------------------------#
[afd0232]661 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts${R_arrow}"
[0170229]662
663 for file in bootscripts/* ; do
664 # Keep the script file name
665 this_script=`basename $file`
666
667 case $this_script in
668 *udev*) continue ;; # This is not a script but a commentary
669 *console*) continue ;; # Use the files that came with the bootscripts
670 *) ;;
671 esac
672
673 # First append each name of the script files to a list (this will become
674 # the names of the targets in the Makefile
675 bootscripttools="$bootscripttools $this_script"
676
677 # Grab the name of the target, strip id number, XXX-script
678 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
679 -e 's@-64bit@@' \
680 -e 's@-64@@' \
681 -e 's@64@@' \
682 -e 's@n32@@'`
683 if [[ `_IS_ $name bootscripts` ]]; then name=lfs-bootscripts; fi
684
685 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
686
687 #--------------------------------------------------------------------#
688 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
689 #--------------------------------------------------------------------#
690 #
691 # Drop in the name of the target on a new line, and the previous target
692 # as a dependency. Also call the echo_message function.
693 echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
694 #
695 # If $vrs isn't empty, we've got a package...
696 #
[c3c4e1d]697 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
[0170229]698 #
699 wrt_run_as_root2 "${this_script}" "${file}"
700 #
701 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
702 #
703 # Include a touch of the target name so make can check if it's already been made.
704 echo -e '\t@touch $@' >> $MKFILE.tmp
705 #
706 #--------------------------------------------------------------------#
707 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
708 #--------------------------------------------------------------------#
709 #
710 # Keep the script file name for Makefile dependencies.
711 PREV=$this_script
712
713 done # for file in bootscripts/* ...
714
715}
716
717
718
719#-----------------------------#
720bootable_Makefiles() { #
721#-----------------------------#
[afd0232]722 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable${R_arrow}"
[0170229]723
724 for file in bootable/* ; do
725 # Keep the script file name
726 this_script=`basename $file`
727
728 # A little housekeeping on the scripts
729 case $this_script in
[87b93b4]730 *grub*) continue ;;
731 *kernel) # if there is no kernel config file do not build the kernel
[4845f38]732 [[ -z $CONFIG ]] && continue
[0271c0c]733 # Copy the config file to /sources with a standardized name
[1917cad]734 cp $CONFIG $BUILDDIR/sources/kernel-config
[87b93b4]735 ;;
[0170229]736 esac
737 #
738 # First append each name of the script files to a list (this will become
739 # the names of the targets in the Makefile
740 bootabletools="$bootabletools $this_script"
741 #
742 # Grab the name of the target, strip id number and misc words.
743 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
744 [[ `_IS_ $this_script "kernel"` ]] && name=linux
745
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 #
[c3c4e1d]759 [[ "$vrs" != "" ]] && wrt_unpack "$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
[b83baf6]802 *grub*) continue ;;
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
885 cross_tools_Makefiles
886 temptools_Makefiles
[afd0232]887 if [[ $METHOD = "chroot" ]]; then
[0170229]888 chroot_Makefiles
889 if [[ $TOOLCHAINTEST = "1" ]]; then
890 testsuite_tools_Makefiles
891 fi
892 final_system_Makefiles
893 bootscripts_Makefiles
894 bootable_Makefiles
895 else
896 boot_Makefiles # This phase must die at the end of its run..
897 if [[ $TOOLCHAINTEST = "1" ]]; then
898 bm_testsuite_tools_Makefiles
899 fi
900 bm_final_system_Makefiles
901 bm_bootscripts_Makefiles
902 bm_bootable_Makefiles
903 fi
904# the_end_Makefiles
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.
937(
938 cat << EOF
939all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8
940 @\$(call echo_finished,$VERSION)
941
942chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment
943
944chapter3: chapter2 $cross_tools
945
946chapter4: chapter3 $temptools
947
948chapter5: chapter4 $chroottools $boottools
949
950chapter6: chapter5 $basicsystem
951
952chapter7: chapter6 $bootscripttools
953
954chapter8: chapter7 $bootabletools
955
956clean-all: clean
957 rm -rf ./{${PROGNAME}-commands,logs,Makefile,dump-clfs-scripts.xsl,functions,packages,patches}
958
959clean: clean-chapter4 clean-chapter3 clean-chapter2
960
961clean-chapter2:
962 -if [ ! -f user-lfs-exist ]; then \\
963 userdel lfs; \\
964 rm -rf /home/lfs; \\
965 fi;
966 rm -rf \$(MOUNT_PT)/tools
967 rm -f /tools
968 rm -rf \$(MOUNT_PT)/cross-tools
969 rm -f /cross-tools
970 rm -f envars user-lfs-exist
971 rm -f 02* logs/02*.log
972
973clean-chapter3:
974 rm -rf \$(MOUNT_PT)/tools/*
975 rm -f $cross_tools restore-lfs-env sources-dir
976 cd logs && rm -f $cross_tools && cd ..
977
978clean-chapter4:
979 -umount \$(MOUNT_PT)/sys
980 -umount \$(MOUNT_PT)/proc
981 -umount \$(MOUNT_PT)/dev/shm
982 -umount \$(MOUNT_PT)/dev/pts
983 -umount \$(MOUNT_PT)/dev
984 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
985 rm -f $temptools
986 cd logs && rm -f $temptools && cd ..
987
988
989restore-lfs-env:
990 @\$(call echo_message, Building)
991 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
992 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
993 fi;
994 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
995 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
996 fi;
997 @chown lfs:lfs /home/lfs/.bash* && \\
998 touch \$@
999
1000EOF
1001) >> $MKFILE
1002
1003
1004 # Bring over the items from the Makefile.tmp
1005 cat $MKFILE.tmp >> $MKFILE
1006 rm $MKFILE.tmp
1007 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1008
1009}
1010
Note: See TracBrowser for help on using the repository browser.