view libposix/mk-tarball @ 14112:aa63a2324d15

add script to make libposix distribution
author Bruce Korb <bkorb@gnu.org>
date Wed, 17 Nov 2010 13:02:52 -0800
parents
children a852b7d09546
line wrap: on
line source

#! /bin/sh
# -*- Mode: Shell-script -*-

# Copyright (C) 2002-2010 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

case "$0" in
*/* ) progdir=`echo "$0" | sed 's@/[^/]*$@@'`
      cd ${progdir}
      progdir=`pwd`
      prognam=`echo "$0" | sed 's@.*/@@'`
      ;;

* )   progdir=`pwd`
      prognam="$0"
      ;;
esac

# kill the patriarch process.  If we are not the patriarch,
# then exit 1 too.
#
func_die()
{
    echo "${prognam} failure:  $*" >&2
    kill -${SIGTERM} ${progpid}
    exit 1
}

func_init()
{
    progpid=$$
    glibdir=`cd .. >/dev/null ; pwd`
    SIGTERM=15

    git --version >/dev/null 2>&1 \
        || func_die "git is not operational"

    case "$*" in
    *'--clean'* )
        git clean -f -x -d .
        ;;
    esac
}

func_mkver()
{
    {
        echo '/*'
        sed '1,/^$/d;s/^#/ */;/http:\/\/www\.gnu\.org/q' ${prognam}
        echo ' */'

        gv=`../build-aux/git-version-gen .tarball-version | \
            sed 's/-dirty/-modified/'`
        sedcmd='/^2[01][0-9][0-9]-[0-1][0-9]-[0-3][0-9]  /{
	  s/ .*//
	  s/-/./gp
	  q
	}'
        dv=`sed -n "${sedcmd}" ${glibdir}/ChangeLog`
        cat <<-_EOF_
		#ifndef LIBPOSIX_GIT_VERSION
		#define LIBPOSIX_GIT_VERSION "$gv"
		#define LIBPOSIX_VERSION     "$dv"

		extern char const libposix_git_version[];
		extern char const libposix_version[];
		#endif  /* LIBPOSIX_GIT_VERSION */
	_EOF_
    } > lib/version.h

    {
        sed -n '1,/^ \*\/$/p' lib/version.h

        cat <<-_EOF_
		#include "version.h"

		char const libposix_git_version[] = LIBPOSIX_GIT_VERSION;
		char const libposix_version[]     = LIBPOSIX_VERSION;
	_EOF_

    } > lib/version.c
}

func_bootstrap()
{
    /bin/sh ./bootstrap \
        || func_die bootstrap failure
}

func_mkdistro()
{
    mkdir _b || die mkdir _b
    cd _b
    ../configure || die configure
    make || die make
    make distcheck || die make distcheck
    mv libposix*.tar.gz .. || die cannot move tarball
}

func_init ${1+"$@"}
func_mkver
func_bootstrap
func_mkdistro

: