2006-08-13 12:01:14 +02:00
|
|
|
|
#!/bin/bash
|
2006-05-24 23:04:49 +02:00
|
|
|
|
#
|
|
|
|
|
# $Id$
|
2006-08-13 12:01:14 +02:00
|
|
|
|
#
|
|
|
|
|
set -e
|
|
|
|
|
|
2006-06-13 02:56:07 +02:00
|
|
|
|
# TEMPORARY VARIABLES.. development use only
|
2006-08-13 12:01:14 +02:00
|
|
|
|
declare MKFILE=Makefile
|
2006-06-13 02:56:07 +02:00
|
|
|
|
declare PREV_PACKAGE=""
|
2006-06-13 03:39:44 +02:00
|
|
|
|
declare BUILD_SCRIPTS=scripts
|
2006-08-21 23:57:52 +02:00
|
|
|
|
declare TRACKING_DIR=tracking-dir
|
2006-06-13 15:00:46 +02:00
|
|
|
|
|
2006-10-14 19:18:59 +02:00
|
|
|
|
HEADER="# This file is automatically generated by gen-makefile.sh
|
2006-08-13 12:01:14 +02:00
|
|
|
|
# YOU MAY NEED TO EDIT THIS FILE MANUALLY
|
|
|
|
|
#
|
|
|
|
|
# Generated on `date \"+%F %X %Z\"`"
|
|
|
|
|
|
2006-06-13 02:56:07 +02:00
|
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
__wrt_target() { # Create target and initialize log file
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
local i=$1
|
|
|
|
|
local PREV=$2
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
|
|
|
|
|
|
|
|
|
$i: $PREV
|
|
|
|
|
@\$(call echo_message, Building)
|
2006-09-11 14:11:49 +02:00
|
|
|
|
@./progress_bar.sh \$@ \$\$PPID &
|
2006-06-13 02:56:07 +02:00
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------#
|
2006-06-13 15:00:46 +02:00
|
|
|
|
__write_build_cmd() { #
|
2006-06-13 02:56:07 +02:00
|
|
|
|
#----------------------------------#
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
2006-08-14 22:59:05 +02:00
|
|
|
|
@source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
|
2006-06-13 02:56:07 +02:00
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#----------------------------------#
|
|
|
|
|
__wrt_touch() { #
|
|
|
|
|
#----------------------------------#
|
2006-06-13 15:00:46 +02:00
|
|
|
|
local pkg_name=$1
|
2006-08-15 03:33:40 +02:00
|
|
|
|
local pkg_ver=$2
|
2006-08-24 20:49:35 +02:00
|
|
|
|
local alsa_ver=$(grep "^alsa[[:space:]]" ../packages | cut -f3)
|
|
|
|
|
local kde_core_ver=$(grep "^kde-core[[:space:]]" ../packages | cut -f3)
|
|
|
|
|
local xorg7_ver=$(grep "^xorg7[[:space:]]" ../packages | cut -f3)
|
2006-08-19 16:45:07 +02:00
|
|
|
|
|
|
|
|
|
if [[ -n "$pkg_ver" ]] ; then
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
2006-08-26 11:43:36 +02:00
|
|
|
|
@rm -f \$(TRACKING_DIR)/${pkg_name#*-?-}-{0..9}* && \\
|
|
|
|
|
touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
|
2006-08-19 16:45:07 +02:00
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
fi
|
|
|
|
|
|
2006-08-24 20:49:35 +02:00
|
|
|
|
case $pkg_name in
|
|
|
|
|
*-alsa-lib ) #this the unique mandatory package for ALSA support.
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
2006-08-26 11:43:36 +02:00
|
|
|
|
@rm -f \$(TRACKING_DIR)/alsa-{0..9}* && \\
|
|
|
|
|
touch \$(TRACKING_DIR)/alsa-${alsa_ver}
|
2006-08-24 20:49:35 +02:00
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
;;
|
|
|
|
|
*-kdebase )
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
2006-08-26 11:43:36 +02:00
|
|
|
|
@rm -f \$(TRACKING_DIR)/kde-core-{0..9}* && \\
|
|
|
|
|
touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
|
2006-08-24 20:49:35 +02:00
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
;;
|
|
|
|
|
*-xorg7-driver ) # xtrerm2 and rman are optional
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
2006-08-26 11:43:36 +02:00
|
|
|
|
@rm -f \$(TRACKING_DIR)/xorg7-{0..9}* && \\
|
|
|
|
|
touch \$(TRACKING_DIR)/xorg7-${xorg7_ver}
|
2006-08-24 20:49:35 +02:00
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
2006-06-13 02:56:07 +02:00
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
|
|
|
|
@touch \$@ && \\
|
|
|
|
|
sleep .25 && \\
|
|
|
|
|
echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
|
|
|
|
echo --------------------------------------------------------------------------------\$(WHITE)
|
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
|
__write_entry() { #
|
|
|
|
|
#----------------------------#
|
2006-06-13 15:00:46 +02:00
|
|
|
|
local script_name=$1
|
2006-08-15 03:33:40 +02:00
|
|
|
|
local pkg_ver=$2
|
2006-08-19 16:45:07 +02:00
|
|
|
|
|
2006-06-13 15:00:46 +02:00
|
|
|
|
echo -n "${tab_}${tab_} entry for <$script_name>"
|
2006-06-13 02:56:07 +02:00
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
# >>>>>>>> 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.
|
2006-06-13 15:00:46 +02:00
|
|
|
|
__wrt_target "${script_name}" "$PREV_PACKAGE"
|
2006-08-13 12:01:14 +02:00
|
|
|
|
__write_build_cmd
|
2006-06-13 02:56:07 +02:00
|
|
|
|
|
|
|
|
|
# Include a touch of the target name so make can check
|
|
|
|
|
# if it's already been made.
|
2006-08-15 03:33:40 +02:00
|
|
|
|
__wrt_touch "${script_name}" "${pkg_ver}"
|
2006-06-13 02:56:07 +02:00
|
|
|
|
#
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
|
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
|
|
|
|
#--------------------------------------------------------------------#
|
2006-06-13 15:00:46 +02:00
|
|
|
|
echo " .. OK"
|
2006-06-13 02:56:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2006-08-23 22:08:23 +02:00
|
|
|
|
#----------------------------#
|
|
|
|
|
__write_meta_pkg_touch() { #
|
|
|
|
|
#----------------------------#
|
|
|
|
|
local meta_pkg=$1
|
|
|
|
|
local pkg_ver=$(grep "^${meta_pkg}[[:space:]]" ../packages | cut -f3)
|
|
|
|
|
local gnome_core_ver=$(grep "^gnome-core[[:space:]]" ../packages | cut -f3)
|
|
|
|
|
local kde_full_ver=$(grep "^kde-full[[:space:]]" ../packages | cut -f3)
|
|
|
|
|
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
2006-08-23 22:44:00 +02:00
|
|
|
|
|
|
|
|
|
999-z-$meta_pkg: $PREV_PACKAGE
|
2006-08-26 11:43:36 +02:00
|
|
|
|
@rm -f \$(TRACKING_DIR)/${meta_pkg}-{0..9}* && \\
|
|
|
|
|
touch \$(TRACKING_DIR)/${meta_pkg}-${pkg_ver}
|
2006-08-23 22:08:23 +02:00
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
|
|
|
|
|
case $meta_pkg in
|
|
|
|
|
gnome-full )
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
2006-08-26 11:43:36 +02:00
|
|
|
|
@rm -f \$(TRACKING_DIR)/gnome-core-{0..9}* && \\
|
|
|
|
|
touch \$(TRACKING_DIR)/gnome-core-${gnome_core_ver}
|
2006-08-23 22:08:23 +02:00
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
;;
|
|
|
|
|
kde-koffice )
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
2006-08-26 11:43:36 +02:00
|
|
|
|
@rm -f \$(TRACKING_DIR)/kde-full-{0..9}* && \\
|
|
|
|
|
touch \$(TRACKING_DIR)/kde-full-${kde_full_ver}
|
2006-08-23 22:08:23 +02:00
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
|
|
|
|
@touch \$@
|
|
|
|
|
EOF
|
|
|
|
|
) >> $MKFILE.tmp
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-13 02:56:07 +02:00
|
|
|
|
#----------------------------#
|
|
|
|
|
generate_Makefile () { #
|
|
|
|
|
#----------------------------#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "${tab_}Creating Makefile... ${BOLD}START${OFF}"
|
|
|
|
|
|
|
|
|
|
# Start with a clean files
|
|
|
|
|
>$MKFILE
|
|
|
|
|
>$MKFILE.tmp
|
|
|
|
|
|
2006-08-13 12:01:14 +02:00
|
|
|
|
|
2006-06-13 02:56:07 +02:00
|
|
|
|
for package_script in scripts/* ; do
|
|
|
|
|
this_script=`basename $package_script`
|
2006-08-19 16:45:07 +02:00
|
|
|
|
pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
|
2006-08-21 20:42:52 +02:00
|
|
|
|
pkg_list="$pkg_list ${this_script}"
|
|
|
|
|
__write_entry "${this_script}" "${pkg_ver}"
|
|
|
|
|
PREV_PACKAGE=${this_script}
|
2006-06-13 02:56:07 +02:00
|
|
|
|
done
|
|
|
|
|
|
2006-08-23 22:08:23 +02:00
|
|
|
|
PACKAGE=$(basename $PWD)
|
|
|
|
|
|
2006-08-24 20:49:35 +02:00
|
|
|
|
# alsa, kde-core and xorg7 are also available dependencies, thus handled
|
|
|
|
|
# in another way.
|
2006-08-23 22:08:23 +02:00
|
|
|
|
case $PACKAGE in
|
|
|
|
|
gnome-core | \
|
|
|
|
|
gnome-full | \
|
|
|
|
|
kde-full | \
|
2006-08-24 20:49:35 +02:00
|
|
|
|
kde-koffice ) pkg_list="$pkg_list 999-z-${PACKAGE}"
|
|
|
|
|
__write_meta_pkg_touch "${PACKAGE}"
|
|
|
|
|
;;
|
2006-08-23 22:08:23 +02:00
|
|
|
|
esac
|
|
|
|
|
|
2006-06-13 02:56:07 +02:00
|
|
|
|
|
|
|
|
|
# Add a header, some variables and include the function file
|
|
|
|
|
# to the top of the real Makefile.
|
|
|
|
|
(
|
|
|
|
|
cat << EOF
|
|
|
|
|
$HEADER
|
|
|
|
|
|
2006-08-23 22:08:23 +02:00
|
|
|
|
PACKAGE= $PACKAGE
|
2006-06-13 15:00:46 +02:00
|
|
|
|
TRACKING_DIR= $TRACKING_DIR
|
2006-06-13 02:56:07 +02:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
2006-06-13 03:39:44 +02:00
|
|
|
|
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 )
|
2006-06-13 02:56:07 +02:00
|
|
|
|
EOF
|
|
|
|
|
) > $MKFILE
|
|
|
|
|
|
|
|
|
|
cat $MKFILE.tmp >> $MKFILE
|
|
|
|
|
echo "${tab_}Creating Makefile... ${BOLD}DONE${OFF}"
|
|
|
|
|
|
2006-06-13 15:00:46 +02:00
|
|
|
|
rm $MKFILE.tmp
|
|
|
|
|
|
2006-06-13 02:56:07 +02:00
|
|
|
|
}
|
2006-08-13 12:01:14 +02:00
|
|
|
|
|
2006-10-14 19:18:59 +02:00
|
|
|
|
if [[ -e Config.in ]] ; then
|
|
|
|
|
echo -e "\n\tThis script must be run from inside a target package directory.\n"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ ! -d scripts ]] ; then
|
|
|
|
|
echo -e "\n\tNo ./scripts/ directory has been found.\n"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2006-08-13 12:01:14 +02:00
|
|
|
|
generate_Makefile
|
|
|
|
|
|
|
|
|
|
cp ../progress_bar.sh .
|
|
|
|
|
|
|
|
|
|
mkdir -p logs
|