source: CLFS/master.sh@ cbe3f2b

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

Updated experimental branch to current trunk code.

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