1 | #####
|
---|
2 | #
|
---|
3 | #
|
---|
4 | #
|
---|
5 | # $Id$
|
---|
6 | #####
|
---|
7 |
|
---|
8 | # TEMPORARY VARIABLES.. development use only
|
---|
9 | declare MKFILE=devMakefile
|
---|
10 | declare PREV_PACKAGE=""
|
---|
11 | declare BUILD_SCRIPTS=scripts
|
---|
12 | declare TRACKING_DIR=/var/lib/jhalfs/BLFS
|
---|
13 |
|
---|
14 |
|
---|
15 | #----------------------------------#
|
---|
16 | __wrt_target() { # Create target and initialize log file
|
---|
17 | #----------------------------------#
|
---|
18 | local i=$1
|
---|
19 | local PREV=$2
|
---|
20 | (
|
---|
21 | cat << EOF
|
---|
22 |
|
---|
23 | $i: $PREV
|
---|
24 | @\$(call echo_message, Building)
|
---|
25 | @./progress_bar.sh \$@ &
|
---|
26 | EOF
|
---|
27 | ) >> $MKFILE.tmp
|
---|
28 | }
|
---|
29 |
|
---|
30 |
|
---|
31 |
|
---|
32 | #----------------------------------#
|
---|
33 | __write_build_cmd() { #
|
---|
34 | #----------------------------------#
|
---|
35 | local this_script=$1
|
---|
36 | local file=$2
|
---|
37 | (
|
---|
38 | cat << EOF
|
---|
39 | @( time { ${BUILD_SCRIPTS}/${file} >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
|
---|
40 | EOF
|
---|
41 | ) >> $MKFILE.tmp
|
---|
42 | }
|
---|
43 |
|
---|
44 | #----------------------------------#
|
---|
45 | __wrt_touch() { #
|
---|
46 | #----------------------------------#
|
---|
47 | local pkg_name=$1
|
---|
48 | (
|
---|
49 | cat << EOF
|
---|
50 | @touch \$@ && \\
|
---|
51 | touch \$(TRACKING_DIR)/${pkg_name#*-} && \\
|
---|
52 | sleep .25 && \\
|
---|
53 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
54 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
55 | EOF
|
---|
56 | ) >> $MKFILE.tmp
|
---|
57 | }
|
---|
58 |
|
---|
59 |
|
---|
60 | #----------------------------#
|
---|
61 | __write_entry() { #
|
---|
62 | #----------------------------#
|
---|
63 | local script_name=$1
|
---|
64 |
|
---|
65 | echo -n "${tab_}${tab_} entry for <$script_name>"
|
---|
66 |
|
---|
67 | #--------------------------------------------------------------------#
|
---|
68 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
69 | #--------------------------------------------------------------------#
|
---|
70 | #
|
---|
71 | # Drop in the name of the target on a new line, and the previous target
|
---|
72 | # as a dependency. Also call the echo_message function.
|
---|
73 | __wrt_target "${script_name}" "$PREV_PACKAGE"
|
---|
74 | __write_build_cmd "${script_name}" "${script_name}"
|
---|
75 |
|
---|
76 | # Include a touch of the target name so make can check
|
---|
77 | # if it's already been made.
|
---|
78 | __wrt_touch "${script_name}"
|
---|
79 | #
|
---|
80 | #--------------------------------------------------------------------#
|
---|
81 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
82 | #--------------------------------------------------------------------#
|
---|
83 | echo " .. OK"
|
---|
84 | }
|
---|
85 |
|
---|
86 | #----------------------------#
|
---|
87 | generate_Makefile () { #
|
---|
88 | #----------------------------#
|
---|
89 |
|
---|
90 |
|
---|
91 | echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
|
---|
92 |
|
---|
93 | # Start with a clean files
|
---|
94 | >$MKFILE
|
---|
95 | >$MKFILE.tmp
|
---|
96 |
|
---|
97 |
|
---|
98 | for package_script in scripts/* ; do
|
---|
99 | this_script=`basename $package_script`
|
---|
100 | if [ ! -e $TRACKING_DIR/${this_script#*-} ]; then
|
---|
101 | pkg_list="$pkg_list ${this_script}"
|
---|
102 | __write_entry $this_script
|
---|
103 | PREV_PACKAGE=${this_script}
|
---|
104 | fi
|
---|
105 | done
|
---|
106 |
|
---|
107 |
|
---|
108 | # Add a header, some variables and include the function file
|
---|
109 | # to the top of the real Makefile.
|
---|
110 | (
|
---|
111 | cat << EOF
|
---|
112 | $HEADER
|
---|
113 |
|
---|
114 | PACKAGE= "`basename $PKGXML .xml`"
|
---|
115 | TRACKING_DIR= $TRACKING_DIR
|
---|
116 |
|
---|
117 | BOLD= "[0;1m"
|
---|
118 | RED= "[1;31m"
|
---|
119 | GREEN= "[0;32m"
|
---|
120 | ORANGE= "[0;33m"
|
---|
121 | BLUE= "[1;34m"
|
---|
122 | WHITE= "[00m"
|
---|
123 |
|
---|
124 | define echo_message
|
---|
125 | @echo \$(BOLD)
|
---|
126 | @echo --------------------------------------------------------------------------------
|
---|
127 | @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
---|
128 | @echo \$(WHITE)
|
---|
129 | endef
|
---|
130 |
|
---|
131 |
|
---|
132 | define fin_message
|
---|
133 | @echo \$(BOLD)
|
---|
134 | @echo --------------------------------------------------------------------------------
|
---|
135 | @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
---|
136 | @echo \$(WHITE)
|
---|
137 | endef
|
---|
138 |
|
---|
139 | all : $pkg_list
|
---|
140 | @\$(call fin_message )
|
---|
141 | EOF
|
---|
142 | ) > $MKFILE
|
---|
143 |
|
---|
144 | cat $MKFILE.tmp >> $MKFILE
|
---|
145 | echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
146 |
|
---|
147 | rm $MKFILE.tmp
|
---|
148 |
|
---|
149 | }
|
---|