source: BLFS/gen-makefile.sh@ b7654ff

experimental
Last change on this file since b7654ff was f694f27, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Last changes to can track installed meta-packages.

  • Property mode set to 100755
File size: 5.4 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 jhalfs
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 \$@ &
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 @touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
59EOF
60) >> $MKFILE.tmp
61 fi
62
63 case $pkg_name in
64 *-alsa-lib ) #this the unique mandatory package for ALSA support.
65(
66cat << EOF
67 @touch \$(TRACKING_DIR)/alsa-${alsa_ver}
68EOF
69) >> $MKFILE.tmp
70 ;;
71 *-kdebase )
72(
73cat << EOF
74 @touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
75EOF
76) >> $MKFILE.tmp
77 ;;
78 *-xorg7-driver ) # xtrerm2 and rman are optional
79(
80cat << EOF
81 @touch \$(TRACKING_DIR)/xorg7-${xorg7_ver}
82EOF
83) >> $MKFILE.tmp
84 ;;
85 esac
86
87(
88cat << EOF
89 @touch \$@ && \\
90 sleep .25 && \\
91 echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
92 echo --------------------------------------------------------------------------------\$(WHITE)
93EOF
94) >> $MKFILE.tmp
95}
96
97
98#----------------------------#
99__write_entry() { #
100#----------------------------#
101 local script_name=$1
102 local pkg_ver=$2
103
104 echo -n "${tab_}${tab_} entry for <$script_name>"
105
106 #--------------------------------------------------------------------#
107 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
108 #--------------------------------------------------------------------#
109 #
110 # Drop in the name of the target on a new line, and the previous target
111 # as a dependency. Also call the echo_message function.
112 __wrt_target "${script_name}" "$PREV_PACKAGE"
113 __write_build_cmd
114
115 # Include a touch of the target name so make can check
116 # if it's already been made.
117 __wrt_touch "${script_name}" "${pkg_ver}"
118 #
119 #--------------------------------------------------------------------#
120 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
121 #--------------------------------------------------------------------#
122 echo " .. OK"
123}
124
125#----------------------------#
126__write_meta_pkg_touch() { #
127#----------------------------#
128 local meta_pkg=$1
129 local pkg_ver=$(grep "^${meta_pkg}[[:space:]]" ../packages | cut -f3)
130 local gnome_core_ver=$(grep "^gnome-core[[:space:]]" ../packages | cut -f3)
131 local kde_full_ver=$(grep "^kde-full[[:space:]]" ../packages | cut -f3)
132
133(
134cat << EOF
135
136999-z-$meta_pkg: $PREV_PACKAGE
137 @touch \$(TRACKING_DIR)/${meta_pkg}-${pkg_ver}
138EOF
139) >> $MKFILE.tmp
140
141 case $meta_pkg in
142 gnome-full )
143(
144cat << EOF
145 @touch \$(TRACKING_DIR)/gnome-core-${gnome_core_ver}
146EOF
147) >> $MKFILE.tmp
148 ;;
149 kde-koffice )
150(
151cat << EOF
152 @touch \$(TRACKING_DIR)/kde-full-${kde_full_ver}
153EOF
154) >> $MKFILE.tmp
155 ;;
156 esac
157
158(
159cat << EOF
160 @touch \$@
161EOF
162) >> $MKFILE.tmp
163
164}
165
166#----------------------------#
167generate_Makefile () { #
168#----------------------------#
169
170
171 echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
172
173 # Start with a clean files
174 >$MKFILE
175 >$MKFILE.tmp
176
177
178 for package_script in scripts/* ; do
179 this_script=`basename $package_script`
180 pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
181 pkg_list="$pkg_list ${this_script}"
182 __write_entry "${this_script}" "${pkg_ver}"
183 PREV_PACKAGE=${this_script}
184 done
185
186 PACKAGE=$(basename $PWD)
187
188 # alsa, kde-core and xorg7 are also available dependencies, thus handled
189 # in another way.
190 case $PACKAGE in
191 gnome-core | \
192 gnome-full | \
193 kde-full | \
194 kde-koffice ) pkg_list="$pkg_list 999-z-${PACKAGE}"
195 __write_meta_pkg_touch "${PACKAGE}"
196 ;;
197 esac
198
199
200 # Add a header, some variables and include the function file
201 # to the top of the real Makefile.
202(
203 cat << EOF
204$HEADER
205
206PACKAGE= $PACKAGE
207TRACKING_DIR= $TRACKING_DIR
208
209BOLD= "[0;1m"
210RED= "[1;31m"
211GREEN= "[0;32m"
212ORANGE= "[0;33m"
213BLUE= "[1;34m"
214WHITE= "[00m"
215
216define echo_message
217 @echo \$(BOLD)
218 @echo --------------------------------------------------------------------------------
219 @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
220 @echo \$(WHITE)
221endef
222
223
224define fin_message
225 @echo \$(BOLD)
226 @echo --------------------------------------------------------------------------------
227 @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
228 @echo \$(WHITE)
229endef
230
231all : $pkg_list
232 @\$(call fin_message )
233EOF
234) > $MKFILE
235
236 cat $MKFILE.tmp >> $MKFILE
237 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
238
239 rm $MKFILE.tmp
240
241}
242
243generate_Makefile
244
245cp ../progress_bar.sh .
246
247mkdir -p logs
Note: See TracBrowser for help on using the repository browser.