[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
|
---|
[cace333e] | 53 | (
|
---|
| 54 | cat << EOF
|
---|
| 55 | @touch \$@ && \\
|
---|
[b928382] | 56 | touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver} && \\
|
---|
[cace333e] | 57 | sleep .25 && \\
|
---|
| 58 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 59 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 60 | EOF
|
---|
| 61 | ) >> $MKFILE.tmp
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | #----------------------------#
|
---|
| 66 | __write_entry() { #
|
---|
| 67 | #----------------------------#
|
---|
[c62275f6] | 68 | local script_name=$1
|
---|
[b928382] | 69 | local pkg_ver=$2
|
---|
| 70 |
|
---|
[c62275f6] | 71 | echo -n "${tab_}${tab_} entry for <$script_name>"
|
---|
[cace333e] | 72 |
|
---|
| 73 | #--------------------------------------------------------------------#
|
---|
| 74 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 75 | #--------------------------------------------------------------------#
|
---|
| 76 | #
|
---|
| 77 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 78 | # as a dependency. Also call the echo_message function.
|
---|
[c62275f6] | 79 | __wrt_target "${script_name}" "$PREV_PACKAGE"
|
---|
[d0d9e90] | 80 | __write_build_cmd
|
---|
[cace333e] | 81 |
|
---|
| 82 | # Include a touch of the target name so make can check
|
---|
| 83 | # if it's already been made.
|
---|
[b928382] | 84 | __wrt_touch "${script_name}" "${pkg_ver}"
|
---|
[cace333e] | 85 | #
|
---|
| 86 | #--------------------------------------------------------------------#
|
---|
| 87 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 88 | #--------------------------------------------------------------------#
|
---|
[c62275f6] | 89 | echo " .. OK"
|
---|
[cace333e] | 90 | }
|
---|
| 91 |
|
---|
| 92 | #----------------------------#
|
---|
| 93 | generate_Makefile () { #
|
---|
| 94 | #----------------------------#
|
---|
| 95 |
|
---|
| 96 |
|
---|
| 97 | echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
|
---|
| 98 |
|
---|
| 99 | # Start with a clean files
|
---|
| 100 | >$MKFILE
|
---|
| 101 | >$MKFILE.tmp
|
---|
| 102 |
|
---|
[d0d9e90] | 103 |
|
---|
[cace333e] | 104 | for package_script in scripts/* ; do
|
---|
| 105 | this_script=`basename $package_script`
|
---|
[b928382] | 106 | script_ver=$(xmllint --noent ../blfs-xml/book/bookinfo.xml 2>/dev/null | \
|
---|
| 107 | grep -i " ${this_script#*-?-}-version " | \
|
---|
| 108 | cut -d "\"" -f2 )
|
---|
| 109 | if [ ! -e $TRACKING_DIR/${this_script#*-?-}-$script_ver ]; then
|
---|
[cace333e] | 110 | pkg_list="$pkg_list ${this_script}"
|
---|
[b928382] | 111 | __write_entry "${this_script}" "${script_ver}"
|
---|
[cace333e] | 112 | PREV_PACKAGE=${this_script}
|
---|
| 113 | fi
|
---|
| 114 | done
|
---|
| 115 |
|
---|
| 116 |
|
---|
| 117 | # Add a header, some variables and include the function file
|
---|
| 118 | # to the top of the real Makefile.
|
---|
| 119 | (
|
---|
| 120 | cat << EOF
|
---|
| 121 | $HEADER
|
---|
| 122 |
|
---|
[d0d9e90] | 123 | PACKAGE= "`basename $PWD`"
|
---|
[c62275f6] | 124 | TRACKING_DIR= $TRACKING_DIR
|
---|
[cace333e] | 125 |
|
---|
| 126 | BOLD= "[0;1m"
|
---|
| 127 | RED= "[1;31m"
|
---|
| 128 | GREEN= "[0;32m"
|
---|
| 129 | ORANGE= "[0;33m"
|
---|
| 130 | BLUE= "[1;34m"
|
---|
| 131 | WHITE= "[00m"
|
---|
| 132 |
|
---|
| 133 | define echo_message
|
---|
| 134 | @echo \$(BOLD)
|
---|
| 135 | @echo --------------------------------------------------------------------------------
|
---|
| 136 | @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
---|
| 137 | @echo \$(WHITE)
|
---|
| 138 | endef
|
---|
| 139 |
|
---|
| 140 |
|
---|
[5d93cec] | 141 | define fin_message
|
---|
| 142 | @echo \$(BOLD)
|
---|
| 143 | @echo --------------------------------------------------------------------------------
|
---|
| 144 | @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
---|
| 145 | @echo \$(WHITE)
|
---|
| 146 | endef
|
---|
| 147 |
|
---|
| 148 | all : $pkg_list
|
---|
| 149 | @\$(call fin_message )
|
---|
[cace333e] | 150 | EOF
|
---|
| 151 | ) > $MKFILE
|
---|
| 152 |
|
---|
| 153 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 154 | echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 155 |
|
---|
[c62275f6] | 156 | rm $MKFILE.tmp
|
---|
| 157 |
|
---|
[cace333e] | 158 | }
|
---|
[d0d9e90] | 159 |
|
---|
| 160 | generate_Makefile
|
---|
| 161 |
|
---|
| 162 | cp ../progress_bar.sh .
|
---|
| 163 |
|
---|
| 164 | mkdir -p logs
|
---|