From e9ab90141032c23a97fa82a723a7a751658bce66 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sat, 5 Mar 2022 15:43:33 -0500 Subject: [PATCH] Pull in gnulib for its portability features. --- .gitignore | 2 ++ .gitmodules | 3 +++ Makefile.am | 14 ++++++++--- bootstrap | 59 +++++++++++++++++++++++++++++++++++++++++++ configure.ac | 8 ++++++ gnulib | 1 + m4/.gitignore | 21 ++++++++++++++++ m4/gnulib-cache.m4 | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 168 insertions(+), 3 deletions(-) create mode 100755 bootstrap create mode 160000 gnulib create mode 100644 m4/gnulib-cache.m4 diff --git a/.gitignore b/.gitignore index 2f2a3da..92acc78 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.o .deps .dirstamp +/INSTALL /Makefile /Makefile.in /aclocal.m4 @@ -12,6 +13,7 @@ /configure /depcomp /install-sh +/lib /libtool /ltmain.sh /missing diff --git a/.gitmodules b/.gitmodules index a0019b3..34c552c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "common"] path = common url = https://git.draconx.ca/dxcommon.git +[submodule "gnulib"] + path = gnulib + url = https://git.savannah.gnu.org/git/gnulib.git diff --git a/Makefile.am b/Makefile.am index c9c2816..48a0b4e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,29 +9,35 @@ ACLOCAL_AMFLAGS = -I m4 -I common/m4 EXTRA_DIST = EXTRA_LIBRARIES = MAINTAINERCLEANFILES = +MOSTLYCLEANFILES = DISTCLEANFILES = CLEANFILES = $(EXTRA_LIBRARIES) -AM_CPPFLAGS = -I$(builddir)/src -I$(srcdir)/src -I$(DX_BASEDIR)/src +AM_CPPFLAGS = -I$(builddir)/src -I$(srcdir)/src -I$(DX_BASEDIR)/src \ + -I$(builddir)/lib -I$(srcdir)/lib AM_CFLAGS = $(MOTIF_CFLAGS) bin_PROGRAMS = rrace-motif rrace_motif_SOURCES = src/game.c src/x11.c rrace_motif_LDADD = $(libmotifmain_a_OBJECTS) $(libmotifui_a_OBJECTS) \ - $(libglohelp_a_OBJECTS) $(MOTIF_LIBS) + $(libglohelp_a_OBJECTS) libgnu.a $(MOTIF_LIBS) +$(rrace_motif_OBJECTS): $(gnulib_headers) EXTRA_LIBRARIES += libmotifmain.a libmotifmain_a_SOURCES = src/motif.c +$(libmotifmain_a_OBJECTS): $(gnulib_headers) $(libmotifmain_a_OBJECTS): src/motifopt.h EXTRA_LIBRARIES += libmotifui.a libmotifui_a_SOURCES = src/motif_ui.c +$(libmotifui_a_OBJECTS): $(gnulib_headers) $(libmotifui_a_OBJECTS): src/motifgui.h src/motifstr.h EXTRA_LIBRARIES += libglohelp.a libglohelp_a_SOURCES = common/src/help.c libglohelp_a_CFLAGS = -DHELP_GETOPT_LONG_ONLY +$(libglohelp_a_OBJECTS): $(gnulib_headers) libglohelp_a_SHORTNAME = glo OPTFILES = src/motifopt.opt @@ -60,6 +66,8 @@ EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-tree.awk $(GUIFILES) check_PROGRAMS = t/boardmove t/rng-test -t_boardmove_LDADD = src/game.$(OBJEXT) +t_boardmove_LDADD = src/game.$(OBJEXT) libgnu.a +$(t_boardmove_OBJECTS): $(gnulib_headers) +include $(top_srcdir)/lib/gnulib.mk include $(top_srcdir)/common/snippet/autotest.mk diff --git a/bootstrap b/bootstrap new file mode 100755 index 0000000..f16d302 --- /dev/null +++ b/bootstrap @@ -0,0 +1,59 @@ +#!/bin/sh +# +# Copyright © 2011-2012, 2015, 2021-2022 Nick Bowler +# +# Simple script to get started from a fresh git checkout. +# +# License WTFPL2: Do What The Fuck You Want To Public License, version 2. +# This is free software: you are free to do what the fuck you want to. +# There is NO WARRANTY, to the extent permitted by law. + +scriptname=$0 + +err() { printf '%s: %s\n' "$scriptname" "$*" 1>&2; } +die() { err "$@"; exit 1; } + +: ${AUTORECONF=autoreconf} +: ${AUTOMAKE=automake} +: ${GNULIB=gnulib} +: ${GIT=git} +: ${PERL=perl} + +$GIT submodule update --init || err "Failed to update submodules from git." + +if test -x $GNULIB/gnulib-tool; then + $GNULIB/gnulib-tool --update -S || die "Failed to update Gnulib." +else + err "Gnulib sources are not properly installed in $GNULIB/" + cat >&2 <<'EOF' + +To bootstrap this package using an external Gnulib, you can set the GNULIB +environment variable to indicate the location of the Gnulib sources. +EOF + + test ! -f configure || cat >&2 <<'EOF' + +However, it seems this package is already bootstrapped. It should not +normally be necessary to run this script from a release tarball. +EOF + exit 1 +fi + +$PERL common/scripts/fix-gnulib.pl -o lib/gnulib.mk -i lib/gnulib.mk.in \ + || die "Failed to fixup Gnulib makefile fragment." + +# Rewrite if ! ... construts produced by gnulib conditional dependencies +# as these fail in heirloom-sh. +sed 's/if ! *\(.*gnulib_enabled[^;]*\); then/if \1; then :; else/' \ + m4/gnulib-comp.m4 >m4/gnulib-comp.m4.new || exit +mv -f m4/gnulib-comp.m4.new m4/gnulib-comp.m4 || exit + +# Punt some automake-generated files so that Gentoo's wrapper script doesn't +# try to detect the automake version in use. +rm -f Makefile.in aclocal.m4 +$AUTORECONF -fis || exit + +amdir=`$AUTOMAKE --print-libdir` +if test -f "$amdir/INSTALL"; then + ln -sf "$amdir/INSTALL" INSTALL +fi diff --git a/configure.ac b/configure.ac index b0c7fb0..88c9db9 100644 --- a/configure.ac +++ b/configure.ac @@ -4,6 +4,9 @@ dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2. dnl This is free software: you are free to do what the fuck you want to. dnl There is NO WARRANTY, to the extent permitted by law. +dnl remove pointless gnulib warning flag check +AC_DEFUN([gl_CC_GNULIB_WARNINGS]) + AC_INIT([rrace], [0], [nbowler@draconx.ca]) AC_CONFIG_HEADERS([config.h]) @@ -12,7 +15,12 @@ AM_SILENT_RULES([yes]) DX_AUTOMAKE_COMPAT AC_PROG_CC_C99 +gl_EARLY LT_INIT +gl_INIT + +AC_CACHE_SAVE +m4_include([lib/gnulib.mk]) AC_PATH_XTRA AS_IF([test x"$no_x" != x"yes"], diff --git a/gnulib b/gnulib new file mode 160000 index 0000000..8c4f4d7 --- /dev/null +++ b/gnulib @@ -0,0 +1 @@ +Subproject commit 8c4f4d7a3c28f88b64fce2fb1d0dc0e570d1a482 diff --git a/m4/.gitignore b/m4/.gitignore index 94e6f26..ff430e2 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -1,5 +1,26 @@ +/00gnulib.m4 +/absolute-header.m4 +/extensions.m4 +/extern-inline.m4 +/getopt.m4 +/gnulib-common.m4 +/gnulib-comp.m4 +/gnulib-tool.m4 +/include_next.m4 +/inline.m4 /libtool.m4 /ltoptions.m4 /ltsugar.m4 /ltversion.m4 /lt~obsolete.m4 +/nocrash.m4 +/off_t.m4 +/pid_t.m4 +/ssize_t.m4 +/stddef_h.m4 +/sys_types_h.m4 +/unistd_h.m4 +/vararrays.m4 +/warn-on-use.m4 +/wchar_t.m4 +/zzgnulib.m4 diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 new file mode 100644 index 0000000..d1c7383 --- /dev/null +++ b/m4/gnulib-cache.m4 @@ -0,0 +1,63 @@ +# Copyright (C) 2002-2022 Free Software Foundation, Inc. +# +# This file 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 3 of the License, or +# (at your option) any later version. +# +# This file 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 file. If not, see . +# +# As a special exception to the GNU General Public License, +# this file may be distributed as part of a program that +# contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# Generated by gnulib-tool. +# +# This file represents the specification of how gnulib-tool is used. +# It acts as a cache: It is written and read by gnulib-tool. +# In projects that use version control, this file is meant to be put under +# version control, like the configure.ac and various Makefile.am files. + + +# Specification in the form of a command-line invocation: +# gnulib-tool --import \ +# --lib=libgnu \ +# --source-base=lib \ +# --m4-base=m4 \ +# --doc-base=doc \ +# --tests-base=tests \ +# --aux-dir=. \ +# --makefile-name=gnulib.mk.in \ +# --conditional-dependencies \ +# --no-libtool \ +# --macro-prefix=gl \ +# --no-vc-files \ +# getopt-gnu \ +# inline + +# Specification in the form of a few gnulib-tool.m4 macro invocations: +gl_LOCAL_DIR([]) +gl_MODULES([ + getopt-gnu + inline +]) +gl_AVOID([]) +gl_SOURCE_BASE([lib]) +gl_M4_BASE([m4]) +gl_PO_BASE([]) +gl_DOC_BASE([doc]) +gl_TESTS_BASE([tests]) +gl_LIB([libgnu]) +gl_MAKEFILE_NAME([gnulib.mk.in]) +gl_CONDITIONAL_DEPENDENCIES +gl_MACRO_PREFIX([gl]) +gl_PO_DOMAIN([]) +gl_WITNESS_C_MACRO([]) +gl_VC_FILES([false]) -- 2.43.2