1 | #!/bin/sh
|
---|
2 |
|
---|
3 | ###################################
|
---|
4 | ### FUNCTIONS ###
|
---|
5 | ###################################
|
---|
6 |
|
---|
7 | unset extract_commands
|
---|
8 | #----------------------------#
|
---|
9 | extract_commands() { #
|
---|
10 | #----------------------------#
|
---|
11 |
|
---|
12 | #Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
---|
13 | test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
---|
14 | exit 1"
|
---|
15 |
|
---|
16 | cd $JHALFSDIR
|
---|
17 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
18 |
|
---|
19 | # Start clean
|
---|
20 | if [ -d ${PROGNAME}-commands ]; then
|
---|
21 | rm -rf ${PROGNAME}-commands
|
---|
22 | else
|
---|
23 | mkdir -v ${PROGNAME}-commands
|
---|
24 | fi
|
---|
25 | echo "Extracting commands... ${BOLD}START${OFF}"
|
---|
26 |
|
---|
27 | echo "${tab_}Extracting commands for ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
|
---|
28 | xsltproc --xinclude \
|
---|
29 | --nonet \
|
---|
30 | --output ./${PROGNAME}-commands/ \
|
---|
31 | $BOOK/stylesheets/dump-commands.xsl $BOOK/$ARCH-index.xml
|
---|
32 |
|
---|
33 | # Grab the patches and package names.
|
---|
34 | cd $JHALFSDIR
|
---|
35 |
|
---|
36 | echo "${tab_}Creating the packages and patches files" ;
|
---|
37 | for i in patches packages ; do rm -f $i ; done
|
---|
38 |
|
---|
39 | grep "\-version " $BOOK/packages.ent | sed -e 's@<!ENTITY @@' \
|
---|
40 | -e 's@">@"@' \
|
---|
41 | -e '/generic/d' >> packages
|
---|
42 |
|
---|
43 | # Download the vim-lang package if it must be installed
|
---|
44 | if [ "$VIMLANG" = "1" ] ; then
|
---|
45 | echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
|
---|
46 | fi
|
---|
47 |
|
---|
48 | grep "^<\!ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
|
---|
49 | # Needed for Groff patchlevel patch
|
---|
50 | GROFFLEVEL=`grep "groff-patchlevel" $BOOK/general.ent | sed -e 's/groff-patchlevel //' \
|
---|
51 | -e 's/"//g' \
|
---|
52 | -e 's@<!ENTITY @@' \
|
---|
53 | -e 's|>||'`
|
---|
54 | sed -i 's|&groff-patchlevel;|'$GROFFLEVEL'|' patches
|
---|
55 |
|
---|
56 |
|
---|
57 | # Preprocess the cmd scripts..
|
---|
58 | echo "${tab_}Preprocessing the cmd scripts"
|
---|
59 | #
|
---|
60 | local file this_script package vrs URLs
|
---|
61 | #
|
---|
62 | # Create a list of URLs..
|
---|
63 | echo "${tab_}${tab_}Writing a list of URLs to filelist_.wget "
|
---|
64 | xsltproc --nonet \
|
---|
65 | --xinclude \
|
---|
66 | -o filelist_.wget \
|
---|
67 | $BOOK/stylesheets/wget.xsl \
|
---|
68 | $BOOK/$ARCH-index.xml > /dev/null 2>&1
|
---|
69 | #
|
---|
70 | # Loop through all the command scripts
|
---|
71 | echo "${tab_}${tab_}Modifying the cmd scripts"
|
---|
72 | for file in `ls ${PROGNAME}-commands/*/*`;do
|
---|
73 | #
|
---|
74 | # 1. Compress the script file (remove blank lines)
|
---|
75 | # 2. Add a variable header and a footer to selected scripts
|
---|
76 | this_script=`basename $file`
|
---|
77 | #
|
---|
78 | # DO NOT play with the chroot scripts.. they are used as is later
|
---|
79 | [[ `_IS_ $this_script "chroot"` ]] && continue
|
---|
80 | #
|
---|
81 | # Strip leading index number and misc test.. This is a miserable method
|
---|
82 | package=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
83 | -e 's@-static@@' \
|
---|
84 | -e 's@-final@@' \
|
---|
85 | -e 's@temp-@@' \
|
---|
86 | -e 's@-64bit@@' \
|
---|
87 | -e 's@-64@@' \
|
---|
88 | -e 's@64@@' \
|
---|
89 | -e 's@-n32@@' \
|
---|
90 | -e 's@-build@@' \
|
---|
91 | -e 's@glibc-headers@glibc@'`
|
---|
92 | #
|
---|
93 | # Find the package version of the command files
|
---|
94 | #
|
---|
95 | # A little package name manipulation
|
---|
96 | case $package in
|
---|
97 | bootscripts) package="lfs-bootscripts" ;;
|
---|
98 | kernel) package="linux" ;;
|
---|
99 | esac
|
---|
100 | vrs=`grep "^$package-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
101 | #
|
---|
102 | # If $vrs isn't empty, we've got a package...
|
---|
103 | # NOTE: The included \n causes the separator to be written
|
---|
104 | # on the next line. This is for cosmetic purposes only...
|
---|
105 | #
|
---|
106 | # Set the appropriate 'sha-bang'.. depending of the phase..
|
---|
107 | case $package in
|
---|
108 | *introduction* | \
|
---|
109 | *changingowner* | \
|
---|
110 | *creatingdirs* | \
|
---|
111 | *createfiles* ) sha_bang=''
|
---|
112 | ;;
|
---|
113 | *) sha_bang='#!/bin/bash'
|
---|
114 | ;;
|
---|
115 | esac
|
---|
116 | #
|
---|
117 | #
|
---|
118 | if [ "$vrs" != "" ] ; then
|
---|
119 | HEADER_STR="cd \$PKGDIR${nl_}#------------------"
|
---|
120 | FOOTER_STR="#------------------${nl_}exit"
|
---|
121 | else
|
---|
122 | HEADER_STR="#------------------"
|
---|
123 | FOOTER_STR="#------------------${nl_}exit"
|
---|
124 | fi
|
---|
125 | PKG_URL=`grep -e "$package-$vrs.*tar." $JHALFSDIR/filelist_.wget` && true
|
---|
126 | PATCHES=`grep "$package-$vrs.*patch" $JHALFSDIR/filelist_.wget` && true
|
---|
127 | #
|
---|
128 | # There would be no URL for a cmd only script, reset package name
|
---|
129 | if [[ $PKG_URL = "" ]]; then
|
---|
130 | package=""
|
---|
131 | fi
|
---|
132 | (
|
---|
133 | cat << EOF
|
---|
134 | ${sha_bang}
|
---|
135 | set -e
|
---|
136 |
|
---|
137 | #####################################
|
---|
138 | NAME=${this_script}
|
---|
139 | PACKAGE=${package}
|
---|
140 | VERSION=${vrs}
|
---|
141 | PKG_URL=( ${PKG_URL} )
|
---|
142 | PATCHES=( ${PATCHES} )
|
---|
143 | #####################################
|
---|
144 |
|
---|
145 | ${HEADER_STR}
|
---|
146 | `grep '.' ${file}`
|
---|
147 | ${FOOTER_STR}
|
---|
148 | EOF
|
---|
149 | ) > tmp.script
|
---|
150 | mv tmp.script ${file}
|
---|
151 |
|
---|
152 | done # for file in `ls $PROGNAME-commands/*/*`
|
---|
153 | #
|
---|
154 | # Make the scripts executable.
|
---|
155 | chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
---|
156 |
|
---|
157 | # Done. Moving on...
|
---|
158 | echo "Extracting commands... ${BOLD}DONE${OFF}"
|
---|
159 | get_sources
|
---|
160 |
|
---|
161 | }
|
---|
162 |
|
---|
163 |
|
---|
164 |
|
---|
165 | #----------------------------#
|
---|
166 | host_prep_Makefiles() { # Initialization of the system
|
---|
167 | #----------------------------#
|
---|
168 | local LFS_HOST
|
---|
169 |
|
---|
170 | echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files${R_arrow}"
|
---|
171 |
|
---|
172 | # defined here, only for ease of reading
|
---|
173 | LFS_HOST="`echo ${MACHTYPE} | sed -e 's/unknown/cross/g' -e 's/-pc-/-cross-/g'`"
|
---|
174 | (
|
---|
175 | cat << EOF
|
---|
176 | 023-creatingtoolsdir:
|
---|
177 | @\$(call echo_message, Building)
|
---|
178 | @mkdir -v \$(MOUNT_PT)/tools && \\
|
---|
179 | rm -fv /tools && \\
|
---|
180 | ln -sv \$(MOUNT_PT)/tools /
|
---|
181 | @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
|
---|
182 | mkdir \$(MOUNT_PT)/sources; \\
|
---|
183 | fi;
|
---|
184 | @chmod a+wt \$(MOUNT_PT)/sources && \\
|
---|
185 | touch \$@
|
---|
186 |
|
---|
187 | 024-creatingcrossdir: 023-creatingtoolsdir
|
---|
188 | @mkdir -v \$(MOUNT_PT)/cross-tools && \\
|
---|
189 | rm -fv /cross-tools && \\
|
---|
190 | ln -sv \$(MOUNT_PT)/cross-tools /
|
---|
191 | @touch \$@
|
---|
192 |
|
---|
193 | 025-addinguser: 024-creatingcrossdir
|
---|
194 | @\$(call echo_message, Building)
|
---|
195 | @if [ ! -d /home/lfs ]; then \\
|
---|
196 | groupadd lfs; \\
|
---|
197 | useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
|
---|
198 | else \\
|
---|
199 | touch user-lfs-exist; \\
|
---|
200 | fi;
|
---|
201 | @chown lfs \$(MOUNT_PT) && \\
|
---|
202 | chown lfs \$(MOUNT_PT)/tools && \\
|
---|
203 | chown lfs \$(MOUNT_PT)/cross-tools && \\
|
---|
204 | chown lfs \$(MOUNT_PT)/sources && \\
|
---|
205 | touch \$@
|
---|
206 |
|
---|
207 | 026-settingenvironment: 025-addinguser
|
---|
208 | @\$(call echo_message, Building)
|
---|
209 | @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
210 | mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
---|
211 | fi;
|
---|
212 | @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
213 | mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
---|
214 | fi;
|
---|
215 | @echo "set +h" > /home/lfs/.bashrc && \\
|
---|
216 | echo "umask 022" >> /home/lfs/.bashrc && \\
|
---|
217 | echo "LFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
|
---|
218 | echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
---|
219 | echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
---|
220 | echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
---|
221 | echo "" >> /home/lfs/.bashrc && \\
|
---|
222 | echo "unset CFLAGS" >> /home/lfs/.bashrc && \\
|
---|
223 | echo "unset CXXFLAGS" >> /home/lfs/.bashrc && \\
|
---|
224 | echo "" >> /home/lfs/.bashrc && \\
|
---|
225 | echo "export LFS_HOST=\"${LFS_HOST}\"" >> /home/lfs/.bashrc && \\
|
---|
226 | echo "export LFS_TARGET=\"${TARGET}\"" >> /home/lfs/.bashrc && \\
|
---|
227 | echo "export LFS_TARGET32=\"${TARGET32}\"" >> /home/lfs/.bashrc && \\
|
---|
228 | echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc
|
---|
229 | @chown lfs:lfs /home/lfs/.bashrc && \\
|
---|
230 | touch envars && \\
|
---|
231 | touch \$@
|
---|
232 | EOF
|
---|
233 | ) >> $MKFILE.tmp
|
---|
234 |
|
---|
235 | }
|
---|
236 |
|
---|
237 |
|
---|
238 |
|
---|
239 | #-----------------------------#
|
---|
240 | cross_tools_Makefiles() { #
|
---|
241 | #-----------------------------#
|
---|
242 | echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools${R_arrow}"
|
---|
243 |
|
---|
244 | for file in cross-tools/* ; do
|
---|
245 | # Keep the script file name
|
---|
246 | this_script=`basename $file`
|
---|
247 | #
|
---|
248 | # Skip this script...
|
---|
249 | case $this_script in
|
---|
250 | *cflags* | *variables* ) # work done in host_prep_Makefiles
|
---|
251 | continue; ;;
|
---|
252 | *) ;;
|
---|
253 | esac
|
---|
254 | #
|
---|
255 | # Set the dependency for the first target.
|
---|
256 | if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
|
---|
257 |
|
---|
258 | # First append each name of the script files to a list (this will become
|
---|
259 | # the names of the targets in the Makefile
|
---|
260 | cross_tools="$cross_tools $this_script"
|
---|
261 |
|
---|
262 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
263 | # and binutils in chapter 5)
|
---|
264 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
265 | -e 's@-static@@' \
|
---|
266 | -e 's@-final@@' \
|
---|
267 | -e 's@-headers@@' \
|
---|
268 | -e 's@-64@@' \
|
---|
269 | -e 's@-n32@@'`
|
---|
270 | # Adjust 'name' and patch a few scripts on the fly..
|
---|
271 | case $name in
|
---|
272 | linux-libc) name=linux-libc-headers ;;
|
---|
273 | esac
|
---|
274 | #
|
---|
275 | # Find the version of the command files, if it corresponds with the building of a specific package
|
---|
276 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
277 |
|
---|
278 |
|
---|
279 | #--------------------------------------------------------------------#
|
---|
280 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
281 | #--------------------------------------------------------------------#
|
---|
282 | #
|
---|
283 | # Drop in the name of the target on a new line, and the previous target
|
---|
284 | # as a dependency. Also call the echo_message function.
|
---|
285 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
286 | #
|
---|
287 | # If $vrs isn't empty, we've got a package...
|
---|
288 | #
|
---|
289 | [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar"
|
---|
290 | #
|
---|
291 | wrt_run_as_lfs "${this_script}" "${file}"
|
---|
292 | #
|
---|
293 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
294 | #
|
---|
295 | # Include a touch of the target name so make can check if it's already been made.
|
---|
296 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
297 | #
|
---|
298 | #--------------------------------------------------------------------#
|
---|
299 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
300 | #--------------------------------------------------------------------#
|
---|
301 | #
|
---|
302 | # Keep the script file name for Makefile dependencies.
|
---|
303 | PREV=$this_script
|
---|
304 |
|
---|
305 | done # for file in ....
|
---|
306 | }
|
---|
307 |
|
---|
308 |
|
---|
309 | #-----------------------------#
|
---|
310 | temptools_Makefiles() { #
|
---|
311 | #-----------------------------#
|
---|
312 | echo "${tab_}${GREEN}Processing... ${L_arrow}temp system${R_arrow}"
|
---|
313 |
|
---|
314 | for file in temp-system/* ; do
|
---|
315 | # Keep the script file name
|
---|
316 | this_script=`basename $file`
|
---|
317 | #
|
---|
318 | # First append each name of the script files to a list (this will become
|
---|
319 | # the names of the targets in the Makefile
|
---|
320 | temptools="$temptools $this_script"
|
---|
321 |
|
---|
322 | #
|
---|
323 | # Grab the name of the target, strip id number, XXX-script
|
---|
324 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
325 | #
|
---|
326 | # Find the version of the command files, if it corresponds with the building of a specific package
|
---|
327 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
328 |
|
---|
329 |
|
---|
330 | #--------------------------------------------------------------------#
|
---|
331 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
332 | #--------------------------------------------------------------------#
|
---|
333 | #
|
---|
334 | # Drop in the name of the target on a new line, and the previous target
|
---|
335 | # as a dependency. Also call the echo_message function.
|
---|
336 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
337 | #
|
---|
338 | # If $vrs isn't empty, we've got a package...
|
---|
339 | # Insert instructions for unpacking the package and to set the PKGDIR variable.
|
---|
340 | #
|
---|
341 | [[ "$vrs" != "" ]] && wrt_unpack "$name-$vrs.tar"
|
---|
342 | #
|
---|
343 | wrt_run_as_lfs "${this_script}" "${file}"
|
---|
344 | #
|
---|
345 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
346 | #
|
---|
347 | # Include a touch of the target name so make can check if it's already been made.
|
---|
348 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
349 | #
|
---|
350 | #--------------------------------------------------------------------#
|
---|
351 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
352 | #--------------------------------------------------------------------#
|
---|
353 | #
|
---|
354 | # Keep the script file name for Makefile dependencies.
|
---|
355 | PREV=$this_script
|
---|
356 | done # for file in ....
|
---|
357 | }
|
---|
358 |
|
---|
359 |
|
---|
360 | #-----------------------------#
|
---|
361 | boot_Makefiles() { #
|
---|
362 | #-----------------------------#
|
---|
363 | echo "${tab_}${GREEN}Processing... ${L_arrow}boot${R_arrow}"
|
---|
364 |
|
---|
365 | for file in boot/* ; do
|
---|
366 | # Keep the script file name
|
---|
367 | this_script=`basename $file`
|
---|
368 |
|
---|
369 | # A little housekeeping on the scripts
|
---|
370 | case $this_script in
|
---|
371 | *grub*) continue ;;
|
---|
372 | *whatnext*) continue ;;
|
---|
373 | *settingenvironment*) sed 's@PS1=@set +h\nPS1=@' -i $file ;;
|
---|
374 | *kernel)
|
---|
375 | sed "s|make mrproper|make mrproper\ncp $CONFIG .config|" -i $file
|
---|
376 | # You cannot run menuconfig from within the makefile
|
---|
377 | sed 's|menuconfig|oldconfig|' -i $file
|
---|
378 | #If defined include the keymap in the kernel
|
---|
379 | if [[ -n "$KEYMAP" ]]; then
|
---|
380 | sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file
|
---|
381 | else
|
---|
382 | sed '/loadkeys -m/d' -i $file
|
---|
383 | sed '/drivers\/char/d' -i $file
|
---|
384 | fi
|
---|
385 | # if there is no kernel config file do not build the kernel
|
---|
386 | [[ -z $CONFIG ]] && continue
|
---|
387 | ;;
|
---|
388 | esac
|
---|
389 | #
|
---|
390 | # First append each name of the script files to a list (this will become
|
---|
391 | # the names of the targets in the Makefile
|
---|
392 | boottools="$boottools $this_script"
|
---|
393 | #
|
---|
394 | # Grab the name of the target, strip id number and misc words.
|
---|
395 | case $this_script in
|
---|
396 | *kernel) name=linux ;;
|
---|
397 | *bootscripts) name=lfs-bootscripts ;;
|
---|
398 | *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
|
---|
399 | esac
|
---|
400 |
|
---|
401 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
402 |
|
---|
403 | #--------------------------------------------------------------------#
|
---|
404 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
405 | #--------------------------------------------------------------------#
|
---|
406 | #
|
---|
407 | # Drop in the name of the target on a new line, and the previous target
|
---|
408 | # as a dependency. Also call the echo_message function.
|
---|
409 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
410 | #
|
---|
411 | # If $vrs isn't empty, we've got a package...
|
---|
412 | # Insert instructions for unpacking the package and changing directories
|
---|
413 | #
|
---|
414 | [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
|
---|
415 | #
|
---|
416 | # Select a script execution method
|
---|
417 | case $this_script in
|
---|
418 | *changingowner*) wrt_run_as_root "${this_script}" "${file}" ;;
|
---|
419 | *devices*) wrt_run_as_root "${this_script}" "${file}" ;;
|
---|
420 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
421 | wrt_copy_fstab "${this_script}"
|
---|
422 | else
|
---|
423 | wrt_run_as_lfs "${this_script}" "${file}"
|
---|
424 | fi
|
---|
425 | ;;
|
---|
426 | *) wrt_run_as_lfs "${this_script}" "${file}" ;;
|
---|
427 | esac
|
---|
428 | #
|
---|
429 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
430 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
431 | #
|
---|
432 | # Include a touch of the target name so make can check if it's already been made.
|
---|
433 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
434 | #
|
---|
435 | #--------------------------------------------------------------------#
|
---|
436 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
437 | #--------------------------------------------------------------------#
|
---|
438 | #
|
---|
439 | # Keep the script file name for Makefile dependencies.
|
---|
440 | PREV=$this_script
|
---|
441 |
|
---|
442 | done
|
---|
443 | # This will force the Makefile to exit and not allow it to be restarted with
|
---|
444 | # the command <make>, The user will have to issue the cmd <make chapterXX>
|
---|
445 | echo -e "\t@\$(call echo_boot_finished,$VERSION) && \\" >> $MKFILE.tmp
|
---|
446 | echo -e "\tfalse" >> $MKFILE.tmp
|
---|
447 | }
|
---|
448 |
|
---|
449 |
|
---|
450 | #-----------------------------#
|
---|
451 | chroot_Makefiles() { #
|
---|
452 | #-----------------------------#
|
---|
453 | echo "${tab_}${GREEN}Processing... ${L_arrow}chroot${R_arrow}"
|
---|
454 |
|
---|
455 | for file in chroot/* ; do
|
---|
456 | # Keep the script file name
|
---|
457 | this_script=`basename $file`
|
---|
458 | #
|
---|
459 | # Skipping scripts is done now and not included in the build tree.
|
---|
460 | [[ `_IS_ $this_script chroot` ]] && continue
|
---|
461 |
|
---|
462 | #
|
---|
463 | # First append each name of the script files to a list (this will become
|
---|
464 | # the names of the targets in the Makefile
|
---|
465 | chroottools="$chroottools $this_script"
|
---|
466 |
|
---|
467 | #
|
---|
468 | # A little housekeeping on the script contents
|
---|
469 | case $this_script in
|
---|
470 | *kernfs*) sed '/exit/d' -i $file ;;
|
---|
471 | *pwdgroup*) sed '/exec/d' -i $file ;;
|
---|
472 | esac
|
---|
473 | #
|
---|
474 | # Grab the name of the target, strip id number, XXX-script
|
---|
475 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
|
---|
476 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
477 |
|
---|
478 | #--------------------------------------------------------------------#
|
---|
479 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
480 | #--------------------------------------------------------------------#
|
---|
481 | #
|
---|
482 | # Drop in the name of the target on a new line, and the previous target
|
---|
483 | # as a dependency. Also call the echo_message function.
|
---|
484 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
485 | #
|
---|
486 | # If $vrs isn't empty, we've got a package...
|
---|
487 | # Insert instructions for unpacking the package and changing directories
|
---|
488 | #
|
---|
489 | if [ "$vrs" != "" ] ; then
|
---|
490 | case $this_script in
|
---|
491 | *util-linux) wrt_unpack "$name-$vrs.tar" ;;
|
---|
492 | *) wrt_unpack2 "$name-$vrs.tar.*" ;;
|
---|
493 | esac
|
---|
494 | fi
|
---|
495 | #
|
---|
496 | # Select a script execution method
|
---|
497 | case $this_script in
|
---|
498 | *kernfs) wrt_run_as_root "${this_script}" "${file}" ;;
|
---|
499 | *util-linux) wrt_run_as_lfs "${this_script}" "${file}" ;;
|
---|
500 | *) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
|
---|
501 | esac
|
---|
502 | #
|
---|
503 | # Housekeeping...remove the build directory(ies), except if the package build fails.
|
---|
504 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
505 | #
|
---|
506 | # Include a touch of the target name so make can check if it's already been made.
|
---|
507 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
508 | #
|
---|
509 | #--------------------------------------------------------------------#
|
---|
510 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
511 | #--------------------------------------------------------------------#
|
---|
512 | #
|
---|
513 | # Keep the script file name for Makefile dependencies.
|
---|
514 | PREV=$this_script
|
---|
515 |
|
---|
516 | done # for file in...
|
---|
517 | }
|
---|
518 |
|
---|
519 |
|
---|
520 | #-----------------------------#
|
---|
521 | testsuite_tools_Makefiles() { #
|
---|
522 | #-----------------------------#
|
---|
523 | echo "${tab_}${GREEN}Processing... ${L_arrow}testsuite tools${R_arrow}"
|
---|
524 |
|
---|
525 | for file in testsuite-tools/* ; do
|
---|
526 | # Keep the script file name
|
---|
527 | this_script=`basename $file`
|
---|
528 |
|
---|
529 | # First append each name of the script files to a list (this will become
|
---|
530 | # the names of the targets in the Makefile
|
---|
531 | testsuitetools="$testsuitetools $this_script"
|
---|
532 |
|
---|
533 | # Grab the name of the target, strip id number, XXX-script
|
---|
534 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
535 | -e 's@-64bit@@' \
|
---|
536 | -e 's@-64@@' \
|
---|
537 | -e 's@64@@' \
|
---|
538 | -e 's@n32@@'`
|
---|
539 |
|
---|
540 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
541 |
|
---|
542 | #--------------------------------------------------------------------#
|
---|
543 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
544 | #--------------------------------------------------------------------#
|
---|
545 | #
|
---|
546 | # Drop in the name of the target on a new line, and the previous target
|
---|
547 | # as a dependency. Also call the echo_message function.
|
---|
548 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
549 | #
|
---|
550 | case $name in
|
---|
551 | tcl) wrt_unpack2 "$name$vrs-src.tar" ;;
|
---|
552 | *) wrt_unpack2 "$name-$vrs.tar" ;;
|
---|
553 | esac
|
---|
554 | #
|
---|
555 | wrt_run_as_chroot1 "${this_script}" "${file}"
|
---|
556 | #
|
---|
557 | wrt_remove_build_dirs "${name}"
|
---|
558 | #
|
---|
559 | # Include a touch of the target name so make can check if it's already been made.
|
---|
560 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
561 | #
|
---|
562 | #--------------------------------------------------------------------#
|
---|
563 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
564 | #--------------------------------------------------------------------#
|
---|
565 | #
|
---|
566 | # Keep the script file name for Makefile dependencies.
|
---|
567 | PREV=$this_script
|
---|
568 |
|
---|
569 | done
|
---|
570 | }
|
---|
571 |
|
---|
572 |
|
---|
573 | #--------------------------------#
|
---|
574 | bm_testsuite_tools_Makefiles() { #
|
---|
575 | #--------------------------------#
|
---|
576 | echo "${tab_}${GREEN}Processing... ${L_arrow}(minimal boot) testsuite tools${R_arrow}"
|
---|
577 |
|
---|
578 | for file in testsuite-tools/* ; do
|
---|
579 | # Keep the script file name
|
---|
580 | this_script=`basename $file`
|
---|
581 |
|
---|
582 | # First append each name of the script files to a list (this will become
|
---|
583 | # the names of the targets in the Makefile
|
---|
584 | testsuitetools="$testsuitetools $this_script"
|
---|
585 |
|
---|
586 | # Grab the name of the target, strip id number, XXX-script
|
---|
587 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
588 | -e 's@-64bit@@' \
|
---|
589 | -e 's@-64@@' \
|
---|
590 | -e 's@64@@' \
|
---|
591 | -e 's@n32@@'`
|
---|
592 |
|
---|
593 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
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.
|
---|
601 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
602 | #
|
---|
603 | case $name in
|
---|
604 | tcl) wrt_unpack4 "$name$vrs-src.tar.*" ;;
|
---|
605 | *) wrt_unpack4 "$name-$vrs.tar.*" ;;
|
---|
606 | esac
|
---|
607 | #
|
---|
608 | wrt_run_as_root2 "${this_script}" "${file}"
|
---|
609 | #
|
---|
610 | wrt_remove_build_dirs2 "${name}"
|
---|
611 | #
|
---|
612 | # Include a touch of the target name so make can check if it's already been made.
|
---|
613 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
614 | #
|
---|
615 | #--------------------------------------------------------------------#
|
---|
616 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
617 | #--------------------------------------------------------------------#
|
---|
618 | #
|
---|
619 | # Keep the script file name for Makefile dependencies.
|
---|
620 | PREV=$this_script
|
---|
621 |
|
---|
622 | done
|
---|
623 | }
|
---|
624 |
|
---|
625 |
|
---|
626 | #-----------------------------#
|
---|
627 | final_system_Makefiles() { #
|
---|
628 | #-----------------------------#
|
---|
629 | echo "${tab_}${GREEN}Processing... ${L_arrow}final system${R_arrow}"
|
---|
630 |
|
---|
631 | for file in final-system/* ; do
|
---|
632 | # Keep the script file name
|
---|
633 | this_script=`basename $file`
|
---|
634 |
|
---|
635 | # Skipping scripts is done now so they are not included in the Makefile.
|
---|
636 | case $this_script in
|
---|
637 | *stripping*) continue ;;
|
---|
638 | *grub*) continue ;;
|
---|
639 | esac
|
---|
640 | #
|
---|
641 | # First append each name of the script files to a list (this will become
|
---|
642 | # the names of the targets in the Makefile
|
---|
643 | basicsystem="$basicsystem $this_script"
|
---|
644 | #
|
---|
645 | # A little customizing via sed scripts first..
|
---|
646 | if [[ $TEST = "0" ]]; then
|
---|
647 | # Drop any package checks..
|
---|
648 | sed -e '/make check/d' -e '/make test/d' -i $file
|
---|
649 | fi
|
---|
650 | case $this_script in
|
---|
651 | *coreutils*) sed 's@set -e@set -e; set +h@' -i $file ;;
|
---|
652 | *groff*) sed "s@\*\*EDITME.*EDITME\*\*@$PAGE@" -i $file ;;
|
---|
653 | *vim*) sed '/vim -c/d' -i $file ;;
|
---|
654 | *bash*) sed '/exec /d' -i $file ;;
|
---|
655 | *shadow*) sed -e '/grpconv/d' -e '/pwconv/d' -e '/passwd root/d' -i $file
|
---|
656 | sed '/sed -i libtool/d' -i $file
|
---|
657 | sed '/search_path/d' -i $file
|
---|
658 | ;;
|
---|
659 | *glibc*) sed '/tzselect/d' -i $file
|
---|
660 | sed "s@\*\*EDITME.*EDITME\*\*@$TIMEZONE@" -i $file
|
---|
661 | # Manipulate glibc's test to work with Makefile
|
---|
662 | sed -e 's/glibc-check-log.*//' \
|
---|
663 | -e 's@make -k check >@make -k check >glibc-check-log 2>\&1 || true\ngrep Error glibc-check-log || true@' -i $file
|
---|
664 | ;;
|
---|
665 | *binutils*) sed '/expect /d' -i $file
|
---|
666 | if [[ $TOOLCHAINTEST = "0" ]]; then
|
---|
667 | sed '/make check/d' -i $file
|
---|
668 | fi
|
---|
669 | ;;
|
---|
670 | *gcc*) # Ignore all gcc testing for now..
|
---|
671 | sed -e '/make -k check/d' -i $file
|
---|
672 | sed -e '/test_summary/d' -i $file
|
---|
673 | ;;
|
---|
674 | *texinfo*) # This sucks as a way to trim a script
|
---|
675 | sed -e '/cd \/usr/d' \
|
---|
676 | -e '/rm dir/d' \
|
---|
677 | -e '/for f in/d' \
|
---|
678 | -e '/do inst/d' \
|
---|
679 | -e '/done/d' -i $file
|
---|
680 | ;;
|
---|
681 | esac
|
---|
682 |
|
---|
683 | # Grab the name of the target, strip id number, XXX-script
|
---|
684 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
685 | -e 's@temp-@@' \
|
---|
686 | -e 's@-64bit@@' \
|
---|
687 | -e 's@-64@@' \
|
---|
688 | -e 's@64@@' \
|
---|
689 | -e 's@n32@@'`
|
---|
690 |
|
---|
691 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
692 |
|
---|
693 | #--------------------------------------------------------------------#
|
---|
694 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
695 | #--------------------------------------------------------------------#
|
---|
696 | #
|
---|
697 | # Drop in the name of the target on a new line, and the previous target
|
---|
698 | # as a dependency. Also call the echo_message function.
|
---|
699 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
700 |
|
---|
701 | # If $vrs isn't empty, we've got a package...
|
---|
702 | if [ "$vrs" != "" ] ; then
|
---|
703 | case $name in
|
---|
704 | temp-perl) wrt_unpack2 "perl-$vrs.tar.*" ;;
|
---|
705 | *) wrt_unpack2 "$name-$vrs.tar.*" ;;
|
---|
706 | esac
|
---|
707 | #
|
---|
708 | # Export a few 'config' vars..
|
---|
709 | case $this_script in
|
---|
710 | *glibc*) # For glibc we can set then TIMEZONE envar.
|
---|
711 | wrt_export_timezone ;;
|
---|
712 | *groff*) # For Groff we need to set PAGE envar.
|
---|
713 | wrt_export_pagesize ;;
|
---|
714 | esac
|
---|
715 | fi
|
---|
716 | #
|
---|
717 | wrt_run_as_chroot1 "${this_script}" "${file}"
|
---|
718 | #
|
---|
719 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
720 | #
|
---|
721 | # Include a touch of the target name so make can check if it's already been made.
|
---|
722 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
723 | #
|
---|
724 | #--------------------------------------------------------------------#
|
---|
725 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
726 | #--------------------------------------------------------------------#
|
---|
727 | #
|
---|
728 | # Keep the script file name for Makefile dependencies.
|
---|
729 | PREV=$this_script
|
---|
730 |
|
---|
731 | done # for file in final-system/* ...
|
---|
732 | }
|
---|
733 |
|
---|
734 |
|
---|
735 | #-----------------------------#
|
---|
736 | bm_final_system_Makefiles() { #
|
---|
737 | #-----------------------------#
|
---|
738 | echo "${tab_}${GREEN}Processing... ${L_arrow}(minimal boot) final system${R_arrow}"
|
---|
739 |
|
---|
740 | for file in final-system/* ; do
|
---|
741 | # Keep the script file name
|
---|
742 | this_script=`basename $file`
|
---|
743 |
|
---|
744 | # Skipping scripts is done now so they are not included in the Makefile.
|
---|
745 | case $this_script in
|
---|
746 | *stripping*) continue ;;
|
---|
747 | *grub*) continue ;;
|
---|
748 | esac
|
---|
749 |
|
---|
750 | # First append each name of the script files to a list (this will become
|
---|
751 | # the names of the targets in the Makefile
|
---|
752 | basicsystem="$basicsystem $this_script"
|
---|
753 |
|
---|
754 | #
|
---|
755 | # A little customizing via sed scripts first..
|
---|
756 | if [[ $TEST = "0" ]]; then
|
---|
757 | # Drop any package checks..
|
---|
758 | sed -e '/make check/d' -e '/make test/d' -i $file
|
---|
759 | fi
|
---|
760 | case $this_script in
|
---|
761 | *coreutils*) sed 's@set -e@set -e; set +h@' -i $file ;;
|
---|
762 | *groff*) sed "s@\*\*EDITME.*EDITME\*\*@$PAGE@" -i $file ;;
|
---|
763 | *vim*) sed '/vim -c/d' -i $file ;;
|
---|
764 | *bash*) sed '/exec /d' -i $file ;;
|
---|
765 | *shadow*) sed -e '/grpconv/d' \
|
---|
766 | -e '/pwconv/d' \
|
---|
767 | -e '/passwd root/d' -i $file
|
---|
768 | sed '/sed -i libtool/d' -i $file
|
---|
769 | sed '/search_path/d' -i $file
|
---|
770 | ;;
|
---|
771 | *psmisc*) # Build fails on creation of this link. <pidof> installed in sysvinit
|
---|
772 | sed -e 's/^ln -s/#ln -s/' -i $file
|
---|
773 | ;;
|
---|
774 | *glibc*) sed '/tzselect/d' -i $file
|
---|
775 | sed "s@\*\*EDITME.*EDITME\*\*@$TIMEZONE@" -i $file
|
---|
776 | # Manipulate glibc's test to work with Makefile
|
---|
777 | sed -e 's/glibc-check-log.*//' -e 's@make -k check >@make -k check >glibc-check-log 2>\&1 || true\ngrep Error glibc-check-log || true@' -i $file
|
---|
778 | ;;
|
---|
779 | *binutils*) sed '/expect /d' -i $file
|
---|
780 | if [[ $TOOLCHAINTEST = "0" ]]; then
|
---|
781 | sed '/make check/d' -i $file
|
---|
782 | fi
|
---|
783 | ;;
|
---|
784 | *gcc*) # Ignore all gcc testing for now..
|
---|
785 | sed -e '/make -k check/d' -i $file
|
---|
786 | sed -e '/test_summary/d' -i $file
|
---|
787 | ;;
|
---|
788 | *texinfo*) # This sucks as a way to trim a script
|
---|
789 | sed -e '/cd \/usr/d' \
|
---|
790 | -e '/rm dir/d' \
|
---|
791 | -e '/for f in/d' \
|
---|
792 | -e '/do inst/d' \
|
---|
793 | -e '/done/d' -i $file
|
---|
794 | ;;
|
---|
795 | esac
|
---|
796 |
|
---|
797 | # Grab the name of the target, strip id number, XXX-script
|
---|
798 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
799 | -e 's@temp-@@' \
|
---|
800 | -e 's@-64bit@@' \
|
---|
801 | -e 's@-64@@' \
|
---|
802 | -e 's@64@@' \
|
---|
803 | -e 's@n32@@'`
|
---|
804 |
|
---|
805 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
806 |
|
---|
807 | #--------------------------------------------------------------------#
|
---|
808 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
809 | #--------------------------------------------------------------------#
|
---|
810 | #
|
---|
811 | # Drop in the name of the target on a new line, and the previous target
|
---|
812 | # as a dependency. Also call the echo_message function.
|
---|
813 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
814 |
|
---|
815 | # If $vrs isn't empty, we've got a package...
|
---|
816 | if [ "$vrs" != "" ] ; then
|
---|
817 | case $name in
|
---|
818 | temp-perl) wrt_unpack4 "perl-$vrs.tar.*" ;;
|
---|
819 | *) wrt_unpack4 "$name-$vrs.tar.*" ;;
|
---|
820 | esac
|
---|
821 | #
|
---|
822 | # Export a few 'config' vars..
|
---|
823 | case $this_script in
|
---|
824 | *glibc*) # For glibc we can set then TIMEZONE envar.
|
---|
825 | echo -e '\t@echo "export TIMEZONE=$(TIMEZONE)" >> envars' >> $MKFILE.tmp ;;
|
---|
826 | *groff*) # For Groff we need to set PAGE envar.
|
---|
827 | echo -e '\t@echo "export PAGE=$(PAGE)" >> envars' >> $MKFILE.tmp ;;
|
---|
828 | esac
|
---|
829 | fi
|
---|
830 | #
|
---|
831 | wrt_run_as_root2 "${this_script}" "${file}"
|
---|
832 | #
|
---|
833 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
|
---|
834 | #
|
---|
835 | # Include a touch of the target name so make can check if it's already been made.
|
---|
836 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
837 | #
|
---|
838 | #--------------------------------------------------------------------#
|
---|
839 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
840 | #--------------------------------------------------------------------#
|
---|
841 | #
|
---|
842 | # Keep the script file name for Makefile dependencies.
|
---|
843 | PREV=$this_script
|
---|
844 |
|
---|
845 | done # for file in final-system/* ...
|
---|
846 | }
|
---|
847 |
|
---|
848 |
|
---|
849 | #-----------------------------#
|
---|
850 | bootscripts_Makefiles() { #
|
---|
851 | #-----------------------------#
|
---|
852 | echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts${R_arrow}"
|
---|
853 |
|
---|
854 | for file in bootscripts/* ; do
|
---|
855 | # Keep the script file name
|
---|
856 | this_script=`basename $file`
|
---|
857 |
|
---|
858 | case $this_script in
|
---|
859 | *udev*) continue ;; # This is not a script but a commentary
|
---|
860 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
861 | *) ;;
|
---|
862 | esac
|
---|
863 |
|
---|
864 | # First append each name of the script files to a list (this will become
|
---|
865 | # the names of the targets in the Makefile
|
---|
866 | bootscripttools="$bootscripttools $this_script"
|
---|
867 |
|
---|
868 | # A little bit of script modification
|
---|
869 | case $this_script in
|
---|
870 | *profile*) # Over-ride the book cmds, write our own simple one.
|
---|
871 | (
|
---|
872 | cat <<- EOF
|
---|
873 | cat > /etc/profile << "_EOF_"
|
---|
874 | # Begin /etc/profile
|
---|
875 |
|
---|
876 | export LC_ALL=${LC_ALL}
|
---|
877 | export LANG=${LANG}
|
---|
878 | export INPUTRC=/etc/inputrc
|
---|
879 |
|
---|
880 | # End /etc/profile
|
---|
881 | _EOF_
|
---|
882 | EOF
|
---|
883 | ) > $file
|
---|
884 | ;;
|
---|
885 | esac
|
---|
886 |
|
---|
887 | # Grab the name of the target, strip id number, XXX-script
|
---|
888 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
889 | -e 's@-64bit@@' \
|
---|
890 | -e 's@-64@@' \
|
---|
891 | -e 's@64@@' \
|
---|
892 | -e 's@n32@@'`
|
---|
893 | if [[ `_IS_ $name bootscripts` ]]; then name=lfs-bootscripts; fi
|
---|
894 |
|
---|
895 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
896 |
|
---|
897 | #--------------------------------------------------------------------#
|
---|
898 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
899 | #--------------------------------------------------------------------#
|
---|
900 | #
|
---|
901 | # Drop in the name of the target on a new line, and the previous target
|
---|
902 | # as a dependency. Also call the echo_message function.
|
---|
903 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
904 | #
|
---|
905 | # If $vrs isn't empty, we've got a package...
|
---|
906 | #
|
---|
907 | [[ "$vrs" != "" ]] && wrt_unpack2 "$name-$vrs.tar.*"
|
---|
908 | #
|
---|
909 | wrt_run_as_chroot1 "${this_script}" "${file}"
|
---|
910 | #
|
---|
911 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
912 | #
|
---|
913 | # Include a touch of the target name so make can check if it's already been made.
|
---|
914 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
915 | #
|
---|
916 | #--------------------------------------------------------------------#
|
---|
917 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
918 | #--------------------------------------------------------------------#
|
---|
919 | #
|
---|
920 | # Keep the script file name for Makefile dependencies.
|
---|
921 | PREV=$this_script
|
---|
922 |
|
---|
923 | done # for file in bootscripts/* ...
|
---|
924 |
|
---|
925 | }
|
---|
926 |
|
---|
927 | #-----------------------------#
|
---|
928 | bm_bootscripts_Makefiles() { #
|
---|
929 | #-----------------------------#
|
---|
930 | echo "${tab_}${GREEN}Processing... ${L_arrow}(minimal boot) bootscripts${R_arrow}"
|
---|
931 |
|
---|
932 | for file in bootscripts/* ; do
|
---|
933 | # Keep the script file name
|
---|
934 | this_script=`basename $file`
|
---|
935 |
|
---|
936 | case $this_script in
|
---|
937 | *udev*) continue ;; # This is not a script but a commentary
|
---|
938 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
939 | *) ;;
|
---|
940 | esac
|
---|
941 |
|
---|
942 | # First append each name of the script files to a list (this will become
|
---|
943 | # the names of the targets in the Makefile
|
---|
944 | bootscripttools="$bootscripttools $this_script"
|
---|
945 |
|
---|
946 | # A little bit of script modification
|
---|
947 | case $this_script in
|
---|
948 | *profile*) # Over-ride the book cmds, write our own simple one.
|
---|
949 | (
|
---|
950 | cat <<- EOF
|
---|
951 | cat > /etc/profile << "_EOF_"
|
---|
952 | # Begin /etc/profile
|
---|
953 |
|
---|
954 | export LC_ALL=${LC_ALL}
|
---|
955 | export LANG=${LANG}
|
---|
956 | export INPUTRC=/etc/inputrc
|
---|
957 |
|
---|
958 | # End /etc/profile
|
---|
959 | _EOF_
|
---|
960 | EOF
|
---|
961 | ) > $file
|
---|
962 | ;;
|
---|
963 | esac
|
---|
964 |
|
---|
965 | # Grab the name of the target, strip id number, XXX-script
|
---|
966 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
967 | -e 's@-64bit@@' \
|
---|
968 | -e 's@-64@@' \
|
---|
969 | -e 's@64@@' \
|
---|
970 | -e 's@n32@@'`
|
---|
971 | if [[ `_IS_ $name bootscripts` ]]; then name=lfs-bootscripts; fi
|
---|
972 |
|
---|
973 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
974 |
|
---|
975 | #--------------------------------------------------------------------#
|
---|
976 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
977 | #--------------------------------------------------------------------#
|
---|
978 | #
|
---|
979 | # Drop in the name of the target on a new line, and the previous target
|
---|
980 | # as a dependency. Also call the echo_message function.
|
---|
981 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
982 | #
|
---|
983 | # If $vrs isn't empty, we've got a package...
|
---|
984 | #
|
---|
985 | [[ "$vrs" != "" ]] && wrt_unpack4 "$name-$vrs.tar.*"
|
---|
986 | #
|
---|
987 | wrt_run_as_root2 "${this_script}" "${file}"
|
---|
988 | #
|
---|
989 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
|
---|
990 | #
|
---|
991 | # Include a touch of the target name so make can check if it's already been made.
|
---|
992 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
993 | #
|
---|
994 | #--------------------------------------------------------------------#
|
---|
995 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
996 | #--------------------------------------------------------------------#
|
---|
997 | #
|
---|
998 | # Keep the script file name for Makefile dependencies.
|
---|
999 | PREV=$this_script
|
---|
1000 |
|
---|
1001 | done # for file in bootscripts/* ...
|
---|
1002 |
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 |
|
---|
1006 |
|
---|
1007 | #-----------------------------#
|
---|
1008 | bootable_Makefiles() { #
|
---|
1009 | #-----------------------------#
|
---|
1010 | echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable${R_arrow}"
|
---|
1011 |
|
---|
1012 | for file in bootable/* ; do
|
---|
1013 | # Keep the script file name
|
---|
1014 | this_script=`basename $file`
|
---|
1015 |
|
---|
1016 | # A little housekeeping on the scripts
|
---|
1017 | case $this_script in
|
---|
1018 | *grub*) continue ;;
|
---|
1019 | *kernel)
|
---|
1020 | sed "s|make mrproper|make mrproper\ncp $CONFIG .config|" -i $file
|
---|
1021 | # You cannot run menuconfig from within the makefile
|
---|
1022 | sed 's|menuconfig|oldconfig|' -i $file
|
---|
1023 | # If defined include the keymap in the kernel
|
---|
1024 | if [[ -n "$KEYMAP" ]]; then
|
---|
1025 | sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file
|
---|
1026 | else
|
---|
1027 | sed '/loadkeys -m/d' -i $file
|
---|
1028 | sed '/drivers\/char/d' -i $file
|
---|
1029 | fi
|
---|
1030 | # if there is no kernel config file do not build the kernel
|
---|
1031 | [[ -z $CONFIG ]] && continue
|
---|
1032 | ;;
|
---|
1033 | esac
|
---|
1034 | #
|
---|
1035 | # First append each name of the script files to a list (this will become
|
---|
1036 | # the names of the targets in the Makefile
|
---|
1037 | bootabletools="$bootabletools $this_script"
|
---|
1038 | #
|
---|
1039 | # Grab the name of the target, strip id number and misc words.
|
---|
1040 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
|
---|
1041 | [[ `_IS_ $this_script "kernel"` ]] && name=linux
|
---|
1042 |
|
---|
1043 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
1044 |
|
---|
1045 | #--------------------------------------------------------------------#
|
---|
1046 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
1047 | #--------------------------------------------------------------------#
|
---|
1048 | #
|
---|
1049 | # Drop in the name of the target on a new line, and the previous target
|
---|
1050 | # as a dependency. Also call the echo_message function.
|
---|
1051 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
1052 | #
|
---|
1053 | # If $vrs isn't empty, we've got a package...
|
---|
1054 | # Insert instructions for unpacking the package and changing directories
|
---|
1055 | #
|
---|
1056 | [[ "$vrs" != "" ]] && wrt_unpack3 "$name-$vrs.tar.*"
|
---|
1057 | #
|
---|
1058 | # Select a script execution method
|
---|
1059 | case $this_script in
|
---|
1060 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
1061 | wrt_copy_fstab "${this_script}"
|
---|
1062 | else
|
---|
1063 | wrt_run_as_lfs "${this_script}" "${file}"
|
---|
1064 | fi
|
---|
1065 | ;;
|
---|
1066 | *) wrt_run_as_lfs "${this_script}" "${file}" ;;
|
---|
1067 | esac
|
---|
1068 | #
|
---|
1069 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
1070 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs "${name}"
|
---|
1071 | #
|
---|
1072 | # Include a touch of the target name so make can check if it's already been made.
|
---|
1073 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
1074 | #
|
---|
1075 | #--------------------------------------------------------------------#
|
---|
1076 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
1077 | #--------------------------------------------------------------------#
|
---|
1078 | #
|
---|
1079 | # Keep the script file name for Makefile dependencies.
|
---|
1080 | PREV=$this_script
|
---|
1081 |
|
---|
1082 | done
|
---|
1083 |
|
---|
1084 | }
|
---|
1085 |
|
---|
1086 |
|
---|
1087 |
|
---|
1088 | #-----------------------------#
|
---|
1089 | bm_bootable_Makefiles() { #
|
---|
1090 | #-----------------------------#
|
---|
1091 | echo "${tab_}${GREEN}Processing... ${L_arrow}(minimal boot) make bootable${R_arrow}"
|
---|
1092 |
|
---|
1093 | for file in bootable/* ; do
|
---|
1094 | # Keep the script file name
|
---|
1095 | this_script=`basename $file`
|
---|
1096 |
|
---|
1097 | # A little housekeeping on the scripts
|
---|
1098 | case $this_script in
|
---|
1099 | *grub*) continue ;;
|
---|
1100 | *kernel) cfg_file="/sources/`basename $CONFIG`"
|
---|
1101 | sed "s|make mrproper|make mrproper\ncp $cfg_file .config|" -i $file
|
---|
1102 | # You cannot run menuconfig from within the makefile
|
---|
1103 | sed 's|menuconfig|oldconfig|' -i $file
|
---|
1104 | # If defined include the keymap in the kernel
|
---|
1105 | if [[ -n "$KEYMAP" ]]; then
|
---|
1106 | sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i $file
|
---|
1107 | else
|
---|
1108 | sed '/loadkeys -m/d' -i $file
|
---|
1109 | sed '/drivers\/char/d' -i $file
|
---|
1110 | fi
|
---|
1111 | # if there is no kernel config file do not build the kernel
|
---|
1112 | [[ -z $CONFIG ]] && continue
|
---|
1113 | ;;
|
---|
1114 | esac
|
---|
1115 | #
|
---|
1116 | # First append each name of the script files to a list (this will become
|
---|
1117 | # the names of the targets in the Makefile
|
---|
1118 | bootabletools="$bootabletools $this_script"
|
---|
1119 | #
|
---|
1120 | # Grab the name of the target, strip id number and misc words.
|
---|
1121 | case $this_script in
|
---|
1122 | *kernel) name=linux
|
---|
1123 | ;;
|
---|
1124 | *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
|
---|
1125 | esac
|
---|
1126 |
|
---|
1127 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
1128 |
|
---|
1129 | #--------------------------------------------------------------------#
|
---|
1130 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
1131 | #--------------------------------------------------------------------#
|
---|
1132 | #
|
---|
1133 | # Drop in the name of the target on a new line, and the previous target
|
---|
1134 | # as a dependency. Also call the echo_message function.
|
---|
1135 | echo -e "\n$this_script: $PREV\n\t@\$(call echo_message, Building)" >> $MKFILE.tmp
|
---|
1136 | #
|
---|
1137 | # If $vrs isn't empty, we've got a package...
|
---|
1138 | # Insert instructions for unpacking the package and changing directories
|
---|
1139 | #
|
---|
1140 | [[ "$vrs" != "" ]] && wrt_unpack4 "$name-$vrs.tar.*"
|
---|
1141 | #
|
---|
1142 | # Select a script execution method
|
---|
1143 | case $this_script in
|
---|
1144 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
1145 | wrt_copy_fstab2 "${this_script}"
|
---|
1146 | else
|
---|
1147 | wrt_run_as_root2 "${this_script}" "${file}"
|
---|
1148 | fi
|
---|
1149 | ;;
|
---|
1150 | *) wrt_run_as_root2 "${this_script}" "${file}" ;;
|
---|
1151 | esac
|
---|
1152 | #
|
---|
1153 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
1154 | [[ "$vrs" != "" ]] && wrt_remove_build_dirs2 "${name}"
|
---|
1155 | #
|
---|
1156 | # Include a touch of the target name so make can check if it's already been made.
|
---|
1157 | echo -e '\t@touch $@' >> $MKFILE.tmp
|
---|
1158 | #
|
---|
1159 | #--------------------------------------------------------------------#
|
---|
1160 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
1161 | #--------------------------------------------------------------------#
|
---|
1162 | #
|
---|
1163 | # Keep the script file name for Makefile dependencies.
|
---|
1164 | PREV=$this_script
|
---|
1165 |
|
---|
1166 | done
|
---|
1167 |
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 |
|
---|
1171 |
|
---|
1172 | #-----------------------------#
|
---|
1173 | the_end_Makefiles() { #
|
---|
1174 | #-----------------------------#
|
---|
1175 | echo "${tab_}${GREEN}Processing... ${L_arrow}THE END${R_arrow}"
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 |
|
---|
1179 | #-----------------------------#
|
---|
1180 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
1181 | #-----------------------------#
|
---|
1182 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
1183 |
|
---|
1184 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
1185 | # Start with a clean Makefile.tmp file
|
---|
1186 | >$MKFILE.tmp
|
---|
1187 |
|
---|
1188 | host_prep_Makefiles
|
---|
1189 | cross_tools_Makefiles
|
---|
1190 | temptools_Makefiles
|
---|
1191 | if [[ $BOOTMINIMAL = "0" ]]; then
|
---|
1192 | chroot_Makefiles
|
---|
1193 | if [[ $TOOLCHAINTEST = "1" ]]; then
|
---|
1194 | testsuite_tools_Makefiles
|
---|
1195 | fi
|
---|
1196 | final_system_Makefiles
|
---|
1197 | bootscripts_Makefiles
|
---|
1198 | bootable_Makefiles
|
---|
1199 | else
|
---|
1200 | boot_Makefiles # This phase must die at the end of its run..
|
---|
1201 | if [[ $TOOLCHAINTEST = "1" ]]; then
|
---|
1202 | bm_testsuite_tools_Makefiles
|
---|
1203 | fi
|
---|
1204 | bm_final_system_Makefiles
|
---|
1205 | bm_bootscripts_Makefiles
|
---|
1206 | bm_bootable_Makefiles
|
---|
1207 | fi
|
---|
1208 | # the_end_Makefiles
|
---|
1209 |
|
---|
1210 |
|
---|
1211 | # Add a header, some variables and include the function file
|
---|
1212 | # to the top of the real Makefile.
|
---|
1213 | (
|
---|
1214 | cat << EOF
|
---|
1215 | $HEADER
|
---|
1216 |
|
---|
1217 | SRC= /sources
|
---|
1218 | MOUNT_PT= $BUILDDIR
|
---|
1219 | PAGE= $PAGE
|
---|
1220 | TIMEZONE= $TIMEZONE
|
---|
1221 |
|
---|
1222 | include makefile-functions
|
---|
1223 |
|
---|
1224 | EOF
|
---|
1225 | ) > $MKFILE
|
---|
1226 |
|
---|
1227 | # Add chroot commands
|
---|
1228 | i=1
|
---|
1229 | for file in chroot/*chroot* ; do
|
---|
1230 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
|
---|
1231 | -e '/^export/d' \
|
---|
1232 | -e '/^logout/d' \
|
---|
1233 | -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
|
---|
1234 | -e 's|\\$|&&|g' \
|
---|
1235 | -e 's|exit||g' \
|
---|
1236 | -e 's|$| -c|' \
|
---|
1237 | -e 's|"$$LFS"|$(MOUNT_PT)|'\
|
---|
1238 | -e 's|set -e||'`
|
---|
1239 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
1240 | i=`expr $i + 1`
|
---|
1241 | done
|
---|
1242 |
|
---|
1243 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
1244 | # as a dependency.
|
---|
1245 | (
|
---|
1246 | cat << EOF
|
---|
1247 | all: chapter2 chapter3 chapter4 chapter5 chapter6 chapter7 chapter8
|
---|
1248 | @\$(call echo_finished,$VERSION)
|
---|
1249 |
|
---|
1250 | chapter2: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingenvironment
|
---|
1251 |
|
---|
1252 | chapter3: chapter2 $cross_tools
|
---|
1253 |
|
---|
1254 | chapter4: chapter3 $temptools
|
---|
1255 |
|
---|
1256 | chapter5: chapter4 $chroottools $boottools
|
---|
1257 |
|
---|
1258 | chapter6: chapter5 $basicsystem
|
---|
1259 |
|
---|
1260 | chapter7: chapter6 $bootscripttools
|
---|
1261 |
|
---|
1262 | chapter8: chapter7 $bootabletools
|
---|
1263 |
|
---|
1264 | clean-all: clean
|
---|
1265 | rm -rf ./{${PROGNAME}-commands,logs,Makefile,dump-clfs-scripts.xsl,functions,packages,patches}
|
---|
1266 |
|
---|
1267 | clean: clean-chapter4 clean-chapter3 clean-chapter2
|
---|
1268 |
|
---|
1269 | clean-chapter2:
|
---|
1270 | -if [ ! -f user-lfs-exist ]; then \\
|
---|
1271 | userdel lfs; \\
|
---|
1272 | rm -rf /home/lfs; \\
|
---|
1273 | fi;
|
---|
1274 | rm -rf \$(MOUNT_PT)/tools
|
---|
1275 | rm -f /tools
|
---|
1276 | rm -rf \$(MOUNT_PT)/cross-tools
|
---|
1277 | rm -f /cross-tools
|
---|
1278 | rm -f envars user-lfs-exist
|
---|
1279 | rm -f 02* logs/02*.log
|
---|
1280 |
|
---|
1281 | clean-chapter3:
|
---|
1282 | rm -rf \$(MOUNT_PT)/tools/*
|
---|
1283 | rm -f $cross_tools restore-lfs-env sources-dir
|
---|
1284 | cd logs && rm -f $cross_tools && cd ..
|
---|
1285 |
|
---|
1286 | clean-chapter4:
|
---|
1287 | -umount \$(MOUNT_PT)/sys
|
---|
1288 | -umount \$(MOUNT_PT)/proc
|
---|
1289 | -umount \$(MOUNT_PT)/dev/shm
|
---|
1290 | -umount \$(MOUNT_PT)/dev/pts
|
---|
1291 | -umount \$(MOUNT_PT)/dev
|
---|
1292 | rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
---|
1293 | rm -f $temptools
|
---|
1294 | cd logs && rm -f $temptools && cd ..
|
---|
1295 |
|
---|
1296 |
|
---|
1297 | restore-lfs-env:
|
---|
1298 | @\$(call echo_message, Building)
|
---|
1299 | @if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
1300 | mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
|
---|
1301 | fi;
|
---|
1302 | @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
1303 | mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
|
---|
1304 | fi;
|
---|
1305 | @chown lfs:lfs /home/lfs/.bash* && \\
|
---|
1306 | touch \$@
|
---|
1307 |
|
---|
1308 | EOF
|
---|
1309 | ) >> $MKFILE
|
---|
1310 |
|
---|
1311 |
|
---|
1312 | # Bring over the items from the Makefile.tmp
|
---|
1313 | cat $MKFILE.tmp >> $MKFILE
|
---|
1314 | rm $MKFILE.tmp
|
---|
1315 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
1316 |
|
---|
1317 | }
|
---|
1318 |
|
---|