1 | #!/bin/bash
|
---|
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 ( SETUP ) ${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 | @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
|
---|
23 | mkdir \$(MOUNT_PT)/sources; \\
|
---|
24 | fi;
|
---|
25 | @chmod a+wt \$(MOUNT_PT)/sources
|
---|
26 | @touch \$@ && \\
|
---|
27 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
28 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
29 |
|
---|
30 | 025-addinguser: 023-creatingtoolsdir
|
---|
31 | @\$(call echo_message, Building)
|
---|
32 | @if [ ! -d /home/\$(LUSER) ]; then \\
|
---|
33 | groupadd \$(LGROUP); \\
|
---|
34 | useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
---|
35 | else \\
|
---|
36 | touch luser-exist; \\
|
---|
37 | fi;
|
---|
38 | @chown -R \$(LUSER) \$(MOUNT_PT) && \\
|
---|
39 | chown \$(LUSER) \$(MOUNT_PT)/sources
|
---|
40 | @touch \$@ && \\
|
---|
41 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
42 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
43 |
|
---|
44 | 026-settingenvironment: 025-addinguser
|
---|
45 | @\$(call echo_message, Building)
|
---|
46 | @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
---|
47 | mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
|
---|
48 | fi;
|
---|
49 | @if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
---|
50 | mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
|
---|
51 | fi;
|
---|
52 | @echo "set +h" > /home/\$(LUSER)/.bashrc && \\
|
---|
53 | echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
|
---|
54 | echo "CLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
|
---|
55 | echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
|
---|
56 | echo "PATH=\$(MOUNT_PT)/cross-tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
|
---|
57 | echo "export CLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
|
---|
58 | echo "" >> /home/\$(LUSER)/.bashrc && \\
|
---|
59 | echo "unset CFLAGS" >> /home/\$(LUSER)/.bashrc && \\
|
---|
60 | echo "unset CXXFLAGS" >> /home/\$(LUSER)/.bashrc && \\
|
---|
61 | echo "" >> /home/\$(LUSER)/.bashrc && \\
|
---|
62 | echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
63 | echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
64 | echo "export CLFS_MIPS_LEVEL=\"${MIPS_LEVEL}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
65 | echo "export BUILD=\"${ABI}\"" >> /home/\$(LUSER)/.bashrc && \\
|
---|
66 | echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc
|
---|
67 | @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
|
---|
68 | touch envars && \\
|
---|
69 | chown \$(LUSER):\$(LGROUP) envars && \\
|
---|
70 | chmod -R a+wt \$(MOUNT_PT)
|
---|
71 | @touch \$@ && \\
|
---|
72 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
73 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
74 |
|
---|
75 | 027-create-directories: 026-settingenvironment
|
---|
76 | @\$(call echo_message, Building)
|
---|
77 |
|
---|
78 | @mkdir -p \$(MOUNT_PT)/{bin,boot,dev,{etc/,}opt,home,lib,mnt}
|
---|
79 | @mkdir -p \$(MOUNT_PT)/{proc,media/{floppy,cdrom},sbin,srv,sys}
|
---|
80 | @mkdir -p \$(MOUNT_PT)/var/{lock,log,mail,run,spool}
|
---|
81 | @mkdir -p \$(MOUNT_PT)/var/{opt,cache,lib/{misc,locate},local}
|
---|
82 | @install -d -m 0750 \$(MOUNT_PT)/root
|
---|
83 | @install -d -m 1777 \$(MOUNT_PT){/var,}/tmp
|
---|
84 | @mkdir -p \$(MOUNT_PT)/usr/{,local/}{bin,include,lib,sbin,src}
|
---|
85 | @mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{doc,info,locale,man}
|
---|
86 | @mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{misc,terminfo,zoneinfo}
|
---|
87 | @mkdir -p \$(MOUNT_PT)/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
|
---|
88 | @for dir in \$(MOUNT_PT)/usr{,/local}; do \\
|
---|
89 | ln -s share/{man,doc,info} \$\$dir ; \\
|
---|
90 | done
|
---|
91 |
|
---|
92 | @touch \$@ && \\
|
---|
93 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
94 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
95 |
|
---|
96 | 028-creating-sysfile: 027-create-directories
|
---|
97 | @\$(call echo_message, Building)
|
---|
98 |
|
---|
99 | @touch \$(MOUNT_PT)/etc/mtab
|
---|
100 | @echo "root::0:0:root:/root:/bin/ash" >> \$(MOUNT_PT)/etc/passwd
|
---|
101 | @echo "root:x:0:" >> \$(MOUNT_PT)/etc/group
|
---|
102 | @echo "bin:x:1:" >> \$(MOUNT_PT)/etc/group
|
---|
103 | @echo "sys:x:2:" >> \$(MOUNT_PT)/etc/group
|
---|
104 | @echo "kmem:x:3" >> \$(MOUNT_PT)/etc/group
|
---|
105 | @echo "tty:x:4:" >> \$(MOUNT_PT)/etc/group
|
---|
106 | @echo "tape:x:5:" >> \$(MOUNT_PT)/etc/group
|
---|
107 | @echo "daemon:x:6:" >> \$(MOUNT_PT)/etc/group
|
---|
108 | @echo "floppy:x:7:" >> \$(MOUNT_PT)/etc/group
|
---|
109 | @echo "disk:x:8:" >> \$(MOUNT_PT)/etc/group
|
---|
110 | @echo "lp:x:9:" >> \$(MOUNT_PT)/etc/group
|
---|
111 | @echo "dialout:x:10:" >> \$(MOUNT_PT)/etc/group
|
---|
112 | @echo "audio:x:11:" >> \$(MOUNT_PT)/etc/group
|
---|
113 | @echo "video:x:12:" >> \$(MOUNT_PT)/etc/group
|
---|
114 | @echo "utmp:x:13:" >> \$(MOUNT_PT)/etc/group
|
---|
115 | @echo "usb:x:14:" >> \$(MOUNT_PT)/etc/group
|
---|
116 | @echo "cdrom:x:15:" >> \$(MOUNT_PT)/etc/group
|
---|
117 |
|
---|
118 | @touch \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/{btmp,lastlog,wtmp}
|
---|
119 | @chmod 664 \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/lastlog
|
---|
120 | @chown -R \$(LUSER) \$(MOUNT_PT)
|
---|
121 |
|
---|
122 | @touch \$@ && \\
|
---|
123 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
124 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
125 |
|
---|
126 | EOF
|
---|
127 | ) >> $MKFILE.tmp
|
---|
128 |
|
---|
129 | host_prep=" 023-creatingtoolsdir 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
|
---|
130 | }
|
---|
131 |
|
---|
132 |
|
---|
133 | #-----------------------------#
|
---|
134 | cross_tools_Makefiles() { #
|
---|
135 | #-----------------------------#
|
---|
136 | echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
|
---|
137 |
|
---|
138 | for file in cross-tools/* ; do
|
---|
139 | # Keep the script file name
|
---|
140 | this_script=`basename $file`
|
---|
141 | #
|
---|
142 | # Skip this script...
|
---|
143 | # NOTE.. the book indicated you only needed to install groff or file if the host
|
---|
144 | # had older versions. The packages would be installed in the target directory
|
---|
145 | # and not the host.
|
---|
146 | case $this_script in
|
---|
147 | *cflags* | *variables* ) # work done in host_prep_Makefiles
|
---|
148 | continue ;;
|
---|
149 | *) ;;
|
---|
150 | esac
|
---|
151 |
|
---|
152 | #
|
---|
153 | # Set the dependency for the first target.
|
---|
154 | if [ -z $PREV ] ; then PREV=028-creating-sysfile ; fi
|
---|
155 |
|
---|
156 | # First append each name of the script files to a list (this will become
|
---|
157 | # the names of the targets in the Makefile)
|
---|
158 | cross_tools="$cross_tools $this_script"
|
---|
159 |
|
---|
160 | # Grab the name of the target (minus the -headers or -cross in the case of gcc
|
---|
161 | # and binutils in chapter 5)
|
---|
162 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
163 | -e 's@-static@@' \
|
---|
164 | -e 's@-final@@' \
|
---|
165 | -e 's@-64@@' \
|
---|
166 | -e 's@-n32@@'`
|
---|
167 | case $name in
|
---|
168 | uclibc*) name="uClibc" ;;
|
---|
169 | esac
|
---|
170 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
171 | #--------------------------------------------------------------------#
|
---|
172 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
173 | #--------------------------------------------------------------------#
|
---|
174 | #
|
---|
175 | # Drop in the name of the target on a new line, and the previous target
|
---|
176 | # as a dependency. Also call the echo_message function.
|
---|
177 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
178 | #
|
---|
179 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
180 | if [ "$pkg_tarball" != "" ] ; then
|
---|
181 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
182 | # If using optimizations, write the instructions
|
---|
183 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
184 | fi
|
---|
185 | #
|
---|
186 | LUSER_wrt_RunAsUser "${file}"
|
---|
187 | #
|
---|
188 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
189 | #
|
---|
190 | # Include a touch of the target name so make can check if it's already been made.
|
---|
191 | wrt_touch
|
---|
192 | #
|
---|
193 | #--------------------------------------------------------------------#
|
---|
194 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
195 | #--------------------------------------------------------------------#
|
---|
196 | #
|
---|
197 | # Keep the script file name for Makefile dependencies.
|
---|
198 | PREV=$this_script
|
---|
199 |
|
---|
200 | done # for file in ....
|
---|
201 | }
|
---|
202 |
|
---|
203 |
|
---|
204 |
|
---|
205 | #-----------------------------#
|
---|
206 | final_system_Makefiles() { #
|
---|
207 | #-----------------------------#
|
---|
208 | echo "${tab_}${GREEN}Processing... ${L_arrow}final system ( LUSER ) ${R_arrow}"
|
---|
209 |
|
---|
210 | for file in final-system/* ; do
|
---|
211 | # Keep the script file name
|
---|
212 | this_script=`basename $file`
|
---|
213 |
|
---|
214 | # Test if the stripping phase must be skipped.
|
---|
215 | # Skip alsp temp-perl for iterative runs
|
---|
216 | case $this_script in
|
---|
217 | *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
|
---|
218 | esac
|
---|
219 |
|
---|
220 | # Grab the name of the target, strip id number, XXX-script
|
---|
221 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
|
---|
222 | -e 's@temp-@@' \
|
---|
223 | -e 's@-64bit@@' \
|
---|
224 | -e 's@-64@@' \
|
---|
225 | -e 's@64@@' \
|
---|
226 | -e 's@n32@@'`
|
---|
227 |
|
---|
228 | # Find the version of the command files, if it corresponds with the building of
|
---|
229 | # a specific package.
|
---|
230 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
231 |
|
---|
232 | # Append each name of the script files to a list (this will become
|
---|
233 | # the names of the targets in the Makefile
|
---|
234 | basicsystem="$basicsystem ${this_script}"
|
---|
235 |
|
---|
236 | #--------------------------------------------------------------------#
|
---|
237 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
238 | #--------------------------------------------------------------------#
|
---|
239 | #
|
---|
240 | # Drop in the name of the target on a new line, and the previous target
|
---|
241 | # as a dependency. Also call the echo_message function.
|
---|
242 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
243 | #
|
---|
244 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
245 | if [ "$pkg_tarball" != "" ] ; then
|
---|
246 | LUSER_wrt_unpack "$pkg_tarball"
|
---|
247 | # If using optimizations, write the instructions
|
---|
248 | [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
---|
249 | fi
|
---|
250 | #
|
---|
251 | LUSER_wrt_RunAsUser "${file}"
|
---|
252 | #
|
---|
253 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
254 | #
|
---|
255 | # Include a touch of the target name so make can check if it's already been made.
|
---|
256 | wrt_touch
|
---|
257 | #
|
---|
258 | #--------------------------------------------------------------------#
|
---|
259 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
260 | #--------------------------------------------------------------------#
|
---|
261 | #
|
---|
262 | # Keep the script file name for Makefile dependencies.
|
---|
263 | PREV=${this_script}
|
---|
264 | done # for file in final-system/* ...
|
---|
265 | }
|
---|
266 |
|
---|
267 |
|
---|
268 |
|
---|
269 | #-----------------------------#
|
---|
270 | bootscripts_Makefiles() { #
|
---|
271 | #-----------------------------#
|
---|
272 | echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts ( LUSER ) ${R_arrow}"
|
---|
273 |
|
---|
274 | for file in bootscripts/* ; do
|
---|
275 | # Keep the script file name
|
---|
276 | this_script=`basename $file`
|
---|
277 |
|
---|
278 | case $this_script in
|
---|
279 | *udev) continue ;; # This is not a script but a commentary, we want udev-rules
|
---|
280 | *console*) continue ;; # Use the files that came with the bootscripts
|
---|
281 | *network*) continue ;; # Manually create these files
|
---|
282 | *) ;;
|
---|
283 | esac
|
---|
284 |
|
---|
285 | # First append each name of the script files to a list (this will become
|
---|
286 | # the names of the targets in the Makefile
|
---|
287 | bootscripttools="$bootscripttools $this_script"
|
---|
288 |
|
---|
289 | # Grab the name of the target, strip id number, XXX-script
|
---|
290 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
|
---|
291 | -e 's@-64bit@@' \
|
---|
292 | -e 's@-64@@' \
|
---|
293 | -e 's@64@@' \
|
---|
294 | -e 's@n32@@'`
|
---|
295 | case $name in
|
---|
296 | *bootscripts*) name=bootscripts-cross-lfs ;;
|
---|
297 | *udev-rules) name=udev-cross-lfs ;;
|
---|
298 | esac
|
---|
299 |
|
---|
300 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
301 |
|
---|
302 | #--------------------------------------------------------------------#
|
---|
303 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
304 | #--------------------------------------------------------------------#
|
---|
305 | #
|
---|
306 | # Drop in the name of the target on a new line, and the previous target
|
---|
307 | # as a dependency. Also call the echo_message function.
|
---|
308 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
309 | #
|
---|
310 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
311 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
312 | #
|
---|
313 | LUSER_wrt_RunAsUser "${file}"
|
---|
314 | #
|
---|
315 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
316 | #
|
---|
317 | # Include a touch of the target name so make can check if it's already been made.
|
---|
318 | wrt_touch
|
---|
319 | #
|
---|
320 | #--------------------------------------------------------------------#
|
---|
321 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
322 | #--------------------------------------------------------------------#
|
---|
323 | #
|
---|
324 | # Keep the script file name for Makefile dependencies.
|
---|
325 | PREV=$this_script
|
---|
326 |
|
---|
327 | done # for file in bootscripts/* ...
|
---|
328 |
|
---|
329 | }
|
---|
330 |
|
---|
331 |
|
---|
332 | #-----------------------------#
|
---|
333 | bootable_Makefiles() { #
|
---|
334 | #-----------------------------#
|
---|
335 | echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable ( LUSER ) ${R_arrow}"
|
---|
336 |
|
---|
337 | for file in bootable/* ; do
|
---|
338 | # Keep the script file name
|
---|
339 | this_script=`basename $file`
|
---|
340 |
|
---|
341 | # A little housekeeping on the scripts
|
---|
342 | case $this_script in
|
---|
343 | *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
|
---|
344 | *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
345 | *kernel) # if there is no kernel config file do not build the kernel
|
---|
346 | [[ -z $CONFIG ]] && continue
|
---|
347 | # Copy the config file to /sources with a standardized name
|
---|
348 | cp $CONFIG $BUILDDIR/sources/kernel-config
|
---|
349 | ;;
|
---|
350 | esac
|
---|
351 | #
|
---|
352 | # First append each name of the script files to a list (this will become
|
---|
353 | # the names of the targets in the Makefile
|
---|
354 | # NOTE: new makfile format forces the last script, *chowning, into a separate
|
---|
355 | # phase.
|
---|
356 | case ${this_script} in
|
---|
357 | *chowning) chowning=${this_script} ;;
|
---|
358 | *) bootable="$bootable $this_script" ;;
|
---|
359 | esac
|
---|
360 | #
|
---|
361 | # Grab the name of the target, strip id number and misc words.
|
---|
362 | name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
|
---|
363 | case $this_script in
|
---|
364 | *kernel*) name=linux
|
---|
365 | ;;
|
---|
366 | esac
|
---|
367 |
|
---|
368 | pkg_tarball=$(get_package_tarball_name $name)
|
---|
369 |
|
---|
370 | #--------------------------------------------------------------------#
|
---|
371 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
372 | #--------------------------------------------------------------------#
|
---|
373 | #
|
---|
374 | # Drop in the name of the target on a new line, and the previous target
|
---|
375 | # as a dependency. Also call the echo_message function.
|
---|
376 | LUSER_wrt_target "${this_script}" "$PREV"
|
---|
377 | #
|
---|
378 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
379 | [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
|
---|
380 | #
|
---|
381 | # Select a script execution method
|
---|
382 | case $this_script in
|
---|
383 | *fstab*) if [[ -n "$FSTAB" ]]; then
|
---|
384 | LUSER_wrt_CopyFstab
|
---|
385 | else
|
---|
386 | LUSER_wrt_RunAsUser "${file}"
|
---|
387 | fi
|
---|
388 | ;;
|
---|
389 | *chowning) wrt_RunAsRoot "${file}"
|
---|
390 | ;;
|
---|
391 | *) LUSER_wrt_RunAsUser "${file}"
|
---|
392 | ;;
|
---|
393 | esac
|
---|
394 | #
|
---|
395 | # Housekeeping...remove any build directory(ies) except if the package build fails.
|
---|
396 | [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
|
---|
397 | #
|
---|
398 | # Include a touch of the target name so make can check if it's already been made.
|
---|
399 | wrt_touch
|
---|
400 | #
|
---|
401 | #--------------------------------------------------------------------#
|
---|
402 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
403 | #--------------------------------------------------------------------#
|
---|
404 | #
|
---|
405 | # Keep the script file name for Makefile dependencies.
|
---|
406 | PREV=$this_script
|
---|
407 |
|
---|
408 | done
|
---|
409 |
|
---|
410 | }
|
---|
411 |
|
---|
412 |
|
---|
413 | #-----------------------------#
|
---|
414 | build_Makefile() { # Construct a Makefile from the book scripts
|
---|
415 | #-----------------------------#
|
---|
416 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
417 |
|
---|
418 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
419 | # Start with a clean Makefile.tmp file
|
---|
420 | >$MKFILE.tmp
|
---|
421 |
|
---|
422 | host_prep_Makefiles
|
---|
423 | cross_tools_Makefiles # $cross_tools
|
---|
424 | final_system_Makefiles # $basicsystem
|
---|
425 | bootscripts_Makefiles # $bootscripttools
|
---|
426 | bootable_Makefiles # $bootable
|
---|
427 |
|
---|
428 | # Add a header, some variables and include the function file
|
---|
429 | # to the top of the real Makefile.
|
---|
430 | wrt_Makefile_header
|
---|
431 |
|
---|
432 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
433 | # as a dependency.
|
---|
434 | (
|
---|
435 | cat << EOF
|
---|
436 |
|
---|
437 | all: ck_UID mk_SETUP mk_LUSER mk_ROOT create-sbu_du-report
|
---|
438 | @sudo make do-housekeeping
|
---|
439 | @\$(call echo_finished,$VERSION)
|
---|
440 |
|
---|
441 | ck_UID:
|
---|
442 | @if [ \`id -u\` = "0" ]; then \\
|
---|
443 | echo "--------------------------------------------------"; \\
|
---|
444 | echo "You cannot run this makefile from the root account"; \\
|
---|
445 | echo "--------------------------------------------------"; \\
|
---|
446 | exit 1; \\
|
---|
447 | fi
|
---|
448 |
|
---|
449 | mk_SETUP:
|
---|
450 | @\$(call echo_SU_request)
|
---|
451 | @sudo make SHELL=/bin/bash SETUP
|
---|
452 | @touch \$@
|
---|
453 |
|
---|
454 | mk_LUSER: mk_SETUP
|
---|
455 | @\$(call echo_SULUSER_request)
|
---|
456 | @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SHELL=/bin/bash LUSER" )
|
---|
457 | @sudo make restore-luser-env
|
---|
458 | @touch \$@
|
---|
459 |
|
---|
460 | mk_ROOT:
|
---|
461 | @sudo make SHELL=/bin/bash ROOT
|
---|
462 | @touch \$@
|
---|
463 |
|
---|
464 |
|
---|
465 | SETUP: $host_prep
|
---|
466 | LUSER: $cross_tools $basicsystem $bootscripttools $bootable
|
---|
467 | ROOT: $chowning
|
---|
468 |
|
---|
469 |
|
---|
470 | create-sbu_du-report: ROOT
|
---|
471 | @\$(call echo_message, Building)
|
---|
472 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
473 | ./create-sbu_du-report.sh logs $VERSION; \\
|
---|
474 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
475 | fi;
|
---|
476 | @touch \$@
|
---|
477 |
|
---|
478 | restore-luser-env:
|
---|
479 | @\$(call echo_message, Building)
|
---|
480 | @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
---|
481 | mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
|
---|
482 | fi;
|
---|
483 | @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
---|
484 | mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
|
---|
485 | fi;
|
---|
486 | @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
|
---|
487 | touch \$@ && \\
|
---|
488 | echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
489 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
490 |
|
---|
491 | do-housekeeping:
|
---|
492 | @-if [ ! -f luser-exist ]; then \\
|
---|
493 | userdel \$(LUSER); \\
|
---|
494 | rm -rf /home/\$(LUSER); \\
|
---|
495 | fi;
|
---|
496 |
|
---|
497 | EOF
|
---|
498 | ) >> $MKFILE
|
---|
499 |
|
---|
500 | # Bring over the items from the Makefile.tmp
|
---|
501 | cat $MKFILE.tmp >> $MKFILE
|
---|
502 | rm $MKFILE.tmp
|
---|
503 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
504 |
|
---|
505 | }
|
---|
506 |
|
---|