#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#
#	pretty-make
#
#	This script helps in pretty-printing of build commands.
#	We invoke it via overridden rules in Makefile.am
#
# $Id: pretty-make 904065 2010-01-28 12:31:53Z borisk $
#

# Grab the action (what we're doing)
action=$1
shift

# Grab the original command
cmd=$@

# Try to find the name of the file we're building. This is fraught with
# problems, and may not be reliable across all compilers. Given the
# dependencies, this is usually the last argument, but sometimes libtool
# adds additional flags, which throws this off. So we look
# for the last arg that doesn't start with - or + (HP aCC style).
while [ $# -gt 0 ]; do
	case ${1} in
	-*)
		;;
	+*)
		;;
	*)
		target=$1
		;;
	esac
	shift
done

# Notify user of the action, and what it's operating on
echo $action $target

# Be verbose if requested
[ ${VERBOSE} ] && echo $cmd

# Execute the original command
$cmd
