source: BLFS/gen-makefile.sh@ 03e4b5b

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

Making use off installed version from packages database.
Not full tested yet.

  • Property mode set to 100755
File size: 3.7 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
52 if [[ -n "$pkg_ver" ]] ; then
53(
54cat << EOF
55 @touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
56EOF
57) >> $MKFILE.tmp
58 fi
59
60(
61cat << EOF
62 @touch \$@ && \\
63 sleep .25 && \\
64 echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
65 echo --------------------------------------------------------------------------------\$(WHITE)
66EOF
67) >> $MKFILE.tmp
68}
69
70
71#----------------------------#
72__write_entry() { #
73#----------------------------#
74 local script_name=$1
75 local pkg_ver=$2
76
77 echo -n "${tab_}${tab_} entry for <$script_name>"
78
79 #--------------------------------------------------------------------#
80 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
81 #--------------------------------------------------------------------#
82 #
83 # Drop in the name of the target on a new line, and the previous target
84 # as a dependency. Also call the echo_message function.
85 __wrt_target "${script_name}" "$PREV_PACKAGE"
86 __write_build_cmd
87
88 # Include a touch of the target name so make can check
89 # if it's already been made.
90 __wrt_touch "${script_name}" "${pkg_ver}"
91 #
92 #--------------------------------------------------------------------#
93 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
94 #--------------------------------------------------------------------#
95 echo " .. OK"
96}
97
98#----------------------------#
99generate_Makefile () { #
100#----------------------------#
101
102
103 echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
104
105 # Start with a clean files
106 >$MKFILE
107 >$MKFILE.tmp
108
109
110 for package_script in scripts/* ; do
111 this_script=`basename $package_script`
112 pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
113 pkg_list="$pkg_list ${this_script}"
114 __write_entry "${this_script}" "${pkg_ver}"
115 PREV_PACKAGE=${this_script}
116 done
117
118
119 # Add a header, some variables and include the function file
120 # to the top of the real Makefile.
121(
122 cat << EOF
123$HEADER
124
125PACKAGE= "`basename $PWD`"
126TRACKING_DIR= $TRACKING_DIR
127
128BOLD= "[0;1m"
129RED= "[1;31m"
130GREEN= "[0;32m"
131ORANGE= "[0;33m"
132BLUE= "[1;34m"
133WHITE= "[00m"
134
135define echo_message
136 @echo \$(BOLD)
137 @echo --------------------------------------------------------------------------------
138 @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
139 @echo \$(WHITE)
140endef
141
142
143define fin_message
144 @echo \$(BOLD)
145 @echo --------------------------------------------------------------------------------
146 @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
147 @echo \$(WHITE)
148endef
149
150all : $pkg_list
151 @\$(call fin_message )
152EOF
153) > $MKFILE
154
155 cat $MKFILE.tmp >> $MKFILE
156 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
157
158 rm $MKFILE.tmp
159
160}
161
162generate_Makefile
163
164cp ../progress_bar.sh .
165
166mkdir -p logs
Note: See TracBrowser for help on using the repository browser.