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