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