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