[d0d9e90] | 1 | #!/bin/bash
|
---|
[cace19a4] | 2 | #
|
---|
| 3 | # $Id$
|
---|
[d0d9e90] | 4 | #
|
---|
| 5 | set -e
|
---|
| 6 |
|
---|
| 7 |
|
---|
[cace333e] | 8 |
|
---|
| 9 | # TEMPORARY VARIABLES.. development use only
|
---|
[d0d9e90] | 10 | declare MKFILE=Makefile
|
---|
[cace333e] | 11 | declare PREV_PACKAGE=""
|
---|
[5d93cec] | 12 | declare BUILD_SCRIPTS=scripts
|
---|
| 13 | declare TRACKING_DIR=/var/lib/jhalfs/BLFS
|
---|
[c62275f6] | 14 |
|
---|
[d0d9e90] | 15 | HEADER="# 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 | (
|
---|
| 27 | cat << EOF
|
---|
| 28 |
|
---|
| 29 | $i: $PREV
|
---|
| 30 | @\$(call echo_message, Building)
|
---|
[c62275f6] | 31 | @./progress_bar.sh \$@ &
|
---|
[cace333e] | 32 | EOF
|
---|
| 33 | ) >> $MKFILE.tmp
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 |
|
---|
| 38 | #----------------------------------#
|
---|
[c62275f6] | 39 | __write_build_cmd() { #
|
---|
[cace333e] | 40 | #----------------------------------#
|
---|
| 41 | (
|
---|
| 42 | cat << EOF
|
---|
[2fedf49] | 43 | @source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
|
---|
[cace333e] | 44 | EOF
|
---|
| 45 | ) >> $MKFILE.tmp
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | #----------------------------------#
|
---|
| 49 | __wrt_touch() { #
|
---|
| 50 | #----------------------------------#
|
---|
[c62275f6] | 51 | local pkg_name=$1
|
---|
[b928382] | 52 | local pkg_ver=$2
|
---|
[5743d54] | 53 |
|
---|
| 54 | if [[ -n "$pkg_ver" ]] ; then
|
---|
| 55 | (
|
---|
| 56 | cat << EOF
|
---|
| 57 | @touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
|
---|
| 58 | EOF
|
---|
| 59 | ) >> $MKFILE.tmp
|
---|
| 60 | fi
|
---|
| 61 |
|
---|
[cace333e] | 62 | (
|
---|
| 63 | cat << EOF
|
---|
| 64 | @touch \$@ && \\
|
---|
| 65 | sleep .25 && \\
|
---|
| 66 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 67 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 68 | EOF
|
---|
| 69 | ) >> $MKFILE.tmp
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | #----------------------------#
|
---|
| 74 | __write_entry() { #
|
---|
| 75 | #----------------------------#
|
---|
[c62275f6] | 76 | local script_name=$1
|
---|
[b928382] | 77 | local pkg_ver=$2
|
---|
[5743d54] | 78 |
|
---|
[c62275f6] | 79 | echo -n "${tab_}${tab_} entry for <$script_name>"
|
---|
[cace333e] | 80 |
|
---|
| 81 | #--------------------------------------------------------------------#
|
---|
| 82 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 83 | #--------------------------------------------------------------------#
|
---|
| 84 | #
|
---|
| 85 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 86 | # as a dependency. Also call the echo_message function.
|
---|
[c62275f6] | 87 | __wrt_target "${script_name}" "$PREV_PACKAGE"
|
---|
[d0d9e90] | 88 | __write_build_cmd
|
---|
[cace333e] | 89 |
|
---|
| 90 | # Include a touch of the target name so make can check
|
---|
| 91 | # if it's already been made.
|
---|
[b928382] | 92 | __wrt_touch "${script_name}" "${pkg_ver}"
|
---|
[cace333e] | 93 | #
|
---|
| 94 | #--------------------------------------------------------------------#
|
---|
| 95 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 96 | #--------------------------------------------------------------------#
|
---|
[c62275f6] | 97 | echo " .. OK"
|
---|
[cace333e] | 98 | }
|
---|
| 99 |
|
---|
| 100 | #----------------------------#
|
---|
| 101 | generate_Makefile () { #
|
---|
| 102 | #----------------------------#
|
---|
| 103 |
|
---|
| 104 |
|
---|
| 105 | echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
|
---|
| 106 |
|
---|
| 107 | # Start with a clean files
|
---|
| 108 | >$MKFILE
|
---|
| 109 | >$MKFILE.tmp
|
---|
| 110 |
|
---|
[d0d9e90] | 111 |
|
---|
[cace333e] | 112 | for package_script in scripts/* ; do
|
---|
| 113 | this_script=`basename $package_script`
|
---|
[5743d54] | 114 | pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
|
---|
[b928382] | 115 | if [ ! -e $TRACKING_DIR/${this_script#*-?-}-$script_ver ]; then
|
---|
[cace333e] | 116 | pkg_list="$pkg_list ${this_script}"
|
---|
[5743d54] | 117 | __write_entry "${this_script}" "${pkg_ver}"
|
---|
[cace333e] | 118 | PREV_PACKAGE=${this_script}
|
---|
| 119 | fi
|
---|
| 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] | 129 | PACKAGE= "`basename $PWD`"
|
---|
[c62275f6] | 130 | TRACKING_DIR= $TRACKING_DIR
|
---|
[cace333e] | 131 |
|
---|
| 132 | BOLD= "[0;1m"
|
---|
| 133 | RED= "[1;31m"
|
---|
| 134 | GREEN= "[0;32m"
|
---|
| 135 | ORANGE= "[0;33m"
|
---|
| 136 | BLUE= "[1;34m"
|
---|
| 137 | WHITE= "[00m"
|
---|
| 138 |
|
---|
| 139 | define echo_message
|
---|
| 140 | @echo \$(BOLD)
|
---|
| 141 | @echo --------------------------------------------------------------------------------
|
---|
| 142 | @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
---|
| 143 | @echo \$(WHITE)
|
---|
| 144 | endef
|
---|
| 145 |
|
---|
| 146 |
|
---|
[5d93cec] | 147 | define fin_message
|
---|
| 148 | @echo \$(BOLD)
|
---|
| 149 | @echo --------------------------------------------------------------------------------
|
---|
| 150 | @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
---|
| 151 | @echo \$(WHITE)
|
---|
| 152 | endef
|
---|
| 153 |
|
---|
| 154 | all : $pkg_list
|
---|
| 155 | @\$(call fin_message )
|
---|
[cace333e] | 156 | EOF
|
---|
| 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 |
|
---|
| 166 | generate_Makefile
|
---|
| 167 |
|
---|
| 168 | cp ../progress_bar.sh .
|
---|
| 169 |
|
---|
| 170 | mkdir -p logs
|
---|