* examples: New directory.
+2021-12-15 Bruno Haible <bruno@clisp.org>
+
+ Add simple examples.
+ * examples: New directory.
+
2021-12-15 Bruno Haible <bruno@clisp.org>
Accommodate non-recursive Automake in a less hacky way.
--- /dev/null
+This directory contains small packages that
+1) show how to use Gnulib and gnulib-tool (working examples),
+2) can be used for doing regression tests, e.g. when modifying gnulib-tool.
--- /dev/null
+Installation:
+ ./autogen.sh
+ ./configure --prefix=/some/prefix
+ make
+ make install
+Cleanup:
+ make distclean
+ ./autoclean.sh
--- /dev/null
+# This file is in the public domain.
+#
+# Makefile configuration - processed by automake.
+
+# General automake options.
+AUTOMAKE_OPTIONS = foreign no-dependencies subdir-objects
+ACLOCAL_AMFLAGS = -I m4 -I gnulib-m4
+
+# The list of subdirectories containing Makefiles.
+SUBDIRS = . tests
+
+AM_CPPFLAGS = -Ilib -I$(srcdir)/lib
+
+# Additional files to be distributed.
+EXTRA_DIST = autogen.sh autoclean.sh gnulib-m4/gnulib-cache.m4
+
+BUILT_SOURCES =
+SUFFIXES =
+MOSTLYCLEANFILES =
+MOSTLYCLEANDIRS =
+CLEANFILES =
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+
+noinst_LIBRARIES =
+
+include lib/gnulib.mk
+include src/local.mk
--- /dev/null
+#!/bin/sh
+# This file is in the public domain.
+#
+# Script for cleaning all autogenerated files.
+
+test ! -f Makefile || make distclean
+
+# Generated by aclocal.
+rm -f aclocal.m4
+
+# Generated by autoconf.
+rm -f configure
+
+# Generated by autoheader.
+rm -f config.h.in
+
+# Generated or brought in by automake.
+rm -f Makefile.in
+rm -f m4/Makefile.in
+rm -f build-aux/compile
+rm -f build-aux/depcomp
+rm -f build-aux/install-sh
+rm -f build-aux/missing
+rm -f build-aux/config.guess
+rm -f build-aux/config.sub
+
+# Generated or brought in by gnulib-tool.
+rm -rf lib gnulib-m4 tests
+rm -f build-aux/ar-lib
+rm -f build-aux/run-test
+rm -f build-aux/test-driver.diff
+
+# Generated by autogen.sh.
+rm -f build-aux/test-driver
--- /dev/null
+#!/bin/sh
+# This file is in the public domain.
+#
+# Script for regenerating all autogenerated files.
+
+# Usage: ./autogen.sh [--skip-gnulib]
+
+skip_gnulib=false
+while :; do
+ case "$1" in
+ --skip-gnulib) skip_gnulib=true; shift;;
+ *) break ;;
+ esac
+done
+
+if test $skip_gnulib = false; then
+ if test -n "$GNULIB_SRCDIR"; then
+ test -d "$GNULIB_SRCDIR" || {
+ echo "*** GNULIB_SRCDIR is set but does not point to an existing directory." 1>&2
+ exit 1
+ }
+ fi
+ # Now it should contain a gnulib-tool.
+ GNULIB_TOOL="$GNULIB_SRCDIR/gnulib-tool"
+ test -f "$GNULIB_TOOL" || {
+ echo "*** gnulib-tool not found." 1>&2
+ exit 1
+ }
+ GNULIB_MODULES='
+ unistd
+ get_ppid_of
+ '
+ $GNULIB_TOOL --lib=libgnu --source-base=lib --m4-base=gnulib-m4 --tests-base=tests \
+ --with-tests --makefile-name=gnulib.mk --tests-makefile-name=Makefile.am --automake-subdir \
+ --import $GNULIB_MODULES
+ $GNULIB_TOOL --copy-file build-aux/ar-lib; chmod a+x build-aux/ar-lib
+ $GNULIB_TOOL --copy-file build-aux/config.guess; chmod a+x build-aux/config.guess
+ $GNULIB_TOOL --copy-file build-aux/config.sub; chmod a+x build-aux/config.sub
+ $GNULIB_TOOL --copy-file build-aux/run-test; chmod a+x build-aux/run-test
+ $GNULIB_TOOL --copy-file build-aux/test-driver.diff
+fi
+
+aclocal -I m4 -I gnulib-m4
+autoconf
+autoheader && touch config.h.in
+automake -a -c
+patch --quiet --forward --reject-file=/dev/null build-aux/test-driver < build-aux/test-driver.diff
+rm -rf autom4te.cache
--- /dev/null
+dnl This file is in the public domain.
+dnl
+dnl Configuration file - processed by autoconf.
+
+AC_INIT([hello-c], [0])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_SRCDIR([src/hello.c])
+AM_INIT_AUTOMAKE
+
+AC_CONFIG_HEADERS([config.h])
+
+AC_PROG_CC
+
+gl_EARLY
+gl_INIT
+
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([tests/Makefile])
+AC_OUTPUT
--- /dev/null
+EXTRA_DIST =
--- /dev/null
+/* This file is in the public domain.
+
+ Source code of the C program. */
+
+
+/* Every source file that uses Gnulib needs this. */
+#include <config.h>
+
+/* Get printf() declaration. */
+#include <stdio.h>
+
+/* Get getpid() declaration. */
+#include <unistd.h>
+
+/* Include Gnulib header files. */
+#include "get_ppid_of.h"
+
+int
+main ()
+{
+ printf ("%s\n", "Hello, world!");
+ printf ("This program is running as process number %d.\n", getpid ());
+ printf ("The parent process number is %d.\n", get_ppid_of (getpid ()));
+
+ return 0;
+}
--- /dev/null
+
+# The list of programs that are built.
+bin_PROGRAMS = src/hello
+
+# The source files of the 'hello' program.
+src_hello_SOURCES = src/hello.c
+src_hello_LDADD = lib/libgnu.a
--- /dev/null
+Installation:
+ ./autogen.sh
+ ./configure --prefix=/some/prefix
+ make
+ make install
+Cleanup:
+ make distclean
+ ./autoclean.sh
--- /dev/null
+# This file is in the public domain.
+#
+# Makefile configuration - processed by automake.
+
+# General automake options.
+AUTOMAKE_OPTIONS = foreign no-dependencies subdir-objects
+ACLOCAL_AMFLAGS = -I m4 -I gnulib-m4
+
+# The list of subdirectories containing Makefiles.
+SUBDIRS =
+
+AM_CPPFLAGS = -Ilib -I$(srcdir)/lib
+
+# Additional files to be distributed.
+EXTRA_DIST = autogen.sh autoclean.sh gnulib-m4/gnulib-cache.m4
+
+BUILT_SOURCES =
+SUFFIXES =
+MOSTLYCLEANFILES =
+MOSTLYCLEANDIRS =
+CLEANFILES =
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+
+noinst_LIBRARIES =
+
+include lib/gnulib.mk
+include src/local.mk
--- /dev/null
+#!/bin/sh
+# This file is in the public domain.
+#
+# Script for cleaning all autogenerated files.
+
+test ! -f Makefile || make distclean
+
+# Generated by aclocal.
+rm -f aclocal.m4
+
+# Generated by autoconf.
+rm -f configure
+
+# Generated by autoheader.
+rm -f config.h.in
+
+# Generated or brought in by automake.
+rm -f Makefile.in
+rm -f m4/Makefile.in
+rm -f build-aux/compile
+rm -f build-aux/depcomp
+rm -f build-aux/install-sh
+rm -f build-aux/missing
+rm -f build-aux/config.guess
+rm -f build-aux/config.sub
+
+# Generated or brought in by gnulib-tool.
+rm -rf lib gnulib-m4
+rm -f build-aux/ar-lib
--- /dev/null
+#!/bin/sh
+# This file is in the public domain.
+#
+# Script for regenerating all autogenerated files.
+
+# Usage: ./autogen.sh [--skip-gnulib]
+
+skip_gnulib=false
+while :; do
+ case "$1" in
+ --skip-gnulib) skip_gnulib=true; shift;;
+ *) break ;;
+ esac
+done
+
+if test $skip_gnulib = false; then
+ if test -n "$GNULIB_SRCDIR"; then
+ test -d "$GNULIB_SRCDIR" || {
+ echo "*** GNULIB_SRCDIR is set but does not point to an existing directory." 1>&2
+ exit 1
+ }
+ fi
+ # Now it should contain a gnulib-tool.
+ GNULIB_TOOL="$GNULIB_SRCDIR/gnulib-tool"
+ test -f "$GNULIB_TOOL" || {
+ echo "*** gnulib-tool not found." 1>&2
+ exit 1
+ }
+ GNULIB_MODULES='
+ alloca
+ unistd
+ get_ppid_of
+ '
+ $GNULIB_TOOL --lib=libgnu --source-base=lib --m4-base=gnulib-m4 \
+ --makefile-name=gnulib.mk --automake-subdir \
+ --import $GNULIB_MODULES
+ $GNULIB_TOOL --copy-file build-aux/ar-lib; chmod a+x build-aux/ar-lib
+ $GNULIB_TOOL --copy-file build-aux/config.guess; chmod a+x build-aux/config.guess
+ $GNULIB_TOOL --copy-file build-aux/config.sub; chmod a+x build-aux/config.sub
+fi
+
+aclocal -I m4 -I gnulib-m4
+autoconf
+autoheader && touch config.h.in
+automake -a -c
+rm -rf autom4te.cache
--- /dev/null
+dnl This file is in the public domain.
+dnl
+dnl Configuration file - processed by autoconf.
+
+AC_INIT([hello-c], [0])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_SRCDIR([src/hello.c])
+AM_INIT_AUTOMAKE
+
+AC_CONFIG_HEADERS([config.h])
+
+AC_PROG_CC
+
+gl_EARLY
+gl_INIT
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
--- /dev/null
+EXTRA_DIST =
--- /dev/null
+/* This file is in the public domain.
+
+ Source code of the C program. */
+
+
+/* Every source file that uses Gnulib needs this. */
+#include <config.h>
+
+/* Get printf() declaration. */
+#include <stdio.h>
+
+/* Get getpid() declaration. */
+#include <unistd.h>
+
+/* Include Gnulib header files. */
+#include "get_ppid_of.h"
+
+int
+main ()
+{
+ printf ("%s\n", "Hello, world!");
+ printf ("This program is running as process number %d.\n", getpid ());
+ printf ("The parent process number is %d.\n", get_ppid_of (getpid ()));
+
+ return 0;
+}
--- /dev/null
+
+# The list of programs that are built.
+bin_PROGRAMS = src/hello
+
+# The source files of the 'hello' program.
+src_hello_SOURCES = src/hello.c
+src_hello_LDADD = lib/libgnu.a
--- /dev/null
+Installation:
+ ./autogen.sh
+ ./configure --prefix=/some/prefix
+ make
+ make install
+Cleanup:
+ make distclean
+ ./autoclean.sh
--- /dev/null
+# This file is in the public domain.
+#
+# Makefile configuration - processed by automake.
+
+# General automake options.
+AUTOMAKE_OPTIONS = foreign no-dependencies subdir-objects
+ACLOCAL_AMFLAGS = -I m4 -I gnulib-m4
+
+# The list of subdirectories containing Makefiles.
+SUBDIRS =
+
+AM_CPPFLAGS = -Ilib -I$(srcdir)/lib
+
+# Additional files to be distributed.
+EXTRA_DIST = autogen.sh autoclean.sh gnulib-m4/gnulib-cache.m4
+
+BUILT_SOURCES =
+SUFFIXES =
+MOSTLYCLEANFILES =
+MOSTLYCLEANDIRS =
+CLEANFILES =
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+
+noinst_LIBRARIES =
+
+include lib/gnulib.mk
+include src/local.mk
--- /dev/null
+#!/bin/sh
+# This file is in the public domain.
+#
+# Script for cleaning all autogenerated files.
+
+test ! -f Makefile || make distclean
+
+# Generated by aclocal.
+rm -f aclocal.m4
+
+# Generated by autoconf.
+rm -f configure
+
+# Generated by autoheader.
+rm -f config.h.in
+
+# Generated or brought in by automake.
+rm -f Makefile.in
+rm -f m4/Makefile.in
+rm -f build-aux/compile
+rm -f build-aux/depcomp
+rm -f build-aux/install-sh
+rm -f build-aux/missing
+rm -f build-aux/config.guess
+rm -f build-aux/config.sub
+
+# Generated or brought in by gnulib-tool.
+rm -rf lib gnulib-m4
+rm -f build-aux/ar-lib
+rm -f build-aux/prefix-gnulib-mk
--- /dev/null
+#!/bin/sh
+# This file is in the public domain.
+#
+# Script for regenerating all autogenerated files.
+
+# Usage: ./autogen.sh [--skip-gnulib]
+
+skip_gnulib=false
+while :; do
+ case "$1" in
+ --skip-gnulib) skip_gnulib=true; shift;;
+ *) break ;;
+ esac
+done
+
+if test $skip_gnulib = false; then
+ if test -n "$GNULIB_SRCDIR"; then
+ test -d "$GNULIB_SRCDIR" || {
+ echo "*** GNULIB_SRCDIR is set but does not point to an existing directory." 1>&2
+ exit 1
+ }
+ fi
+ # Now it should contain a gnulib-tool.
+ GNULIB_TOOL="$GNULIB_SRCDIR/gnulib-tool"
+ test -f "$GNULIB_TOOL" || {
+ echo "*** gnulib-tool not found." 1>&2
+ exit 1
+ }
+ GNULIB_MODULES='
+ alloca
+ unistd
+ get_ppid_of
+ non-recursive-gnulib-prefix-hack
+ '
+ $GNULIB_TOOL --lib=libgnu --source-base=lib --m4-base=gnulib-m4 \
+ --makefile-name=gnulib.mk \
+ --import $GNULIB_MODULES
+ build-aux/prefix-gnulib-mk --lib-name=libgnu lib/gnulib.mk
+ $GNULIB_TOOL --copy-file build-aux/ar-lib; chmod a+x build-aux/ar-lib
+ $GNULIB_TOOL --copy-file build-aux/config.guess; chmod a+x build-aux/config.guess
+ $GNULIB_TOOL --copy-file build-aux/config.sub; chmod a+x build-aux/config.sub
+fi
+
+aclocal -I m4 -I gnulib-m4
+autoconf
+autoheader && touch config.h.in
+automake -a -c
+rm -rf autom4te.cache
--- /dev/null
+dnl This file is in the public domain.
+dnl
+dnl Configuration file - processed by autoconf.
+
+AC_INIT([hello-c], [0])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_SRCDIR([src/hello.c])
+AM_INIT_AUTOMAKE
+
+AC_CONFIG_HEADERS([config.h])
+
+AC_PROG_CC
+
+gl_EARLY
+gl_INIT
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
--- /dev/null
+EXTRA_DIST =
--- /dev/null
+/* This file is in the public domain.
+
+ Source code of the C program. */
+
+
+/* Every source file that uses Gnulib needs this. */
+#include <config.h>
+
+/* Get printf() declaration. */
+#include <stdio.h>
+
+/* Get getpid() declaration. */
+#include <unistd.h>
+
+/* Include Gnulib header files. */
+#include "get_ppid_of.h"
+
+int
+main ()
+{
+ printf ("%s\n", "Hello, world!");
+ printf ("This program is running as process number %d.\n", getpid ());
+ printf ("The parent process number is %d.\n", get_ppid_of (getpid ()));
+
+ return 0;
+}
--- /dev/null
+
+# The list of programs that are built.
+bin_PROGRAMS = src/hello
+
+# The source files of the 'hello' program.
+src_hello_SOURCES = src/hello.c
+src_hello_LDADD = lib/libgnu.a
--- /dev/null
+Installation:
+ ./autogen.sh
+ ./configure --prefix=/some/prefix
+ make
+ make install
+Cleanup:
+ make distclean
+ ./autoclean.sh
--- /dev/null
+# This file is in the public domain.
+#
+# Makefile configuration - processed by automake.
+
+# General automake options.
+AUTOMAKE_OPTIONS = foreign no-dependencies
+ACLOCAL_AMFLAGS = -I m4 -I gnulib-m4
+
+# The list of subdirectories containing Makefiles.
+SUBDIRS = m4 lib tests
+
+AM_CPPFLAGS = -Ilib -I$(srcdir)/lib
+
+# The list of programs that are built.
+bin_PROGRAMS = hello
+
+# The source files of the 'hello' program.
+hello_SOURCES = hello.c
+hello_LDADD = lib/libgnu.a
+
+# Additional files to be distributed.
+EXTRA_DIST = autogen.sh autoclean.sh gnulib-m4/gnulib-cache.m4
--- /dev/null
+#!/bin/sh
+# This file is in the public domain.
+#
+# Script for cleaning all autogenerated files.
+
+test ! -f Makefile || make distclean
+
+# Generated by aclocal.
+rm -f aclocal.m4
+
+# Generated by autoconf.
+rm -f configure
+
+# Generated by autoheader.
+rm -f config.h.in
+
+# Generated or brought in by automake.
+rm -f Makefile.in
+rm -f m4/Makefile.in
+rm -f build-aux/compile
+rm -f build-aux/depcomp
+rm -f build-aux/install-sh
+rm -f build-aux/missing
+rm -f build-aux/config.guess
+rm -f build-aux/config.sub
+
+# Generated or brought in by gnulib-tool.
+rm -rf lib gnulib-m4 tests
+rm -f build-aux/ar-lib
+rm -f build-aux/run-test
+rm -f build-aux/test-driver.diff
+
+# Generated by autogen.sh.
+rm -f build-aux/test-driver
--- /dev/null
+#!/bin/sh
+# This file is in the public domain.
+#
+# Script for regenerating all autogenerated files.
+
+# Usage: ./autogen.sh [--skip-gnulib]
+
+skip_gnulib=false
+while :; do
+ case "$1" in
+ --skip-gnulib) skip_gnulib=true; shift;;
+ *) break ;;
+ esac
+done
+
+if test $skip_gnulib = false; then
+ if test -n "$GNULIB_SRCDIR"; then
+ test -d "$GNULIB_SRCDIR" || {
+ echo "*** GNULIB_SRCDIR is set but does not point to an existing directory." 1>&2
+ exit 1
+ }
+ fi
+ # Now it should contain a gnulib-tool.
+ GNULIB_TOOL="$GNULIB_SRCDIR/gnulib-tool"
+ test -f "$GNULIB_TOOL" || {
+ echo "*** gnulib-tool not found." 1>&2
+ exit 1
+ }
+ GNULIB_MODULES='
+ unistd
+ get_ppid_of
+ '
+ $GNULIB_TOOL --lib=libgnu --source-base=lib --m4-base=gnulib-m4 --tests-base=tests \
+ --with-tests \
+ --import $GNULIB_MODULES
+ mkdir -p build-aux
+ $GNULIB_TOOL --copy-file build-aux/ar-lib; chmod a+x build-aux/ar-lib
+ $GNULIB_TOOL --copy-file build-aux/config.guess; chmod a+x build-aux/config.guess
+ $GNULIB_TOOL --copy-file build-aux/config.sub; chmod a+x build-aux/config.sub
+ $GNULIB_TOOL --copy-file build-aux/run-test; chmod a+x build-aux/run-test
+ $GNULIB_TOOL --copy-file build-aux/test-driver.diff
+fi
+
+aclocal -I m4 -I gnulib-m4
+autoconf
+autoheader && touch config.h.in
+automake -a -c
+patch --quiet --forward --reject-file=/dev/null build-aux/test-driver < build-aux/test-driver.diff
+rm -rf autom4te.cache
--- /dev/null
+dnl This file is in the public domain.
+dnl
+dnl Configuration file - processed by autoconf.
+
+AC_INIT([hello-c], [0])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_SRCDIR([hello.c])
+AM_INIT_AUTOMAKE
+
+AC_CONFIG_HEADERS([config.h])
+
+AC_PROG_CC
+
+gl_EARLY
+gl_INIT
+
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([m4/Makefile])
+AC_CONFIG_FILES([lib/Makefile])
+AC_CONFIG_FILES([tests/Makefile])
+AC_OUTPUT
--- /dev/null
+/* This file is in the public domain.
+
+ Source code of the C program. */
+
+
+/* Every source file that uses Gnulib needs this. */
+#include <config.h>
+
+/* Get printf() declaration. */
+#include <stdio.h>
+
+/* Get getpid() declaration. */
+#include <unistd.h>
+
+/* Include Gnulib header files. */
+#include "get_ppid_of.h"
+
+int
+main ()
+{
+ printf ("%s\n", "Hello, world!");
+ printf ("This program is running as process number %d.\n", getpid ());
+ printf ("The parent process number is %d.\n", get_ppid_of (getpid ()));
+
+ return 0;
+}
--- /dev/null
+EXTRA_DIST =
--- /dev/null
+Installation:
+ ./autogen.sh
+ ./configure --prefix=/some/prefix
+ make
+ make install
+Cleanup:
+ make distclean
+ ./autoclean.sh
--- /dev/null
+# This file is in the public domain.
+#
+# Makefile configuration - processed by automake.
+
+# General automake options.
+AUTOMAKE_OPTIONS = foreign no-dependencies
+ACLOCAL_AMFLAGS = -I m4
+
+# The list of subdirectories containing Makefiles.
+SUBDIRS = m4
+
+# The list of programs that are built.
+bin_PROGRAMS = hello
+
+# The source files of the 'hello' program.
+hello_SOURCES = hello.c
+
+# Additional files to be distributed.
+EXTRA_DIST = autogen.sh autoclean.sh
--- /dev/null
+#!/bin/sh
+# This file is in the public domain.
+#
+# Script for cleaning all autogenerated files.
+
+test ! -f Makefile || make distclean
+
+# Generated by aclocal.
+rm -f aclocal.m4
+
+# Generated by autoconf.
+rm -f configure
+
+# Generated or brought in by automake.
+rm -f Makefile.in
+rm -f m4/Makefile.in
+rm -f build-aux/compile
+rm -f build-aux/install-sh
+rm -f build-aux/missing
+rm -f build-aux/config.guess
+rm -f build-aux/config.sub
--- /dev/null
+#!/bin/sh
+# This file is in the public domain.
+#
+# Script for regenerating all autogenerated files.
+
+aclocal -I m4
+autoconf
+automake -a -c
+rm -rf autom4te.cache
--- /dev/null
+dnl This file is in the public domain.
+dnl
+dnl Configuration file - processed by autoconf.
+
+AC_INIT([hello-c], [0])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_SRCDIR([hello.c])
+AM_INIT_AUTOMAKE
+
+AC_PROG_CC
+AC_CHECK_HEADERS([unistd.h])
+
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([m4/Makefile])
+AC_OUTPUT
--- /dev/null
+/* This file is in the public domain.
+
+ Source code of the C program. */
+
+
+/* Get printf() declaration. */
+#include <stdio.h>
+
+/* Get getpid() declaration. */
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+int
+main ()
+{
+ printf ("%s\n", "Hello, world!");
+ printf ("This program is running as process number %d.", getpid ());
+ putchar ('\n');
+
+ return 0;
+}
--- /dev/null
+EXTRA_DIST =