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