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