source: BLFS/gen-makefile.sh@ 1d4eebf

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

Typo fix.

  • Property mode set to 100755
File size: 5.9 KB
Line 
1#!/bin/bash
2#
3# $Id$
4#
5set -e
6
7# TEMPORARY VARIABLES.. development use only
8declare MKFILE=Makefile
9declare PREV_PACKAGE=""
10declare BUILD_SCRIPTS=scripts
11declare TRACKING_DIR=tracking-dir
12
13HEADER="# This file is automatically generated by gen-makefile.sh
14# YOU MAY NEED TO EDIT THIS FILE MANUALLY
15#
16# Generated on `date \"+%F %X %Z\"`"
17
18
19#----------------------------------#
20__wrt_target() { # Create target and initialize log file
21#----------------------------------#
22 local i=$1
23 local PREV=$2
24(
25cat << EOF
26
27$i: $PREV
28 @\$(call echo_message, Building)
29 @./progress_bar.sh \$@ \$\$PPID &
30EOF
31) >> $MKFILE.tmp
32}
33
34
35
36#----------------------------------#
37__write_build_cmd() { #
38#----------------------------------#
39(
40cat << EOF
41 @source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
42EOF
43) >> $MKFILE.tmp
44}
45
46#----------------------------------#
47__wrt_touch() { #
48#----------------------------------#
49 local pkg_name=$1
50 local pkg_ver=$2
51 local alsa_ver=$(grep "^alsa[[:space:]]" ../packages | cut -f3)
52 local kde_core_ver=$(grep "^kde-core[[:space:]]" ../packages | cut -f3)
53 local xorg7_ver=$(grep "^xorg7[[:space:]]" ../packages | cut -f3)
54
55 if [[ -n "$pkg_ver" ]] ; then
56(
57cat << EOF
58 @rm -f \$(TRACKING_DIR)/${pkg_name#*-?-}-{0..9}* && \\
59 touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
60EOF
61) >> $MKFILE.tmp
62 fi
63
64 case $pkg_name in
65 *-alsa-lib ) #this the unique mandatory package for ALSA support.
66(
67cat << EOF
68 @rm -f \$(TRACKING_DIR)/alsa-{0..9}* && \\
69 touch \$(TRACKING_DIR)/alsa-${alsa_ver}
70EOF
71) >> $MKFILE.tmp
72 ;;
73 *-kdebase )
74(
75cat << EOF
76 @rm -f \$(TRACKING_DIR)/kde-core-{0..9}* && \\
77 touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
78EOF
79) >> $MKFILE.tmp
80 ;;
81 *-xorg7-driver ) # xtrerm2 and rman are optional
82(
83cat << EOF
84 @rm -f \$(TRACKING_DIR)/xorg7-{0..9}* && \\
85 touch \$(TRACKING_DIR)/xorg7-${xorg7_ver}
86EOF
87) >> $MKFILE.tmp
88 ;;
89 esac
90
91(
92cat << EOF
93 @touch \$@ && \\
94 sleep .25 && \\
95 echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
96 echo --------------------------------------------------------------------------------\$(WHITE)
97EOF
98) >> $MKFILE.tmp
99}
100
101
102#----------------------------#
103__write_entry() { #
104#----------------------------#
105 local script_name=$1
106 local pkg_ver=$2
107
108 echo -n "${tab_}${tab_} entry for <$script_name>"
109
110 #--------------------------------------------------------------------#
111 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
112 #--------------------------------------------------------------------#
113 #
114 # Drop in the name of the target on a new line, and the previous target
115 # as a dependency. Also call the echo_message function.
116 __wrt_target "${script_name}" "$PREV_PACKAGE"
117 __write_build_cmd
118
119 # Include a touch of the target name so make can check
120 # if it's already been made.
121 __wrt_touch "${script_name}" "${pkg_ver}"
122 #
123 #--------------------------------------------------------------------#
124 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
125 #--------------------------------------------------------------------#
126 echo " .. OK"
127}
128
129#----------------------------#
130__write_meta_pkg_touch() { #
131#----------------------------#
132 local meta_pkg=$1
133 local pkg_ver=$(grep "^${meta_pkg}[[:space:]]" ../packages | cut -f3)
134 local gnome_core_ver=$(grep "^gnome-core[[:space:]]" ../packages | cut -f3)
135 local kde_full_ver=$(grep "^kde-full[[:space:]]" ../packages | cut -f3)
136
137(
138cat << EOF
139
140999-z-$meta_pkg: $PREV_PACKAGE
141 @rm -f \$(TRACKING_DIR)/${meta_pkg}-{0..9}* && \\
142 touch \$(TRACKING_DIR)/${meta_pkg}-${pkg_ver}
143EOF
144) >> $MKFILE.tmp
145
146 case $meta_pkg in
147 gnome-full )
148(
149cat << EOF
150 @rm -f \$(TRACKING_DIR)/gnome-core-{0..9}* && \\
151 touch \$(TRACKING_DIR)/gnome-core-${gnome_core_ver}
152EOF
153) >> $MKFILE.tmp
154 ;;
155 kde-koffice )
156(
157cat << EOF
158 @rm -f \$(TRACKING_DIR)/kde-full-{0..9}* && \\
159 touch \$(TRACKING_DIR)/kde-full-${kde_full_ver}
160EOF
161) >> $MKFILE.tmp
162 ;;
163 esac
164
165(
166cat << EOF
167 @touch \$@
168EOF
169) >> $MKFILE.tmp
170
171}
172
173#----------------------------#
174generate_Makefile () { #
175#----------------------------#
176
177
178 echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
179
180 # Start with a clean files
181 >$MKFILE
182 >$MKFILE.tmp
183
184
185 for package_script in scripts/* ; do
186 this_script=`basename $package_script`
187 pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
188 pkg_list="$pkg_list ${this_script}"
189 __write_entry "${this_script}" "${pkg_ver}"
190 PREV_PACKAGE=${this_script}
191 done
192
193 PACKAGE=$(basename $PWD)
194
195 # alsa, kde-core and xorg7 are also available dependencies, thus handled
196 # in another way.
197 case $PACKAGE in
198 gnome-core | \
199 gnome-full | \
200 kde-full | \
201 kde-koffice ) pkg_list="$pkg_list 999-z-${PACKAGE}"
202 __write_meta_pkg_touch "${PACKAGE}"
203 ;;
204 esac
205
206
207 # Add a header, some variables and include the function file
208 # to the top of the real Makefile.
209(
210 cat << EOF
211$HEADER
212
213PACKAGE= $PACKAGE
214TRACKING_DIR= $TRACKING_DIR
215
216BOLD= "[0;1m"
217RED= "[1;31m"
218GREEN= "[0;32m"
219ORANGE= "[0;33m"
220BLUE= "[1;34m"
221WHITE= "[00m"
222
223define echo_message
224 @echo \$(BOLD)
225 @echo --------------------------------------------------------------------------------
226 @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
227 @echo \$(WHITE)
228endef
229
230
231define fin_message
232 @echo \$(BOLD)
233 @echo --------------------------------------------------------------------------------
234 @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
235 @echo \$(WHITE)
236endef
237
238all : $pkg_list
239 @\$(call fin_message )
240EOF
241) > $MKFILE
242
243 cat $MKFILE.tmp >> $MKFILE
244 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
245
246 rm $MKFILE.tmp
247
248}
249
250if [[ -e Config.in ]] ; then
251 echo -e "\n\tThis script must be run from inside a target package directory.\n"
252 exit 1
253fi
254
255if [[ ! -d scripts ]] ; then
256 echo -e "\n\tNo ./scripts/ directory has been found.\n"
257 exit 1
258fi
259
260generate_Makefile
261
262cp ../progress_bar.sh .
263
264mkdir -p logs
Note: See TracBrowser for help on using the repository browser.