source: CLFS/master.sh@ 89fc40c

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

Fixed unpack of Tree package.

  • Property mode set to 100755
File size: 42.7 KB
Line 
1#!/bin/sh
2# $Id$
3
4###################################
5### FUNCTIONS ###
6###################################
7
8
9
10#----------------------------#
11host_prep_Makefiles() { # Initialization of the system
12#----------------------------#
13 local LFS_HOST
14
15 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files${R_arrow}"
16
17 # defined here, only for ease of reading
18 LFS_HOST="`echo ${MACHTYPE} | sed -e 's/unknown/cross/g' -e 's/-pc-/-cross-/g'`"
19(
20cat << EOF
21023-creatingtoolsdir:
22 @\$(call echo_message, Building)
23 @mkdir \$(MOUNT_PT)/tools && \\
24 rm -f /tools && \\
25 ln -s \$(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 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
32 echo --------------------------------------------------------------------------------\$(WHITE)
33
34024-creatingcrossdir: 023-creatingtoolsdir
35 @mkdir -v \$(MOUNT_PT)/cross-tools && \\
36 rm -f /cross-tools && \\
37 ln -s \$(MOUNT_PT)/cross-tools /
38 @touch \$@ && \\
39 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
40 echo --------------------------------------------------------------------------------\$(WHITE)
41
42025-addinguser: 024-creatingcrossdir
43 @\$(call echo_message, Building)
44 @if [ ! -d /home/lfs ]; then \\
45 groupadd lfs; \\
46 useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
47 else \\
48 touch user-lfs-exist; \\
49 fi;
50 @chown lfs \$(MOUNT_PT) && \\
51 chown lfs \$(MOUNT_PT)/tools && \\
52 chown lfs \$(MOUNT_PT)/cross-tools && \\
53 chown lfs \$(MOUNT_PT)/sources && \\
54 touch \$@ && \\
55 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
56 echo --------------------------------------------------------------------------------\$(WHITE)
57
58026-settingenvironment: 025-addinguser
59 @\$(call echo_message, Building)
60 @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
61 mv /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
62 fi;
63 @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
64 mv /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
65 fi;
66 @echo "set +h" > /home/lfs/.bashrc && \\
67 echo "umask 022" >> /home/lfs/.bashrc && \\
68 echo "LFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
69 echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
70 echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
71 echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
72 echo "" >> /home/lfs/.bashrc && \\
73 echo "unset CFLAGS" >> /home/lfs/.bashrc && \\
74 echo "unset CXXFLAGS" >> /home/lfs/.bashrc && \\
75 echo "" >> /home/lfs/.bashrc && \\
76 echo "export LFS_HOST=\"${LFS_HOST}\"" >> /home/lfs/.bashrc && \\
77 echo "export LFS_TARGET=\"${TARGET}\"" >> /home/lfs/.bashrc && \\
78 echo "export LFS_TARGET32=\"${TARGET32}\"" >> /home/lfs/.bashrc && \\
79 echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc
80 @chown lfs:lfs /home/lfs/.bashrc && \\
81 touch envars && \\
82 touch \$@ && \\
83 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
84 echo --------------------------------------------------------------------------------\$(WHITE)
85EOF
86) >> $MKFILE.tmp
87
88}
89
90
91
92#-----------------------------#
93cross_tools_Makefiles() { #
94#-----------------------------#
95 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools${R_arrow}"
96
97 for file in cross-tools/* ; do
98 # Keep the script file name
99 this_script=`basename $file`
100 #
101 # Skip this script...
102 case $this_script in
103 *cflags* | *variables* ) # work done in host_prep_Makefiles
104 continue; ;;
105 *) ;;
106 esac
107 #
108 # Set the dependency for the first target.
109 if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
110
111 # First append each name of the script files to a list (this will become
112 # the names of the targets in the Makefile
113 cross_tools="$cross_tools $this_script"
114
115 # Grab the name of the target (minus the -headers or -cross in the case of gcc
116 # and binutils in chapter 5)
117 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
118 -e 's@-static@@' \
119 -e 's@-final@@' \
120 -e 's@-headers@@' \
121 -e 's@-64@@' \
122 -e 's@-n32@@'`
123 # Adjust 'name' and patch a few scripts on the fly..
124 case $name in
125 linux-libc) name=linux-libc-headers ;;
126 linux) name=linux-headers ;;
127 esac
128 #
129 # Find the version of the command files, if it corresponds with the building of a specific package
130
131 # oh-oh.. This small ugly is necessary to handle the LFS headers naming scheme
132 if [ "${name}" = "linux-headers" ]; then
133 linux_vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
134 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
135 vrs=${linux_vrs}-${vrs##*-}
136 else
137 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
138 fi
139 #--------------------------------------------------------------------#
140 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
141 #--------------------------------------------------------------------#
142 #
143 # Drop in the name of the target on a new line, and the previous target
144 # as a dependency. Also call the echo_message function.
145 wrt_target "${this_script}" "$PREV"
146 #
147 # If $vrs isn't empty, we've got a package...
148 #
149 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
150 #
151 wrt_run_as_su "${this_script}" "${file}"
152 #
153 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
154 #
155 # Include a touch of the target name so make can check if it's already been made.
156 wrt_touch
157 #
158 #--------------------------------------------------------------------#
159 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
160 #--------------------------------------------------------------------#
161 #
162 # Keep the script file name for Makefile dependencies.
163 PREV=$this_script
164
165 done # for file in ....
166}
167
168
169#-----------------------------#
170temptools_Makefiles() { #
171#-----------------------------#
172 echo "${tab_}${GREEN}Processing... ${L_arrow}temp system${R_arrow}"
173
174 for file in temp-system/* ; do
175 # Keep the script file name
176 this_script=`basename $file`
177 #
178 # First append each name of the script files to a list (this will become
179 # the names of the targets in the Makefile
180 temptools="$temptools $this_script"
181
182 #
183 # Grab the name of the target, strip id number, XXX-script
184 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
185 #
186 # Find the version of the command files, if it corresponds with the building of a specific package
187 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
188
189
190 #--------------------------------------------------------------------#
191 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
192 #--------------------------------------------------------------------#
193 #
194 # Drop in the name of the target on a new line, and the previous target
195 # as a dependency. Also call the echo_message function.
196 wrt_target "${this_script}" "$PREV"
197 #
198 # If $vrs isn't empty, we've got a package...
199 # Insert instructions for unpacking the package and to set the PKGDIR variable.
200 #
201 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
202 [[ "$vrs" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
203 #
204 wrt_run_as_su "${this_script}" "${file}"
205 #
206 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
207 #
208 # Include a touch of the target name so make can check if it's already been made.
209 wrt_touch
210 #
211 #--------------------------------------------------------------------#
212 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
213 #--------------------------------------------------------------------#
214 #
215 # Keep the script file name for Makefile dependencies.
216 PREV=$this_script
217 done # for file in ....
218}
219
220
221#-----------------------------#
222boot_Makefiles() { #
223#-----------------------------#
224 echo "${tab_}${GREEN}Processing... ${L_arrow}boot${R_arrow}"
225
226 for file in boot/* ; do
227 # Keep the script file name
228 this_script=`basename $file`
229
230 # A little housekeeping on the scripts
231 case $this_script in
232 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
233 *whatnext*) continue ;;
234 *kernel) # if there is no kernel config file do not build the kernel
235 [[ -z $CONFIG ]] && continue
236 # Copy the config file to /sources with a standardized name
237 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
238 ;;
239 esac
240 #
241 # First append each name of the script files to a list (this will become
242 # the names of the targets in the Makefile
243 boottools="$boottools $this_script"
244 #
245 # Grab the name of the target, strip id number and misc words.
246 case $this_script in
247 *kernel) name=linux ;;
248 *bootscripts) name="bootscripts-cross-lfs" ;;
249 *udev-rules) name="udev-cross-lfs" ;;
250 *grub-build) name=grub ;;
251 *-aboot-build) name=aboot ;;
252 *yaboot-build) name=yaboot ;;
253 *colo-build) name=colo ;;
254 *silo-build) name=silo ;;
255 *arcload-build) name=arcload ;;
256 *lilo-build) name=lilo ;;
257 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
258 esac
259
260 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
261
262 #--------------------------------------------------------------------#
263 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
264 #--------------------------------------------------------------------#
265 #
266 # Drop in the name of the target on a new line, and the previous target
267 # as a dependency. Also call the echo_message function.
268 wrt_target "${this_script}" "$PREV"
269 #
270 # If $vrs isn't empty, we've got a package...
271 # Insert instructions for unpacking the package and changing directories
272 #
273 [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar.*"
274 [[ "$vrs" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
275 #
276 # Select a script execution method
277 case $this_script in
278 *changingowner*) wrt_run_as_root "${this_script}" "${file}" ;;
279 *devices*) wrt_run_as_root "${this_script}" "${file}" ;;
280 *fstab*) if [[ -n "$FSTAB" ]]; then
281 wrt_copy_fstab "${this_script}"
282 else
283 wrt_run_as_su "${this_script}" "${file}"
284 fi
285 ;;
286 *) wrt_run_as_su "${this_script}" "${file}" ;;
287 esac
288 #
289 # Housekeeping...remove any build directory(ies) except if the package build fails.
290 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
291 #
292 # Include a touch of the target name so make can check if it's already been made.
293 wrt_touch
294 #
295 #--------------------------------------------------------------------#
296 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
297 #--------------------------------------------------------------------#
298 #
299 # Keep the script file name for Makefile dependencies.
300 PREV=$this_script
301
302 done
303}
304
305
306#-----------------------------#
307chroot_Makefiles() { #
308#-----------------------------#
309 echo "${tab_}${GREEN}Processing... ${L_arrow}chroot${R_arrow}"
310
311 for file in chroot/* ; do
312 # Keep the script file name
313 this_script=`basename $file`
314 #
315 # Skipping scripts is done now and not included in the build tree.
316 case $this_script in
317 *chroot*) continue ;;
318 esac
319
320 #
321 # First append each name of the script files to a list (this will become
322 # the names of the targets in the Makefile
323 chroottools="$chroottools $this_script"
324
325 # Grab the name of the target, strip id number, XXX-script
326 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
327 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
328
329 #--------------------------------------------------------------------#
330 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
331 #--------------------------------------------------------------------#
332 #
333 # Drop in the name of the target on a new line, and the previous target
334 # as a dependency. Also call the echo_message function.
335 wrt_target "${this_script}" "$PREV"
336 #
337 # If $vrs isn't empty, we've got a package...
338 # Insert instructions for unpacking the package and changing directories
339 #
340 if [ "$vrs" != "" ] ; then
341 case $this_script in
342 *util-linux) wrt_unpack "$name-$vrs.tar.*" ;;
343 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
344 esac
345 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
346 fi
347 #
348 # Select a script execution method
349 case $this_script in
350 *kernfs) wrt_run_as_root "${this_script}" "${file}" ;;
351 *util-linux) wrt_run_as_su "${this_script}" "${file}" ;;
352 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
353 esac
354 #
355 # Housekeeping...remove the build directory(ies), except if the package build fails.
356 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
357 #
358 # Include a touch of the target name so make can check if it's already been made.
359 wrt_touch
360 #
361 #--------------------------------------------------------------------#
362 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
363 #--------------------------------------------------------------------#
364 #
365 # Keep the script file name for Makefile dependencies.
366 PREV=$this_script
367
368 done # for file in...
369}
370
371
372#-----------------------------#
373testsuite_tools_Makefiles() { #
374#-----------------------------#
375 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools${R_arrow}"
376
377 for file in testsuite-tools/* ; do
378 # Keep the script file name
379 this_script=`basename $file`
380
381 # First append each name of the script files to a list (this will become
382 # the names of the targets in the Makefile
383 testsuitetools="$testsuitetools $this_script"
384
385 # Grab the name of the target, strip id number, XXX-script
386 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
387 -e 's@-64bit@@' \
388 -e 's@-64@@' \
389 -e 's@64@@' \
390 -e 's@n32@@'`
391
392 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
393
394 #--------------------------------------------------------------------#
395 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
396 #--------------------------------------------------------------------#
397 #
398 # Drop in the name of the target on a new line, and the previous target
399 # as a dependency. Also call the echo_message function.
400 wrt_target "${this_script}" "$PREV"
401 #
402 case $name in
403 tcl) wrt_unpack2 "$name$vrs-src.tar.*" ;;
404 tree) wrt_unpack2 "$name-$vrs.tgz" ;;
405 *) wrt_unpack2 "$name-$vrs.tar.*" ;;
406 esac
407 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
408 #
409 wrt_run_as_chroot1 "${this_script}" "${file}"
410 #
411 wrt_remove_build_dirs "${name}"
412 #
413 # Include a touch of the target name so make can check if it's already been made.
414 wrt_touch
415 #
416 #--------------------------------------------------------------------#
417 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
418 #--------------------------------------------------------------------#
419 #
420 # Keep the script file name for Makefile dependencies.
421 PREV=$this_script
422
423 done
424}
425
426
427#--------------------------------#
428bm_testsuite_tools_Makefiles() { #
429#--------------------------------#
430 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools${R_arrow}"
431
432 for file in testsuite-tools/* ; do
433 # Keep the script file name
434 this_script=`basename $file`
435
436 # First append each name of the script files to a list (this will become
437 # the names of the targets in the Makefile
438 PREV=
439 testsuitetools="$testsuitetools $this_script"
440
441 # Grab the name of the target, strip id number, XXX-script
442 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
443 -e 's@-64bit@@' \
444 -e 's@-64@@' \
445 -e 's@64@@' \
446 -e 's@n32@@'`
447
448 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
449
450 #--------------------------------------------------------------------#
451 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
452 #--------------------------------------------------------------------#
453 #
454 # Drop in the name of the target on a new line, and the previous target
455 # as a dependency. Also call the echo_message function.
456 wrt_target "${this_script}" "$PREV"
457 #
458 case $name in
459 tcl) wrt_unpack3 "$name$vrs-src.tar.*" ;;
460 tree) wrt_unpack3 "$name-$vrs.tgz" ;;
461 *) wrt_unpack3 "$name-$vrs.tar.*" ;;
462 esac
463 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
464 #
465 wrt_run_as_root2 "${this_script}" "${file}"
466 #
467 wrt_remove_build_dirs2 "${name}"
468 #
469 # Include a touch of the target name so make can check if it's already been made.
470 wrt_touch
471 #
472 #--------------------------------------------------------------------#
473 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
474 #--------------------------------------------------------------------#
475 #
476 # Keep the script file name for Makefile dependencies.
477 PREV=$this_script
478
479 done
480}
481
482
483#-----------------------------#
484final_system_Makefiles() { #
485#-----------------------------#
486 # Set envars and scripts for iteration targets
487 LOGS="" # Start with an empty global LOGS envar
488 if [[ -z "$1" ]] ; then
489 local N=""
490 else
491 local N=-build_$1
492 local basicsystem=""
493 mkdir final-system$N
494 cp final-system/* final-system$N
495 for script in final-system$N/* ; do
496 # Overwrite existing symlinks, files, and dirs
497 sed -e 's/ln -sv/&f/g' \
498 -e 's/mv -v/&f/g' \
499 -e 's/mkdir -v/&p/g' -i ${script}
500 done
501 # Remove Bzip2 binaries before make install
502 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
503 # Delete *old Readline libraries just after make install
504 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
505 fi
506
507 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N${R_arrow}"
508
509 for file in final-system$N/* ; do
510 # Keep the script file name
511 this_script=`basename $file`
512
513 # Test if the stripping phase must be skipped.
514 # Skip alsp temp-perl for iterative runs
515 case $this_script in
516 *stripping*) [[ "$STRIP" = "0" ]] && continue ;;
517 *temp-perl*) [[ -n "$N" ]] && continue ;;
518 esac
519
520 # Grab the name of the target, strip id number, XXX-script
521 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
522 -e 's@temp-@@' \
523 -e 's@-64bit@@' \
524 -e 's@-64@@' \
525 -e 's@64@@' \
526 -e 's@n32@@'`
527
528 # Find the version of the command files, if it corresponds with the building of
529 # a specific package. We need this here to can skip scripts not needed for
530 # iterations rebuilds
531
532 # oh-oh.. This small ugly is necessary to handle the LFS headers naming scheme
533 if [ "${name}" = "linux-headers" ]; then
534 linux_vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
535 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
536 vrs=${linux_vrs}-${vrs##*-}
537 else
538 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
539 fi
540
541 if [[ "$vrs" = "" ]] && [[ -n "$N" ]] ; then
542 case "${this_script}" in
543 *stripping*) ;;
544 *) continue ;;
545 esac
546 fi
547
548 # Append each name of the script files to a list (this will become
549 # the names of the targets in the Makefile
550 basicsystem="$basicsystem ${this_script}${N}"
551
552 # Append each name of the script files to a list (this will become
553 # the names of the logs to be moved for each iteration)
554 LOGS="$LOGS ${this_script}"
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.
562 wrt_target "${this_script}${N}" "$PREV"
563
564 # If $vrs isn't empty, we've got a package...
565 if [ "$vrs" != "" ] ; then
566 FILE="$name-$vrs.tar.*"
567 wrt_unpack2 "$FILE"
568 # If the testsuites must be run, initialize the log file
569 case $name in
570 binutils | gcc | glibc )
571 [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
572 ;;
573 * )
574 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
575 ;;
576 esac
577 # If using optimizations, write the instructions
578 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
579 fi
580 #
581 wrt_run_as_chroot1 "${this_script}" "${file}"
582 #
583 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
584 #
585 # Include a touch of the target name so make can check if it's already been made.
586 wrt_touch
587 #
588 #--------------------------------------------------------------------#
589 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
590 #--------------------------------------------------------------------#
591 #
592 # Keep the script file name for Makefile dependencies.
593 PREV=${this_script}${N}
594 # Set system_build envar for iteration targets
595 system_build=$basicsystem
596 done # for file in final-system/* ...
597}
598
599
600#-----------------------------#
601bm_final_system_Makefiles() { #
602#-----------------------------#
603 # Set envars and scripts for iteration targets
604 LOGS="" # Start with an empty global LOGS envar
605 if [[ -z "$1" ]] ; then
606 local N=""
607 # The makesys phase was initiated in bm_testsuite_tools_makefile
608 [[ "$TEST" = 0 ]] && PREV=""
609 else
610 local N=-build_$1
611 local basicsystem=""
612 mkdir final-system$N
613 cp final-system/* final-system$N
614 for script in final-system$N/* ; do
615 # Overwrite existing symlinks, files, and dirs
616 sed -e 's/ln -sv/&f/g' \
617 -e 's/mv -v/&f/g' \
618 -e 's/mkdir -v/&p/g' -i ${script}
619 done
620 # Remove Bzip2 binaries before make install
621 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
622 # Delete *old Readline libraries just after make install
623 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
624 fi
625
626 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N${R_arrow}"
627
628 for file in final-system$N/* ; do
629 # Keep the script file name
630 this_script=`basename $file`
631
632 # Test if the stripping phase must be skipped
633 # Skip alsp temp-perl for iterative runs
634 case $this_script in
635 *stripping*) [[ "$STRIP" = "0" ]] && continue ;;
636 *temp-perl*) [[ -n "$N" ]] && continue ;;
637 esac
638
639 # Grab the name of the target, strip id number, XXX-script
640 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
641 -e 's@temp-@@' \
642 -e 's@-64bit@@' \
643 -e 's@-64@@' \
644 -e 's@64@@' \
645 -e 's@n32@@'`
646
647 # Find the version of the command files, if it corresponds with the building of
648 # a specific package. We need this here to can skip scripts not needed for
649 # iterations rebuilds
650 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
651
652 if [[ "$vrs" = "" ]] && [[ -n "$N" ]] ; then
653 case "${this_script}" in
654 *stripping*) ;;
655 *) continue ;;
656 esac
657 fi
658
659 # Append each name of the script files to a list (this will become
660 # the names of the targets in the Makefile
661 basicsystem="$basicsystem ${this_script}${N}"
662
663 # Append each name of the script files to a list (this will become
664 # the names of the logs to be moved for each iteration)
665 LOGS="$LOGS ${this_script}"
666
667 #--------------------------------------------------------------------#
668 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
669 #--------------------------------------------------------------------#
670 #
671 # Drop in the name of the target on a new line, and the previous target
672 # as a dependency. Also call the echo_message function.
673 wrt_target "${this_script}${N}" "$PREV"
674
675 # If $vrs isn't empty, we've got a package...
676 if [ "$vrs" != "" ] ; then
677 FILE="$name-$vrs.tar.*"
678 wrt_unpack3 "$FILE"
679 # If the testsuites must be run, initialize the log file
680 case $name in
681 binutils | gcc | glibc )
682 [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
683 ;;
684 * )
685 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
686 ;;
687 esac
688 # If using optimizations, write the instructions
689 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
690 fi
691 #
692 wrt_run_as_root2 "${this_script}" "${file}"
693 #
694 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
695 #
696 # Include a touch of the target name so make can check if it's already been made.
697 wrt_touch
698 #
699 #--------------------------------------------------------------------#
700 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
701 #--------------------------------------------------------------------#
702 #
703 # Keep the script file name for Makefile dependencies.
704 PREV=${this_script}${N}
705 # Set system_build envar for iteration targets
706 system_build=$basicsystem
707 done # for file in final-system/* ...
708}
709
710
711#-----------------------------#
712bootscripts_Makefiles() { #
713#-----------------------------#
714 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts${R_arrow}"
715
716 for file in bootscripts/* ; do
717 # Keep the script file name
718 this_script=`basename $file`
719
720 case $this_script in
721 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
722 *console*) continue ;; # Use the files that came with the bootscripts
723 *) ;;
724 esac
725
726 # First append each name of the script files to a list (this will become
727 # the names of the targets in the Makefile
728 bootscripttools="$bootscripttools $this_script"
729
730 # Grab the name of the target, strip id number, XXX-script
731 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
732 -e 's@-64bit@@' \
733 -e 's@-64@@' \
734 -e 's@64@@' \
735 -e 's@n32@@'`
736 case $name in
737 *bootscripts*) name=bootscripts-cross-lfs ;;
738 *udev-rules) name=udev-cross-lfs ;;
739 esac
740 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
741
742 #--------------------------------------------------------------------#
743 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
744 #--------------------------------------------------------------------#
745 #
746 # Drop in the name of the target on a new line, and the previous target
747 # as a dependency. Also call the echo_message function.
748 wrt_target "${this_script}" "$PREV"
749 #
750 # If $vrs isn't empty, we've got a package...
751 #
752 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
753 #
754 wrt_run_as_chroot1 "${this_script}" "${file}"
755 #
756 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
757 #
758 # Include a touch of the target name so make can check if it's already been made.
759 wrt_touch
760 #
761 #--------------------------------------------------------------------#
762 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
763 #--------------------------------------------------------------------#
764 #
765 # Keep the script file name for Makefile dependencies.
766 PREV=$this_script
767
768 done # for file in bootscripts/* ...
769
770}
771
772#-----------------------------#
773bm_bootscripts_Makefiles() { #
774#-----------------------------#
775 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts${R_arrow}"
776
777 for file in bootscripts/* ; do
778 # Keep the script file name
779 this_script=`basename $file`
780
781 case $this_script in
782 *udev*) continue ;; # This is not a script but a commentary
783 *console*) continue ;; # Use the files that came with the bootscripts
784 *) ;;
785 esac
786
787 # First append each name of the script files to a list (this will become
788 # the names of the targets in the Makefile
789 bootscripttools="$bootscripttools $this_script"
790
791 # Grab the name of the target, strip id number, XXX-script
792 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
793 -e 's@-64bit@@' \
794 -e 's@-64@@' \
795 -e 's@64@@' \
796 -e 's@n32@@'`
797 case $name in
798 *bootscripts*) name=bootscripts-cross-lfs
799 ;;
800 esac
801 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
802
803 #--------------------------------------------------------------------#
804 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
805 #--------------------------------------------------------------------#
806 #
807 # Drop in the name of the target on a new line, and the previous target
808 # as a dependency. Also call the echo_message function.
809 wrt_target "${this_script}" "$PREV"
810 #
811 # If $vrs isn't empty, we've got a package...
812 #
813 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
814 #
815 wrt_run_as_root2 "${this_script}" "${file}"
816 #
817 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
818 #
819 # Include a touch of the target name so make can check if it's already been made.
820 wrt_touch
821 #
822 #--------------------------------------------------------------------#
823 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
824 #--------------------------------------------------------------------#
825 #
826 # Keep the script file name for Makefile dependencies.
827 PREV=$this_script
828
829 done # for file in bootscripts/* ...
830
831}
832
833
834
835#-----------------------------#
836bootable_Makefiles() { #
837#-----------------------------#
838 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable${R_arrow}"
839
840 for file in {bootable,the-end}/* ; do
841 # Keep the script file name
842 this_script=`basename $file`
843
844 # A little housekeeping on the scripts
845 case $this_script in
846 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
847 *kernel) # if there is no kernel config file do not build the kernel
848 [[ -z $CONFIG ]] && continue
849 # Copy the config file to /sources with a standardized name
850 cp $CONFIG $BUILDDIR/sources/kernel-config
851 ;;
852 esac
853 #
854 # First append each name of the script files to a list (this will become
855 # the names of the targets in the Makefile
856 bootabletools="$bootabletools $this_script"
857 #
858 # Grab the name of the target, strip id number and misc words.
859 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
860 case $this_script in
861 *kernel*) name=linux
862 ;;
863 esac
864 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
865
866 #--------------------------------------------------------------------#
867 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
868 #--------------------------------------------------------------------#
869 #
870 # Drop in the name of the target on a new line, and the previous target
871 # as a dependency. Also call the echo_message function.
872 wrt_target "${this_script}" "$PREV"
873 #
874 # If $vrs isn't empty, we've got a package...
875 # Insert instructions for unpacking the package and changing directories
876 #
877 [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
878 #
879 # Select a script execution method
880 case $this_script in
881 *fstab*) if [[ -n "$FSTAB" ]]; then
882 wrt_copy_fstab "${this_script}"
883 else
884 wrt_run_as_chroot1 "${this_script}" "${file}"
885 fi
886 ;;
887 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
888 esac
889 #
890 # Housekeeping...remove any build directory(ies) except if the package build fails.
891 [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
892 #
893 # Include a touch of the target name so make can check if it's already been made.
894 wrt_touch
895 #
896 #--------------------------------------------------------------------#
897 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
898 #--------------------------------------------------------------------#
899 #
900 # Keep the script file name for Makefile dependencies.
901 PREV=$this_script
902
903 done
904
905 # Add SBU-disk_usage report target if required
906 if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
907
908}
909
910
911
912#-----------------------------#
913bm_bootable_Makefiles() { #
914#-----------------------------#
915 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable${R_arrow}"
916
917 for file in {bootable,the-end}/* ; do
918 # Keep the script file name
919 this_script=`basename $file`
920
921 # A little housekeeping on the scripts
922 case $this_script in
923 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
924 *kernel) # if there is no kernel config file do not build the kernel
925 [[ -z $CONFIG ]] && continue
926 # Copy the named config file to /sources with a standardized name
927 cp $CONFIG $BUILDDIR/sources/kernel-config
928 ;;
929 esac
930 #
931 # First append each name of the script files to a list (this will become
932 # the names of the targets in the Makefile
933 bootabletools="$bootabletools $this_script"
934 #
935 # Grab the name of the target, strip id number and misc words.
936 case $this_script in
937 *kernel) name=linux
938 ;;
939 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
940 esac
941
942 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
943
944 #--------------------------------------------------------------------#
945 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
946 #--------------------------------------------------------------------#
947 #
948 # Drop in the name of the target on a new line, and the previous target
949 # as a dependency. Also call the echo_message function.
950 wrt_target "${this_script}" "$PREV"
951 #
952 # If $vrs isn't empty, we've got a package...
953 # Insert instructions for unpacking the package and changing directories
954 #
955 [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
956 #
957 # Select a script execution method
958 case $this_script in
959 *fstab*) if [[ -n "$FSTAB" ]]; then
960 # Minimal boot mode has no access to original file, store in /sources
961 cp $FSTAB $BUILDDIR/sources/fstab
962 wrt_copy_fstab2 "${this_script}"
963 else
964 wrt_run_as_root2 "${this_script}" "${file}"
965 fi
966 ;;
967 *) wrt_run_as_root2 "${this_script}" "${file}" ;;
968 esac
969 #
970 # Housekeeping...remove any build directory(ies) except if the package build fails.
971 [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
972 #
973 # Include a touch of the target name so make can check if it's already been made.
974 wrt_touch
975 #
976 #--------------------------------------------------------------------#
977 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
978 #--------------------------------------------------------------------#
979 #
980 # Keep the script file name for Makefile dependencies.
981 PREV=$this_script
982
983 done
984
985 # Add SBU-disk_usage report target if required
986 if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
987
988}
989
990
991#-----------------------------#
992build_Makefile() { # Construct a Makefile from the book scripts
993#-----------------------------#
994 echo "Creating Makefile... ${BOLD}START${OFF}"
995
996 cd $JHALFSDIR/${PROGNAME}-commands
997 # Start with a clean Makefile.tmp file
998 >$MKFILE.tmp
999
1000 host_prep_Makefiles
1001 cross_tools_Makefiles # $cross_tools
1002 temptools_Makefiles # $temptools
1003 if [[ $METHOD = "chroot" ]]; then
1004 chroot_Makefiles # $chroottools
1005 if [[ ! $TEST = "0" ]]; then
1006 testsuite_tools_Makefiles # $testsuitetools
1007 fi
1008 final_system_Makefiles # $basicsystem
1009 # Add the iterations targets, if needed
1010 [[ "$COMPARE" != "0" ]] && wrt_compare_targets
1011 bootscripts_Makefiles # $bootscripttools
1012 bootable_Makefiles # $bootabletools
1013 else
1014 boot_Makefiles # $boottools
1015 if [[ ! $TEST = "0" ]]; then
1016 bm_testsuite_tools_Makefiles # $testsuitetools
1017 fi
1018 bm_final_system_Makefiles # $basicsystem
1019 # Add the iterations targets, if needed
1020 [[ "$COMPARE" != "0" ]] && wrt_compare_targets
1021 bm_bootscripts_Makefiles # $bootscipttools
1022 bm_bootable_Makefiles # $bootabletoosl
1023 fi
1024# the_end_Makefiles
1025
1026
1027 # Add a header, some variables and include the function file
1028 # to the top of the real Makefile.
1029(
1030 cat << EOF
1031$HEADER
1032
1033SRC= /sources
1034MOUNT_PT= $BUILDDIR
1035PKG_LST= $PKG_LST
1036
1037include makefile-functions
1038
1039EOF
1040) > $MKFILE
1041
1042 # Add chroot commands
1043 if [ "$METHOD" = "chroot" ] ; then
1044 chroot=`cat chroot/*chroot* | sed -e '/#!\/tools\/bin\/bash/d' \
1045 -e '/^export/d' \
1046 -e '/^logout/d' \
1047 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
1048 -e 's|\\$|&&|g' \
1049 -e 's|exit||g' \
1050 -e 's|$| -c|' \
1051 -e 's|"$$LFS"|$(MOUNT_PT)|'\
1052 -e 's|set -e||'`
1053 echo -e "CHROOT1= $chroot\n" >> $MKFILE
1054 fi
1055
1056 # Drop in the main target 'all:' and the chapter targets with each sub-target
1057 # as a dependency.
1058if [[ "${METHOD}" = "chroot" ]]; then
1059(
1060 cat << EOF
1061all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8 do-housekeeping
1062 @\$(call echo_finished,$VERSION)
1063
1064chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment
1065
1066chapter3: chapter2 $cross_tools
1067
1068chapter4: chapter3 $temptools
1069
1070chapter5: chapter4 $chroottools $testsuitetools
1071
1072chapter6: chapter5 $basicsystem
1073
1074chapter7: chapter6 $bootscripttools
1075
1076chapter8: chapter7 $bootabletools
1077
1078clean-all: clean
1079 rm -rf ./{clfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
1080
1081clean: clean-chapter4 clean-chapter3 clean-chapter2
1082
1083clean-chapter2:
1084 -if [ ! -f user-lfs-exist ]; then \\
1085 userdel lfs; \\
1086 rm -rf /home/lfs; \\
1087 fi;
1088 rm -rf \$(MOUNT_PT)/tools
1089 rm -f /tools
1090 rm -rf \$(MOUNT_PT)/cross-tools
1091 rm -f /cross-tools
1092 rm -f envars user-lfs-exist
1093 rm -f 02* logs/02*.log
1094
1095clean-chapter3:
1096 rm -rf \$(MOUNT_PT)/tools/*
1097 rm -f $cross_tools restore-lfs-env sources-dir
1098 cd logs && rm -f $cross_tools && cd ..
1099
1100clean-chapter4:
1101 -umount \$(MOUNT_PT)/sys
1102 -umount \$(MOUNT_PT)/proc
1103 -umount \$(MOUNT_PT)/dev/shm
1104 -umount \$(MOUNT_PT)/dev/pts
1105 -umount \$(MOUNT_PT)/dev
1106 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
1107 rm -f $temptools
1108 cd logs && rm -f $temptools && cd ..
1109
1110
1111restore-lfs-env:
1112 @\$(call echo_message, Building)
1113 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
1114 mv -f /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
1115 fi;
1116 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
1117 mv /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
1118 fi;
1119 @chown lfs:lfs /home/lfs/.bash* && \\
1120 touch \$@ && \\
1121 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
1122 echo --------------------------------------------------------------------------------\$(WHITE)
1123
1124do-housekeeping:
1125 @-umount \$(MOUNT_PT)/dev/pts
1126 @-umount \$(MOUNT_PT)/dev/shm
1127 @-umount \$(MOUNT_PT)/dev
1128 @-umount \$(MOUNT_PT)/sys
1129 @-umount \$(MOUNT_PT)/proc
1130 @-if [ ! -f user-lfs-exist ]; then \\
1131 userdel lfs; \\
1132 rm -rf /home/lfs; \\
1133 fi;
1134
1135EOF
1136) >> $MKFILE
1137fi
1138
1139
1140if [[ "${METHOD}" = "boot" ]]; then
1141(
1142 cat << EOF
1143
1144all: makeboot
1145
1146makeboot: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment \
1147 $cross_tools\
1148 $temptools \
1149 $chroottools \
1150 $boottools
1151 @\$(call echo_boot_finished,$VERSION)
1152
1153makesys: $testsuitetools $basicsystem $bootscripttools $bootabletools
1154 @\$(call echo_finished,$VERSION)
1155
1156
1157clean-all: clean
1158 rm -rf ./{clfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
1159
1160clean: clean-makesys clean-makeboot clean-jhalfs
1161
1162clean-jhalfs:
1163 -if [ ! -f user-lfs-exist ]; then \\
1164 userdel lfs; \\
1165 rm -rf /home/lfs; \\
1166 fi;
1167 rm -rf \$(MOUNT_PT)/tools
1168 rm -f /tools
1169 rm -rf \$(MOUNT_PT)/cross-tools
1170 rm -f /cross-tools
1171 rm -f envars user-lfs-exist
1172 rm -f 02* logs/02*.log
1173
1174clean-makeboot:
1175 rm -rf /tools/*
1176 rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools
1177 rm -f restore-lfs-env sources-dir
1178 cd logs && rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools && cd ..
1179
1180clean-makesys:
1181 -umount \$(MOUNT_PT)/sys
1182 -umount \$(MOUNT_PT)/proc
1183 -umount \$(MOUNT_PT)/dev/shm
1184 -umount \$(MOUNT_PT)/dev/pts
1185 -umount \$(MOUNT_PT)/dev
1186 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
1187 rm -f $basicsystem
1188 rm -f $bootscripttools
1189 rm -f $bootabletools
1190 cd logs && rm -f $basicsystem && rm -f $bootscripttools && rm -f $bootabletools && cd ..
1191
1192
1193restore-lfs-env:
1194 @\$(call echo_message, Building)
1195 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
1196 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
1197 fi;
1198 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
1199 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
1200 fi;
1201 @chown lfs:lfs /home/lfs/.bash* && \\
1202 touch \$@ && \\
1203 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
1204 echo --------------------------------------------------------------------------------\$(WHITE)
1205
1206
1207EOF
1208) >> $MKFILE
1209fi
1210
1211 # Bring over the items from the Makefile.tmp
1212 cat $MKFILE.tmp >> $MKFILE
1213 rm $MKFILE.tmp
1214 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1215
1216}
1217
Note: See TracBrowser for help on using the repository browser.