#!/bin/sh
#  Copyright 2010 Intel Corp.
# 
#  Authors: Peter Zhu <peter.j.zhu@intel.com>
# 
#  This program is free software; you can redistribute it and/or modify it
#  under the terms and conditions of the GNU Lesser General Public License,
#  version 2.1, as published by the Free Software Foundation.
# 
#  This program is distributed in the hope it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
#  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
#  more details.
# 
#  You should have received a copy of the GNU Lesser General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
# 

WDIR=$PWD
PKG=$1
MAKEFILEIN=/usr/share/meego-packaging-tools/Makefile.in

if [ -z "$PKG" ]; then
    if [ -d ".osc" -a -f ".osc/_package" ]; then
       PKG=`cat .osc/_package`
    else
       echo "Can't determine package name, provide the name as first argument please..."
       exit 1
    fi
fi 

if [ ! -f "Makefile" ]; then
    if [ -f "${MAKEFILEIN}" ]; then
        sed -e "s/@@PKG_NAME@@/${PKG}/" ${MAKEFILEIN} > ${WDIR}/Makefile
    else
        echo "Makefile.in not found..."
    fi
else
    echo "Makefile already exists, not creating a new one..."
fi
