[41d4c11] | 1 | #####
|
---|
| 2 | #
|
---|
| 3 | #
|
---|
[cace19a4] | 4 | #
|
---|
| 5 | # $Id$
|
---|
[41d4c11] | 6 | #####
|
---|
[cace333e] | 7 |
|
---|
| 8 | # TEMPORARY VARIABLES.. development use only
|
---|
| 9 | declare MKFILE=devMakefile
|
---|
| 10 | declare PREV_PACKAGE=""
|
---|
[5d93cec] | 11 | declare BUILD_SCRIPTS=scripts
|
---|
| 12 | declare TRACKING_DIR=/var/lib/jhalfs/BLFS
|
---|
[c62275f6] | 13 |
|
---|
[cace333e] | 14 |
|
---|
| 15 | #----------------------------------#
|
---|
| 16 | __wrt_target() { # Create target and initialize log file
|
---|
| 17 | #----------------------------------#
|
---|
| 18 | local i=$1
|
---|
| 19 | local PREV=$2
|
---|
| 20 | (
|
---|
| 21 | cat << EOF
|
---|
| 22 |
|
---|
| 23 | $i: $PREV
|
---|
| 24 | @\$(call echo_message, Building)
|
---|
[c62275f6] | 25 | @./progress_bar.sh \$@ &
|
---|
[cace333e] | 26 | EOF
|
---|
| 27 | ) >> $MKFILE.tmp
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | #----------------------------------#
|
---|
[c62275f6] | 33 | __write_build_cmd() { #
|
---|
[cace333e] | 34 | #----------------------------------#
|
---|
| 35 | local this_script=$1
|
---|
| 36 | local file=$2
|
---|
| 37 | (
|
---|
| 38 | cat << EOF
|
---|
[d3f24df] | 39 | @( time { ${BUILD_SCRIPTS}/${file} >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
|
---|
[cace333e] | 40 | EOF
|
---|
| 41 | ) >> $MKFILE.tmp
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | #----------------------------------#
|
---|
| 45 | __wrt_touch() { #
|
---|
| 46 | #----------------------------------#
|
---|
[c62275f6] | 47 | local pkg_name=$1
|
---|
[cace333e] | 48 | (
|
---|
| 49 | cat << EOF
|
---|
| 50 | @touch \$@ && \\
|
---|
[c62275f6] | 51 | touch \$(TRACKING_DIR)/${pkg_name#*-} && \\
|
---|
[cace333e] | 52 | sleep .25 && \\
|
---|
| 53 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 54 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 55 | EOF
|
---|
| 56 | ) >> $MKFILE.tmp
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | #----------------------------#
|
---|
| 61 | __write_entry() { #
|
---|
| 62 | #----------------------------#
|
---|
[c62275f6] | 63 | local script_name=$1
|
---|
[cace333e] | 64 |
|
---|
[c62275f6] | 65 | echo -n "${tab_}${tab_} entry for <$script_name>"
|
---|
[cace333e] | 66 |
|
---|
| 67 | #--------------------------------------------------------------------#
|
---|
| 68 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 69 | #--------------------------------------------------------------------#
|
---|
| 70 | #
|
---|
| 71 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 72 | # as a dependency. Also call the echo_message function.
|
---|
[c62275f6] | 73 | __wrt_target "${script_name}" "$PREV_PACKAGE"
|
---|
| 74 | __write_build_cmd "${script_name}" "${script_name}"
|
---|
[cace333e] | 75 |
|
---|
| 76 | # Include a touch of the target name so make can check
|
---|
| 77 | # if it's already been made.
|
---|
[c62275f6] | 78 | __wrt_touch "${script_name}"
|
---|
[cace333e] | 79 | #
|
---|
| 80 | #--------------------------------------------------------------------#
|
---|
| 81 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 82 | #--------------------------------------------------------------------#
|
---|
[c62275f6] | 83 | echo " .. OK"
|
---|
[cace333e] | 84 | }
|
---|
| 85 |
|
---|
| 86 | #----------------------------#
|
---|
| 87 | generate_Makefile () { #
|
---|
| 88 | #----------------------------#
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
|
---|
| 92 |
|
---|
| 93 | # Start with a clean files
|
---|
| 94 | >$MKFILE
|
---|
| 95 | >$MKFILE.tmp
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | for package_script in scripts/* ; do
|
---|
| 99 | this_script=`basename $package_script`
|
---|
| 100 | if [ ! -e $TRACKING_DIR/${this_script#*-} ]; then
|
---|
| 101 | pkg_list="$pkg_list ${this_script}"
|
---|
| 102 | __write_entry $this_script
|
---|
| 103 | PREV_PACKAGE=${this_script}
|
---|
| 104 | fi
|
---|
| 105 | done
|
---|
| 106 |
|
---|
| 107 |
|
---|
| 108 | # Add a header, some variables and include the function file
|
---|
| 109 | # to the top of the real Makefile.
|
---|
| 110 | (
|
---|
| 111 | cat << EOF
|
---|
| 112 | $HEADER
|
---|
| 113 |
|
---|
[5d93cec] | 114 | PACKAGE= "`basename $PKGXML .xml`"
|
---|
[c62275f6] | 115 | TRACKING_DIR= $TRACKING_DIR
|
---|
[cace333e] | 116 |
|
---|
| 117 | BOLD= "[0;1m"
|
---|
| 118 | RED= "[1;31m"
|
---|
| 119 | GREEN= "[0;32m"
|
---|
| 120 | ORANGE= "[0;33m"
|
---|
| 121 | BLUE= "[1;34m"
|
---|
| 122 | WHITE= "[00m"
|
---|
| 123 |
|
---|
| 124 | define echo_message
|
---|
| 125 | @echo \$(BOLD)
|
---|
| 126 | @echo --------------------------------------------------------------------------------
|
---|
| 127 | @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
---|
| 128 | @echo \$(WHITE)
|
---|
| 129 | endef
|
---|
| 130 |
|
---|
| 131 |
|
---|
[5d93cec] | 132 | define fin_message
|
---|
| 133 | @echo \$(BOLD)
|
---|
| 134 | @echo --------------------------------------------------------------------------------
|
---|
| 135 | @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
---|
| 136 | @echo \$(WHITE)
|
---|
| 137 | endef
|
---|
| 138 |
|
---|
| 139 | all : $pkg_list
|
---|
| 140 | @\$(call fin_message )
|
---|
[cace333e] | 141 | EOF
|
---|
| 142 | ) > $MKFILE
|
---|
| 143 |
|
---|
| 144 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 145 | echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 146 |
|
---|
[c62275f6] | 147 | rm $MKFILE.tmp
|
---|
| 148 |
|
---|
[cace333e] | 149 | }
|
---|