source: common/libs/func_wrt_Makefile@ b7ea8ff

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

Make SHELL=/bin/bash a Makefile variable instead using it inside the sub-make invocations to avoid be propagated to make processes started by the actual build scripts.

  • Property mode set to 100644
File size: 7.2 KB
RevLine 
[fe30c61]1#!/bin/bash
2
3# $Id$
4
5#=== MAKEFILE HEADER ===
6
[195ed9f]7#----------------------------------#
8wrt_Makefile_header() { #
9#----------------------------------#
10(
11 cat << EOF
12# This file is automatically generated by jhalfs
[fe30c61]13# DO NOT EDIT THIS FILE MANUALLY
14#
[195ed9f]15# Generated on `date "+%F %X %Z"`
16
[81f7dc1]17SHELL = /bin/bash
[195ed9f]18
19SRC = /sources
20MOUNT_PT = $BUILDDIR
21PKG_LST = $PKG_LST
22LUSER = $LUSER
23LGROUP = $LGROUP
24SCRIPT_ROOT = $SCRIPT_ROOT
25
26BASEDIR = \$(MOUNT_PT)
27SRCSDIR = \$(BASEDIR)/sources
28CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
29LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/logs
30TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/test-logs
31
32crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
33crLOGDIR = /\$(SCRIPT_ROOT)/logs
34crTESTLOGDIR = /\$(SCRIPT_ROOT)/test-logs
35
36SU_LUSER = su - \$(LUSER) -c
37LUSER_HOME = /home/\$(LUSER)
38PRT_DU = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found \$(MOUNT_PT) \`\n"
39PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found / \`\n"
40
[3e7ceed]41ADD_REPORT = $REPORT
42ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
43ADD_BLFS_TOOLS = $BLFS_TOOL
[1838bc7]44
45
[195ed9f]46export PATH := \${PATH}:/usr/sbin
47
48include makefile-functions
49
50EOF
51) > $MKFILE
52}
[fe30c61]53
54#=======================
55
56
57#==== PACKAGES NAMES ===
58
59#----------------------------------#
60get_package_tarball_name() { #
61#----------------------------------#
62 local script_name=`echo ${1} | sed -e 's@[0-9]\{1\}-@@'`
63
64 # The use of 'head' is necessary to limit the return value to the FIRST match..
65 # hopefully this will not cause problems.
66 #
67 case $script_name in
68 tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 )
69 ;;
[3c38ab0]70 uClibc)
71 if [[ "${PROGNAME}" = "clfs3" ]]; then
72 echo $(grep "^uClibc-" $JHALFSDIR/pkg_tarball_list | head -n1 )
73 else
74 echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
75 fi
76 ;;
[fe30c61]77 linux-headers)
[62d690d]78 if [[ "${PROGNAME}" = "lfs" ]] || [[ "${PROGNAME}" = "hlfs" ]] ; then
[fe30c61]79 # Uses kernel headers directly
80 echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
81 else
[62d690d]82 # CLFS{,2,3} use massaged headers package
[fe30c61]83 echo $(grep "^linux-headers-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
84 fi
85 ;;
86 *) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
87 ;;
88 esac
89
90}
91
92#=======================
93
94
95#==== TARGET HEADER ====
96
97#----------------------------------#
98LUSER_wrt_target() { # Create target and initialize log file
99#----------------------------------#
100 local i=$1
101 local PREV=$2
102(
103cat << EOF
104
105$i: $PREV
106 @\$(call echo_message, Building)
107 @./progress_bar.sh \$@ \$\$PPID &
108 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
109 @\$(PRT_DU) >>logs/\$@
110EOF
111) >> $MKFILE.tmp
112}
113
114#----------------------------------#
115CHROOT_wrt_target() { # Create target and initialize log file
116#----------------------------------#
117 local i=$1
118 local PREV=$2
119(
120cat << EOF
121
122$i: $PREV
123 @\$(call echo_message, Building)
124 @./progress_bar.sh \$@ \$\$PPID &
[6bb080e]125 @echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@
126 @\$(PRT_DU_CR) >>logs/\$@
[fe30c61]127EOF
128) >> $MKFILE.tmp
129}
130
131#=======================
132
133
134#======== UNPACK =======
135
136#----------------------------------#
137LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
138#----------------------------------#
139 local FILE=$1
140 local optSAVE_PREVIOUS=$2
141
142 if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
143(
144cat << EOF
145 @\$(call remove_existing_dirs,$FILE)
146EOF
147) >> $MKFILE.tmp
148 fi
149
150(
151cat << EOF
152 @\$(call unpack,$FILE)
153 @\$(call get_pkg_root_LUSER)
154EOF
155) >> $MKFILE.tmp
156}
157
158#----------------------------------#
159CHROOT_Unpack() { #
160#----------------------------------#
161 local FILE=$1
162 local optSAVE_PREVIOUS=$2
163
164 if [ "${optSAVE_PREVIOUS}" != "1" ]; then
165(
166cat << EOF
167 @\$(call remove_existing_dirs2,$FILE)
168EOF
169) >> $MKFILE.tmp
170 fi
171(
172cat << EOF
[1f81129]173 @\$(call unpack2,$FILE)
[fe30c61]174 @\$(call get_pkg_root2)
175EOF
176) >> $MKFILE.tmp
177}
178
179#=======================
180
181
182#===== TESTS LOGS ======
183
184#----------------------------------#
185LUSER_wrt_test_log() { # Initialize testsuite log file
186#----------------------------------#
187 local TESTLOGFILE=$1
188(
189cat << EOF
[6bb080e]190 @echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
[10c8b78]191 echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/\$@
[fe30c61]192EOF
193) >> $MKFILE.tmp
194}
195
196#----------------------------------#
197CHROOT_wrt_test_log() { #
198#----------------------------------#
199 local TESTLOGFILE=$1
200(
201cat << EOF
[8f2c086]202 @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
[6bb080e]203 echo "\$(nl_)\`date\`\$(nl_)" >test-logs/\$@
[fe30c61]204EOF
205) >> $MKFILE.tmp
206}
207
208#=======================
209
210
211#======== RUN AS =======
212
213#----------------------------------#
214wrt_RunAsRoot() { # Some scripts must be run as root..
215#----------------------------------#
216 local MOUNT_ENV
[8f2c086]217 local file=$1
[fe30c61]218
219 case ${PROGNAME} in
220 lfs ) MOUNT_ENV="LFS" ;;
221 clfs ) MOUNT_ENV="CLFS" ;;
222 clfs2 ) MOUNT_ENV="CLFS" ;;
223 clfs3 ) MOUNT_ENV="CLFS" ;;
224 hlfs ) MOUNT_ENV="HLFS" ;;
225 *) echo "undefined progname $PROGNAME"; exit 1 ;;
226 esac
227
228(
229cat << EOF
230 @( time { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
231 \$(PRT_DU) >>logs/\$@
232EOF
233) >> $MKFILE.tmp
234}
235
236#----------------------------------#
237LUSER_wrt_RunAsUser() { # Execute script inside time { }, footer to log file
238#----------------------------------#
239 local file=$1
240
241(
242cat << EOF
243 @( time { source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1; } ) 2>> logs/\$@ && \\
244 \$(PRT_DU) >> logs/\$@
245EOF
246) >> $MKFILE.tmp
247}
248
249#----------------------------------#
250CHROOT_wrt_RunAsRoot() { #
251#----------------------------------#
252 local file=$1
253(
254cat << EOF
[8f2c086]255 @( time { source envars && \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
[fe30c61]256 \$(PRT_DU_CR) >>logs/\$@
257EOF
258) >> $MKFILE.tmp
259
260}
261
262#=======================
263
264
265#====== COPY FSTAB =====
266
267#----------------------------------#
268LUSER_wrt_CopyFstab() { #
269#----------------------------------#
270(
271cat << EOF
272 @( time { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
273EOF
274) >> $MKFILE.tmp
275}
276
277#----------------------------------#
278CHROOT_wrt_CopyFstab() { #
279#----------------------------------#
280(
281cat << EOF
282 @( time { cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
283EOF
284) >> $MKFILE.tmp
285}
286
287#=======================
288
289
290#==== RM BUILD DIRS ====
291
292#----------------------------------#
293LUSER_RemoveBuildDirs() { #
294#----------------------------------#
295 local name=$1
296(
297cat << EOF
298 @\$(call remove_build_dirs,$name)
299EOF
300) >> $MKFILE.tmp
301}
302
303#----------------------------------#
304CHROOT_wrt_RemoveBuildDirs() { #
305#----------------------------------#
306 local name=$1
307(
308cat << EOF
309 @\$(call remove_build_dirs2,$name)
310EOF
311) >> $MKFILE.tmp
312}
313
314#=======================
315
316
317#======== TOUCH ========
318
319#----------------------------------#
320wrt_touch() { #
321#----------------------------------#
322(
323cat << EOF
324 @\$(call housekeeping)
325EOF
326) >> $MKFILE.tmp
327}
328
329#=======================
Note: See TracBrowser for help on using the repository browser.