source: BLFS/libs/func_makefile@ c62275f6

experimental
Last change on this file since c62275f6 was c62275f6, checked in by George Boudreau <georgeb@…>, 19 years ago

housekeeping on func_makefile

  • Property mode set to 100644
File size: 3.6 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 SCRIPT_ROOT=jhalfs
12declare BUILD_SCRIPTS=scripts
13declare TRACKING_DIR=/var/lib/jhalfs/BLFS
14declare BUILDDIR=~/TRIAL
[c62275f6]15
[cace333e]16
17#----------------------------------#
18__wrt_target() { # Create target and initialize log file
19#----------------------------------#
20 local i=$1
21 local PREV=$2
22(
23cat << EOF
24
25$i: $PREV
26 @\$(call echo_message, Building)
[c62275f6]27 @./progress_bar.sh \$@ &
[cace333e]28EOF
29) >> $MKFILE.tmp
30}
31
32
33
34#----------------------------------#
[c62275f6]35__write_build_cmd() { #
[cace333e]36#----------------------------------#
37 local this_script=$1
38 local file=$2
39(
40cat << EOF
[c62275f6]41 @( time { export LFS=\$(MOUNT_PT) && ${BUILD_SCRIPTS}/${file} >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
[cace333e]42EOF
43) >> $MKFILE.tmp
44}
45
46#----------------------------------#
47__wrt_touch() { #
48#----------------------------------#
[c62275f6]49 local pkg_name=$1
[cace333e]50(
51cat << EOF
52 @touch \$@ && \\
[c62275f6]53 touch \$(TRACKING_DIR)/${pkg_name#*-} && \\
[cace333e]54 sleep .25 && \\
55 echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
56 echo --------------------------------------------------------------------------------\$(WHITE)
57EOF
58) >> $MKFILE.tmp
59}
60
61
62#----------------------------#
63__write_entry() { #
64#----------------------------#
[c62275f6]65 local script_name=$1
[cace333e]66
[c62275f6]67 echo -n "${tab_}${tab_} entry for <$script_name>"
[cace333e]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.
[c62275f6]75 __wrt_target "${script_name}" "$PREV_PACKAGE"
76 __write_build_cmd "${script_name}" "${script_name}"
[cace333e]77
78 # Include a touch of the target name so make can check
79 # if it's already been made.
[c62275f6]80 __wrt_touch "${script_name}"
[cace333e]81 #
82 #--------------------------------------------------------------------#
83 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
84 #--------------------------------------------------------------------#
[c62275f6]85 echo " .. OK"
[cace333e]86}
87
88#----------------------------#
89generate_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
116SRC= /sources
117MOUNT_PT= $BUILDDIR
[5d93cec]118PACKAGE= "`basename $PKGXML .xml`"
[c62275f6]119TRACKING_DIR= $TRACKING_DIR
[cace333e]120
121BOLD= "[0;1m"
122RED= "[1;31m"
123GREEN= "[0;32m"
124ORANGE= "[0;33m"
125BLUE= "[1;34m"
126WHITE= "[00m"
127
128define echo_message
129 @echo \$(BOLD)
130 @echo --------------------------------------------------------------------------------
131 @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
132 @echo \$(WHITE)
133endef
134
135
[5d93cec]136define fin_message
137 @echo \$(BOLD)
138 @echo --------------------------------------------------------------------------------
139 @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
140 @echo \$(WHITE)
141endef
142
143all : $pkg_list
144 @\$(call fin_message )
[cace333e]145EOF
146) > $MKFILE
147
148 cat $MKFILE.tmp >> $MKFILE
149 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
150
[c62275f6]151 rm $MKFILE.tmp
152
[cace333e]153}
Note: See TracBrowser for help on using the repository browser.