source: BLFS/gen-makefile.sh@ d0d9e90

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

Merged r2925:2931 from trunk

  • Property mode set to 100755
File size: 3.5 KB
RevLine 
[d0d9e90]1#!/bin/bash
[cace19a4]2#
3# $Id$
[d0d9e90]4#
5set -e
6
7
[cace333e]8
9# TEMPORARY VARIABLES.. development use only
[d0d9e90]10declare MKFILE=Makefile
[cace333e]11declare PREV_PACKAGE=""
[5d93cec]12declare BUILD_SCRIPTS=scripts
13declare TRACKING_DIR=/var/lib/jhalfs/BLFS
[c62275f6]14
[d0d9e90]15HEADER="# This file is automatically generated by jhalfs
16# YOU MAY NEED TO EDIT THIS FILE MANUALLY
17#
18# Generated on `date \"+%F %X %Z\"`"
19
[cace333e]20
21#----------------------------------#
22__wrt_target() { # Create target and initialize log file
23#----------------------------------#
24 local i=$1
25 local PREV=$2
26(
27cat << EOF
28
29$i: $PREV
30 @\$(call echo_message, Building)
[c62275f6]31 @./progress_bar.sh \$@ &
[cace333e]32EOF
33) >> $MKFILE.tmp
34}
35
36
37
38#----------------------------------#
[c62275f6]39__write_build_cmd() { #
[cace333e]40#----------------------------------#
41(
42cat << EOF
[d0d9e90]43 @source ../makefile.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
[cace333e]44EOF
45) >> $MKFILE.tmp
46}
47
48#----------------------------------#
49__wrt_touch() { #
50#----------------------------------#
[c62275f6]51 local pkg_name=$1
[cace333e]52(
53cat << EOF
54 @touch \$@ && \\
[d0d9e90]55 touch \$(TRACKING_DIR)/${pkg_name#*-?-} && \\
[cace333e]56 sleep .25 && \\
57 echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
58 echo --------------------------------------------------------------------------------\$(WHITE)
59EOF
60) >> $MKFILE.tmp
61}
62
63
64#----------------------------#
65__write_entry() { #
66#----------------------------#
[c62275f6]67 local script_name=$1
[cace333e]68
[c62275f6]69 echo -n "${tab_}${tab_} entry for <$script_name>"
[cace333e]70
71 #--------------------------------------------------------------------#
72 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
73 #--------------------------------------------------------------------#
74 #
75 # Drop in the name of the target on a new line, and the previous target
76 # as a dependency. Also call the echo_message function.
[c62275f6]77 __wrt_target "${script_name}" "$PREV_PACKAGE"
[d0d9e90]78 __write_build_cmd
[cace333e]79
80 # Include a touch of the target name so make can check
81 # if it's already been made.
[c62275f6]82 __wrt_touch "${script_name}"
[cace333e]83 #
84 #--------------------------------------------------------------------#
85 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
86 #--------------------------------------------------------------------#
[c62275f6]87 echo " .. OK"
[cace333e]88}
89
90#----------------------------#
91generate_Makefile () { #
92#----------------------------#
93
94
95 echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
96
97 # Start with a clean files
98 >$MKFILE
99 >$MKFILE.tmp
100
[d0d9e90]101
[cace333e]102 for package_script in scripts/* ; do
103 this_script=`basename $package_script`
104 if [ ! -e $TRACKING_DIR/${this_script#*-} ]; then
105 pkg_list="$pkg_list ${this_script}"
106 __write_entry $this_script
107 PREV_PACKAGE=${this_script}
108 fi
109 done
110
111
112 # Add a header, some variables and include the function file
113 # to the top of the real Makefile.
114(
115 cat << EOF
116$HEADER
117
[d0d9e90]118PACKAGE= "`basename $PWD`"
[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}
[d0d9e90]154
155generate_Makefile
156
157cp ../progress_bar.sh .
158
159mkdir -p logs
Note: See TracBrowser for help on using the repository browser.