2006-08-12 14:34:01 +02:00
|
|
|
|
#!/bin/bash
|
2006-07-16 12:29:37 +02:00
|
|
|
|
#
|
|
|
|
|
# $Id$
|
2006-08-12 14:34:01 +02:00
|
|
|
|
#
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
|
2006-07-16 12:29:37 +02:00
|
|
|
|
|
|
|
|
|
# TEMPORARY VARIABLES.. development use only
|
2006-08-12 14:34:01 +02:00
|
|
|
|
declare MKFILE=Makefile
|
2006-07-16 12:29:37 +02:00
|
|
|
|
declare PREV_PACKAGE=""
|
|
|
|
|
declare BUILD_SCRIPTS=scripts
|
|
|
|
|
declare TRACKING_DIR=/var/lib/jhalfs/BLFS
|
|
|
|
|
|
2006-08-12 14:34:01 +02:00
|
|
|
|
HEADER="# This file is automatically generated by jhalfs
|
|
|
|
|
# YOU MAY NEED TO EDIT THIS FILE MANUALLY
|
|
|
|
|
#
|
|
|
|
|
# Generated on `date \"+%F %X %Z\"`"
|
|
|
|
|
|
2006-07-16 12:29:37 +02:00
|
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
__wrt_target() { # Create target and initialize log file
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
local i=$1
|
|
|
|
|
local PREV=$2
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
|
|
$i: $PREV
|
|
|
|
|
@\$(call echo_message, Building)
|
|
|
|
|
@./progress_bar.sh \$@ &
|
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
__write_build_cmd() { #
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
2006-08-14 20:33:05 +02:00
|
|
|
|
@source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
|
2006-07-16 12:29:37 +02:00
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
__wrt_touch() { #
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
local pkg_name=$1
|
2006-08-15 13:31:17 +02:00
|
|
|
|
local pkg_ver=$2
|
2006-07-16 12:29:37 +02:00
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
|
|
|
|
@touch \$@ && \\
|
2006-08-15 13:31:17 +02:00
|
|
|
|
touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver} && \\
|
2006-07-16 12:29:37 +02:00
|
|
|
|
sleep .25 && \\
|
|
|
|
|
echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
|
|
|
|
echo --------------------------------------------------------------------------------\$(WHITE)
|
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
|
__write_entry() { #
|
|
|
|
|
#----------------------------#
|
|
|
|
|
local script_name=$1
|
2006-08-15 13:31:17 +02:00
|
|
|
|
local pkg_ver=$2
|
|
|
|
|
|
2006-07-16 12:29:37 +02:00
|
|
|
|
echo -n "${tab_}${tab_} entry for <$script_name>"
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
#
|
|
|
|
|
# Drop in the name of the target on a new line, and the previous target
|
|
|
|
|
# as a dependency. Also call the echo_message function.
|
|
|
|
|
__wrt_target "${script_name}" "$PREV_PACKAGE"
|
2006-08-12 15:19:29 +02:00
|
|
|
|
__write_build_cmd
|
2006-07-16 12:29:37 +02:00
|
|
|
|
|
|
|
|
|
# Include a touch of the target name so make can check
|
|
|
|
|
# if it's already been made.
|
2006-08-15 13:31:17 +02:00
|
|
|
|
__wrt_touch "${script_name}" "${pkg_ver}"
|
2006-07-16 12:29:37 +02:00
|
|
|
|
#
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
echo " .. OK"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
|
generate_Makefile () { #
|
|
|
|
|
#----------------------------#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
|
|
|
|
|
|
|
|
|
|
# Start with a clean files
|
|
|
|
|
>$MKFILE
|
|
|
|
|
>$MKFILE.tmp
|
|
|
|
|
|
2006-08-12 14:34:01 +02:00
|
|
|
|
|
2006-07-16 12:29:37 +02:00
|
|
|
|
for package_script in scripts/* ; do
|
|
|
|
|
this_script=`basename $package_script`
|
2006-08-15 13:31:17 +02:00
|
|
|
|
script_ver=$(xmllint --noent ../blfs-xml/book/bookinfo.xml 2>/dev/null | \
|
|
|
|
|
grep -i " ${this_script#*-?-}-version " | \
|
|
|
|
|
cut -d "\"" -f2 )
|
|
|
|
|
if [ ! -e $TRACKING_DIR/${this_script#*-?-}-$script_ver ]; then
|
2006-07-16 12:29:37 +02:00
|
|
|
|
pkg_list="$pkg_list ${this_script}"
|
2006-08-15 13:31:17 +02:00
|
|
|
|
__write_entry "${this_script}" "${script_ver}"
|
2006-07-16 12:29:37 +02:00
|
|
|
|
PREV_PACKAGE=${this_script}
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Add a header, some variables and include the function file
|
|
|
|
|
# to the top of the real Makefile.
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
|
|
|
|
$HEADER
|
|
|
|
|
|
2006-08-12 14:34:01 +02:00
|
|
|
|
PACKAGE= "`basename $PWD`"
|
2006-07-16 12:29:37 +02:00
|
|
|
|
TRACKING_DIR= $TRACKING_DIR
|
|
|
|
|
|
|
|
|
|
BOLD= "[0;1m"
|
|
|
|
|
RED= "[1;31m"
|
|
|
|
|
GREEN= "[0;32m"
|
|
|
|
|
ORANGE= "[0;33m"
|
|
|
|
|
BLUE= "[1;34m"
|
|
|
|
|
WHITE= "[00m"
|
|
|
|
|
|
|
|
|
|
define echo_message
|
|
|
|
|
@echo \$(BOLD)
|
|
|
|
|
@echo --------------------------------------------------------------------------------
|
|
|
|
|
@echo \$(BOLD)\$(1) target \$(BLUE)\$@\$(BOLD)
|
|
|
|
|
@echo \$(WHITE)
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
define fin_message
|
|
|
|
|
@echo \$(BOLD)
|
|
|
|
|
@echo --------------------------------------------------------------------------------
|
|
|
|
|
@echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
|
|
|
|
|
@echo \$(WHITE)
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
all : $pkg_list
|
|
|
|
|
@\$(call fin_message )
|
|
|
|
|
EOF
|
|
|
|
|
) > $MKFILE
|
|
|
|
|
|
|
|
|
|
cat $MKFILE.tmp >> $MKFILE
|
|
|
|
|
echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
|
|
|
|
|
|
|
|
|
rm $MKFILE.tmp
|
|
|
|
|
|
|
|
|
|
}
|
2006-08-12 14:34:01 +02:00
|
|
|
|
|
|
|
|
|
generate_Makefile
|
|
|
|
|
|
|
|
|
|
cp ../progress_bar.sh .
|
|
|
|
|
|
|
|
|
|
mkdir -p logs
|