NetBSD/gnu/dist/gettext/misc/combine-sh

142 lines
3.3 KiB
Bash

#!/bin/sh
TMPDIR=/tmp
TMPNAME=/tmp/combine1.$$.sed
trap 'rm -fr $TMPNAME combine; exit 1' 1 2 15
rm -f $TMPNAME
cat > $TMPNAME <<EOF
/@@ end of prolog @@/,/@@ begin of epilog @@/!d
/@@ end of prolog @@/ {
=
d
}
/@@ begin of epilog @@/d
EOF
rm -fr combine
mkdir combine
cat > combine/libintl.c <<EOF
/* Combined sources of GNU gettext library
Copyright (C) 1995 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 2, 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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#define USE_COMBINED_HEADER 1
#include "libintlP.h"
#if HAVE_CATGETS
#include <stdlib.h>
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif
#ifdef HAVE_NL_TYPES_H
# include <nl_types.h>
#endif
EOF
CATCFILES=cat-compat.c
GETCFILES="bindtextdom.c dcgettext.c dgettext.c finddomain.c gettext.c \
loadmsgcat.c textdomain.c"
for file in $CATCFILES; do
sed -f $TMPNAME < $file \
| sed -e '1s/.*/#line & "'$file'"/' >> combine/libintl.c
done
cat >> combine/libintl.c <<EOF
#else /* !HAVE_CATGETS */
#include <alloca.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_MMAP
# include <sys/mman.h>
#endif
EOF
for file in $GETCFILES; do
sed -f $TMPNAME < $file \
| sed -e '1s/.*/#line & "'$file'"/' >> combine/libintl.c
done
cat >> combine/libintl.c <<EOF
#endif /* HAVE_CATGETS */
EOF
cat > combine/libintlP.h <<EOF
/* Combined header files of GNU gettext library
Copyright (C) 1995 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 2, 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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
EOF
PUBHEAD=libgettext.h
PRIVHEAD="gettext.h gettextP.h hash-string.h"
for file in $PUBHEAD; do
sed -f $TMPNAME < $file \
| sed -e '1s/.*/#line & "'$file'"/' >> combine/libintlP.h
done
cat >> combine/libintlP.h <<EOF
#ifdef USE_COMBINED_HEADER
EOF
for file in $PRIVHEAD; do
sed -f $TMPNAME < $file \
| sed -e '1s/.*/#line & "'$file'"/' >> combine/libintlP.h
done
cat >> combine/libintlP.h <<EOF
#endif /* USE_COMBINED_HEADER */
EOF
rm -f $TMPNAME
exit 0