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
Line 
1#####
2#
3#
4#
5# $Id$
6#####
7
8# TEMPORARY VARIABLES.. development use only
9declare MKFILE=devMakefile
10declare PREV_PACKAGE=""
11declare SCRIPT_ROOT=jhalfs
12declare BUILD_SCRIPTS=scripts
13declare TRACKING_DIR=/var/lib/jhalfs/BLFS
14declare BUILDDIR=~/TRIAL
15
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)
27 @./progress_bar.sh \$@ &
28EOF
29) >> $MKFILE.tmp
30}
31
32
33
34#----------------------------------#
35__write_build_cmd() { #
36#----------------------------------#
37 local this_script=$1
38 local file=$2
39(
40cat << EOF
41 @( time { export LFS=\$(MOUNT_PT) && ${BUILD_SCRIPTS}/${file} >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
42EOF
43) >> $MKFILE.tmp
44}
45
46#----------------------------------#
47__wrt_touch() { #
48#----------------------------------#
49 local pkg_name=$1
50(
51cat << 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)
57EOF
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#----------------------------#
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
118PACKAGE= "`basename $PKGXML .xml`"
119TRACKING_DIR= $TRACKING_DIR
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
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 )
145EOF
146) > $MKFILE
147
148 cat $MKFILE.tmp >> $MKFILE
149 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
150
151 rm $MKFILE.tmp
152
153}
Note: See TracBrowser for help on using the repository browser.