Miguel Flores Silverio 8571af
#!/bin/sh
Miguel Flores Silverio 8571af
# Small script to generate the perf-man tarball. The script relies on having
Miguel Flores Silverio 8571af
# LINUX_GIT set in your local .bashrc. By default the script will use the
Miguel Flores Silverio 8571af
# the kernel version of the upstream tree set in LINUX_GIT. Use --version=x.y
Miguel Flores Silverio 8571af
# to set a specific version.
Miguel Flores Silverio 8571af
Miguel Flores Silverio 8571af
# [Default] eg. ./scritps/generate-perf-man
Miguel Flores Silverio 8571af
# eg. ./scripts/generate-perf-man --version=4.8
Miguel Flores Silverio 8571af
function usage(){
Miguel Flores Silverio 8571af
    echo
Miguel Flores Silverio 8571af
    echo "Helps generate the perf-man tarball                              "
Miguel Flores Silverio 8571af
    echo "-h, --help                                                       "
Miguel Flores Silverio 8571af
    echo
Miguel Flores Silverio 8571af
    echo "./generate-perf-man.sh   #Generates using upstream kernel version"
Miguel Flores Silverio 8571af
    echo
Miguel Flores Silverio 8571af
    echo "./generate-perf-man.sh --version=x.y  #Generate using x.y version"
Miguel Flores Silverio 8571af
}
Miguel Flores Silverio 8571af
Miguel Flores Silverio 8571af
if [ -f ~/.bashrc ]; then
Miguel Flores Silverio 8571af
    source ~/.bashrc
Miguel Flores Silverio 8571af
fi
Miguel Flores Silverio 8571af
Miguel Flores Silverio 8571af
if [ ! -d "$LINUX_GIT" ]; then
Miguel Flores Silverio 8571af
    echo "Error: \$LINUX_GIT is not set to the upstream git tree."
Miguel Flores Silverio 8571af
    exit 1
Miguel Flores Silverio 8571af
fi
Miguel Flores Silverio 8571af
Miguel Flores Silverio 8571af
BASEDIR=$(dirname "$(cd $(dirname $BASH_SOURCE[0]) && pwd)")
Miguel Flores Silverio 8571af
pushd "$LINUX_GIT" > /dev/null
Miguel Flores Silverio 8571af
KERNEL_VERSION=$( awk '/^VERSION =/ {print $3}' Makefile )
Miguel Flores Silverio 8571af
KERNEL_PATCHLEVEL=$( awk '/^PATCHLEVEL =/ {print $3}' Makefile )
Miguel Flores Silverio 8571af
Miguel Flores Silverio 8571af
if [ ! -z "$@" ]; then
Miguel Flores Silverio 8571af
    for opt in "$@"; do
Miguel Flores Silverio 8571af
	case $opt in
Miguel Flores Silverio 8571af
	    --version=*.*)
Miguel Flores Silverio 8571af
		version="${opt#*=}"
Miguel Flores Silverio 8571af
		KERNEL_VERSION=$( awk -F. '{print $1}' <<< $version )
Miguel Flores Silverio 8571af
		KERNEL_PATCHLEVEL=$( awk -F. '{print $2}' <<< $version )
Miguel Flores Silverio 8571af
		;;
Miguel Flores Silverio 8571af
	    -h | --help)
Miguel Flores Silverio 8571af
		usage
Miguel Flores Silverio 8571af
		exit 0
Miguel Flores Silverio 8571af
		;;
Miguel Flores Silverio 8571af
	    *)
Miguel Flores Silverio 8571af
		;;
Miguel Flores Silverio 8571af
	esac
Miguel Flores Silverio 8571af
    done
Miguel Flores Silverio 8571af
fi
a04e78
cd tools/kvm/kvm_stat/
a04e78
make man
a04e78
mv kvm_stat.1 ../../perf/Documentation
a04e78
cd ../../perf/Documentation/
Miguel Flores Silverio 8571af
make
Miguel Flores Silverio 8571af
tar -czvf $BASEDIR/perf-man-${KERNEL_VERSION}.${KERNEL_PATCHLEVEL}.tar.gz *.1
Miguel Flores Silverio 8571af
make clean
a04e78
rm kvm_stat.1
Miguel Flores Silverio 8571af
popd