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

experimental
Last change on this file since 1c2d4d7 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
RevLine 
[d0d9e90]1#!/bin/bash
[cace19a4]2#
3# $Id$
[d0d9e90]4#
5set -e
6
[cace333e]7# TEMPORARY VARIABLES.. development use only
[d0d9e90]8declare MKFILE=Makefile
[cace333e]9declare PREV_PACKAGE=""
[5d93cec]10declare BUILD_SCRIPTS=scripts
[bc40917]11declare TRACKING_DIR=tracking-dir
[c62275f6]12
[d0d9e90]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
[cace333e]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)
[c62275f6]29 @./progress_bar.sh \$@ &
[cace333e]30EOF
31) >> $MKFILE.tmp
32}
33
34
35
36#----------------------------------#
[c62275f6]37__write_build_cmd() { #
[cace333e]38#----------------------------------#
39(
40cat << EOF
[2fedf49]41 @source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
[cace333e]42EOF
43) >> $MKFILE.tmp
44}
45
46#----------------------------------#
47__wrt_touch() { #
48#----------------------------------#
[c62275f6]49 local pkg_name=$1
[b928382]50 local pkg_ver=$2
[f694f27]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)
[5743d54]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
[f694f27]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
[cace333e]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#----------------------------#
[c62275f6]101 local script_name=$1
[b928382]102 local pkg_ver=$2
[5743d54]103
[c62275f6]104 echo -n "${tab_}${tab_} entry for <$script_name>"
[cace333e]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.
[c62275f6]112 __wrt_target "${script_name}" "$PREV_PACKAGE"
[d0d9e90]113 __write_build_cmd
[cace333e]114
115 # Include a touch of the target name so make can check
116 # if it's already been made.
[b928382]117 __wrt_touch "${script_name}" "${pkg_ver}"
[cace333e]118 #
119 #--------------------------------------------------------------------#
120 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
121 #--------------------------------------------------------------------#
[c62275f6]122 echo " .. OK"
[cace333e]123}
124
[431520b]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
[0050352]135
136999-z-$meta_pkg: $PREV_PACKAGE
[431520b]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
[cace333e]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
[d0d9e90]177
[cace333e]178 for package_script in scripts/* ; do
179 this_script=`basename $package_script`
[5743d54]180 pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
[5f14bd3]181 pkg_list="$pkg_list ${this_script}"
182 __write_entry "${this_script}" "${pkg_ver}"
183 PREV_PACKAGE=${this_script}
[cace333e]184 done
185
[431520b]186 PACKAGE=$(basename $PWD)
187
[f694f27]188 # alsa, kde-core and xorg7 are also available dependencies, thus handled
189 # in another way.
[431520b]190 case $PACKAGE in
191 gnome-core | \
192 gnome-full | \
193 kde-full | \
[f694f27]194 kde-koffice ) pkg_list="$pkg_list 999-z-${PACKAGE}"
195 __write_meta_pkg_touch "${PACKAGE}"
196 ;;
[431520b]197 esac
198
[cace333e]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
[431520b]206PACKAGE= $PACKAGE
[c62275f6]207TRACKING_DIR= $TRACKING_DIR
[cace333e]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
[5d93cec]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 )
[cace333e]233EOF
234) > $MKFILE
235
236 cat $MKFILE.tmp >> $MKFILE
237 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
238
[c62275f6]239 rm $MKFILE.tmp
240
[cace333e]241}
[d0d9e90]242
243generate_Makefile
244
245cp ../progress_bar.sh .
246
247mkdir -p logs
Note: See TracBrowser for help on using the repository browser.