source: BLFS/gen-makefile.sh@ e22aa96

ablfs-more legacy trunk
Last change on this file since e22aa96 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
RevLine 
[6d0dbc3]1#!/bin/bash
[3c10176]2#
3# $Id$
[6d0dbc3]4#
5set -e
6
[e576789]7declare TOPDIR='..'
8declare ATOPDIR=`cd $TOPDIR; pwd`
[6d0dbc3]9declare MKFILE=Makefile
[3c10176]10declare PREV_PACKAGE=""
[e576789]11declare BUILD_SCRIPTS=${TOPDIR}/scripts
[8ebac92]12declare TRACKING_FILE=tracking-dir/instpkg.xml
[e576789]13declare XSLDIR=${TOPDIR}/xsl
14declare PACK_FILE=${TOPDIR}/packages.xml
15declare BUMP=${XSLDIR}/bump.xsl
[3c10176]16
[aecb378]17HEADER="# This file is automatically generated by gen-makefile.sh
[6d0dbc3]18# YOU MAY NEED TO EDIT THIS FILE MANUALLY
19#
20# Generated on `date \"+%F %X %Z\"`"
21
[3c10176]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)
[fc8b962]33 @/bin/bash progress_bar.sh \$@ \$\$PPID &
[3c10176]34EOF
35) >> $MKFILE.tmp
36}
37
38
39
40#----------------------------------#
41__write_build_cmd() { #
42#----------------------------------#
43(
44cat << EOF
[e576789]45 @source ${TOPDIR}/envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
[3c10176]46EOF
47) >> $MKFILE.tmp
48}
49
50#----------------------------------#
51__wrt_touch() { #
52#----------------------------------#
[a30c80e]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
[f4ed135]57
58(
59cat << EOF
[e576789]60 @xsltproc --stringparam packages ${PACK_FILE} \\
[a30c80e]61 --stringparam package "${pkg_name}" \\
[e576789]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 \$@ && \\
[3c10176]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
[f4ed135]80
[3c10176]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"
[dc67791]90 __write_build_cmd
[3c10176]91
92 # Include a touch of the target name so make can check
93 # if it's already been made.
[e576789]94 __wrt_touch "${script_name}"
[3c10176]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
[6d0dbc3]113
[e576789]114 for package_script in ${BUILD_SCRIPTS}/* ; do
[3c10176]115 this_script=`basename $package_script`
[f4ed135]116 pkg_list="$pkg_list ${this_script}"
[e576789]117 __write_entry "${this_script}"
[f4ed135]118 PREV_PACKAGE=${this_script}
[3c10176]119 done
120
121(
122 cat << EOF
123$HEADER
124
[e576789]125TRACKING_FILE= $TRACKING_FILE
[3c10176]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
[e576789]142define end_message
[3c10176]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
[e576789]150 @\$(call end_message )
[3c10176]151EOF
152) > $MKFILE
153
154 cat $MKFILE.tmp >> $MKFILE
155 echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
156
157 rm $MKFILE.tmp
158
159}
[6d0dbc3]160
[e576789]161if [[ ! -d ${BUILD_SCRIPTS} ]] ; then
[e253015]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
[aecb378]172 exit 1
173fi
174
[e576789]175rm -rf *
[aecb378]176
[6d0dbc3]177generate_Makefile
178
[e576789]179cp ${TOPDIR}/progress_bar.sh .
[6d0dbc3]180
181mkdir -p logs
Note: See TracBrowser for help on using the repository browser.