[d0d9e90] | 1 | #!/bin/bash
|
---|
[cace19a4] | 2 | #
|
---|
| 3 | # $Id$
|
---|
[d0d9e90] | 4 | #
|
---|
| 5 | set -e
|
---|
| 6 |
|
---|
[cace333e] | 7 | # TEMPORARY VARIABLES.. development use only
|
---|
[d0d9e90] | 8 | declare MKFILE=Makefile
|
---|
[cace333e] | 9 | declare PREV_PACKAGE=""
|
---|
[5d93cec] | 10 | declare BUILD_SCRIPTS=scripts
|
---|
[bc40917] | 11 | declare TRACKING_DIR=tracking-dir
|
---|
[c62275f6] | 12 |
|
---|
[d0d9e90] | 13 | HEADER="# This file is automatically generated by jhalfs
|
---|
| 14 | # YOU MAY NEED TO EDIT THIS FILE MANUALLY
|
---|
| 15 | #
|
---|
| 16 | # Generated on `date \"+%F %X %Z\"`"
|
---|
| 17 |
|
---|
[cace333e] | 18 |
|
---|
| 19 | #----------------------------------#
|
---|
| 20 | __wrt_target() { # Create target and initialize log file
|
---|
| 21 | #----------------------------------#
|
---|
| 22 | local i=$1
|
---|
| 23 | local PREV=$2
|
---|
| 24 | (
|
---|
| 25 | cat << EOF
|
---|
| 26 |
|
---|
| 27 | $i: $PREV
|
---|
| 28 | @\$(call echo_message, Building)
|
---|
[c62275f6] | 29 | @./progress_bar.sh \$@ &
|
---|
[cace333e] | 30 | EOF
|
---|
| 31 | ) >> $MKFILE.tmp
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | #----------------------------------#
|
---|
[c62275f6] | 37 | __write_build_cmd() { #
|
---|
[cace333e] | 38 | #----------------------------------#
|
---|
| 39 | (
|
---|
| 40 | cat << EOF
|
---|
[2fedf49] | 41 | @source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
|
---|
[cace333e] | 42 | EOF
|
---|
| 43 | ) >> $MKFILE.tmp
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | #----------------------------------#
|
---|
| 47 | __wrt_touch() { #
|
---|
| 48 | #----------------------------------#
|
---|
[c62275f6] | 49 | local pkg_name=$1
|
---|
[b928382] | 50 | local pkg_ver=$2
|
---|
[5743d54] | 51 |
|
---|
| 52 | if [[ -n "$pkg_ver" ]] ; then
|
---|
| 53 | (
|
---|
| 54 | cat << EOF
|
---|
| 55 | @touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
|
---|
| 56 | EOF
|
---|
| 57 | ) >> $MKFILE.tmp
|
---|
| 58 | fi
|
---|
| 59 |
|
---|
[cace333e] | 60 | (
|
---|
| 61 | cat << EOF
|
---|
| 62 | @touch \$@ && \\
|
---|
| 63 | sleep .25 && \\
|
---|
| 64 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 65 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 66 | EOF
|
---|
| 67 | ) >> $MKFILE.tmp
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | #----------------------------#
|
---|
| 72 | __write_entry() { #
|
---|
| 73 | #----------------------------#
|
---|
[c62275f6] | 74 | local script_name=$1
|
---|
[b928382] | 75 | local pkg_ver=$2
|
---|
[5743d54] | 76 |
|
---|
[c62275f6] | 77 | echo -n "${tab_}${tab_} entry for <$script_name>"
|
---|
[cace333e] | 78 |
|
---|
| 79 | #--------------------------------------------------------------------#
|
---|
| 80 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 81 | #--------------------------------------------------------------------#
|
---|
| 82 | #
|
---|
| 83 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 84 | # as a dependency. Also call the echo_message function.
|
---|
[c62275f6] | 85 | __wrt_target "${script_name}" "$PREV_PACKAGE"
|
---|
[d0d9e90] | 86 | __write_build_cmd
|
---|
[cace333e] | 87 |
|
---|
| 88 | # Include a touch of the target name so make can check
|
---|
| 89 | # if it's already been made.
|
---|
[b928382] | 90 | __wrt_touch "${script_name}" "${pkg_ver}"
|
---|
[cace333e] | 91 | #
|
---|
| 92 | #--------------------------------------------------------------------#
|
---|
| 93 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 94 | #--------------------------------------------------------------------#
|
---|
[c62275f6] | 95 | echo " .. OK"
|
---|
[cace333e] | 96 | }
|
---|
| 97 |
|
---|
[431520b] | 98 | #----------------------------#
|
---|
| 99 | __write_meta_pkg_touch() { #
|
---|
| 100 | #----------------------------#
|
---|
| 101 | local meta_pkg=$1
|
---|
| 102 | local pkg_ver=$(grep "^${meta_pkg}[[:space:]]" ../packages | cut -f3)
|
---|
| 103 | local gnome_core_ver=$(grep "^gnome-core[[:space:]]" ../packages | cut -f3)
|
---|
| 104 | local kde_core_ver=$(grep "^kde-core[[:space:]]" ../packages | cut -f3)
|
---|
| 105 | local kde_full_ver=$(grep "^kde-full[[:space:]]" ../packages | cut -f3)
|
---|
| 106 |
|
---|
| 107 | (
|
---|
| 108 | cat << EOF
|
---|
[0050352] | 109 |
|
---|
| 110 | 999-z-$meta_pkg: $PREV_PACKAGE
|
---|
[431520b] | 111 | @touch \$(TRACKING_DIR)/${meta_pkg}-${pkg_ver}
|
---|
| 112 | EOF
|
---|
| 113 | ) >> $MKFILE.tmp
|
---|
| 114 |
|
---|
| 115 | case $meta_pkg in
|
---|
| 116 | gnome-full )
|
---|
| 117 | (
|
---|
| 118 | cat << EOF
|
---|
| 119 | @touch \$(TRACKING_DIR)/gnome-core-${gnome_core_ver}
|
---|
| 120 | EOF
|
---|
| 121 | ) >> $MKFILE.tmp
|
---|
| 122 | ;;
|
---|
| 123 | kde-full )
|
---|
| 124 | (
|
---|
| 125 | cat << EOF
|
---|
| 126 | @touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
|
---|
| 127 | EOF
|
---|
| 128 | ) >> $MKFILE.tmp
|
---|
| 129 | ;;
|
---|
| 130 | kde-koffice )
|
---|
| 131 | (
|
---|
| 132 | cat << EOF
|
---|
| 133 | @touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
|
---|
| 134 | @touch \$(TRACKING_DIR)/kde-full-${kde_full_ver}
|
---|
| 135 | EOF
|
---|
| 136 | ) >> $MKFILE.tmp
|
---|
| 137 | ;;
|
---|
| 138 | esac
|
---|
| 139 |
|
---|
| 140 | (
|
---|
| 141 | cat << EOF
|
---|
| 142 | @touch \$@
|
---|
| 143 | EOF
|
---|
| 144 | ) >> $MKFILE.tmp
|
---|
| 145 |
|
---|
| 146 | }
|
---|
| 147 |
|
---|
[cace333e] | 148 | #----------------------------#
|
---|
| 149 | generate_Makefile () { #
|
---|
| 150 | #----------------------------#
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 | echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
|
---|
| 154 |
|
---|
| 155 | # Start with a clean files
|
---|
| 156 | >$MKFILE
|
---|
| 157 | >$MKFILE.tmp
|
---|
| 158 |
|
---|
[d0d9e90] | 159 |
|
---|
[cace333e] | 160 | for package_script in scripts/* ; do
|
---|
| 161 | this_script=`basename $package_script`
|
---|
[5743d54] | 162 | pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
|
---|
[5f14bd3] | 163 | pkg_list="$pkg_list ${this_script}"
|
---|
| 164 | __write_entry "${this_script}" "${pkg_ver}"
|
---|
| 165 | PREV_PACKAGE=${this_script}
|
---|
[cace333e] | 166 | done
|
---|
| 167 |
|
---|
[431520b] | 168 | PACKAGE=$(basename $PWD)
|
---|
| 169 |
|
---|
| 170 | case $PACKAGE in
|
---|
| 171 | alsa | \
|
---|
| 172 | gnome-core | \
|
---|
| 173 | gnome-full | \
|
---|
| 174 | kde-core | \
|
---|
| 175 | kde-full | \
|
---|
| 176 | kde-koffice | \
|
---|
[0050352] | 177 | xorg7 ) pkg_list="$pkg_list 999-z-${PACKAGE}"
|
---|
| 178 | __write_meta_pkg_touch "${PACKAGE}"
|
---|
| 179 | ;;
|
---|
[431520b] | 180 | esac
|
---|
| 181 |
|
---|
[cace333e] | 182 |
|
---|
| 183 | # Add a header, some variables and include the function file
|
---|
| 184 | # to the top of the real Makefile.
|
---|
| 185 | (
|
---|
| 186 | cat << EOF
|
---|
| 187 | $HEADER
|
---|
| 188 |
|
---|
[431520b] | 189 | PACKAGE= $PACKAGE
|
---|
[c62275f6] | 190 | TRACKING_DIR= $TRACKING_DIR
|
---|
[cace333e] | 191 |
|
---|
| 192 | BOLD= "[0;1m"
|
---|
| 193 | RED= "[1;31m"
|
---|
| 194 | GREEN= "[0;32m"
|
---|
| 195 | ORANGE= "[0;33m"
|
---|
| 196 | BLUE= "[1;34m"
|
---|
| 197 | WHITE= "[00m"
|
---|
| 198 |
|
---|
| 199 | define echo_message
|
---|
| 200 | @echo \$(BOLD)
|
---|
| 201 | @echo --------------------------------------------------------------------------------
|
---|
| 202 | @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
---|
| 203 | @echo \$(WHITE)
|
---|
| 204 | endef
|
---|
| 205 |
|
---|
| 206 |
|
---|
[5d93cec] | 207 | define fin_message
|
---|
| 208 | @echo \$(BOLD)
|
---|
| 209 | @echo --------------------------------------------------------------------------------
|
---|
| 210 | @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
---|
| 211 | @echo \$(WHITE)
|
---|
| 212 | endef
|
---|
| 213 |
|
---|
| 214 | all : $pkg_list
|
---|
| 215 | @\$(call fin_message )
|
---|
[cace333e] | 216 | EOF
|
---|
| 217 | ) > $MKFILE
|
---|
| 218 |
|
---|
| 219 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 220 | echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 221 |
|
---|
[c62275f6] | 222 | rm $MKFILE.tmp
|
---|
| 223 |
|
---|
[cace333e] | 224 | }
|
---|
[d0d9e90] | 225 |
|
---|
| 226 | generate_Makefile
|
---|
| 227 |
|
---|
| 228 | cp ../progress_bar.sh .
|
---|
| 229 |
|
---|
| 230 | mkdir -p logs
|
---|