From d5a0b05f5269c63e61fcb5dcb53209388c1d3e81 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sun, 7 Jul 2019 15:50:45 +0300 Subject: [PATCH] Add the bootstrap script * .gitignore: New file. * bootstrap: New file. * wordsplit.at: Convert to stand-alone script. * wsp.c: Support the --version option. --- .gitignore | 9 +++ bootstrap | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++ wordsplit.at | 3 +- wsp.c | 15 +++++ 4 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100755 bootstrap 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 < package.m4 < 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 < Makefile.am + mk_atlocal + common_notice +} + +function mk_shared() { + (cat < Makefile.am + mk_atlocal + common_notice +} + +function mk_static() { + (cat < Makefile.am + mk_atlocal + common_notice +} + +function mk_embedded() { + (mk_testsuite wordsplit.o + echo "AM_CPPFLAGS = " + )> Makefile.am + mk_atlocal + cat <&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 . -AT_BANNER(Wordsplit) +AT_INIT +AT_TESTED(wsp) m4_pushdef([wspnum],[0]) m4_pushdef([wspid]) diff --git a/wsp.c b/wsp.c index 6f8cdc7..6217d5e 100644 --- a/wsp.c +++ b/wsp.c @@ -23,6 +23,7 @@ #include #include #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;