[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
|
---|
[f694f27] | 51 | local alsa_ver=$(grep "^alsa[[:space:]]" ../packages | cut -f3)
|
---|
| 52 | local kde_core_ver=$(grep "^kde-core[[:space:]]" ../packages | cut -f3)
|
---|
| 53 | local xorg7_ver=$(grep "^xorg7[[:space:]]" ../packages | cut -f3)
|
---|
[5743d54] | 54 |
|
---|
| 55 | if [[ -n "$pkg_ver" ]] ; then
|
---|
| 56 | (
|
---|
| 57 | cat << EOF
|
---|
| 58 | @touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
|
---|
| 59 | EOF
|
---|
| 60 | ) >> $MKFILE.tmp
|
---|
| 61 | fi
|
---|
| 62 |
|
---|
[f694f27] | 63 | case $pkg_name in
|
---|
| 64 | *-alsa-lib ) #this the unique mandatory package for ALSA support.
|
---|
| 65 | (
|
---|
| 66 | cat << EOF
|
---|
| 67 | @touch \$(TRACKING_DIR)/alsa-${alsa_ver}
|
---|
| 68 | EOF
|
---|
| 69 | ) >> $MKFILE.tmp
|
---|
| 70 | ;;
|
---|
| 71 | *-kdebase )
|
---|
| 72 | (
|
---|
| 73 | cat << EOF
|
---|
| 74 | @touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
|
---|
| 75 | EOF
|
---|
| 76 | ) >> $MKFILE.tmp
|
---|
| 77 | ;;
|
---|
| 78 | *-xorg7-driver ) # xtrerm2 and rman are optional
|
---|
| 79 | (
|
---|
| 80 | cat << EOF
|
---|
| 81 | @touch \$(TRACKING_DIR)/xorg7-${xorg7_ver}
|
---|
| 82 | EOF
|
---|
| 83 | ) >> $MKFILE.tmp
|
---|
| 84 | ;;
|
---|
| 85 | esac
|
---|
| 86 |
|
---|
[cace333e] | 87 | (
|
---|
| 88 | cat << EOF
|
---|
| 89 | @touch \$@ && \\
|
---|
| 90 | sleep .25 && \\
|
---|
| 91 | echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
---|
| 92 | echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 93 | EOF
|
---|
| 94 | ) >> $MKFILE.tmp
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | #----------------------------#
|
---|
| 99 | __write_entry() { #
|
---|
| 100 | #----------------------------#
|
---|
[c62275f6] | 101 | local script_name=$1
|
---|
[b928382] | 102 | local pkg_ver=$2
|
---|
[5743d54] | 103 |
|
---|
[c62275f6] | 104 | echo -n "${tab_}${tab_} entry for <$script_name>"
|
---|
[cace333e] | 105 |
|
---|
| 106 | #--------------------------------------------------------------------#
|
---|
| 107 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 108 | #--------------------------------------------------------------------#
|
---|
| 109 | #
|
---|
| 110 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 111 | # as a dependency. Also call the echo_message function.
|
---|
[c62275f6] | 112 | __wrt_target "${script_name}" "$PREV_PACKAGE"
|
---|
[d0d9e90] | 113 | __write_build_cmd
|
---|
[cace333e] | 114 |
|
---|
| 115 | # Include a touch of the target name so make can check
|
---|
| 116 | # if it's already been made.
|
---|
[b928382] | 117 | __wrt_touch "${script_name}" "${pkg_ver}"
|
---|
[cace333e] | 118 | #
|
---|
| 119 | #--------------------------------------------------------------------#
|
---|
| 120 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 121 | #--------------------------------------------------------------------#
|
---|
[c62275f6] | 122 | echo " .. OK"
|
---|
[cace333e] | 123 | }
|
---|
| 124 |
|
---|
[431520b] | 125 | #----------------------------#
|
---|
| 126 | __write_meta_pkg_touch() { #
|
---|
| 127 | #----------------------------#
|
---|
| 128 | local meta_pkg=$1
|
---|
| 129 | local pkg_ver=$(grep "^${meta_pkg}[[:space:]]" ../packages | cut -f3)
|
---|
| 130 | local gnome_core_ver=$(grep "^gnome-core[[:space:]]" ../packages | cut -f3)
|
---|
| 131 | local kde_full_ver=$(grep "^kde-full[[:space:]]" ../packages | cut -f3)
|
---|
| 132 |
|
---|
| 133 | (
|
---|
| 134 | cat << EOF
|
---|
[0050352] | 135 |
|
---|
| 136 | 999-z-$meta_pkg: $PREV_PACKAGE
|
---|
[431520b] | 137 | @touch \$(TRACKING_DIR)/${meta_pkg}-${pkg_ver}
|
---|
| 138 | EOF
|
---|
| 139 | ) >> $MKFILE.tmp
|
---|
| 140 |
|
---|
| 141 | case $meta_pkg in
|
---|
| 142 | gnome-full )
|
---|
| 143 | (
|
---|
| 144 | cat << EOF
|
---|
| 145 | @touch \$(TRACKING_DIR)/gnome-core-${gnome_core_ver}
|
---|
| 146 | EOF
|
---|
| 147 | ) >> $MKFILE.tmp
|
---|
| 148 | ;;
|
---|
| 149 | kde-koffice )
|
---|
| 150 | (
|
---|
| 151 | cat << EOF
|
---|
| 152 | @touch \$(TRACKING_DIR)/kde-full-${kde_full_ver}
|
---|
| 153 | EOF
|
---|
| 154 | ) >> $MKFILE.tmp
|
---|
| 155 | ;;
|
---|
| 156 | esac
|
---|
| 157 |
|
---|
| 158 | (
|
---|
| 159 | cat << EOF
|
---|
| 160 | @touch \$@
|
---|
| 161 | EOF
|
---|
| 162 | ) >> $MKFILE.tmp
|
---|
| 163 |
|
---|
| 164 | }
|
---|
| 165 |
|
---|
[cace333e] | 166 | #----------------------------#
|
---|
| 167 | generate_Makefile () { #
|
---|
| 168 | #----------------------------#
|
---|
| 169 |
|
---|
| 170 |
|
---|
| 171 | echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
|
---|
| 172 |
|
---|
| 173 | # Start with a clean files
|
---|
| 174 | >$MKFILE
|
---|
| 175 | >$MKFILE.tmp
|
---|
| 176 |
|
---|
[d0d9e90] | 177 |
|
---|
[cace333e] | 178 | for package_script in scripts/* ; do
|
---|
| 179 | this_script=`basename $package_script`
|
---|
[5743d54] | 180 | pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
|
---|
[5f14bd3] | 181 | pkg_list="$pkg_list ${this_script}"
|
---|
| 182 | __write_entry "${this_script}" "${pkg_ver}"
|
---|
| 183 | PREV_PACKAGE=${this_script}
|
---|
[cace333e] | 184 | done
|
---|
| 185 |
|
---|
[431520b] | 186 | PACKAGE=$(basename $PWD)
|
---|
| 187 |
|
---|
[f694f27] | 188 | # alsa, kde-core and xorg7 are also available dependencies, thus handled
|
---|
| 189 | # in another way.
|
---|
[431520b] | 190 | case $PACKAGE in
|
---|
| 191 | gnome-core | \
|
---|
| 192 | gnome-full | \
|
---|
| 193 | kde-full | \
|
---|
[f694f27] | 194 | kde-koffice ) pkg_list="$pkg_list 999-z-${PACKAGE}"
|
---|
| 195 | __write_meta_pkg_touch "${PACKAGE}"
|
---|
| 196 | ;;
|
---|
[431520b] | 197 | esac
|
---|
| 198 |
|
---|
[cace333e] | 199 |
|
---|
| 200 | # Add a header, some variables and include the function file
|
---|
| 201 | # to the top of the real Makefile.
|
---|
| 202 | (
|
---|
| 203 | cat << EOF
|
---|
| 204 | $HEADER
|
---|
| 205 |
|
---|
[431520b] | 206 | PACKAGE= $PACKAGE
|
---|
[c62275f6] | 207 | TRACKING_DIR= $TRACKING_DIR
|
---|
[cace333e] | 208 |
|
---|
| 209 | BOLD= "[0;1m"
|
---|
| 210 | RED= "[1;31m"
|
---|
| 211 | GREEN= "[0;32m"
|
---|
| 212 | ORANGE= "[0;33m"
|
---|
| 213 | BLUE= "[1;34m"
|
---|
| 214 | WHITE= "[00m"
|
---|
| 215 |
|
---|
| 216 | define echo_message
|
---|
| 217 | @echo \$(BOLD)
|
---|
| 218 | @echo --------------------------------------------------------------------------------
|
---|
| 219 | @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
---|
| 220 | @echo \$(WHITE)
|
---|
| 221 | endef
|
---|
| 222 |
|
---|
| 223 |
|
---|
[5d93cec] | 224 | define fin_message
|
---|
| 225 | @echo \$(BOLD)
|
---|
| 226 | @echo --------------------------------------------------------------------------------
|
---|
| 227 | @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
---|
| 228 | @echo \$(WHITE)
|
---|
| 229 | endef
|
---|
| 230 |
|
---|
| 231 | all : $pkg_list
|
---|
| 232 | @\$(call fin_message )
|
---|
[cace333e] | 233 | EOF
|
---|
| 234 | ) > $MKFILE
|
---|
| 235 |
|
---|
| 236 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 237 | echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 238 |
|
---|
[c62275f6] | 239 | rm $MKFILE.tmp
|
---|
| 240 |
|
---|
[cace333e] | 241 | }
|
---|
[d0d9e90] | 242 |
|
---|
| 243 | generate_Makefile
|
---|
| 244 |
|
---|
| 245 | cp ../progress_bar.sh .
|
---|
| 246 |
|
---|
| 247 | mkdir -p logs
|
---|