source: BLFS/gen-makefile.sh@ b533b78

2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since b533b78 was fc8b962, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

BLFS: Fixed progress_bar.sh run.

  • Property mode set to 100755
File size: 5.9 KB
RevLine 
[6d0dbc3]1#!/bin/bash
[3c10176]2#
3# $Id$
[6d0dbc3]4#
5set -e
6
[3c10176]7# TEMPORARY VARIABLES.. development use only
[6d0dbc3]8declare MKFILE=Makefile
[3c10176]9declare PREV_PACKAGE=""
10declare BUILD_SCRIPTS=scripts
[f4ed135]11declare TRACKING_DIR=tracking-dir
[3c10176]12
[aecb378]13HEADER="# This file is automatically generated by gen-makefile.sh
[6d0dbc3]14# YOU MAY NEED TO EDIT THIS FILE MANUALLY
15#
16# Generated on `date \"+%F %X %Z\"`"
17
[3c10176]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)
[fc8b962]29 @/bin/bash progress_bar.sh \$@ \$\$PPID &
[3c10176]30EOF
31) >> $MKFILE.tmp
32}
33
34
35
36#----------------------------------#
37__write_build_cmd() { #
38#----------------------------------#
39(
40cat << EOF
[57c7bfe]41 @source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
[3c10176]42EOF
43) >> $MKFILE.tmp
44}
45
46#----------------------------------#
47__wrt_touch() { #
48#----------------------------------#
49 local pkg_name=$1
[356f5bb]50 local pkg_ver=$2
[f4ed135]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
[423c229]58 @rm -f \$(TRACKING_DIR)/${pkg_name#*-?-}-{0..9}* && \\
59 touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
[f4ed135]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
[423c229]68 @rm -f \$(TRACKING_DIR)/alsa-{0..9}* && \\
69 touch \$(TRACKING_DIR)/alsa-${alsa_ver}
[f4ed135]70EOF
71) >> $MKFILE.tmp
72 ;;
73 *-kdebase )
74(
75cat << EOF
[423c229]76 @rm -f \$(TRACKING_DIR)/kde-core-{0..9}* && \\
77 touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
[f4ed135]78EOF
79) >> $MKFILE.tmp
80 ;;
81 *-xorg7-driver ) # xtrerm2 and rman are optional
82(
83cat << EOF
[423c229]84 @rm -f \$(TRACKING_DIR)/xorg7-{0..9}* && \\
85 touch \$(TRACKING_DIR)/xorg7-${xorg7_ver}
[f4ed135]86EOF
87) >> $MKFILE.tmp
88 ;;
89 esac
90
[3c10176]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
[356f5bb]106 local pkg_ver=$2
[f4ed135]107
[3c10176]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"
[dc67791]117 __write_build_cmd
[3c10176]118
119 # Include a touch of the target name so make can check
120 # if it's already been made.
[356f5bb]121 __wrt_touch "${script_name}" "${pkg_ver}"
[3c10176]122 #
123 #--------------------------------------------------------------------#
124 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
125 #--------------------------------------------------------------------#
126 echo " .. OK"
127}
128
[f4ed135]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
[423c229]141 @rm -f \$(TRACKING_DIR)/${meta_pkg}-{0..9}* && \\
142 touch \$(TRACKING_DIR)/${meta_pkg}-${pkg_ver}
[f4ed135]143EOF
144) >> $MKFILE.tmp
145
146 case $meta_pkg in
147 gnome-full )
148(
149cat << EOF
[423c229]150 @rm -f \$(TRACKING_DIR)/gnome-core-{0..9}* && \\
151 touch \$(TRACKING_DIR)/gnome-core-${gnome_core_ver}
[f4ed135]152EOF
153) >> $MKFILE.tmp
154 ;;
155 kde-koffice )
156(
157cat << EOF
[423c229]158 @rm -f \$(TRACKING_DIR)/kde-full-{0..9}* && \\
159 touch \$(TRACKING_DIR)/kde-full-${kde_full_ver}
[f4ed135]160EOF
161) >> $MKFILE.tmp
162 ;;
163 esac
164
165(
166cat << EOF
167 @touch \$@
168EOF
169) >> $MKFILE.tmp
170
171}
172
[3c10176]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
[6d0dbc3]184
[3c10176]185 for package_script in scripts/* ; do
186 this_script=`basename $package_script`
[f4ed135]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}
[3c10176]191 done
192
[f4ed135]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
[3c10176]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
[f4ed135]213PACKAGE= $PACKAGE
[3c10176]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}
[6d0dbc3]249
[aecb378]250if [[ -e Config.in ]] ; then
[ae158a6]251 echo -e "\n\tThis script must be run from inside a target package directory.\n"
[aecb378]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
[6d0dbc3]260generate_Makefile
261
262cp ../progress_bar.sh .
263
264mkdir -p logs
Note: See TracBrowser for help on using the repository browser.