source: BLFS/libs/func_makefile@ 8381f6e

experimental
Last change on this file since 8381f6e was d3f24df, checked in by George Boudreau <georgeb@…>, 18 years ago

trimming some variables from func_makefile

  • Property mode set to 100644
File size: 3.4 KB
Line 
1#####
2#
3#
4#
5# $Id$
6#####
7
8# TEMPORARY VARIABLES.. development use only
9declare MKFILE=devMakefile
10declare PREV_PACKAGE=""
11declare BUILD_SCRIPTS=scripts
12declare 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(
21cat << EOF
22
23$i: $PREV
24 @\$(call echo_message, Building)
25 @./progress_bar.sh \$@ &
26EOF
27) >> $MKFILE.tmp
28}
29
30
31
32#----------------------------------#
33__write_build_cmd() { #
34#----------------------------------#
35 local this_script=$1
36 local file=$2
37(
38cat << EOF
39 @( time { ${BUILD_SCRIPTS}/${file} >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
40EOF
41) >> $MKFILE.tmp
42}
43
44#----------------------------------#
45__wrt_touch() { #
46#----------------------------------#
47 local pkg_name=$1
48(
49cat << 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)
55EOF
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#----------------------------#
87generate_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
114PACKAGE= "`basename $PKGXML .xml`"
115TRACKING_DIR= $TRACKING_DIR
116
117BOLD= "[0;1m"
118RED= "[1;31m"
119GREEN= "[0;32m"
120ORANGE= "[0;33m"
121BLUE= "[1;34m"
122WHITE= "[00m"
123
124define echo_message
125 @echo \$(BOLD)
126 @echo --------------------------------------------------------------------------------
127 @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
128 @echo \$(WHITE)
129endef
130
131
132define fin_message
133 @echo \$(BOLD)
134 @echo --------------------------------------------------------------------------------
135 @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
136 @echo \$(WHITE)
137endef
138
139all : $pkg_list
140 @\$(call fin_message )
141EOF
142) > $MKFILE
143
144 cat $MKFILE.tmp >> $MKFILE
145 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
146
147 rm $MKFILE.tmp
148
149}
Note: See TracBrowser for help on using the repository browser.