source: CLFS/master.sh@ fc87e13

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

The ICA/farce Bzip2 fix is needed only on LFS-6.2 and CLFS-1.0.

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