source: CLFS/master.sh@ a7db907

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

Extensive code changes. A different method for finding the tarball name.

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