1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # $Id$
|
---|
4 | #
|
---|
5 | set -e
|
---|
6 |
|
---|
7 | # TEMPORARY VARIABLES.. development use only
|
---|
8 | declare MKFILE=Makefile
|
---|
9 | declare PREV_PACKAGE=""
|
---|
10 | declare BUILD_SCRIPTS=scripts
|
---|
11 | declare TRACKING_DIR=tracking-dir
|
---|
12 |
|
---|
13 | HEADER="# 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 | (
|
---|
25 | cat << EOF
|
---|
26 |
|
---|
27 | $i: $PREV
|
---|
28 | @\$(call echo_message, Building)
|
---|
29 | @./progress_bar.sh \$@ &
|
---|
30 | EOF
|
---|
31 | ) >> $MKFILE.tmp
|
---|
32 | }
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | #----------------------------------#
|
---|
37 | __write_build_cmd() { #
|
---|
38 | #----------------------------------#
|
---|
39 | (
|
---|
40 | cat << EOF
|
---|
41 | @source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
|
---|
42 | EOF
|
---|
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 | (
|
---|
57 | cat << EOF
|
---|
58 | @rm -f \$(TRACKING_DIR)/${pkg_name#*-?-}-{0..9}* && \\
|
---|
59 | touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
|
---|
60 | EOF
|
---|
61 | ) >> $MKFILE.tmp
|
---|
62 | fi
|
---|
63 |
|
---|
64 | case $pkg_name in
|
---|
65 | *-alsa-lib ) #this the unique mandatory package for ALSA support.
|
---|
66 | (
|
---|
67 | cat << EOF
|
---|
68 | @rm -f \$(TRACKING_DIR)/alsa-{0..9}* && \\
|
---|
69 | touch \$(TRACKING_DIR)/alsa-${alsa_ver}
|
---|
70 | EOF
|
---|
71 | ) >> $MKFILE.tmp
|
---|
72 | ;;
|
---|
73 | *-kdebase )
|
---|
74 | (
|
---|
75 | cat << EOF
|
---|
76 | @rm -f \$(TRACKING_DIR)/kde-core-{0..9}* && \\
|
---|
77 | touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
|
---|
78 | EOF
|
---|
79 | ) >> $MKFILE.tmp
|
---|
80 | ;;
|
---|
81 | *-xorg7-driver ) # xtrerm2 and rman are optional
|
---|
82 | (
|
---|
83 | cat << EOF
|
---|
84 | @rm -f \$(TRACKING_DIR)/xorg7-{0..9}* && \\
|
---|
85 | touch \$(TRACKING_DIR)/xorg7-${xorg7_ver}
|
---|
86 | EOF
|
---|
87 | ) >> $MKFILE.tmp
|
---|
88 | ;;
|
---|
89 | esac
|
---|
90 |
|
---|
91 | (
|
---|
92 | cat << EOF
|
---|
93 | @touch \$@ && \\
|
---|
94 | sleep .25 && \\
|
---|
95 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
96 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
97 | EOF
|
---|
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 | (
|
---|
138 | cat << EOF
|
---|
139 |
|
---|
140 | 999-z-$meta_pkg: $PREV_PACKAGE
|
---|
141 | @rm -f \$(TRACKING_DIR)/${meta_pkg}-{0..9}* && \\
|
---|
142 | touch \$(TRACKING_DIR)/${meta_pkg}-${pkg_ver}
|
---|
143 | EOF
|
---|
144 | ) >> $MKFILE.tmp
|
---|
145 |
|
---|
146 | case $meta_pkg in
|
---|
147 | gnome-full )
|
---|
148 | (
|
---|
149 | cat << EOF
|
---|
150 | @rm -f \$(TRACKING_DIR)/gnome-core-{0..9}* && \\
|
---|
151 | touch \$(TRACKING_DIR)/gnome-core-${gnome_core_ver}
|
---|
152 | EOF
|
---|
153 | ) >> $MKFILE.tmp
|
---|
154 | ;;
|
---|
155 | kde-koffice )
|
---|
156 | (
|
---|
157 | cat << EOF
|
---|
158 | @rm -f \$(TRACKING_DIR)/kde-full-{0..9}* && \\
|
---|
159 | touch \$(TRACKING_DIR)/kde-full-${kde_full_ver}
|
---|
160 | EOF
|
---|
161 | ) >> $MKFILE.tmp
|
---|
162 | ;;
|
---|
163 | esac
|
---|
164 |
|
---|
165 | (
|
---|
166 | cat << EOF
|
---|
167 | @touch \$@
|
---|
168 | EOF
|
---|
169 | ) >> $MKFILE.tmp
|
---|
170 |
|
---|
171 | }
|
---|
172 |
|
---|
173 | #----------------------------#
|
---|
174 | generate_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 |
|
---|
213 | PACKAGE= $PACKAGE
|
---|
214 | TRACKING_DIR= $TRACKING_DIR
|
---|
215 |
|
---|
216 | BOLD= "[0;1m"
|
---|
217 | RED= "[1;31m"
|
---|
218 | GREEN= "[0;32m"
|
---|
219 | ORANGE= "[0;33m"
|
---|
220 | BLUE= "[1;34m"
|
---|
221 | WHITE= "[00m"
|
---|
222 |
|
---|
223 | define echo_message
|
---|
224 | @echo \$(BOLD)
|
---|
225 | @echo --------------------------------------------------------------------------------
|
---|
226 | @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
---|
227 | @echo \$(WHITE)
|
---|
228 | endef
|
---|
229 |
|
---|
230 |
|
---|
231 | define fin_message
|
---|
232 | @echo \$(BOLD)
|
---|
233 | @echo --------------------------------------------------------------------------------
|
---|
234 | @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
---|
235 | @echo \$(WHITE)
|
---|
236 | endef
|
---|
237 |
|
---|
238 | all : $pkg_list
|
---|
239 | @\$(call fin_message )
|
---|
240 | EOF
|
---|
241 | ) > $MKFILE
|
---|
242 |
|
---|
243 | cat $MKFILE.tmp >> $MKFILE
|
---|
244 | echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
245 |
|
---|
246 | rm $MKFILE.tmp
|
---|
247 |
|
---|
248 | }
|
---|
249 |
|
---|
250 | generate_Makefile
|
---|
251 |
|
---|
252 | cp ../progress_bar.sh .
|
---|
253 |
|
---|
254 | mkdir -p logs
|
---|