source: BLFS/gen-makefile.sh@ 9ddc6cf

experimental
Last change on this file since 9ddc6cf was 2d0a2e5, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Making TRACKING_DIR a configurable value.

  • Property mode set to 100755
File size: 3.8 KB
Line 
1#!/bin/bash
2#
3# $Id$
4#
5set -e
6
7# Uncomment this when reasy to be used
8#source ../configuration
9
10# TEMPORARY VARIABLES.. development use only
11declare MKFILE=Makefile
12declare PREV_PACKAGE=""
13declare BUILD_SCRIPTS=scripts
14# Remove this when we can use configuration
15declare TRACKING_DIR=/var/lib/jhalfs/BLFS
16
17HEADER="# This file is automatically generated by jhalfs
18# YOU MAY NEED TO EDIT THIS FILE MANUALLY
19#
20# Generated on `date \"+%F %X %Z\"`"
21
22
23#----------------------------------#
24__wrt_target() { # Create target and initialize log file
25#----------------------------------#
26 local i=$1
27 local PREV=$2
28(
29cat << EOF
30
31$i: $PREV
32 @\$(call echo_message, Building)
33 @./progress_bar.sh \$@ &
34EOF
35) >> $MKFILE.tmp
36}
37
38
39
40#----------------------------------#
41__write_build_cmd() { #
42#----------------------------------#
43(
44cat << EOF
45 @source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
46EOF
47) >> $MKFILE.tmp
48}
49
50#----------------------------------#
51__wrt_touch() { #
52#----------------------------------#
53 local pkg_name=$1
54 local pkg_ver=$2
55
56 if [[ -n "$pkg_ver" ]] ; then
57(
58cat << EOF
59 @touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
60EOF
61) >> $MKFILE.tmp
62 fi
63
64(
65cat << EOF
66 @touch \$@ && \\
67 sleep .25 && \\
68 echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
69 echo --------------------------------------------------------------------------------\$(WHITE)
70EOF
71) >> $MKFILE.tmp
72}
73
74
75#----------------------------#
76__write_entry() { #
77#----------------------------#
78 local script_name=$1
79 local pkg_ver=$2
80
81 echo -n "${tab_}${tab_} entry for <$script_name>"
82
83 #--------------------------------------------------------------------#
84 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
85 #--------------------------------------------------------------------#
86 #
87 # Drop in the name of the target on a new line, and the previous target
88 # as a dependency. Also call the echo_message function.
89 __wrt_target "${script_name}" "$PREV_PACKAGE"
90 __write_build_cmd
91
92 # Include a touch of the target name so make can check
93 # if it's already been made.
94 __wrt_touch "${script_name}" "${pkg_ver}"
95 #
96 #--------------------------------------------------------------------#
97 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
98 #--------------------------------------------------------------------#
99 echo " .. OK"
100}
101
102#----------------------------#
103generate_Makefile () { #
104#----------------------------#
105
106
107 echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
108
109 # Start with a clean files
110 >$MKFILE
111 >$MKFILE.tmp
112
113
114 for package_script in scripts/* ; do
115 this_script=`basename $package_script`
116 pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
117 pkg_list="$pkg_list ${this_script}"
118 __write_entry "${this_script}" "${pkg_ver}"
119 PREV_PACKAGE=${this_script}
120 done
121
122
123 # Add a header, some variables and include the function file
124 # to the top of the real Makefile.
125(
126 cat << EOF
127$HEADER
128
129PACKAGE= "`basename $PWD`"
130TRACKING_DIR= $TRACKING_DIR
131
132BOLD= "[0;1m"
133RED= "[1;31m"
134GREEN= "[0;32m"
135ORANGE= "[0;33m"
136BLUE= "[1;34m"
137WHITE= "[00m"
138
139define echo_message
140 @echo \$(BOLD)
141 @echo --------------------------------------------------------------------------------
142 @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
143 @echo \$(WHITE)
144endef
145
146
147define fin_message
148 @echo \$(BOLD)
149 @echo --------------------------------------------------------------------------------
150 @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
151 @echo \$(WHITE)
152endef
153
154all : $pkg_list
155 @\$(call fin_message )
156EOF
157) > $MKFILE
158
159 cat $MKFILE.tmp >> $MKFILE
160 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
161
162 rm $MKFILE.tmp
163
164}
165
166generate_Makefile
167
168cp ../progress_bar.sh .
169
170mkdir -p logs
Note: See TracBrowser for help on using the repository browser.