[0170229] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
| 3 |
|
---|
| 4 | #----------------------------#
|
---|
| 5 | build_Makefile() {
|
---|
| 6 | #----------------------------#
|
---|
| 7 | echo -n "Creating Makefile... "
|
---|
| 8 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 9 |
|
---|
| 10 | # Start with a clean Makefile file
|
---|
| 11 | >$MKFILE
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 | # Add a header, some variables and include the function file
|
---|
| 15 | # to the top of the real Makefile.
|
---|
| 16 | (
|
---|
| 17 | cat << EOF
|
---|
| 18 | $HEADER
|
---|
| 19 |
|
---|
| 20 | include makefile-functions
|
---|
| 21 |
|
---|
| 22 | EOF
|
---|
| 23 | ) > $MKFILE
|
---|
| 24 |
|
---|
| 25 | # Drop in a dummy target 'all:'.
|
---|
| 26 | (
|
---|
| 27 | cat << EOF
|
---|
| 28 | all:
|
---|
| 29 | @echo -e "\nThere is no default target predefined"
|
---|
| 30 | @echo -e "You must to tell what package(s) you want to install"
|
---|
| 31 | @echo -e "or edit the \"all\" Makefile target to create your own"
|
---|
| 32 | @echo -e "defualt target.\n"
|
---|
| 33 | @exit
|
---|
| 34 | EOF
|
---|
| 35 | ) >> $MKFILE
|
---|
| 36 |
|
---|
| 37 | # Bring over the build targets.
|
---|
| 38 | for file in */* ; do
|
---|
| 39 | # Keep the script file name
|
---|
| 40 | case $file in
|
---|
| 41 | gnome/config )
|
---|
| 42 | this_script=config-gnome
|
---|
| 43 | ;;
|
---|
| 44 | gnome/pre-install-config )
|
---|
| 45 | this_script=pre-intall-config-gnome
|
---|
| 46 | ;;
|
---|
| 47 | kde/config )
|
---|
| 48 | this_script=config-kde
|
---|
| 49 | ;;
|
---|
| 50 | kde/pre-install-config )
|
---|
| 51 | this_script=pre-intall-config-kde
|
---|
| 52 | ;;
|
---|
| 53 | * )
|
---|
| 54 | this_script=`basename $file`
|
---|
| 55 | ;;
|
---|
| 56 | esac
|
---|
| 57 |
|
---|
| 58 | # Dump the package dependencies.
|
---|
| 59 | REQUIRED=`grep "REQUIRED" $file | sed 's/# REQUIRED://' | tr -d '\n'`
|
---|
| 60 | if [ "$DEPEND" != "0" ] ; then
|
---|
| 61 | RECOMMENDED=`grep "RECOMMENDED" $file | sed 's/# RECOMMENDED://' | tr -d '\n'`
|
---|
| 62 | fi
|
---|
| 63 | if [ "$DEPEND" = "2" ] ; then
|
---|
| 64 | OPTIONAL=`grep "OPTIONAL" $file | sed 's/# OPTIONAL://' | tr -d '\n'`
|
---|
| 65 | fi
|
---|
| 66 |
|
---|
| 67 | # Drop in the name of the target on a new line plus its dependencies
|
---|
| 68 | # and call the echo_message function.
|
---|
| 69 | (
|
---|
| 70 | cat << EOF
|
---|
| 71 |
|
---|
| 72 | $this_script: $REQUIRED $RECOMMENDED $OPTIONAL
|
---|
| 73 | @\$(call echo_message, Building)
|
---|
| 74 | EOF
|
---|
| 75 | ) >> $MKFILE
|
---|
| 76 |
|
---|
| 77 | # Insert date and disk usage at the top of the log file, the script run
|
---|
| 78 | # and date and disk usage again at the bottom of the log file.
|
---|
| 79 | (
|
---|
| 80 | cat << EOF
|
---|
| 81 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=logs/* /\`\n" >logs/$this_script && \\
|
---|
| 82 | $JHALFSDIR/${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\
|
---|
| 83 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=logs/* /\`\n" >>logs/$this_script
|
---|
| 84 | EOF
|
---|
| 85 | ) >> $MKFILE
|
---|
| 86 |
|
---|
| 87 | # Include a touch of the target name so make can check
|
---|
| 88 | # if it's already been made.
|
---|
| 89 | (
|
---|
| 90 | cat << EOF
|
---|
| 91 | @touch \$@
|
---|
| 92 | EOF
|
---|
| 93 | ) >> $MKFILE
|
---|
| 94 |
|
---|
| 95 | done
|
---|
| 96 | echo -ne "done\n"
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 |
|
---|