source: CLFS/master.sh@ 269d81c

2.4 ablfs-more legacy new_features trunk
Last change on this file since 269d81c was 269d81c, checked in by Pierre Labastie <pierre@…>, 11 years ago

Incorporates BLFS tools to CLFS. WOrks with method=chroot. Not tested
with method=boot

  • Property mode set to 100644
File size: 38.9 KB
Line 
1#!/bin/bash
2# $Id$
3
4
5orphan_scripts="" # 2 scripts do not fit BOOT_Makefiles LUSER environment
6
7
8#--------------------------------------#
9host_prep_Makefiles() { #
10#--------------------------------------#
11 local CLFS_HOST
12
13 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
14
15 # defined here, only for ease of reading
16 CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
17(
18cat << EOF
19023-creatingtoolsdir:
20 @\$(call echo_message, Building)
21 @install -dv \$(MOUNT_PT)/tools && \\
22 rm -f /tools && \\
23 ln -s \$(MOUNT_PT)/tools /
24 @\$(call housekeeping)
25
26024-creatingcrossdir: 023-creatingtoolsdir
27 @\$(call echo_message, Building)
28 @install -dv \$(MOUNT_PT)/cross-tools && \\
29 rm -f /cross-tools && \\
30 ln -s \$(MOUNT_PT)/cross-tools /
31 @\$(call housekeeping)
32
33025-addinguser: 024-creatingcrossdir
34 @\$(call echo_message, Building)
35 @if [ ! -d \$(LUSER_HOME) ]; then \\
36 groupadd \$(LGROUP); \\
37 useradd -s /bin/bash -g \$(LGROUP) -d \$(LUSER_HOME) \$(LUSER); \\
38 mkdir -pv \$(LUSER_HOME); \\
39 chown -v \$(LUSER):\$(LGROUP) \$(LUSER_HOME); \\
40 else \\
41 touch luser-exist; \\
42 fi
43 @chown -v \$(LUSER) \$(MOUNT_PT)/tools && \\
44 chown -v \$(LUSER) \$(MOUNT_PT)/cross-tools && \\
45 chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
46 chmod a+wt \$(SRCSDIR)
47 @\$(call housekeeping)
48
49026-settingenvironment: 025-addinguser
50 @\$(call echo_message, Building)
51 @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
52 mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
53 fi
54 @if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
55 mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
56 fi;
57 @echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
58 echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
59 echo "CLFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
60 echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
61 echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
62 echo "export CLFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
63 echo "" >> \$(LUSER_HOME)/.bashrc && \\
64 echo "unset CFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
65 echo "unset CXXFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
66 echo "" >> \$(LUSER_HOME)/.bashrc && \\
67 echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> \$(LUSER_HOME)/.bashrc && \\
68 echo "export CLFS_TARGET=\"${TARGET}\"" >> \$(LUSER_HOME)/.bashrc && \\
69 echo "export CLFS_TARGET32=\"${TARGET32}\"" >> \$(LUSER_HOME)/.bashrc && \\
70 echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc
71 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
72 touch envars && \\
73 chmod -R a+wt \$(MOUNT_PT) && \\
74 chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT)
75 @\$(call housekeeping)
76EOF
77) >> $MKFILE.tmp
78 host_prep=" 023-creatingtoolsdir 024-creatingcrossdir 026-settingenvironment"
79
80}
81
82#--------------------------------------#
83cross_tools_Makefiles() { #
84#--------------------------------------#
85 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
86
87 for file in cross-tools/* ; do
88 # Keep the script file name
89 this_script=`basename $file`
90 #
91 # Skip this script...
92 case $this_script in
93 *cflags* | *variables* ) # work done in host_prep_Makefiles
94 continue; ;;
95 *) ;;
96 esac
97 #
98 # Set the dependency for the first target.
99 if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
100
101 # First append each name of the script files to a list (this will become
102 # the names of the targets in the Makefile
103 cross_tools="$cross_tools $this_script"
104
105 # Grab the name of the target (minus the -headers or -cross in the case of gcc
106 # and binutils in chapter 5)
107 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
108 -e 's@-static@@' \
109 -e 's@-final@@' \
110 -e 's@-64@@' \
111 -e 's@-n32@@'`
112 pkg_tarball=$(get_package_tarball_name $name)
113
114 #--------------------------------------------------------------------#
115 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
116 #--------------------------------------------------------------------#
117 #
118 # Drop in the name of the target on a new line, and the previous target
119 # as a dependency. Also call the echo_message function.
120 LUSER_wrt_target "${this_script}" "$PREV"
121 #
122 # If $pkg_tarball isn't empty, we've got a package...
123 #
124 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
125 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = 3 ]] && wrt_makeflags "${name}"
126 #
127 LUSER_wrt_RunAsUser "${file}"
128 #
129 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
130 #
131 # Include a touch of the target name so make can check if it's already been made.
132 wrt_touch
133 #
134 #--------------------------------------------------------------------#
135 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
136 #--------------------------------------------------------------------#
137 #
138 # Keep the script file name for Makefile dependencies.
139 PREV=$this_script
140
141 done # for file in ....
142}
143
144#--------------------------------------#
145temptools_Makefiles() { #
146#--------------------------------------#
147 echo "${tab_}${GREEN}Processing... ${L_arrow}temp system ( LUSER ) ${R_arrow}"
148
149 for file in temp-system/* ; do
150 # Keep the script file name
151 this_script=`basename $file`
152 #
153 # Deal with any odd scripts..
154 case $this_script in
155 *choose) # The choose script will fail if you cannot enter the new environment
156 # If the 'boot' build method was chosen don't run the script
157 [[ $METHOD = "boot" ]] && continue; ;;
158 *) ;;
159 esac
160
161 #
162 # First append each name of the script files to a list (this will become
163 # the names of the targets in the Makefile
164 temptools="$temptools $this_script"
165
166 #
167 # Grab the name of the target, strip id number, XXX-script
168 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
169 #
170 pkg_tarball=$(get_package_tarball_name $name)
171
172 #--------------------------------------------------------------------#
173 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
174 #--------------------------------------------------------------------#
175 #
176 # Drop in the name of the target on a new line, and the previous target
177 # as a dependency. Also call the echo_message function.
178 LUSER_wrt_target "${this_script}" "$PREV"
179 #
180 # If $pkg_tarball isn't empty, we've got a package...
181 # Insert instructions for unpacking the package and to set the PKGDIR variable.
182 #
183 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
184 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
185 #
186 LUSER_wrt_RunAsUser "${file}"
187 #
188 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
189 #
190 # Include a touch of the target name so make can check if it's already been made.
191 wrt_touch
192 #
193 #--------------------------------------------------------------------#
194 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
195 #--------------------------------------------------------------------#
196 #
197 # Keep the script file name for Makefile dependencies.
198 PREV=$this_script
199 done # for file in ....
200}
201
202
203#--------------------------------------#
204chroot_Makefiles() { #
205#--------------------------------------#
206 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools CHROOT ( CHROOT ) ${R_arrow}"
207
208 for file in chroot/* ; do
209 # Keep the script file name
210 this_script=`basename $file`
211 #
212 # Skipping scripts is done now and not included in the build tree.
213 case $this_script in
214 *chroot*) continue ;;
215 esac
216
217 #
218 # First append each name of the script files to a list (this will become
219 # the names of the targets in the Makefile
220 case "${this_script}" in
221 *kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;;
222 *) chroottools="$chroottools $this_script" ;;
223 esac
224
225 # Grab the name of the target, strip id number, XXX-script
226 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
227
228 pkg_tarball=$(get_package_tarball_name $name)
229
230 # This is very ugly:: util-linux is in /chroot but must be run under LUSER
231 # Same for e2fsprogs (in CLFS 1.1.0)
232 # .. Customized makefile entry
233 case "${this_script}" in
234 *util-linux)
235 LUSER_wrt_target "${this_script}" "$PREV"
236 LUSER_wrt_unpack "$pkg_tarball"
237 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
238 LUSER_wrt_RunAsUser "${file}"
239 LUSER_RemoveBuildDirs "${name}"
240 wrt_touch
241 temptools="$temptools $this_script"
242 continue ;;
243 *util-linux-ng)
244 LUSER_wrt_target "${this_script}" "$PREV"
245 LUSER_wrt_unpack "$pkg_tarball"
246 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
247 LUSER_wrt_RunAsUser "${file}"
248 LUSER_RemoveBuildDirs "${name}"
249 wrt_touch
250 temptools="$temptools $this_script"
251 continue ;;
252 *util-linux-libs)
253 LUSER_wrt_target "${this_script}" "$PREV"
254 LUSER_wrt_unpack "$pkg_tarball"
255 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
256 LUSER_wrt_RunAsUser "${file}"
257 LUSER_RemoveBuildDirs "${name}"
258 wrt_touch
259 temptools="$temptools $this_script"
260 continue ;;
261 *e2fsprogs)
262 LUSER_wrt_target "${this_script}" "$PREV"
263 LUSER_wrt_unpack "$pkg_tarball"
264 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
265 LUSER_wrt_RunAsUser "${file}"
266 LUSER_RemoveBuildDirs "${name}"
267 wrt_touch
268 temptools="$temptools $this_script"
269 continue ;;
270 *e2fsprogs-libs)
271 LUSER_wrt_target "${this_script}" "$PREV"
272 LUSER_wrt_unpack "$pkg_tarball"
273 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
274 LUSER_wrt_RunAsUser "${file}"
275 LUSER_RemoveBuildDirs "${name}"
276 wrt_touch
277 temptools="$temptools $this_script"
278 continue ;;
279 esac
280
281
282 #--------------------------------------------------------------------#
283 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
284 #--------------------------------------------------------------------#
285 #
286 # Drop in the name of the target on a new line, and the previous target
287 # as a dependency. Also call the echo_message function.
288 CHROOT_wrt_target "${this_script}" "$PREV"
289 #
290 # If $pkg_tarball isn't empty, we've got a package...
291 # Insert instructions for unpacking the package and changing directories
292 #
293 if [ "$pkg_tarball" != "" ] ; then
294 CHROOT_Unpack "$pkg_tarball"
295 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
296 fi
297 #
298 # Select a script execution method
299 case $this_script in
300 *kernfs) wrt_RunAsRoot "${file}" ;;
301 *) CHROOT_wrt_RunAsRoot "${file}" ;;
302 esac
303 #
304 # Housekeeping...remove the build directory(ies), except if the package build fails.
305 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
306 #
307 # Include a touch of the target name so make can check if it's already been made.
308 wrt_touch
309 #
310 #--------------------------------------------------------------------#
311 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
312 #--------------------------------------------------------------------#
313 #
314 # Keep the script file name for Makefile dependencies.
315 PREV=$this_script
316
317 done # for file in...
318}
319
320
321#--------------------------------------#
322boot_Makefiles() { #
323#--------------------------------------#
324
325 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools BOOT ( LUSER ) ${R_arrow}"
326 #
327 # Create a target bootable partition containing a compile environment. Later
328 # on we boot into this environment and contine the build.
329 #
330 for file in boot/* ; do
331 # Keep the script file name
332 this_script=`basename $file`
333
334 # A little housekeeping on the scripts
335 case $this_script in
336 *grub | *aboot | *colo | *silo | *arcload | *lilo | *introduction ) continue ;;
337 *whatnext*) continue ;;
338 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
339 *kernel) # if there is no kernel config file do not build the kernel
340 [[ -z $CONFIG ]] && continue
341 # Copy the config file to /sources with a standardized name
342 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
343 ;;
344 esac
345 #
346 # First append each name of the script files to a list (this will become
347 # the names of the targets in the Makefile
348 case "${this_script}" in
349 *changingowner) orphan_scripts="${orphan_scripts} ${this_script}" ;;
350 *devices) orphan_scripts="${orphan_scripts} ${this_script}" ;;
351 *) boottools="$boottools $this_script" ;;
352 esac
353 #
354 # Grab the name of the target, strip id number and misc words.
355 case $this_script in
356 *kernel) name=linux ;;
357 *bootscripts) name="bootscripts-cross-lfs" ;;
358 *udev-rules) name="udev-cross-lfs" ;;
359 *grub-build) name=grub ;;
360 *-aboot-build) name=aboot ;;
361 *yaboot-build) name=yaboot ;;
362 *colo-build) name=colo ;;
363 *silo-build) name=silo ;;
364 *arcload-build) name=arcload ;;
365 *lilo-build) name=lilo ;;
366 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
367 esac
368 # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
369 pkg_tarball=$(get_package_tarball_name $name)
370
371 #--------------------------------------------------------------------#
372 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
373 #--------------------------------------------------------------------#
374 #
375 # Drop in the name of the target on a new line, and the previous target
376 # as a dependency. Also call the echo_message function.
377 LUSER_wrt_target "${this_script}" "$PREV"
378 #
379 # If $pkg_tarball isn't empty, we've got a package...
380 # Insert instructions for unpacking the package and changing directories
381 #
382 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
383 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
384 #
385 # Select a script execution method
386 case $this_script in
387 # The following 2 scripts are defined in the /boot directory but need
388 # to be run as a root user. Set them up here but run them in another phase
389 *changingowner*) wrt_RunAsRoot "${file}" ;;
390 *devices*) wrt_RunAsRoot "${file}" ;;
391 *fstab*) if [[ -n "$FSTAB" ]]; then
392 LUSER_wrt_CopyFstab
393 else
394 LUSER_wrt_RunAsUser "${file}"
395 fi
396 ;;
397 *) LUSER_wrt_RunAsUser "${file}" ;;
398 esac
399 #
400 # Housekeeping...remove any build directory(ies) except if the package build fails.
401 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
402 #
403 # Include a touch of the target name so make can check if it's already been made.
404 wrt_touch
405 #
406 #--------------------------------------------------------------------#
407 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
408 #--------------------------------------------------------------------#
409 #
410 # Keep the script file name for Makefile dependencies.
411 PREV=$this_script
412
413 done
414}
415
416
417#--------------------------------------#
418testsuite_tools_Makefiles() { #
419#--------------------------------------#
420
421 if [[ "${METHOD}" = "chroot" ]]; then
422 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}"
423 else
424 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}"
425 PREV=""
426 fi
427
428 for file in testsuite-tools/* ; do
429 # Keep the script file name
430 this_script=`basename $file`
431
432 # First append each name of the script files to a list (this will become
433 # the names of the targets in the Makefile
434 testsuitetools="$testsuitetools $this_script"
435
436 # Grab the name of the target, strip id number, XXX-script
437 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
438 -e 's@-64bit@@' \
439 -e 's@-64@@' \
440 -e 's@64@@' \
441 -e 's@n32@@'`
442
443 pkg_tarball=$(get_package_tarball_name $name)
444
445 #--------------------------------------------------------------------#
446 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
447 #--------------------------------------------------------------------#
448 #
449 # Drop in the name of the target on a new line, and the previous target
450 # as a dependency. Also call the echo_message function.
451 CHROOT_wrt_target "${this_script}" "$PREV"
452 #
453 CHROOT_Unpack "$pkg_tarball"
454 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
455 #
456 CHROOT_wrt_RunAsRoot "${file}"
457 #
458 CHROOT_wrt_RemoveBuildDirs "${name}"
459 #
460 # Include a touch of the target name so make can check if it's already been made.
461 wrt_touch
462 #
463 #--------------------------------------------------------------------#
464 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
465 #--------------------------------------------------------------------#
466 #
467 # Keep the script file name for Makefile dependencies.
468 PREV=$this_script
469
470 done
471}
472
473
474#--------------------------------------#
475final_system_Makefiles() { #
476#--------------------------------------#
477 # Set envars and scripts for iteration targets
478 if [[ -z "$1" ]] ; then
479 local N=""
480 # In boot method the makesys phase was initiated in testsuite_tools_makefile
481 [[ "${METHOD}" = "boot" ]] && [[ "$TEST" = 0 ]] && PREV=""
482 else
483 local N=-build_$1
484 local basicsystem=""
485 mkdir final-system$N
486 cp final-system/* final-system$N
487 for script in final-system$N/* ; do
488 # Overwrite existing symlinks, files, and dirs
489 sed -e 's/ln -sv/&f/g' \
490 -e 's/mv -v/&f/g' \
491 -e 's/mkdir -v/&p/g' -i ${script}
492 # Rename the scripts
493 mv ${script} ${script}$N
494 done
495 # Remove Bzip2 binaries before make install (CLFS-1.0 compatibility)
496 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2$N
497 # Delete *old Readline libraries just after make install
498 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline$N
499 fi
500
501 if [[ "${METHOD}" = "chroot" ]]; then
502 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}"
503 else
504 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}"
505 fi
506
507 for file in final-system$N/* ; do
508 # Keep the script file name
509 this_script=`basename $file`
510
511 # Test if the stripping phase must be skipped.
512 # Skip alsp temp-perl for iterative runs
513 case $this_script in
514 *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
515 *temp-perl*) [[ -n "$N" ]] && continue ;;
516 esac
517
518 # Grab the name of the target, strip id number, XXX-script
519 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
520 -e 's@temp-@@' \
521 -e 's@-64bit@@' \
522 -e 's@-64@@' \
523 -e 's@64@@' \
524 -e 's@n32@@' \
525 -e 's,'$N',,'`
526
527 # Find the version of the command files, if it corresponds with the building of
528 # a specific package. We need this here to can skip scripts not needed for
529 # iterations rebuilds
530 pkg_tarball=$(get_package_tarball_name $name)
531
532 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
533 case "${this_script}" in
534 *stripping*) ;;
535 *) continue ;;
536 esac
537 fi
538
539 # Append each name of the script files to a list (this will become
540 # the names of the targets in the Makefile
541 basicsystem="$basicsystem ${this_script}"
542
543 #--------------------------------------------------------------------#
544 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
545 #--------------------------------------------------------------------#
546 #
547 # Drop in the name of the target on a new line, and the previous target
548 # as a dependency. Also call the echo_message function.
549 CHROOT_wrt_target "${this_script}" "$PREV"
550
551 # If $pkg_tarball isn't empty, we've got a package...
552 if [ "$pkg_tarball" != "" ] ; then
553 # Touch timestamp file if installed files logs will be created.
554 # But only for the firt build when running iterative builds.
555 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
556 CHROOT_wrt_TouchTimestamp
557 fi
558 CHROOT_Unpack "$pkg_tarball"
559 # If the testsuites must be run, initialize the log file
560 case $name in
561 binutils | gcc | glibc | eglibc | gmp | mpfr | mpc | isl | cloog )
562 [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
563 ;;
564 * )
565 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
566 ;;
567 esac
568 # If using optimizations, write the instructions
569 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
570 fi
571 #
572 CHROOT_wrt_RunAsRoot "${file}"
573 #
574 # Write installed files log and remove the build directory(ies)
575 # except if the package build fails.
576 if [ "$pkg_tarball" != "" ] ; then
577 CHROOT_wrt_RemoveBuildDirs "$name"
578 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
579 CHROOT_wrt_LogNewFiles "$name"
580 fi
581 fi
582 #
583 # Include a touch of the target name so make can check
584 # if it's already been made.
585 wrt_touch
586 #
587 #--------------------------------------------------------------------#
588 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
589 #--------------------------------------------------------------------#
590 #
591 # Keep the script file name for Makefile dependencies.
592 PREV=${this_script}
593 # Set system_build envar for iteration targets
594 system_build=$basicsystem
595 done # for file in final-system/* ...
596}
597
598#--------------------------------------#
599bootscripts_Makefiles() { #
600#--------------------------------------#
601
602 if [[ "${METHOD}" = "chroot" ]]; then
603 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts ( CHROOT ) ${R_arrow}"
604 else
605 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts ( ROOT ) ${R_arrow}"
606 fi
607
608 for file in bootscripts/* ; do
609 # Keep the script file name
610 this_script=`basename $file`
611
612 case $this_script in
613 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
614 *console*) continue ;; # Use the files that came with the bootscripts
615 *) ;;
616 esac
617
618 # First append each name of the script files to a list (this will become
619 # the names of the targets in the Makefile
620 bootscripttools="$bootscripttools $this_script"
621
622 # Grab the name of the target, strip id number, XXX-script
623 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
624 -e 's@-64bit@@' \
625 -e 's@-64@@' \
626 -e 's@64@@' \
627 -e 's@n32@@'`
628 case $name in
629 *bootscripts*) name=bootscripts-cross-lfs ;;
630 *udev-rules) name=udev-cross-lfs ;;
631 esac
632
633 pkg_tarball=$(get_package_tarball_name $name)
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 CHROOT_wrt_target "${this_script}" "$PREV"
642 #
643 # If $pkg_tarball isn't empty, we've got a package...
644 #
645 if [ "$pkg_tarball" != "" ] ; then
646 if [ "${INSTALL_LOG}" = "y" ] ; then
647 CHROOT_wrt_LogNewFiles "$name"
648 fi
649 CHROOT_Unpack "$pkg_tarball"
650 fi
651 #
652 CHROOT_wrt_RunAsRoot "${file}"
653 #
654 # Write installed files log and remove the build directory(ies)
655 # except if the package build fails.
656 if [ "$pkg_tarball" != "" ] ; then
657 CHROOT_wrt_RemoveBuildDirs "$name"
658 if [ "${INSTALL_LOG}" = "y" ] ; then
659 CHROOT_wrt_LogNewFiles "$name"
660 fi
661 fi
662 #
663 # Include a touch of the target name so make can check if it's already been made.
664 wrt_touch
665 #
666 #--------------------------------------------------------------------#
667 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
668 #--------------------------------------------------------------------#
669 #
670 # Keep the script file name for Makefile dependencies.
671 PREV=$this_script
672
673 done # for file in bootscripts/* ...
674}
675
676#--------------------------------------#
677network_Makefiles() { #
678#--------------------------------------#
679
680 if [[ "${METHOD}" = "chroot" ]]; then
681 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) network ( CHROOT ) ${R_arrow}"
682 else
683 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) network ( ROOT ) ${R_arrow}"
684 fi
685
686 for file in network/* ; do
687 # Keep the script file name
688 this_script=`basename $file`
689
690 case $this_script in
691 *choose) continue ;; # This is not a script but a commentary.
692 *dhcp) continue ;; # Assume static networking.
693 *dhcpcd) continue ;; # Assume static networking.
694 *) ;;
695 esac
696
697 # First append each name of the script files to a list (this will become
698 # the names of the targets in the Makefile
699 networktools="$networktools $this_script"
700
701 # Grab the name of the target, strip id number, XXX-script
702 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
703 -e 's@-64bit@@' \
704 -e 's@-64@@' \
705 -e 's@64@@' \
706 -e 's@n32@@'`
707 case $name in
708 *network*) name=network-cross-lfs ;;
709 esac
710
711 pkg_tarball=$(get_package_tarball_name $name)
712
713 #--------------------------------------------------------------------#
714 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
715 #--------------------------------------------------------------------#
716 #
717 # Drop in the name of the target on a new line, and the previous target
718 # as a dependency. Also call the echo_message function.
719 CHROOT_wrt_target "${this_script}" "$PREV"
720 #
721 # If $pkg_tarball isn't empty, we've got a package...
722 #
723 if [ "$pkg_tarball" != "" ] ; then
724 if [ "${INSTALL_LOG}" = "y" ] ; then
725 CHROOT_wrt_LogNewFiles "$name"
726 fi
727 CHROOT_Unpack "$pkg_tarball"
728 fi
729 #
730 CHROOT_wrt_RunAsRoot "${file}"
731 #
732 # Write installed files log and remove the build directory(ies)
733 # except if the package build fails.
734 if [ "$pkg_tarball" != "" ] ; then
735 CHROOT_wrt_RemoveBuildDirs "$name"
736 if [ "${INSTALL_LOG}" = "y" ] ; then
737 CHROOT_wrt_LogNewFiles "$name"
738 fi
739 fi
740 #
741 # Include a touch of the target name so make can check if it's already been made.
742 wrt_touch
743 #
744 #--------------------------------------------------------------------#
745 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
746 #--------------------------------------------------------------------#
747 #
748 # Keep the script file name for Makefile dependencies.
749 PREV=$this_script
750
751 done # for file in network/* ...
752}
753
754#--------------------------------------#
755bootable_Makefiles() { #
756#--------------------------------------#
757
758 if [[ "${METHOD}" = "chroot" ]]; then
759 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
760 else
761 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
762 fi
763
764
765 for file in bootable/* ; do
766 # Keep the script file name
767 this_script=`basename $file`
768
769 # A little housekeeping on the scripts
770 case $this_script in
771 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
772 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
773 *kernel) # if there is no kernel config file do not build the kernel
774 [[ -z $CONFIG ]] && continue
775 # Copy the config file to /sources with a standardized name
776 cp $CONFIG $BUILDDIR/sources/kernel-config
777 ;;
778 esac
779 #
780 # First append each name of the script files to a list (this will become
781 # the names of the targets in the Makefile
782 bootabletools="$bootabletools $this_script"
783 #
784 # Grab the name of the target, strip id number and misc words.
785 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
786 case $this_script in
787 *kernel*) name=linux
788 ;;
789 esac
790
791 pkg_tarball=$(get_package_tarball_name $name)
792
793 #--------------------------------------------------------------------#
794 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
795 #--------------------------------------------------------------------#
796 #
797 # Drop in the name of the target on a new line, and the previous target
798 # as a dependency. Also call the echo_message function.
799 CHROOT_wrt_target "${this_script}" "$PREV"
800 #
801 # If $pkg_tarball isn't empty, we've got a package...
802 # Insert instructions for unpacking the package and changing directories
803 #
804 if [ "$pkg_tarball" != "" ] ; then
805 if [ "${INSTALL_LOG}" = "y" ] ; then
806 CHROOT_wrt_LogNewFiles "$name"
807 fi
808 CHROOT_Unpack "$pkg_tarball"
809 fi
810 #
811 # Select a script execution method
812 case $this_script in
813 *fstab*) if [[ -n "$FSTAB" ]]; then
814 CHROOT_wrt_CopyFstab
815 else
816 CHROOT_wrt_RunAsRoot "${file}"
817 fi
818 ;;
819 *) CHROOT_wrt_RunAsRoot "${file}"
820 ;;
821 esac
822 #
823 # Write installed files log and remove the build directory(ies)
824 # except if the package build fails.
825 if [ "$pkg_tarball" != "" ] ; then
826 CHROOT_wrt_RemoveBuildDirs "$name"
827 if [ "${INSTALL_LOG}" = "y" ] ; then
828 CHROOT_wrt_LogNewFiles "$name"
829 fi
830 fi
831 #
832 # Include a touch of the target name so make can check if it's already been made.
833 wrt_touch
834 #
835 #--------------------------------------------------------------------#
836 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
837 #--------------------------------------------------------------------#
838 #
839 # Keep the script file name for Makefile dependencies.
840 PREV=$this_script
841
842 done
843
844}
845
846
847#--------------------------------------#
848build_Makefile() { # Construct a Makefile from the book scripts
849#--------------------------------------#
850
851 echo "...Creating Makefile... ${BOLD}START${OFF}"
852
853 cd $JHALFSDIR/${PROGNAME}-commands
854 # Start with clean files
855 >$MKFILE
856 >$MKFILE.tmp
857
858 method_cmds=${METHOD}_Makefiles
859
860 host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
861 cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
862 temptools_Makefiles # mk_TEMP (LUSER) $temptools
863 $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
864 if [[ ! $TEST = "0" ]]; then
865 testsuite_tools_Makefiles # mk_SYSTOOLS (CHROOT) $testsuitetools
866 fi
867 final_system_Makefiles # mk_FINAL (CHROOT) $basicsystem
868 # Add the iterations targets, if needed
869 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
870 bootscripts_Makefiles # mk_BOOTSCRIPT (CHROOT) $bootscripttools
871 if [ -d network ]; then
872 network_Makefiles # If present, process network setup.
873 fi
874 bootable_Makefiles # mk_BOOTABLE (CHROOT) $bootabletools
875
876 # Add the CUSTOM_TOOLS targets, if needed
877 [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
878
879 # Add a header, some variables and include the function file
880 # to the top of the real Makefile.
881 wrt_Makefile_header
882
883 # Add chroot commands
884 if [ "$METHOD" = "chroot" ] ; then
885 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
886 chroot=`cat chroot/???-chroot | \
887 sed -e "s@chroot@$CHROOT_LOC@" \
888 -e '/#!\/bin\/bash/d' \
889 -e '/^export/d' \
890 -e '/^logout/d' \
891 -e 's@ \\\@ @g' | \
892 tr -d '\n' | \
893 sed -e 's/ */ /g' \
894 -e 's|\\$|&&|g' \
895 -e 's|exit||g' \
896 -e 's|$| -c|' \
897 -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
898 -e 's|set -e||' \
899 -e 's|set +h||'`
900 echo -e "CHROOT1= $chroot\n" >> $MKFILE
901 fi
902
903################## CHROOT ####################
904
905if [[ "${METHOD}" = "chroot" ]]; then
906(
907cat << EOF
908
909all: ck_UID mk_SETUP mk_CROSS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
910 @sudo make do-housekeeping
911 @echo "$VERSION - jhalfs build" > clfs-release && \\
912 sudo mv clfs-release \$(MOUNT_PT)/etc && \\
913 sudo chown root:root \$(MOUNT_PT)/etc/clfs-release
914 @\$(call echo_finished,$VERSION)
915
916ck_UID:
917 @if [ \`id -u\` = "0" ]; then \\
918 echo "+--------------------------------------------------+"; \\
919 echo "|You cannot run this makefile from the root account|"; \\
920 echo "+--------------------------------------------------+"; \\
921 exit 1; \\
922 fi
923
924#---------------AS ROOT
925mk_SETUP:
926 @\$(call echo_SU_request)
927 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
928 @touch \$@
929
930#---------------AS LUSER
931mk_CROSS: mk_SETUP
932 @\$(call echo_PHASE,Cross and Temporary Tools)
933 @( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
934 @sudo make restore-luser-env
935 @touch \$@
936
937mk_SUDO: mk_CROSS
938 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
939 @touch \$@
940
941#---------------CHROOT JAIL
942mk_SYSTOOLS: mk_SUDO
943 @\$(call echo_CHROOT_request)
944 @\$(call echo_PHASE, CHROOT JAIL )
945 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) PREP_CHROOT_JAIL")
946 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT_JAIL")
947 @touch \$@
948
949mk_BLFS_TOOL: create-sbu_du-report
950 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
951 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
952 (sudo \$(CHROOT1) "make -C $BLFS_ROOT/work"); \\
953 fi;
954 @touch \$@
955
956mk_CUSTOM_TOOLS: mk_BLFS_TOOL
957 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
958 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
959 sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
960 (sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
961 fi;
962 @touch \$@
963
964SETUP: $host_prep
965AS_LUSER: $cross_tools $temptools
966SUDO: $orphan_scripts
967PREP_CHROOT_JAIL: SHELL=/tools/bin/bash
968PREP_CHROOT_JAIL: ${chroottools}
969CHROOT_JAIL: SHELL=/tools/bin/bash
970CHROOT_JAIL: $testsuitetools $basicsystem $bootscripttools $bootabletools
971CUSTOM_TOOLS: $custom_list
972
973
974create-sbu_du-report: mk_SYSTOOLS
975 @\$(call echo_message, Building)
976 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
977 ./create-sbu_du-report.sh logs $VERSION; \\
978 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
979 fi;
980 @touch \$@
981
982do-housekeeping:
983 @-umount \$(MOUNT_PT)/dev/pts
984 @-if [ -h \$(MOUNT_PT)/dev/shm ]; then \\
985 link=\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
986 umount \$(MOUNT_PT)/\$\$link; \\
987 unset link; \\
988 else \\
989 umount \$(MOUNT_PT)/dev/shm; \\
990 fi
991 @-umount \$(MOUNT_PT)/dev
992 @-umount \$(MOUNT_PT)/sys
993 @-umount \$(MOUNT_PT)/proc
994 @-rm /tools /cross-tools
995 @-if [ ! -f luser-exist ]; then \\
996 userdel \$(LUSER); \\
997 rm -rf \$(LUSER_HOME); \\
998 fi;
999
1000EOF
1001) >> $MKFILE
1002
1003fi
1004
1005################### BOOT #####################
1006
1007if [[ "${METHOD}" = "boot" ]]; then
1008(
1009cat << EOF
1010
1011all: ck_UID mk_SETUP mk_CROSS mk_SUDO
1012 @sudo make restore-luser-env
1013 @sudo make do-housekeeping
1014 @\$(call echo_boot_finished,$VERSION)
1015
1016makesys: mk_FINAL mk_CUSTOM_TOOLS mk_BLFS_TOOL
1017 @echo "$VERSION - jhalfs build" > /etc/clfs-release
1018 @\$(call echo_finished,$VERSION)
1019
1020
1021ck_UID:
1022 @if [ \`id -u\` = "0" ]; then \\
1023 echo "+--------------------------------------------------+"; \\
1024 echo "|You cannot run this makefile from the root account|"; \\
1025 echo "|However, if this is the boot environment |"; \\
1026 echo "| the command you are looking for is |"; \\
1027 echo "| make makesys |"; \\
1028 echo "| to complete the build |"; \\
1029 echo "+--------------------------------------------------+"; \\
1030 exit 1; \\
1031 fi
1032
1033#---------------AS ROOT
1034
1035mk_SETUP:
1036 @\$(call echo_SU_request)
1037 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
1038 @touch \$@
1039
1040#---------------AS LUSER
1041
1042mk_CROSS: mk_SETUP
1043 @\$(call echo_PHASE,Cross Tool)
1044 @( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
1045 @touch \$@
1046
1047mk_SUDO: mk_CROSS
1048 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
1049 @touch \$@
1050
1051#---------------AS ROOT
1052
1053mk_FINAL:
1054 @\$(call echo_PHASE,Final System)
1055 @( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) AS_ROOT )
1056 @touch \$@
1057
1058mk_BLFS_TOOL: mk_FINAL
1059 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
1060 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
1061 ( make -C $BLFS_ROOT/work ); \\
1062 fi;
1063 @touch \$@
1064
1065mk_CUSTOM_TOOLS: mk_BLFS_TOOL
1066 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
1067 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
1068 mkdir -p ${TRACKING_DIR}; \\
1069 ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS ); \\
1070 fi;
1071 @touch \$@
1072
1073SETUP: $host_prep
1074AS_LUSER: $cross_tools $temptools ${boottools}
1075SUDO: $orphan_scripts
1076AS_ROOT: SHELL=/tools/bin/bash
1077AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
1078CUSTOM_TOOLS: $custom_list
1079
1080do-housekeeping:
1081 @-rm /tools /cross-tools
1082 @-if [ ! -f luser-exist ]; then \\
1083 userdel \$(LUSER); \\
1084 rm -rf \$(LUSER_HOME); \\
1085 fi;
1086
1087EOF
1088) >> $MKFILE
1089fi
1090
1091(
1092 cat << EOF
1093
1094restore-luser-env:
1095 @\$(call echo_message, Building)
1096 @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
1097 mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
1098 fi;
1099 @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
1100 mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
1101 fi;
1102 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
1103 touch \$@ && \\
1104 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
1105 echo --------------------------------------------------------------------------------\$(WHITE)
1106
1107########################################################
1108
1109
1110EOF
1111) >> $MKFILE
1112
1113 # Bring over the items from the Makefile.tmp
1114 cat $MKFILE.tmp >> $MKFILE
1115 rm $MKFILE.tmp
1116
1117 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1118}
Note: See TracBrowser for help on using the repository browser.