source: common/libs/func_wrt_Makefile@ e5fe832

experimental
Last change on this file since e5fe832 was aafcfa9, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Makefile envars and fuctions revised.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1#!/bin/bash
2
3# $Id$
4
5#=== MAKEFILE HEADER ===
6
7#----------------------------------#
8wrt_Makefile_header() { #
9#----------------------------------#
10(
11 cat << EOF
12# This file is automatically generated by jhalfs
13# DO NOT EDIT THIS FILE MANUALLY
14#
15# Generated on `date "+%F %X %Z"`
16
17
18SHELL = /bin/bash
19
20MOUNT_PT = $BUILDDIR
21SCRIPT_ROOT = $SCRIPT_ROOT
22CMDSDIR = $PROGNAME-commands
23SRC = /sources
24SRCSDIR = \$(MOUNT_PT)\$(SRC)
25FILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
26
27LUSER = $LUSER
28LGROUP = $LGROUP
29LHOME = $LHOME
30LUSER_HOME = \$(LHOME)/\$(LUSER)
31SU_LUSER = su - \$(LUSER) -c
32
33ADD_REPORT = $REPORT
34ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
35ADD_BLFS_TOOLS = $BLFS_TOOL
36
37
38export PATH := \${PATH}:/usr/sbin
39
40include makefile-functions
41
42EOF
43) > $MKFILE
44}
45
46#=======================
47
48
49#==== TARGET HEADER ====
50
51#----------------------------------#
52wrt_target() { # Create target
53#----------------------------------#
54 local i=$1
55 local PREV=$2
56(
57cat << EOF
58
59$i: $PREV
60 @\$(call echo_message, Building)
61 @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
62EOF
63) >> $MKFILE.tmp
64}
65
66#=======================
67
68
69#======== RUN THE SCRIPT =======
70
71#----------------------------------#
72wrt_RunAsRoot() { # Some not-chroot scripts must be run as root..
73#----------------------------------#
74 local MOUNT_ENV
75 local file=$1
76
77 case ${PROGNAME} in
78 lfs ) MOUNT_ENV="LFS" ;;
79 clfs ) MOUNT_ENV="CLFS" ;;
80 clfs2 ) MOUNT_ENV="CLFS" ;;
81 clfs3 ) MOUNT_ENV="CLFS" ;;
82 hlfs ) MOUNT_ENV="HLFS" ;;
83 *) echo "undefined progname $PROGNAME"; exit 1 ;;
84 esac
85
86(
87cat << EOF
88 @export ${MOUNT_ENV}=\$(MOUNT_PT) && \$(CMDSDIR)/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
89EOF
90) >> $MKFILE.tmp
91}
92
93#----------------------------------#
94wrt_RunScript() { #
95#----------------------------------#
96 local file=$1
97
98(
99cat << EOF
100 @\$(CMDSDIR)/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
101EOF
102) >> $MKFILE.tmp
103}
104
105#=======================
106
107
108#====== COPY FSTAB =====
109
110#----------------------------------#
111LUSER_wrt_CopyFstab() { # Needed for CLFS Sysroot and Embedded
112#----------------------------------#
113(
114cat << EOF
115 @cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab > $LOGDIRBASE/\$@ 2>&1
116EOF
117) >> $MKFILE.tmp
118}
119
120#----------------------------------#
121wrt_CopyFstab() { #
122#----------------------------------#
123(
124cat << EOF
125 @cp -v /sources/fstab /etc/fstab > $LOGDIRBASE/\$@ 2>&1
126EOF
127) >> $MKFILE.tmp
128}
129
130#=======================
131
132
133#==== INSTALLED FILES LOGS ====
134
135#----------------------------------#
136LUSER_wrt_TouchTimestamp() { # Needed for CLFS Sysroot and Embedded
137#----------------------------------#
138(
139cat << EOF
140 @\$(call touch_timestamp_LUSER)
141EOF
142) >> $MKFILE.tmp
143}
144
145#----------------------------------#
146wrt_TouchTimestamp() { #
147#----------------------------------#
148(
149cat << EOF
150 @\$(call touch_timestamp)
151EOF
152) >> $MKFILE.tmp
153}
154
155#----------------------------------#
156LUSER_wrt_LogNewFiles() { # Needed for CLFS Sysroot and Embedded
157#----------------------------------#
158 local name=$1
159(
160cat << EOF
161 @\$(call log_new_files_LUSER,$name)
162EOF
163) >> $MKFILE.tmp
164}
165
166#----------------------------------#
167wrt_LogNewFiles() { #
168#----------------------------------#
169 local name=$1
170(
171cat << EOF
172 @\$(call log_new_files,$name)
173EOF
174) >> $MKFILE.tmp
175}
176
177#=======================
178
179
180#======== TOUCH ========
181
182#----------------------------------#
183wrt_touch() { #
184#----------------------------------#
185(
186cat << EOF
187 @\$(call housekeeping)
188EOF
189) >> $MKFILE.tmp
190}
191
192#=======================
Note: See TracBrowser for help on using the repository browser.