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 | declare LOGDIR=$BUILDDIR/logs
|
---|
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 | EOF
|
---|
28 | ) >> $MKFILE.tmp
|
---|
29 | }
|
---|
30 |
|
---|
31 |
|
---|
32 |
|
---|
33 | #----------------------------------#
|
---|
34 | __write_build_cmd() { # Some scripts must be run as root..
|
---|
35 | #----------------------------------#
|
---|
36 | local this_script=$1
|
---|
37 | local file=$2
|
---|
38 | (
|
---|
39 | cat << EOF
|
---|
40 | @( time { export LFS=\$(MOUNT_PT) && ${BUILD_SCRIPTS}/$file >>\$(LOGDIR)/$this_script 2>&1 ; } ) 2>>\$(LOGDIR)/$this_script
|
---|
41 | EOF
|
---|
42 | ) >> $MKFILE.tmp
|
---|
43 | }
|
---|
44 |
|
---|
45 | #----------------------------------#
|
---|
46 | __wrt_touch() { #
|
---|
47 | #----------------------------------#
|
---|
48 | (
|
---|
49 | cat << EOF
|
---|
50 | @touch \$@ && \\
|
---|
51 | touch /var/lib/jhalfs/BLFS/${1#*-} && \\
|
---|
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 pkg_name=$1
|
---|
64 |
|
---|
65 | echo "${tab_}${tab_} entry for <$pkg_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 "${pkg_name}" "$PREV_PACKAGE"
|
---|
74 | __write_build_cmd "${pkg_name}" "${pkg_name}"
|
---|
75 |
|
---|
76 | # Include a touch of the target name so make can check
|
---|
77 | # if it's already been made.
|
---|
78 | __wrt_touch "${pkg_name}"
|
---|
79 | #
|
---|
80 | #--------------------------------------------------------------------#
|
---|
81 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
82 | #--------------------------------------------------------------------#
|
---|
83 |
|
---|
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 | SRC= /sources
|
---|
115 | MOUNT_PT= $BUILDDIR
|
---|
116 | LOGDIR= $LOGDIR
|
---|
117 | PACKAGE= "`basename $PKGXML .xml`"
|
---|
118 |
|
---|
119 | BOLD= "[0;1m"
|
---|
120 | RED= "[1;31m"
|
---|
121 | GREEN= "[0;32m"
|
---|
122 | ORANGE= "[0;33m"
|
---|
123 | BLUE= "[1;34m"
|
---|
124 | WHITE= "[00m"
|
---|
125 |
|
---|
126 | define echo_message
|
---|
127 | @echo \$(BOLD)
|
---|
128 | @echo --------------------------------------------------------------------------------
|
---|
129 | @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
---|
130 | @echo \$(WHITE)
|
---|
131 | endef
|
---|
132 |
|
---|
133 |
|
---|
134 | define fin_message
|
---|
135 | @echo \$(BOLD)
|
---|
136 | @echo --------------------------------------------------------------------------------
|
---|
137 | @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
---|
138 | @echo \$(WHITE)
|
---|
139 | endef
|
---|
140 |
|
---|
141 | all : $pkg_list
|
---|
142 | @\$(call fin_message )
|
---|
143 | EOF
|
---|
144 | ) > $MKFILE
|
---|
145 |
|
---|
146 |
|
---|
147 | cat $MKFILE.tmp >> $MKFILE
|
---|
148 |
|
---|
149 | echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
150 |
|
---|
151 | }
|
---|