source: CLFS/master.sh@ 5c575e1

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 5c575e1 was f546320, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Ported INSTALL_LOG support to all books.

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