source: CLFS/master.sh@ a2c9b41

1.0 2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since a2c9b41 was 06cf3c1, checked in by George Boudreau <georgeb@…>, 18 years ago

oops, bug fix related to tcl package name extraction..

  • Property mode set to 100755
File size: 41.3 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@-64@@' \
121 -e 's@-n32@@'`
122 pkg_tarball=$(get_package_tarball_name $name)
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 wrt_target "${this_script}" "$PREV"
131 #
132 # If $pkg_tarball isn't empty, we've got a package...
133 #
134 [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
135 #
136 wrt_run_as_su "${this_script}" "${file}"
137 #
138 [[ "$pkg_tarball" != "" ]] && 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 wrt_touch
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 pkg_tarball=$(get_package_tarball_name $name)
172
173 #--------------------------------------------------------------------#
174 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
175 #--------------------------------------------------------------------#
176 #
177 # Drop in the name of the target on a new line, and the previous target
178 # as a dependency. Also call the echo_message function.
179 wrt_target "${this_script}" "$PREV"
180 #
181 # If $pkg_tarball isn't empty, we've got a package...
182 # Insert instructions for unpacking the package and to set the PKGDIR variable.
183 #
184 [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
185 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
186 #
187 wrt_run_as_su "${this_script}" "${file}"
188 #
189 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
190 #
191 # Include a touch of the target name so make can check if it's already been made.
192 wrt_touch
193 #
194 #--------------------------------------------------------------------#
195 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
196 #--------------------------------------------------------------------#
197 #
198 # Keep the script file name for Makefile dependencies.
199 PREV=$this_script
200 done # for file in ....
201}
202
203
204#-----------------------------#
205boot_Makefiles() { #
206#-----------------------------#
207 echo "${tab_}${GREEN}Processing... ${L_arrow}boot${R_arrow}"
208
209 for file in boot/* ; do
210 # Keep the script file name
211 this_script=`basename $file`
212
213 # A little housekeeping on the scripts
214 case $this_script in
215 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
216 *whatnext*) continue ;;
217 *kernel) # if there is no kernel config file do not build the kernel
218 [[ -z $CONFIG ]] && continue
219 # Copy the config file to /sources with a standardized name
220 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
221 ;;
222 esac
223 #
224 # First append each name of the script files to a list (this will become
225 # the names of the targets in the Makefile
226 boottools="$boottools $this_script"
227 #
228 # Grab the name of the target, strip id number and misc words.
229 case $this_script in
230 *kernel) name=linux ;;
231 *bootscripts) name="bootscripts-cross-lfs" ;;
232 *udev-rules) name="udev-cross-lfs" ;;
233 *grub-build) name=grub ;;
234 *-aboot-build) name=aboot ;;
235 *yaboot-build) name=yaboot ;;
236 *colo-build) name=colo ;;
237 *silo-build) name=silo ;;
238 *arcload-build) name=arcload ;;
239 *lilo-build) name=lilo ;;
240 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
241 esac
242 # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
243 pkg_tarball=$(get_package_tarball_name $name)
244
245 #--------------------------------------------------------------------#
246 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
247 #--------------------------------------------------------------------#
248 #
249 # Drop in the name of the target on a new line, and the previous target
250 # as a dependency. Also call the echo_message function.
251 wrt_target "${this_script}" "$PREV"
252 #
253 # If $pkg_tarball isn't empty, we've got a package...
254 # Insert instructions for unpacking the package and changing directories
255 #
256 [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
257 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
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 [[ "$pkg_tarball" != "" ]] && 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 wrt_touch
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
311 pkg_tarball=$(get_package_tarball_name $name)
312
313 #--------------------------------------------------------------------#
314 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
315 #--------------------------------------------------------------------#
316 #
317 # Drop in the name of the target on a new line, and the previous target
318 # as a dependency. Also call the echo_message function.
319 wrt_target "${this_script}" "$PREV"
320 #
321 # If $pkg_tarball isn't empty, we've got a package...
322 # Insert instructions for unpacking the package and changing directories
323 #
324 if [ "$pkg_tarball" != "" ] ; then
325 case $this_script in
326 *util-linux) wrt_unpack "$pkg_tarball" ;;
327 *) wrt_unpack2 "$pkg_tarball" ;;
328 esac
329 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
330 fi
331 #
332 # Select a script execution method
333 case $this_script in
334 *kernfs) wrt_run_as_root "${this_script}" "${file}" ;;
335 *util-linux) wrt_run_as_su "${this_script}" "${file}" ;;
336 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
337 esac
338 #
339 # Housekeeping...remove the build directory(ies), except if the package build fails.
340 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
341 #
342 # Include a touch of the target name so make can check if it's already been made.
343 wrt_touch
344 #
345 #--------------------------------------------------------------------#
346 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
347 #--------------------------------------------------------------------#
348 #
349 # Keep the script file name for Makefile dependencies.
350 PREV=$this_script
351
352 done # for file in...
353}
354
355
356#-----------------------------#
357testsuite_tools_Makefiles() { #
358#-----------------------------#
359 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools${R_arrow}"
360
361 for file in testsuite-tools/* ; do
362 # Keep the script file name
363 this_script=`basename $file`
364
365 # First append each name of the script files to a list (this will become
366 # the names of the targets in the Makefile
367 testsuitetools="$testsuitetools $this_script"
368
369 # Grab the name of the target, strip id number, XXX-script
370 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
371 -e 's@-64bit@@' \
372 -e 's@-64@@' \
373 -e 's@64@@' \
374 -e 's@n32@@'`
375
376 pkg_tarball=$(get_package_tarball_name $name)
377
378 #--------------------------------------------------------------------#
379 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
380 #--------------------------------------------------------------------#
381 #
382 # Drop in the name of the target on a new line, and the previous target
383 # as a dependency. Also call the echo_message function.
384 wrt_target "${this_script}" "$PREV"
385 #
386 wrt_unpack2 "$pkg_tarball"
387 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
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 wrt_touch
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 pkg_tarball=$(get_package_tarball_name $name)
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.
436 wrt_target "${this_script}" "$PREV"
437 #
438 wrt_unpack3 "$pkg_tarball"
439 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
440 #
441 wrt_run_as_root2 "${this_script}" "${file}"
442 #
443 wrt_remove_build_dirs2 "${name}"
444 #
445 # Include a touch of the target name so make can check if it's already been made.
446 wrt_touch
447 #
448 #--------------------------------------------------------------------#
449 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
450 #--------------------------------------------------------------------#
451 #
452 # Keep the script file name for Makefile dependencies.
453 PREV=$this_script
454
455 done
456}
457
458
459#-----------------------------#
460final_system_Makefiles() { #
461#-----------------------------#
462 # Set envars and scripts for iteration targets
463 LOGS="" # Start with an empty global LOGS envar
464 if [[ -z "$1" ]] ; then
465 local N=""
466 else
467 local N=-build_$1
468 local basicsystem=""
469 mkdir final-system$N
470 cp final-system/* final-system$N
471 for script in final-system$N/* ; do
472 # Overwrite existing symlinks, files, and dirs
473 sed -e 's/ln -sv/&f/g' \
474 -e 's/mv -v/&f/g' \
475 -e 's/mkdir -v/&p/g' -i ${script}
476 done
477 # Remove Bzip2 binaries before make install
478 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
479 # Delete *old Readline libraries just after make install
480 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
481 fi
482
483 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N${R_arrow}"
484
485 for file in final-system$N/* ; do
486 # Keep the script file name
487 this_script=`basename $file`
488
489 # Test if the stripping phase must be skipped.
490 # Skip alsp temp-perl for iterative runs
491 case $this_script in
492 *stripping*) [[ "$STRIP" = "0" ]] && continue ;;
493 *temp-perl*) [[ -n "$N" ]] && continue ;;
494 esac
495
496 # Grab the name of the target, strip id number, XXX-script
497 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
498 -e 's@temp-@@' \
499 -e 's@-64bit@@' \
500 -e 's@-64@@' \
501 -e 's@64@@' \
502 -e 's@n32@@'`
503
504 # Find the version of the command files, if it corresponds with the building of
505 # a specific package. We need this here to can skip scripts not needed for
506 # iterations rebuilds
507 pkg_tarball=$(get_package_tarball_name $name)
508
509 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
510 case "${this_script}" in
511 *stripping*) ;;
512 *) continue ;;
513 esac
514 fi
515
516 # Append each name of the script files to a list (this will become
517 # the names of the targets in the Makefile
518 basicsystem="$basicsystem ${this_script}${N}"
519
520 # Append each name of the script files to a list (this will become
521 # the names of the logs to be moved for each iteration)
522 LOGS="$LOGS ${this_script}"
523
524 #--------------------------------------------------------------------#
525 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
526 #--------------------------------------------------------------------#
527 #
528 # Drop in the name of the target on a new line, and the previous target
529 # as a dependency. Also call the echo_message function.
530 wrt_target "${this_script}${N}" "$PREV"
531
532 # If $pkg_tarball isn't empty, we've got a package...
533 if [ "$pkg_tarball" != "" ] ; then
534 wrt_unpack2 "$pkg_tarball"
535 # If the testsuites must be run, initialize the log file
536 case $name in
537 binutils | gcc | glibc )
538 [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
539 ;;
540 * )
541 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
542 ;;
543 esac
544 # If using optimizations, write the instructions
545 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
546 fi
547 #
548 wrt_run_as_chroot1 "${this_script}" "${file}"
549 #
550 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
551 #
552 # Include a touch of the target name so make can check if it's already been made.
553 wrt_touch
554 #
555 #--------------------------------------------------------------------#
556 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
557 #--------------------------------------------------------------------#
558 #
559 # Keep the script file name for Makefile dependencies.
560 PREV=${this_script}${N}
561 # Set system_build envar for iteration targets
562 system_build=$basicsystem
563 done # for file in final-system/* ...
564}
565
566
567#-----------------------------#
568bm_final_system_Makefiles() { #
569#-----------------------------#
570 # Set envars and scripts for iteration targets
571 LOGS="" # Start with an empty global LOGS envar
572 if [[ -z "$1" ]] ; then
573 local N=""
574 # The makesys phase was initiated in bm_testsuite_tools_makefile
575 [[ "$TEST" = 0 ]] && PREV=""
576 else
577 local N=-build_$1
578 local basicsystem=""
579 mkdir final-system$N
580 cp final-system/* final-system$N
581 for script in final-system$N/* ; do
582 # Overwrite existing symlinks, files, and dirs
583 sed -e 's/ln -sv/&f/g' \
584 -e 's/mv -v/&f/g' \
585 -e 's/mkdir -v/&p/g' -i ${script}
586 done
587 # Remove Bzip2 binaries before make install
588 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
589 # Delete *old Readline libraries just after make install
590 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
591 fi
592
593 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N${R_arrow}"
594
595 for file in final-system$N/* ; do
596 # Keep the script file name
597 this_script=`basename $file`
598
599 # Test if the stripping phase must be skipped
600 # Skip alsp temp-perl for iterative runs
601 case $this_script in
602 *stripping*) [[ "$STRIP" = "0" ]] && continue ;;
603 *temp-perl*) [[ -n "$N" ]] && continue ;;
604 esac
605
606 # Grab the name of the target, strip id number, XXX-script
607 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
608 -e 's@temp-@@' \
609 -e 's@-64bit@@' \
610 -e 's@-64@@' \
611 -e 's@64@@' \
612 -e 's@n32@@'`
613
614 # Find the version of the command files, if it corresponds with the building of
615 # a specific package. We need this here to can skip scripts not needed for
616 # iterations rebuilds
617
618 pkg_tarball=$(get_package_tarball_name $name)
619
620 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
621 case "${this_script}" in
622 *stripping*) ;;
623 *) continue ;;
624 esac
625 fi
626
627 # Append each name of the script files to a list (this will become
628 # the names of the targets in the Makefile
629 basicsystem="$basicsystem ${this_script}${N}"
630
631 # Append each name of the script files to a list (this will become
632 # the names of the logs to be moved for each iteration)
633 LOGS="$LOGS ${this_script}"
634
635 #--------------------------------------------------------------------#
636 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
637 #--------------------------------------------------------------------#
638 #
639 # Drop in the name of the target on a new line, and the previous target
640 # as a dependency. Also call the echo_message function.
641 wrt_target "${this_script}${N}" "$PREV"
642
643 # If $pkg_tarball isn't empty, we've got a package...
644 if [ "$pkg_tarball" != "" ] ; then
645 FILE="$pkg_tarball"
646 wrt_unpack3 "$FILE"
647 # If the testsuites must be run, initialize the log file
648 case $name in
649 binutils | gcc | glibc )
650 [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
651 ;;
652 * )
653 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
654 ;;
655 esac
656 # If using optimizations, write the instructions
657 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
658 fi
659 #
660 wrt_run_as_root2 "${this_script}" "${file}"
661 #
662 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs2 "${name}"
663 #
664 # Include a touch of the target name so make can check if it's already been made.
665 wrt_touch
666 #
667 #--------------------------------------------------------------------#
668 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
669 #--------------------------------------------------------------------#
670 #
671 # Keep the script file name for Makefile dependencies.
672 PREV=${this_script}${N}
673 # Set system_build envar for iteration targets
674 system_build=$basicsystem
675 done # for file in final-system/* ...
676}
677
678
679#-----------------------------#
680bootscripts_Makefiles() { #
681#-----------------------------#
682 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts${R_arrow}"
683
684 for file in bootscripts/* ; do
685 # Keep the script file name
686 this_script=`basename $file`
687
688 case $this_script in
689 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
690 *console*) continue ;; # Use the files that came with the bootscripts
691 *) ;;
692 esac
693
694 # First append each name of the script files to a list (this will become
695 # the names of the targets in the Makefile
696 bootscripttools="$bootscripttools $this_script"
697
698 # Grab the name of the target, strip id number, XXX-script
699 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
700 -e 's@-64bit@@' \
701 -e 's@-64@@' \
702 -e 's@64@@' \
703 -e 's@n32@@'`
704 case $name in
705 *bootscripts*) name=bootscripts-cross-lfs ;;
706 *udev-rules) name=udev-cross-lfs ;;
707 esac
708
709 pkg_tarball=$(get_package_tarball_name $name)
710
711 #--------------------------------------------------------------------#
712 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
713 #--------------------------------------------------------------------#
714 #
715 # Drop in the name of the target on a new line, and the previous target
716 # as a dependency. Also call the echo_message function.
717 wrt_target "${this_script}" "$PREV"
718 #
719 # If $pkg_tarball isn't empty, we've got a package...
720 #
721 [[ "$pkg_tarball" != "" ]] && wrt_unpack2 "$pkg_tarball"
722 #
723 wrt_run_as_chroot1 "${this_script}" "${file}"
724 #
725 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
726 #
727 # Include a touch of the target name so make can check if it's already been made.
728 wrt_touch
729 #
730 #--------------------------------------------------------------------#
731 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
732 #--------------------------------------------------------------------#
733 #
734 # Keep the script file name for Makefile dependencies.
735 PREV=$this_script
736
737 done # for file in bootscripts/* ...
738
739}
740
741#-----------------------------#
742bm_bootscripts_Makefiles() { #
743#-----------------------------#
744 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts${R_arrow}"
745
746 for file in bootscripts/* ; do
747 # Keep the script file name
748 this_script=`basename $file`
749
750 case $this_script in
751 *udev*) continue ;; # This is not a script but a commentary
752 *console*) continue ;; # Use the files that came with the bootscripts
753 *) ;;
754 esac
755
756 # First append each name of the script files to a list (this will become
757 # the names of the targets in the Makefile
758 bootscripttools="$bootscripttools $this_script"
759
760 # Grab the name of the target, strip id number, XXX-script
761 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
762 -e 's@-64bit@@' \
763 -e 's@-64@@' \
764 -e 's@64@@' \
765 -e 's@n32@@'`
766 case $name in
767 *bootscripts*) name=bootscripts-cross-lfs
768 ;;
769 esac
770
771 pkg_tarball=$(get_package_tarball_name $name)
772
773 #--------------------------------------------------------------------#
774 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
775 #--------------------------------------------------------------------#
776 #
777 # Drop in the name of the target on a new line, and the previous target
778 # as a dependency. Also call the echo_message function.
779 wrt_target "${this_script}" "$PREV"
780 #
781 # If $pkg_tarball isn't empty, we've got a package...
782 #
783 [[ "$pkg_tarball" != "" ]] && wrt_unpack3 "$pkg_tarball"
784 #
785 wrt_run_as_root2 "${this_script}" "${file}"
786 #
787 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs2 "${name}"
788 #
789 # Include a touch of the target name so make can check if it's already been made.
790 wrt_touch
791 #
792 #--------------------------------------------------------------------#
793 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
794 #--------------------------------------------------------------------#
795 #
796 # Keep the script file name for Makefile dependencies.
797 PREV=$this_script
798
799 done # for file in bootscripts/* ...
800
801}
802
803
804
805#-----------------------------#
806bootable_Makefiles() { #
807#-----------------------------#
808 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable${R_arrow}"
809
810 for file in {bootable,the-end}/* ; do
811 # Keep the script file name
812 this_script=`basename $file`
813
814 # A little housekeeping on the scripts
815 case $this_script in
816 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
817 *kernel) # if there is no kernel config file do not build the kernel
818 [[ -z $CONFIG ]] && continue
819 # Copy the config file to /sources with a standardized name
820 cp $CONFIG $BUILDDIR/sources/kernel-config
821 ;;
822 esac
823 #
824 # First append each name of the script files to a list (this will become
825 # the names of the targets in the Makefile
826 bootabletools="$bootabletools $this_script"
827 #
828 # Grab the name of the target, strip id number and misc words.
829 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
830 case $this_script in
831 *kernel*) name=linux
832 ;;
833 esac
834
835 pkg_tarball=$(get_package_tarball_name $name)
836
837 #--------------------------------------------------------------------#
838 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
839 #--------------------------------------------------------------------#
840 #
841 # Drop in the name of the target on a new line, and the previous target
842 # as a dependency. Also call the echo_message function.
843 wrt_target "${this_script}" "$PREV"
844 #
845 # If $pkg_tarball isn't empty, we've got a package...
846 # Insert instructions for unpacking the package and changing directories
847 #
848 [[ "$pkg_tarball" != "" ]] && wrt_unpack2 "$pkg_tarball"
849 #
850 # Select a script execution method
851 case $this_script in
852 *fstab*) if [[ -n "$FSTAB" ]]; then
853 wrt_copy_fstab "${this_script}"
854 else
855 wrt_run_as_chroot1 "${this_script}" "${file}"
856 fi
857 ;;
858 *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
859 esac
860 #
861 # Housekeeping...remove any build directory(ies) except if the package build fails.
862 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
863 #
864 # Include a touch of the target name so make can check if it's already been made.
865 wrt_touch
866 #
867 #--------------------------------------------------------------------#
868 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
869 #--------------------------------------------------------------------#
870 #
871 # Keep the script file name for Makefile dependencies.
872 PREV=$this_script
873
874 done
875
876 # Add SBU-disk_usage report target if required
877 if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
878
879}
880
881
882
883#-----------------------------#
884bm_bootable_Makefiles() { #
885#-----------------------------#
886 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable${R_arrow}"
887
888 for file in {bootable,the-end}/* ; do
889 # Keep the script file name
890 this_script=`basename $file`
891
892 # A little housekeeping on the scripts
893 case $this_script in
894 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
895 *kernel) # if there is no kernel config file do not build the kernel
896 [[ -z $CONFIG ]] && continue
897 # Copy the named config file to /sources with a standardized name
898 cp $CONFIG $BUILDDIR/sources/kernel-config
899 ;;
900 esac
901 #
902 # First append each name of the script files to a list (this will become
903 # the names of the targets in the Makefile
904 bootabletools="$bootabletools $this_script"
905 #
906 # Grab the name of the target, strip id number and misc words.
907 case $this_script in
908 *kernel) name=linux ;;
909 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
910 esac
911
912 pkg_tarball=$(get_package_tarball_name $name)
913
914 #--------------------------------------------------------------------#
915 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
916 #--------------------------------------------------------------------#
917 #
918 # Drop in the name of the target on a new line, and the previous target
919 # as a dependency. Also call the echo_message function.
920 wrt_target "${this_script}" "$PREV"
921 #
922 # If $pkg_tarball isn't empty, we've got a package...
923 # Insert instructions for unpacking the package and changing directories
924 #
925 [[ "$pkg_tarball" != "" ]] && wrt_unpack3 "$pkg_tarball"
926 #
927 # Select a script execution method
928 case $this_script in
929 *fstab*) if [[ -n "$FSTAB" ]]; then
930 # Minimal boot mode has no access to original file, store in /sources
931 cp $FSTAB $BUILDDIR/sources/fstab
932 wrt_copy_fstab2 "${this_script}"
933 else
934 wrt_run_as_root2 "${this_script}" "${file}"
935 fi
936 ;;
937 *) wrt_run_as_root2 "${this_script}" "${file}" ;;
938 esac
939 #
940 # Housekeeping...remove any build directory(ies) except if the package build fails.
941 [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs2 "${name}"
942 #
943 # Include a touch of the target name so make can check if it's already been made.
944 wrt_touch
945 #
946 #--------------------------------------------------------------------#
947 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
948 #--------------------------------------------------------------------#
949 #
950 # Keep the script file name for Makefile dependencies.
951 PREV=$this_script
952
953 done
954
955 # Add SBU-disk_usage report target if required
956 if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
957
958}
959
960
961#-----------------------------#
962build_Makefile() { # Construct a Makefile from the book scripts
963#-----------------------------#
964 echo "Creating Makefile... ${BOLD}START${OFF}"
965
966 cd $JHALFSDIR/${PROGNAME}-commands
967 # Start with a clean Makefile.tmp file
968 >$MKFILE.tmp
969
970 host_prep_Makefiles
971 cross_tools_Makefiles # $cross_tools
972 temptools_Makefiles # $temptools
973 if [[ $METHOD = "chroot" ]]; then
974 chroot_Makefiles # $chroottools
975 if [[ ! $TEST = "0" ]]; then
976 testsuite_tools_Makefiles # $testsuitetools
977 fi
978 final_system_Makefiles # $basicsystem
979 # Add the iterations targets, if needed
980 [[ "$COMPARE" != "0" ]] && wrt_compare_targets
981 bootscripts_Makefiles # $bootscripttools
982 bootable_Makefiles # $bootabletools
983 else
984 boot_Makefiles # $boottools
985 if [[ ! $TEST = "0" ]]; then
986 bm_testsuite_tools_Makefiles # $testsuitetools
987 fi
988 bm_final_system_Makefiles # $basicsystem
989 # Add the iterations targets, if needed
990 [[ "$COMPARE" != "0" ]] && wrt_compare_targets
991 bm_bootscripts_Makefiles # $bootscipttools
992 bm_bootable_Makefiles # $bootabletoosl
993 fi
994# the_end_Makefiles
995
996
997 # Add a header, some variables and include the function file
998 # to the top of the real Makefile.
999(
1000 cat << EOF
1001$HEADER
1002
1003SRC= /sources
1004MOUNT_PT= $BUILDDIR
1005PKG_LST= $PKG_LST
1006
1007include makefile-functions
1008
1009EOF
1010) > $MKFILE
1011
1012 # Add chroot commands
1013 if [ "$METHOD" = "chroot" ] ; then
1014 chroot=`cat chroot/*chroot* | sed -e '/#!\/tools\/bin\/bash/d' \
1015 -e '/^export/d' \
1016 -e '/^logout/d' \
1017 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
1018 -e 's|\\$|&&|g' \
1019 -e 's|exit||g' \
1020 -e 's|$| -c|' \
1021 -e 's|"$$LFS"|$(MOUNT_PT)|'\
1022 -e 's|set -e||'`
1023 echo -e "CHROOT1= $chroot\n" >> $MKFILE
1024 fi
1025
1026 # Drop in the main target 'all:' and the chapter targets with each sub-target
1027 # as a dependency.
1028if [[ "${METHOD}" = "chroot" ]]; then
1029(
1030 cat << EOF
1031all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8 do-housekeeping
1032 @\$(call echo_finished,$VERSION)
1033
1034chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment
1035
1036chapter3: chapter2 $cross_tools
1037
1038chapter4: chapter3 $temptools
1039
1040chapter5: chapter4 $chroottools $testsuitetools
1041
1042chapter6: chapter5 $basicsystem
1043
1044chapter7: chapter6 $bootscripttools
1045
1046chapter8: chapter7 $bootabletools
1047
1048clean-all: clean
1049 rm -rf ./{clfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
1050
1051clean: clean-chapter4 clean-chapter3 clean-chapter2
1052
1053restart:
1054 @echo "This feature does not exist for the CLFS makefile. (yet)"
1055
1056clean-chapter2:
1057 -if [ ! -f user-lfs-exist ]; then \\
1058 userdel lfs; \\
1059 rm -rf /home/lfs; \\
1060 fi;
1061 rm -rf \$(MOUNT_PT)/tools
1062 rm -f /tools
1063 rm -rf \$(MOUNT_PT)/cross-tools
1064 rm -f /cross-tools
1065 rm -f envars user-lfs-exist
1066 rm -f 02* logs/02*.log
1067
1068clean-chapter3:
1069 rm -rf \$(MOUNT_PT)/tools/*
1070 rm -f $cross_tools restore-lfs-env sources-dir
1071 cd logs && rm -f $cross_tools && cd ..
1072
1073clean-chapter4:
1074 -umount \$(MOUNT_PT)/sys
1075 -umount \$(MOUNT_PT)/proc
1076 -umount \$(MOUNT_PT)/dev/shm
1077 -umount \$(MOUNT_PT)/dev/pts
1078 -umount \$(MOUNT_PT)/dev
1079 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
1080 rm -f $temptools
1081 cd logs && rm -f $temptools && cd ..
1082
1083
1084restore-lfs-env:
1085 @\$(call echo_message, Building)
1086 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
1087 mv -f /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
1088 fi;
1089 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
1090 mv /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
1091 fi;
1092 @chown lfs:lfs /home/lfs/.bash* && \\
1093 touch \$@ && \\
1094 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
1095 echo --------------------------------------------------------------------------------\$(WHITE)
1096
1097do-housekeeping:
1098 @-umount \$(MOUNT_PT)/dev/pts
1099 @-umount \$(MOUNT_PT)/dev/shm
1100 @-umount \$(MOUNT_PT)/dev
1101 @-umount \$(MOUNT_PT)/sys
1102 @-umount \$(MOUNT_PT)/proc
1103 @-if [ ! -f user-lfs-exist ]; then \\
1104 userdel lfs; \\
1105 rm -rf /home/lfs; \\
1106 fi;
1107
1108EOF
1109) >> $MKFILE
1110fi
1111
1112
1113if [[ "${METHOD}" = "boot" ]]; then
1114(
1115 cat << EOF
1116
1117all: makeboot
1118
1119makeboot: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment \
1120 $cross_tools\
1121 $temptools \
1122 $chroottools \
1123 $boottools
1124 @\$(call echo_boot_finished,$VERSION)
1125
1126makesys: $testsuitetools $basicsystem $bootscripttools $bootabletools
1127 @\$(call echo_finished,$VERSION)
1128
1129
1130clean-all: clean
1131 rm -rf ./{clfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
1132
1133clean: clean-makesys clean-makeboot clean-jhalfs
1134
1135restart:
1136 @echo "This feature does not exist for the CLFS makefile. (yet)"
1137
1138clean-jhalfs:
1139 -if [ ! -f user-lfs-exist ]; then \\
1140 userdel lfs; \\
1141 rm -rf /home/lfs; \\
1142 fi;
1143 rm -rf \$(MOUNT_PT)/tools
1144 rm -f /tools
1145 rm -rf \$(MOUNT_PT)/cross-tools
1146 rm -f /cross-tools
1147 rm -f envars user-lfs-exist
1148 rm -f 02* logs/02*.log
1149
1150clean-makeboot:
1151 rm -rf /tools/*
1152 rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools
1153 rm -f restore-lfs-env sources-dir
1154 cd logs && rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools && cd ..
1155
1156clean-makesys:
1157 -umount \$(MOUNT_PT)/sys
1158 -umount \$(MOUNT_PT)/proc
1159 -umount \$(MOUNT_PT)/dev/shm
1160 -umount \$(MOUNT_PT)/dev/pts
1161 -umount \$(MOUNT_PT)/dev
1162 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
1163 rm -f $basicsystem
1164 rm -f $bootscripttools
1165 rm -f $bootabletools
1166 cd logs && rm -f $basicsystem && rm -f $bootscripttools && rm -f $bootabletools && cd ..
1167
1168
1169restore-lfs-env:
1170 @\$(call echo_message, Building)
1171 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
1172 mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
1173 fi;
1174 @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
1175 mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
1176 fi;
1177 @chown lfs:lfs /home/lfs/.bash* && \\
1178 touch \$@ && \\
1179 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
1180 echo --------------------------------------------------------------------------------\$(WHITE)
1181
1182
1183EOF
1184) >> $MKFILE
1185fi
1186
1187 # Bring over the items from the Makefile.tmp
1188 cat $MKFILE.tmp >> $MKFILE
1189 rm $MKFILE.tmp
1190 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1191
1192}
1193
Note: See TracBrowser for help on using the repository browser.