source: BLFS/gen-makefile.sh@ 2d99aa4

ablfs-more legacy trunk
Last change on this file since 2d99aa4 was a30c80e, checked in by Pierre Labastie <pierre@…>, 5 years ago

Remove the lfs- prefix when writing to the instpkg file, for lfs bootscripts

  • Property mode set to 100755
File size: 4.3 KB
Line 
1#!/bin/bash
2#
3# $Id$
4#
5set -e
6
7declare TOPDIR='..'
8declare ATOPDIR=`cd $TOPDIR; pwd`
9declare MKFILE=Makefile
10declare PREV_PACKAGE=""
11declare BUILD_SCRIPTS=${TOPDIR}/scripts
12declare TRACKING_FILE=tracking-dir/instpkg.xml
13declare XSLDIR=${TOPDIR}/xsl
14declare PACK_FILE=${TOPDIR}/packages.xml
15declare BUMP=${XSLDIR}/bump.xsl
16
17HEADER="# This file is automatically generated by gen-makefile.sh
18# YOU MAY NEED TO EDIT THIS FILE MANUALLY
19#
20# Generated on `date \"+%F %X %Z\"`"
21
22
23#----------------------------------#
24__wrt_target() { # Create target and initialize log file
25#----------------------------------#
26 local i=$1
27 local PREV=$2
28(
29cat << EOF
30
31$i: $PREV
32 @\$(call echo_message, Building)
33 @/bin/bash progress_bar.sh \$@ \$\$PPID &
34EOF
35) >> $MKFILE.tmp
36}
37
38
39
40#----------------------------------#
41__write_build_cmd() { #
42#----------------------------------#
43(
44cat << EOF
45 @source ${TOPDIR}/envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
46EOF
47) >> $MKFILE.tmp
48}
49
50#----------------------------------#
51__wrt_touch() { #
52#----------------------------------#
53local pkg_name="${1#*-?-}"
54# For having a unique id, we have added lfs- to bootscripts package.
55# We need to remove it now.
56case "$pkg_name" in lfs-bootscripts) pkg_name=bootscripts ;; esac
57
58(
59cat << EOF
60 @xsltproc --stringparam packages ${PACK_FILE} \\
61 --stringparam package "${pkg_name}" \\
62 -o track.tmp \\
63 ${BUMP} \$(TRACKING_FILE) && \\
64 sed -i 's@PACKDESC@${ATOPDIR}/packdesc.dtd@' track.tmp && \\
65 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE) && \\
66 rm track.tmp && \\
67 touch \$@ && \\
68 sleep .25 && \\
69 echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
70 echo --------------------------------------------------------------------------------\$(WHITE)
71EOF
72) >> $MKFILE.tmp
73}
74
75
76#----------------------------#
77__write_entry() { #
78#----------------------------#
79 local script_name=$1
80
81 echo -n "${tab_}${tab_} entry for <$script_name>"
82
83 #--------------------------------------------------------------------#
84 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
85 #--------------------------------------------------------------------#
86 #
87 # Drop in the name of the target on a new line, and the previous target
88 # as a dependency. Also call the echo_message function.
89 __wrt_target "${script_name}" "$PREV_PACKAGE"
90 __write_build_cmd
91
92 # Include a touch of the target name so make can check
93 # if it's already been made.
94 __wrt_touch "${script_name}"
95 #
96 #--------------------------------------------------------------------#
97 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
98 #--------------------------------------------------------------------#
99 echo " .. OK"
100}
101
102#----------------------------#
103generate_Makefile () { #
104#----------------------------#
105
106
107 echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
108
109 # Start with a clean files
110 >$MKFILE
111 >$MKFILE.tmp
112
113
114 for package_script in ${BUILD_SCRIPTS}/* ; do
115 this_script=`basename $package_script`
116 pkg_list="$pkg_list ${this_script}"
117 __write_entry "${this_script}"
118 PREV_PACKAGE=${this_script}
119 done
120
121(
122 cat << EOF
123$HEADER
124
125TRACKING_FILE= $TRACKING_FILE
126
127BOLD= "[0;1m"
128RED= "[1;31m"
129GREEN= "[0;32m"
130ORANGE= "[0;33m"
131BLUE= "[1;34m"
132WHITE= "[00m"
133
134define echo_message
135 @echo \$(BOLD)
136 @echo --------------------------------------------------------------------------------
137 @echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
138 @echo \$(WHITE)
139endef
140
141
142define end_message
143 @echo \$(BOLD)
144 @echo --------------------------------------------------------------------------------
145 @echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
146 @echo \$(WHITE)
147endef
148
149all : $pkg_list
150 @\$(call end_message )
151EOF
152) > $MKFILE
153
154 cat $MKFILE.tmp >> $MKFILE
155 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
156
157 rm $MKFILE.tmp
158
159}
160
161if [[ ! -d ${BUILD_SCRIPTS} ]] ; then
162 echo -e "\n\tThe '${BUILD_SCRIPTS}' directory has not been found.\n"
163 exit 1
164fi
165
166# Let us make a clean base, but first ensure that we are
167# not emptying a useful directory.
168MYDIR=$(pwd)
169MYDIR=$(basename $MYDIR)
170if [ "${MYDIR#work}" = "${MYDIR}" ] ; then
171 echo -e \\n\\tDirectory ${BOLD}$MYDIR${OFF} does not begin with \"work\"\\n
172 exit 1
173fi
174
175rm -rf *
176
177generate_Makefile
178
179cp ${TOPDIR}/progress_bar.sh .
180
181mkdir -p logs
Note: See TracBrowser for help on using the repository browser.