mirror of
git://git.gnu.org.ua/wordsplit.git
synced 2025-04-26 00:29:54 +03:00
Add the bootstrap script
* .gitignore: New file. * bootstrap: New file. * wordsplit.at: Convert to stand-alone script. * wsp.c: Support the --version option.
This commit is contained in:
parent
42acf86a10
commit
d5a0b05f52
4 changed files with 188 additions and 1 deletions
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
*~
|
||||||
|
.emacs*
|
||||||
|
package.m4
|
||||||
|
wordsplit-version.h
|
||||||
|
Makefile.am
|
||||||
|
Makefile.in
|
||||||
|
Makefile
|
||||||
|
configure.ac
|
||||||
|
configure
|
162
bootstrap
Executable file
162
bootstrap
Executable file
|
@ -0,0 +1,162 @@
|
||||||
|
#! /bin/sh
|
||||||
|
cd $(dirname $0)
|
||||||
|
version=$(git describe)
|
||||||
|
|
||||||
|
function genfiles() {
|
||||||
|
cat > wordsplit-version.h <<EOF
|
||||||
|
#define WORDSPLIT_VERSION "$version"
|
||||||
|
EOF
|
||||||
|
cat > package.m4 <<EOF
|
||||||
|
m4_define([AT_PACKAGE_NAME], [wordsplit])
|
||||||
|
m4_define([AT_PACKAGE_TARNAME], [wordsplit])
|
||||||
|
m4_define([AT_PACKAGE_VERSION], [$version])
|
||||||
|
m4_define([AT_PACKAGE_STRING], [AT_PACKAGE_NAME AT_PACKAGE_VERSION])
|
||||||
|
m4_define([AT_PACKAGE_BUGREPORT], [gray@gnu.org])
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
function mk_atlocal() {
|
||||||
|
cat <<\EOF
|
||||||
|
# @configure_input@ -*- shell-script -*-
|
||||||
|
# Configurable variable values for wordsplit test suite.
|
||||||
|
# Copyright (C) 2016-2019 Sergey Poznyakoff
|
||||||
|
|
||||||
|
PATH=@abs_builddir@:$srcdir:$PATH
|
||||||
|
EOF
|
||||||
|
} > atlocal.in
|
||||||
|
|
||||||
|
|
||||||
|
function mk_testsuite() {
|
||||||
|
sed -e 's|MODDIR|$moddir|' <<\EOF
|
||||||
|
# ##################
|
||||||
|
# Testsuite
|
||||||
|
# ##################
|
||||||
|
EXTRA_DIST = testsuite wordsplit.at package.m4
|
||||||
|
DISTCLEANFILES = atconfig
|
||||||
|
MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
|
||||||
|
|
||||||
|
TESTSUITE = $(srcdir)/testsuite
|
||||||
|
M4=m4
|
||||||
|
AUTOTEST = $(AUTOM4TE) --language=autotest
|
||||||
|
$(TESTSUITE): wordsplit.at
|
||||||
|
$(AM_V_GEN)$(AUTOTEST) -I $(srcdir) wordsplit.at -o $(TESTSUITE).tmp
|
||||||
|
$(AM_V_at)mv $(TESTSUITE).tmp $(TESTSUITE)
|
||||||
|
|
||||||
|
atconfig: $(top_builddir)/config.status
|
||||||
|
cd $(top_builddir) && ./config.status MODDIR/$@
|
||||||
|
|
||||||
|
clean-local:
|
||||||
|
@test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
|
||||||
|
|
||||||
|
check-local: atconfig atlocal $(TESTSUITE)
|
||||||
|
@$(SHELL) $(TESTSUITE)
|
||||||
|
|
||||||
|
noinst_PROGRAMS = wsp
|
||||||
|
wsp_SOURCES = wsp.c wordsplit-version.h
|
||||||
|
EOF
|
||||||
|
echo "wsp_LDADD = $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function common_notice() {
|
||||||
|
cat <<EOF
|
||||||
|
Add the following to your configure.ac:
|
||||||
|
|
||||||
|
AC_CONFIG_TESTDIR($moddir)
|
||||||
|
AC_CONFIG_FILES([$moddir/Makefile $moddir/atlocal])
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
function mk_installed() {
|
||||||
|
(cat <<EOF
|
||||||
|
lib_LTLIBRARIES = libwordsplit.la
|
||||||
|
libwordsplit_la_SOURCES = wordsplit.c
|
||||||
|
include_HEADERS = wordsplit.h
|
||||||
|
|
||||||
|
EOF
|
||||||
|
mk_testsuite ./libwordsplit.la) > Makefile.am
|
||||||
|
mk_atlocal
|
||||||
|
common_notice
|
||||||
|
}
|
||||||
|
|
||||||
|
function mk_shared() {
|
||||||
|
(cat <<EOF
|
||||||
|
noinst_LTLIBRARIES = libwordsplit.la
|
||||||
|
libwordsplit_la_SOURCES = wordsplit.c wordsplit.h
|
||||||
|
|
||||||
|
EOF
|
||||||
|
mk_testsuite ./libwordsplit.la) > Makefile.am
|
||||||
|
mk_atlocal
|
||||||
|
common_notice
|
||||||
|
}
|
||||||
|
|
||||||
|
function mk_static() {
|
||||||
|
(cat <<EOF
|
||||||
|
noinst_LIBRARIES = libwordsplit.a
|
||||||
|
libwordsplit_a_SOURCES = wordsplit.c wordsplit.h
|
||||||
|
|
||||||
|
EOF
|
||||||
|
mk_testsuite ./libwordsplit.a) > Makefile.am
|
||||||
|
mk_atlocal
|
||||||
|
common_notice
|
||||||
|
}
|
||||||
|
|
||||||
|
function mk_embedded() {
|
||||||
|
(mk_testsuite wordsplit.o
|
||||||
|
echo "AM_CPPFLAGS = "
|
||||||
|
)> Makefile.am
|
||||||
|
mk_atlocal
|
||||||
|
cat <<EOF
|
||||||
|
Add the following to the _SOURCES variable of your top-level Makefile.am:
|
||||||
|
|
||||||
|
wordsplit/wordsplit.c\\
|
||||||
|
wordsplit/wordsplit.h
|
||||||
|
|
||||||
|
If test framework is enabled, add also the line
|
||||||
|
|
||||||
|
SUBDIRS = . wordsplit
|
||||||
|
|
||||||
|
and the following lines to your configure.ac:
|
||||||
|
|
||||||
|
AC_CONFIG_TESTDIR($moddir)
|
||||||
|
AC_CONFIG_FILES([$moddir/Makefile $moddir/atlocal])
|
||||||
|
|
||||||
|
Replace ellipsis with the leading path components to the embedded wordsplit
|
||||||
|
sources.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
cat <<EOF
|
||||||
|
usage: $0 MODE MODDIR
|
||||||
|
|
||||||
|
MODE is any of:
|
||||||
|
installed standalone installable library
|
||||||
|
shared shared convenience library (lt)
|
||||||
|
static static convenience library
|
||||||
|
embedded embedded into another library
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
#
|
||||||
|
if [ $# -ne 2 ]; then
|
||||||
|
usage >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
moddir=$2
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
installed|shared|static|standalone|embedded)
|
||||||
|
genfiles
|
||||||
|
mk_$1
|
||||||
|
;;
|
||||||
|
clean)
|
||||||
|
rm -f Makefile.am package.m4 wordsplit-version.h atlocal.in
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with wordsplit. If not, see <http://www.gnu.org/licenses/>.
|
# along with wordsplit. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
AT_BANNER(Wordsplit)
|
AT_INIT
|
||||||
|
AT_TESTED(wsp)
|
||||||
|
|
||||||
m4_pushdef([wspnum],[0])
|
m4_pushdef([wspnum],[0])
|
||||||
m4_pushdef([wspid])
|
m4_pushdef([wspid])
|
||||||
|
|
15
wsp.c
15
wsp.c
|
@ -23,6 +23,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "wordsplit.h"
|
#include "wordsplit.h"
|
||||||
|
#include "wordsplit-version.h"
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
|
@ -83,6 +84,12 @@ struct wsopt
|
||||||
/* Index of the next argument in the argv */
|
/* Index of the next argument in the argv */
|
||||||
static int wsoptind = -1;
|
static int wsoptind = -1;
|
||||||
|
|
||||||
|
void
|
||||||
|
print_version (void)
|
||||||
|
{
|
||||||
|
printf ("wsp (wordsplit %s)\n", WORDSPLIT_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse next argument from the command line. Return EOF on end of arguments
|
/* Parse next argument from the command line. Return EOF on end of arguments
|
||||||
or when the "--" argument is seen. */
|
or when the "--" argument is seen. */
|
||||||
static int
|
static int
|
||||||
|
@ -110,7 +117,15 @@ getwsopt (int argc, char **argv, struct wsopt *wso, struct wsclosure *wsc)
|
||||||
wsoptind--;
|
wsoptind--;
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp (opt, "--version") == 0)
|
||||||
|
{
|
||||||
|
print_version ();
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
opt++; /* skip past initial dash */
|
opt++; /* skip past initial dash */
|
||||||
|
|
||||||
if (strncmp (opt, "no-", 3) == 0)
|
if (strncmp (opt, "no-", 3) == 0)
|
||||||
{
|
{
|
||||||
negate = 1;
|
negate = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue