[6d0dbc3] | 1 | #!/bin/bash
|
---|
[3c10176] | 2 | #
|
---|
| 3 | # $Id$
|
---|
[6d0dbc3] | 4 | #
|
---|
| 5 | set -e
|
---|
| 6 |
|
---|
| 7 |
|
---|
[3c10176] | 8 |
|
---|
| 9 | # TEMPORARY VARIABLES.. development use only
|
---|
[6d0dbc3] | 10 | declare MKFILE=Makefile
|
---|
[3c10176] | 11 | declare PREV_PACKAGE=""
|
---|
| 12 | declare BUILD_SCRIPTS=scripts
|
---|
| 13 | declare TRACKING_DIR=/var/lib/jhalfs/BLFS
|
---|
| 14 |
|
---|
[6d0dbc3] | 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 |
|
---|
[3c10176] | 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)
|
---|
| 31 | @./progress_bar.sh \$@ &
|
---|
| 32 | EOF
|
---|
| 33 | ) >> $MKFILE.tmp
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 |
|
---|
| 38 | #----------------------------------#
|
---|
| 39 | __write_build_cmd() { #
|
---|
| 40 | #----------------------------------#
|
---|
| 41 | (
|
---|
| 42 | cat << EOF
|
---|
[57c7bfe] | 43 | @source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
|
---|
[3c10176] | 44 | EOF
|
---|
| 45 | ) >> $MKFILE.tmp
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | #----------------------------------#
|
---|
| 49 | __wrt_touch() { #
|
---|
| 50 | #----------------------------------#
|
---|
| 51 | local pkg_name=$1
|
---|
[356f5bb] | 52 | local pkg_ver=$2
|
---|
[3c10176] | 53 | (
|
---|
| 54 | cat << EOF
|
---|
| 55 | @touch \$@ && \\
|
---|
[356f5bb] | 56 | touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver} && \\
|
---|
[3c10176] | 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 | #----------------------------#
|
---|
| 68 | local script_name=$1
|
---|
[356f5bb] | 69 | local pkg_ver=$2
|
---|
| 70 |
|
---|
[3c10176] | 71 | echo -n "${tab_}${tab_} entry for <$script_name>"
|
---|
| 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.
|
---|
| 79 | __wrt_target "${script_name}" "$PREV_PACKAGE"
|
---|
[dc67791] | 80 | __write_build_cmd
|
---|
[3c10176] | 81 |
|
---|
| 82 | # Include a touch of the target name so make can check
|
---|
| 83 | # if it's already been made.
|
---|
[356f5bb] | 84 | __wrt_touch "${script_name}" "${pkg_ver}"
|
---|
[3c10176] | 85 | #
|
---|
| 86 | #--------------------------------------------------------------------#
|
---|
| 87 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 88 | #--------------------------------------------------------------------#
|
---|
| 89 | echo " .. OK"
|
---|
| 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 |
|
---|
[6d0dbc3] | 103 |
|
---|
[3c10176] | 104 | for package_script in scripts/* ; do
|
---|
| 105 | this_script=`basename $package_script`
|
---|
[356f5bb] | 106 | script_ver=$(xmllint --noent ../blfs-xml/book/bookinfo.xml 2>/dev/null | \
|
---|
| 107 | grep -i " ${this_script#*-?-}-version " | \
|
---|
| 108 | cut -d "\"" -f2 )
|
---|
| 109 | echo "${this_script} ... ${this_script#*-?-} .. ver ${script_ver}"
|
---|
| 110 | if [ ! -e $TRACKING_DIR/${this_script#*-?-}-$script_ver ]; then
|
---|
[3c10176] | 111 | pkg_list="$pkg_list ${this_script}"
|
---|
[356f5bb] | 112 | __write_entry "${this_script}" "${script_ver}"
|
---|
[3c10176] | 113 | PREV_PACKAGE=${this_script}
|
---|
| 114 | fi
|
---|
| 115 | done
|
---|
| 116 |
|
---|
| 117 |
|
---|
| 118 | # Add a header, some variables and include the function file
|
---|
| 119 | # to the top of the real Makefile.
|
---|
| 120 | (
|
---|
| 121 | cat << EOF
|
---|
| 122 | $HEADER
|
---|
| 123 |
|
---|
[6d0dbc3] | 124 | PACKAGE= "`basename $PWD`"
|
---|
[3c10176] | 125 | TRACKING_DIR= $TRACKING_DIR
|
---|
| 126 |
|
---|
| 127 | BOLD= "[0;1m"
|
---|
| 128 | RED= "[1;31m"
|
---|
| 129 | GREEN= "[0;32m"
|
---|
| 130 | ORANGE= "[0;33m"
|
---|
| 131 | BLUE= "[1;34m"
|
---|
| 132 | WHITE= "[00m"
|
---|
| 133 |
|
---|
| 134 | define echo_message
|
---|
| 135 | @echo \$(BOLD)
|
---|
| 136 | @echo --------------------------------------------------------------------------------
|
---|
| 137 | @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
---|
| 138 | @echo \$(WHITE)
|
---|
| 139 | endef
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | define fin_message
|
---|
| 143 | @echo \$(BOLD)
|
---|
| 144 | @echo --------------------------------------------------------------------------------
|
---|
| 145 | @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
---|
| 146 | @echo \$(WHITE)
|
---|
| 147 | endef
|
---|
| 148 |
|
---|
| 149 | all : $pkg_list
|
---|
| 150 | @\$(call fin_message )
|
---|
| 151 | EOF
|
---|
| 152 | ) > $MKFILE
|
---|
| 153 |
|
---|
| 154 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 155 | echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 156 |
|
---|
| 157 | rm $MKFILE.tmp
|
---|
| 158 |
|
---|
| 159 | }
|
---|
[6d0dbc3] | 160 |
|
---|
| 161 | generate_Makefile
|
---|
| 162 |
|
---|
| 163 | cp ../progress_bar.sh .
|
---|
| 164 |
|
---|
| 165 | mkdir -p logs
|
---|