source: BLFS/libs/func_makefile@ f2382aa

experimental
Last change on this file since f2382aa 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
RevLine 
[41d4c11]1#####
2#
3#
[cace19a4]4#
5# $Id$
[41d4c11]6#####
[cace333e]7
8# TEMPORARY VARIABLES.. development use only
9declare MKFILE=devMakefile
10declare PREV_PACKAGE=""
[5d93cec]11declare BUILD_SCRIPTS=scripts
12declare TRACKING_DIR=/var/lib/jhalfs/BLFS
[c62275f6]13
[cace333e]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)
[c62275f6]25 @./progress_bar.sh \$@ &
[cace333e]26EOF
27) >> $MKFILE.tmp
28}
29
30
31
32#----------------------------------#
[c62275f6]33__write_build_cmd() { #
[cace333e]34#----------------------------------#
35 local this_script=$1
36 local file=$2
37(
38cat << EOF
[d3f24df]39 @( time { ${BUILD_SCRIPTS}/${file} >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
[cace333e]40EOF
41) >> $MKFILE.tmp
42}
43
44#----------------------------------#
45__wrt_touch() { #
46#----------------------------------#
[c62275f6]47 local pkg_name=$1
[cace333e]48(
49cat << EOF
50 @touch \$@ && \\
[c62275f6]51 touch \$(TRACKING_DIR)/${pkg_name#*-} && \\
[cace333e]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#----------------------------#
[c62275f6]63 local script_name=$1
[cace333e]64
[c62275f6]65 echo -n "${tab_}${tab_} entry for <$script_name>"
[cace333e]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.
[c62275f6]73 __wrt_target "${script_name}" "$PREV_PACKAGE"
74 __write_build_cmd "${script_name}" "${script_name}"
[cace333e]75
76 # Include a touch of the target name so make can check
77 # if it's already been made.
[c62275f6]78 __wrt_touch "${script_name}"
[cace333e]79 #
80 #--------------------------------------------------------------------#
81 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
82 #--------------------------------------------------------------------#
[c62275f6]83 echo " .. OK"
[cace333e]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
[5d93cec]114PACKAGE= "`basename $PKGXML .xml`"
[c62275f6]115TRACKING_DIR= $TRACKING_DIR
[cace333e]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
[5d93cec]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 )
[cace333e]141EOF
142) > $MKFILE
143
144 cat $MKFILE.tmp >> $MKFILE
145 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
146
[c62275f6]147 rm $MKFILE.tmp
148
[cace333e]149}
Note: See TracBrowser for help on using the repository browser.