diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-07-07 15:50:45 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-07-07 16:15:32 +0300 |
commit | d5a0b05f5269c63e61fcb5dcb53209388c1d3e81 (patch) | |
tree | 2303685723668ad698f12c03e788ecb088e82600 | |
parent | 42acf86a105cbbd1df123acb07309b27211bbf67 (diff) | |
download | wordsplit-d5a0b05f5269c63e61fcb5dcb53209388c1d3e81.tar.gz wordsplit-d5a0b05f5269c63e61fcb5dcb53209388c1d3e81.tar.bz2 |
Add the bootstrap script
* .gitignore: New file.
* bootstrap: New file.
* wordsplit.at: Convert to stand-alone script.
* wsp.c: Support the --version option.
-rw-r--r-- | .gitignore | 9 | ||||
-rwxr-xr-x | bootstrap | 162 | ||||
-rw-r--r-- | wordsplit.at | 3 | ||||
-rw-r--r-- | wsp.c | 15 |
4 files changed, 188 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4b54ce9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*~ +.emacs* +package.m4 +wordsplit-version.h +Makefile.am +Makefile.in +Makefile +configure.ac +configure diff --git a/bootstrap b/bootstrap new file mode 100755 index 0000000..4cc4178 --- /dev/null +++ b/bootstrap @@ -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 + + diff --git a/wordsplit.at b/wordsplit.at index 13f2f84..52a4a75 100644 --- a/wordsplit.at +++ b/wordsplit.at @@ -14,7 +14,8 @@ # You should have received a copy of the GNU General Public License # 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([wspid]) @@ -23,6 +23,7 @@ #include <assert.h> #include <errno.h> #include "wordsplit.h" +#include "wordsplit-version.h" extern char **environ; @@ -83,6 +84,12 @@ struct wsopt /* Index of the next argument in the argv */ 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 or when the "--" argument is seen. */ static int @@ -110,7 +117,15 @@ getwsopt (int argc, char **argv, struct wsopt *wso, struct wsclosure *wsc) wsoptind--; return EOF; } + + if (strcmp (opt, "--version") == 0) + { + print_version (); + exit (0); + } + opt++; /* skip past initial dash */ + if (strncmp (opt, "no-", 3) == 0) { negate = 1; |