source: BLFS/gen-makefile.sh@ 50fb011

experimental
Last change on this file since 50fb011 was 848985f, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Be sure that only the tracking file for the just installed package version is left on TRACKING_DIR.

  • Property mode set to 100755
File size: 5.7 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
[848985f]58 @rm -f \$(TRACKING_DIR)/${pkg_name#*-?-}-{0..9}* && \\
59 touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
[5743d54]60EOF
61) >> $MKFILE.tmp
62 fi
63
[f694f27]64 case $pkg_name in
65 *-alsa-lib ) #this the unique mandatory package for ALSA support.
66(
67cat << EOF
[848985f]68 @rm -f \$(TRACKING_DIR)/alsa-{0..9}* && \\
69 touch \$(TRACKING_DIR)/alsa-${alsa_ver}
[f694f27]70EOF
71) >> $MKFILE.tmp
72 ;;
73 *-kdebase )
74(
75cat << EOF
[848985f]76 @rm -f \$(TRACKING_DIR)/kde-core-{0..9}* && \\
77 touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
[f694f27]78EOF
79) >> $MKFILE.tmp
80 ;;
81 *-xorg7-driver ) # xtrerm2 and rman are optional
82(
83cat << EOF
[848985f]84 @rm -f \$(TRACKING_DIR)/xorg7-{0..9}* && \\
85 touch \$(TRACKING_DIR)/xorg7-${xorg7_ver}
[f694f27]86EOF
87) >> $MKFILE.tmp
88 ;;
89 esac
90
[cace333e]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#----------------------------#
[c62275f6]105 local script_name=$1
[b928382]106 local pkg_ver=$2
[5743d54]107
[c62275f6]108 echo -n "${tab_}${tab_} entry for <$script_name>"
[cace333e]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.
[c62275f6]116 __wrt_target "${script_name}" "$PREV_PACKAGE"
[d0d9e90]117 __write_build_cmd
[cace333e]118
119 # Include a touch of the target name so make can check
120 # if it's already been made.
[b928382]121 __wrt_touch "${script_name}" "${pkg_ver}"
[cace333e]122 #
123 #--------------------------------------------------------------------#
124 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
125 #--------------------------------------------------------------------#
[c62275f6]126 echo " .. OK"
[cace333e]127}
128
[431520b]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
[0050352]139
140999-z-$meta_pkg: $PREV_PACKAGE
[848985f]141 @rm -f \$(TRACKING_DIR)/${meta_pkg}-{0..9}* && \\
142 touch \$(TRACKING_DIR)/${meta_pkg}-${pkg_ver}
[431520b]143EOF
144) >> $MKFILE.tmp
145
146 case $meta_pkg in
147 gnome-full )
148(
149cat << EOF
[848985f]150 @rm -f \$(TRACKING_DIR)/gnome-core-{0..9}* && \\
151 touch \$(TRACKING_DIR)/gnome-core-${gnome_core_ver}
[431520b]152EOF
153) >> $MKFILE.tmp
154 ;;
155 kde-koffice )
156(
157cat << EOF
[848985f]158 @rm -f \$(TRACKING_DIR)/kde-full-{0..9}* && \\
159 touch \$(TRACKING_DIR)/kde-full-${kde_full_ver}
[431520b]160EOF
161) >> $MKFILE.tmp
162 ;;
163 esac
164
165(
166cat << EOF
167 @touch \$@
168EOF
169) >> $MKFILE.tmp
170
171}
172
[cace333e]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
[d0d9e90]184
[cace333e]185 for package_script in scripts/* ; do
186 this_script=`basename $package_script`
[5743d54]187 pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
[5f14bd3]188 pkg_list="$pkg_list ${this_script}"
189 __write_entry "${this_script}" "${pkg_ver}"
190 PREV_PACKAGE=${this_script}
[cace333e]191 done
192
[431520b]193 PACKAGE=$(basename $PWD)
194
[f694f27]195 # alsa, kde-core and xorg7 are also available dependencies, thus handled
196 # in another way.
[431520b]197 case $PACKAGE in
198 gnome-core | \
199 gnome-full | \
200 kde-full | \
[f694f27]201 kde-koffice ) pkg_list="$pkg_list 999-z-${PACKAGE}"
202 __write_meta_pkg_touch "${PACKAGE}"
203 ;;
[431520b]204 esac
205
[cace333e]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
[431520b]213PACKAGE= $PACKAGE
[c62275f6]214TRACKING_DIR= $TRACKING_DIR
[cace333e]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
[5d93cec]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 )
[cace333e]240EOF
241) > $MKFILE
242
243 cat $MKFILE.tmp >> $MKFILE
244 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
245
[c62275f6]246 rm $MKFILE.tmp
247
[cace333e]248}
[d0d9e90]249
250generate_Makefile
251
252cp ../progress_bar.sh .
253
254mkdir -p logs
Note: See TracBrowser for help on using the repository browser.