[41d4c11] | 1 | #####
|
---|
| 2 | #
|
---|
| 3 | #
|
---|
[cace19a4] | 4 | #
|
---|
| 5 | # $Id$
|
---|
[41d4c11] | 6 | #####
|
---|
[cace333e] | 7 |
|
---|
| 8 | # TEMPORARY VARIABLES.. development use only
|
---|
| 9 | declare MKFILE=devMakefile
|
---|
| 10 | declare PREV_PACKAGE=""
|
---|
[5d93cec] | 11 | declare SCRIPT_ROOT=jhalfs
|
---|
| 12 | declare BUILD_SCRIPTS=scripts
|
---|
| 13 | declare TRACKING_DIR=/var/lib/jhalfs/BLFS
|
---|
| 14 | declare BUILDDIR=~/TRIAL
|
---|
[c62275f6] | 15 |
|
---|
[cace333e] | 16 |
|
---|
| 17 | #----------------------------------#
|
---|
| 18 | __wrt_target() { # Create target and initialize log file
|
---|
| 19 | #----------------------------------#
|
---|
| 20 | local i=$1
|
---|
| 21 | local PREV=$2
|
---|
| 22 | (
|
---|
| 23 | cat << EOF
|
---|
| 24 |
|
---|
| 25 | $i: $PREV
|
---|
| 26 | @\$(call echo_message, Building)
|
---|
[c62275f6] | 27 | @./progress_bar.sh \$@ &
|
---|
[cace333e] | 28 | EOF
|
---|
| 29 | ) >> $MKFILE.tmp
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | #----------------------------------#
|
---|
[c62275f6] | 35 | __write_build_cmd() { #
|
---|
[cace333e] | 36 | #----------------------------------#
|
---|
| 37 | local this_script=$1
|
---|
| 38 | local file=$2
|
---|
| 39 | (
|
---|
| 40 | cat << EOF
|
---|
[c62275f6] | 41 | @( time { export LFS=\$(MOUNT_PT) && ${BUILD_SCRIPTS}/${file} >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
|
---|
[cace333e] | 42 | EOF
|
---|
| 43 | ) >> $MKFILE.tmp
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | #----------------------------------#
|
---|
| 47 | __wrt_touch() { #
|
---|
| 48 | #----------------------------------#
|
---|
[c62275f6] | 49 | local pkg_name=$1
|
---|
[cace333e] | 50 | (
|
---|
| 51 | cat << EOF
|
---|
| 52 | @touch \$@ && \\
|
---|
[c62275f6] | 53 | touch \$(TRACKING_DIR)/${pkg_name#*-} && \\
|
---|
[cace333e] | 54 | sleep .25 && \\
|
---|
| 55 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 56 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 57 | EOF
|
---|
| 58 | ) >> $MKFILE.tmp
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | #----------------------------#
|
---|
| 63 | __write_entry() { #
|
---|
| 64 | #----------------------------#
|
---|
[c62275f6] | 65 | local script_name=$1
|
---|
[cace333e] | 66 |
|
---|
[c62275f6] | 67 | echo -n "${tab_}${tab_} entry for <$script_name>"
|
---|
[cace333e] | 68 |
|
---|
| 69 | #--------------------------------------------------------------------#
|
---|
| 70 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 71 | #--------------------------------------------------------------------#
|
---|
| 72 | #
|
---|
| 73 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 74 | # as a dependency. Also call the echo_message function.
|
---|
[c62275f6] | 75 | __wrt_target "${script_name}" "$PREV_PACKAGE"
|
---|
| 76 | __write_build_cmd "${script_name}" "${script_name}"
|
---|
[cace333e] | 77 |
|
---|
| 78 | # Include a touch of the target name so make can check
|
---|
| 79 | # if it's already been made.
|
---|
[c62275f6] | 80 | __wrt_touch "${script_name}"
|
---|
[cace333e] | 81 | #
|
---|
| 82 | #--------------------------------------------------------------------#
|
---|
| 83 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 84 | #--------------------------------------------------------------------#
|
---|
[c62275f6] | 85 | echo " .. OK"
|
---|
[cace333e] | 86 | }
|
---|
| 87 |
|
---|
| 88 | #----------------------------#
|
---|
| 89 | generate_Makefile () { #
|
---|
| 90 | #----------------------------#
|
---|
| 91 |
|
---|
| 92 |
|
---|
| 93 | echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
|
---|
| 94 |
|
---|
| 95 | # Start with a clean files
|
---|
| 96 | >$MKFILE
|
---|
| 97 | >$MKFILE.tmp
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | for package_script in scripts/* ; do
|
---|
| 101 | this_script=`basename $package_script`
|
---|
| 102 | if [ ! -e $TRACKING_DIR/${this_script#*-} ]; then
|
---|
| 103 | pkg_list="$pkg_list ${this_script}"
|
---|
| 104 | __write_entry $this_script
|
---|
| 105 | PREV_PACKAGE=${this_script}
|
---|
| 106 | fi
|
---|
| 107 | done
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 | # Add a header, some variables and include the function file
|
---|
| 111 | # to the top of the real Makefile.
|
---|
| 112 | (
|
---|
| 113 | cat << EOF
|
---|
| 114 | $HEADER
|
---|
| 115 |
|
---|
| 116 | SRC= /sources
|
---|
| 117 | MOUNT_PT= $BUILDDIR
|
---|
[5d93cec] | 118 | PACKAGE= "`basename $PKGXML .xml`"
|
---|
[c62275f6] | 119 | TRACKING_DIR= $TRACKING_DIR
|
---|
[cace333e] | 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 |
|
---|
[5d93cec] | 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 )
|
---|
[cace333e] | 145 | EOF
|
---|
| 146 | ) > $MKFILE
|
---|
| 147 |
|
---|
| 148 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 149 | echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 150 |
|
---|
[c62275f6] | 151 | rm $MKFILE.tmp
|
---|
| 152 |
|
---|
[cace333e] | 153 | }
|
---|