source: BLFS/gen-makefile.sh@ 2d0a2e5

experimental
Last change on this file since 2d0a2e5 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
RevLine 
[d0d9e90]1#!/bin/bash
[cace19a4]2#
3# $Id$
[d0d9e90]4#
5set -e
6
[2d0a2e5]7# Uncomment this when reasy to be used
8#source ../configuration
[cace333e]9
10# TEMPORARY VARIABLES.. development use only
[d0d9e90]11declare MKFILE=Makefile
[cace333e]12declare PREV_PACKAGE=""
[5d93cec]13declare BUILD_SCRIPTS=scripts
[2d0a2e5]14# Remove this when we can use configuration
[5d93cec]15declare TRACKING_DIR=/var/lib/jhalfs/BLFS
[c62275f6]16
[d0d9e90]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
[cace333e]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)
[c62275f6]33 @./progress_bar.sh \$@ &
[cace333e]34EOF
35) >> $MKFILE.tmp
36}
37
38
39
40#----------------------------------#
[c62275f6]41__write_build_cmd() { #
[cace333e]42#----------------------------------#
43(
44cat << EOF
[2fedf49]45 @source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
[cace333e]46EOF
47) >> $MKFILE.tmp
48}
49
50#----------------------------------#
51__wrt_touch() { #
52#----------------------------------#
[c62275f6]53 local pkg_name=$1
[b928382]54 local pkg_ver=$2
[5743d54]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
[cace333e]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#----------------------------#
[c62275f6]78 local script_name=$1
[b928382]79 local pkg_ver=$2
[5743d54]80
[c62275f6]81 echo -n "${tab_}${tab_} entry for <$script_name>"
[cace333e]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.
[c62275f6]89 __wrt_target "${script_name}" "$PREV_PACKAGE"
[d0d9e90]90 __write_build_cmd
[cace333e]91
92 # Include a touch of the target name so make can check
93 # if it's already been made.
[b928382]94 __wrt_touch "${script_name}" "${pkg_ver}"
[cace333e]95 #
96 #--------------------------------------------------------------------#
97 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
98 #--------------------------------------------------------------------#
[c62275f6]99 echo " .. OK"
[cace333e]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
[d0d9e90]113
[cace333e]114 for package_script in scripts/* ; do
115 this_script=`basename $package_script`
[5743d54]116 pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
[5f14bd3]117 pkg_list="$pkg_list ${this_script}"
118 __write_entry "${this_script}" "${pkg_ver}"
119 PREV_PACKAGE=${this_script}
[cace333e]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
[d0d9e90]129PACKAGE= "`basename $PWD`"
[c62275f6]130TRACKING_DIR= $TRACKING_DIR
[cace333e]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
[5d93cec]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 )
[cace333e]156EOF
157) > $MKFILE
158
159 cat $MKFILE.tmp >> $MKFILE
160 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
161
[c62275f6]162 rm $MKFILE.tmp
163
[cace333e]164}
[d0d9e90]165
166generate_Makefile
167
168cp ../progress_bar.sh .
169
170mkdir -p logs
Note: See TracBrowser for help on using the repository browser.