[d0d9e90] | 1 | #!/bin/bash
|
---|
[cace19a4] | 2 | #
|
---|
| 3 | # $Id$
|
---|
[d0d9e90] | 4 | #
|
---|
| 5 | set -e
|
---|
| 6 |
|
---|
[2d0a2e5] | 7 | # Uncomment this when reasy to be used
|
---|
| 8 | #source ../configuration
|
---|
[cace333e] | 9 |
|
---|
| 10 | # TEMPORARY VARIABLES.. development use only
|
---|
[d0d9e90] | 11 | declare MKFILE=Makefile
|
---|
[cace333e] | 12 | declare PREV_PACKAGE=""
|
---|
[5d93cec] | 13 | declare BUILD_SCRIPTS=scripts
|
---|
[2d0a2e5] | 14 | # Remove this when we can use configuration
|
---|
[5d93cec] | 15 | declare TRACKING_DIR=/var/lib/jhalfs/BLFS
|
---|
[c62275f6] | 16 |
|
---|
[d0d9e90] | 17 | HEADER="# 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 | (
|
---|
| 29 | cat << EOF
|
---|
| 30 |
|
---|
| 31 | $i: $PREV
|
---|
| 32 | @\$(call echo_message, Building)
|
---|
[c62275f6] | 33 | @./progress_bar.sh \$@ &
|
---|
[cace333e] | 34 | EOF
|
---|
| 35 | ) >> $MKFILE.tmp
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | #----------------------------------#
|
---|
[c62275f6] | 41 | __write_build_cmd() { #
|
---|
[cace333e] | 42 | #----------------------------------#
|
---|
| 43 | (
|
---|
| 44 | cat << EOF
|
---|
[2fedf49] | 45 | @source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
|
---|
[cace333e] | 46 | EOF
|
---|
| 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 | (
|
---|
| 58 | cat << EOF
|
---|
| 59 | @touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
|
---|
| 60 | EOF
|
---|
| 61 | ) >> $MKFILE.tmp
|
---|
| 62 | fi
|
---|
| 63 |
|
---|
[cace333e] | 64 | (
|
---|
| 65 | cat << EOF
|
---|
| 66 | @touch \$@ && \\
|
---|
| 67 | sleep .25 && \\
|
---|
| 68 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 69 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 70 | EOF
|
---|
| 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 | #----------------------------#
|
---|
| 103 | generate_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] | 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
|
---|