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