]> git.draconx.ca Git - dxcommon.git/log
dxcommon.git
16 months agoAdd a helper macro to use the new gen-options packed format.
Nick Bowler [Sun, 8 Jan 2023 05:32:22 +0000 (00:32 -0500)]
Add a helper macro to use the new gen-options packed format.

Abstract some of the boilerplate into a new macro.  The gen-options.awk
is augmented to also give the packed format width as a power of two
(8/16/32/64).  Other than that we can use all the existing definitions
to make this common code in a new "xtra.h" header file.

16 months agogen-options.awk: Work around busybox regex bug.
Nick Bowler [Sun, 8 Jan 2023 04:19:18 +0000 (23:19 -0500)]
gen-options.awk: Work around busybox regex bug.

It appears that busybox awk does not recognize \] in a character class,
interpreting the backslash literally and taking the ] as the end of the
character class:

  % printf '%s\n' ']' '\]' | busybox awk '/^[\]]$/ { print; }'
  \]

  % printf '%s\n' ']' '\]' | gawk '/^[\]]$/ { print; }'
  ]

Busybox does accept []] as meaning "] is part of the character class",
but this syntax is not portable to heirloom (and presumably also Solaris
10) awk, which only works with [\]].  GNU awk accepts either form.

So instead, let's avoid this problematic construct entirely by writing
the test in a different way.

16 months agogen-options.awk: Fix generated help text under mawk.
Nick Bowler [Sun, 8 Jan 2023 04:14:56 +0000 (23:14 -0500)]
gen-options.awk: Fix generated help text under mawk.

It appears that the following construction is not portable:

  % gawk 'BEGIN { a[0] = 0 in a ? 54 : 42; print a[0]; }'
  42

  % mawk 'BEGIN { a[0] = 0 in a ? 54 : 42; print a[0]; }'
  54

In gen-options.awk, this results in results in bogus leading newlines
added to the help text.  It is easy enough to restructure the code
to not do that, separating the test from the assignment.

16 months agogen-options.awk: Add a more compact data representation.
Nick Bowler [Sun, 8 Jan 2023 02:14:10 +0000 (21:14 -0500)]
gen-options.awk: Add a more compact data representation.

Add a new set of macros that can be used to encode the long options
array as integers, which is possible provided that the "action"
feature is not used.  In addition to reducing the size of the
static array, it should be helpful to avoid relocations in
position-independent executables and improve data sharing.

16 months agogen-strtab.awk: Work around portability problems with \\\\.
Nick Bowler [Wed, 4 Jan 2023 03:41:58 +0000 (22:41 -0500)]
gen-strtab.awk: Work around portability problems with \\\\.

It seems that mawk, and also gawk in POSIX mode, handle backslashes
in the (g)sub replacement strings strangely.  For example:

  % echo 'hello' | mawk '{ sub(/e/, "\\\\"); print }'
  h\llo

  % echo 'hello' | gawk '{ sub(/e/, "\\\\"); print }'
  h\\llo

  % echo 'hello' | POSIXLY_CORRECT=1 gawk '{ sub(/e/, "\\\\"); print }'
  h\llo

This causes errors when the script tries to use gsub to restore
the double backslashes on these implementations.  There seems to
be no trouble substiting "\\" to get a single backslash, so we
can work around the problem by doubling up the characters being
replaced instead (which additionally requires an adjustment to
the length calculations to reverse this).

16 months agogen-strtab.awk: Work around parse issue on HP-UX 11.
Nick Bowler [Wed, 4 Jan 2023 02:19:09 +0000 (21:19 -0500)]
gen-strtab.awk: Work around parse issue on HP-UX 11.

HP-UX 11 awk seems to have some issues parsing ! in expressions.
For example:

  % awk 'BEGIN { print 1 + !0 }'
  syntax error The source line is 1.
  The error context is
BEGIN { print 1 + >>>  ! <<< 0 }
  awk: The statement cannot be correctly parsed.
  The source line is 1.

Adding parentheses appers sufficient to avoid the problem:

  % awk 'BEGIN { print 1 + (!0) }'
  2

16 months agogen-strtab.awk: Add a feature to disable l10n markings.
Nick Bowler [Tue, 3 Jan 2023 04:08:00 +0000 (23:08 -0500)]
gen-strtab.awk: Add a feature to disable l10n markings.

Preceding an identifier with two ampersands now causes the output to
not include the N_ macro for that string, so xgettext won't pick it up.
This enables creating a mixed string table with some strings marked as
translatable and others not.

16 months agogen-strtab.awk: Add options to tweak the output.
Nick Bowler [Tue, 3 Jan 2023 02:31:45 +0000 (21:31 -0500)]
gen-strtab.awk: Add options to tweak the output.

Add a @nozero option to ensure all strings have non-zero offsets
into the strtab.

17 months agoDX_PROG_MD5: direct probing error messages to the log file.
Nick Bowler [Fri, 18 Nov 2022 03:00:27 +0000 (22:00 -0500)]
DX_PROG_MD5: direct probing error messages to the log file.

Otherwise we can get a bunch of garbage printed to the terminal when
configuring on some systems.

17 months agoAdd a macro to probe -mwindows on MinGW.
Nick Bowler [Fri, 18 Nov 2022 02:55:34 +0000 (21:55 -0500)]
Add a macro to probe -mwindows on MinGW.

MinGW is typically configured to build console applications by default.
So in order to build a normal Windows GUI application, this flag is
needed when linking.  Otherwise, a console window will be opened when
the program is run.

Other Windows compilers probably have similar options which can added to
the probe in the future.

22 months agogen-tree.awk: Allow simple '#' comments.
Nick Bowler [Sat, 18 Jun 2022 01:33:07 +0000 (21:33 -0400)]
gen-tree.awk: Allow simple '#' comments.

22 months agogen-tree.awk: Add options to tweak the strtab output.
Nick Bowler [Sat, 18 Jun 2022 01:29:28 +0000 (21:29 -0400)]
gen-tree.awk: Add options to tweak the strtab output.

Add a @nostrtab option to disable the string table output in tree
generation, and make it possible to omit the node identifiers from
the initializers.

23 months agoAdd some curses-related feature tests.
Nick Bowler [Tue, 7 Jun 2022 03:56:03 +0000 (23:56 -0400)]
Add some curses-related feature tests.

Add helper macros to check the existence of specific functions in the
curses library, and also a helper to check for mouse support functions.

23 months agoAdd library test for curses.
Nick Bowler [Sun, 5 Jun 2022 15:59:13 +0000 (11:59 -0400)]
Add library test for curses.

23 months agoAdd missing file for autotest snippet test.
Nick Bowler [Wed, 8 Jun 2022 01:50:06 +0000 (21:50 -0400)]
Add missing file for autotest snippet test.

The test for --disable-dependency-tracking depends on a mock autotest
command but I apparently failed to commit that script.

2 years agoexported.sh: Work around DJGPP shell redirection bug.
Nick Bowler [Thu, 21 Apr 2022 05:29:22 +0000 (01:29 -0400)]
exported.sh: Work around DJGPP shell redirection bug.

In DJGPP's bash port, it seems that redirections of the form

  /absolute/path/to/program 3>&-

result in the file descriptor being closed for the whole shell,
rather than just for the one command as expected.  Since some of
the configure substitutions into exported.sh can be absolute paths,
this causes failures.

Using a different command syntax avoids this problem.  For example,

  { /absolute/path/to/program; } 3>&-

appears to work as expected.  Adjust the exported.sh.in snippet to
do just that.  There is still one redirection error message printed
to stderr by DJGPP bash but it appears spurious at first glance.
All the redirections now appear to be working properly and the
script output looks good.

2 years agoexported.sh: Restructure argument processing a bit.
Nick Bowler [Thu, 21 Apr 2022 05:23:05 +0000 (01:23 -0400)]
exported.sh: Restructure argument processing a bit.

Adjust the script to iterate over arguments using a for loop instead of
repeatedly checkind $# and shifting.  More significantly, avoid calling
expr on each filename where a case pattern can do the job.

Additionally, add a new test case to verify the basic sanity of this
script and its corresponding Autoconf macro.

2 years agoFix autotest snippet with --disable-dependency-tracking.
Nick Bowler [Sat, 26 Mar 2022 03:58:29 +0000 (23:58 -0400)]
Fix autotest snippet with --disable-dependency-tracking.

When configuring with --disable-dependency-tracking, the .deps
directories are not created by config.status so unconditionally
creating files in there will not work.

We can avoid this problem by adjusting the rule to skip updating
testsuite.P in this configuration.  Add a new test case to expose
the issue.

2 years agoFix glconfig with --disable-dependency-tracking.
Nick Bowler [Thu, 24 Mar 2022 02:22:50 +0000 (22:22 -0400)]
Fix glconfig with --disable-dependency-tracking.

When configuring with --disable-dependency-tracking, the .deps
directories are not created by config.status so unconditionally
creating files in there will not work.

Making the dependency file generation conditional will avoid this
problem.  Add a new test case to cover this issue.

2 years agofix-gnulib: Ensure header rules create output directory.
Nick Bowler [Thu, 24 Mar 2022 01:31:06 +0000 (21:31 -0400)]
fix-gnulib: Ensure header rules create output directory.

Normally there is no problem, but when performing a VPATH builds
with --disable-dependency-tracking the "lib" directory does not get
created by configure and some of the rules that create header files
will fail.

It seems recent versions of Gnulib have a potential solution for this
particular problem but is easy enough to patch it up here too.

2 years agofix-gnulib: Drop silly libgnu warning options.
Nick Bowler [Sun, 27 Feb 2022 01:21:42 +0000 (20:21 -0500)]
fix-gnulib: Drop silly libgnu warning options.

We really don't care about upstream's choice of build warning flags.
All pushing this on downstream users does is massively inflate generated
makefiles for no actual benefit.

2 years agofix-ltdl: Fix LIBOBJ mangling to work with automake-1.16.
Nick Bowler [Sat, 26 Feb 2022 22:55:30 +0000 (17:55 -0500)]
fix-ltdl: Fix LIBOBJ mangling to work with automake-1.16.

Apparently automake 1.16 changed how object files in a subdirectory are
named when using subdir-objects.  As the generated rules to copy compiled
objects to the ltdl_LTLIBOBJ substituted names, these rules are now failing
on current automake.

Fix this by explicitly setting a _SHORTNAME for the dummy libobj library,
which explicitly sets the name to use and thus it will be consistent
between different Automake versions.

Add new test cases to verify this behaviour.

2 years agofix-ltdl: Fix order-only hack with HP-UX make.
Nick Bowler [Sat, 26 Feb 2022 20:26:58 +0000 (15:26 -0500)]
fix-ltdl: Fix order-only hack with HP-UX make.

HP-UX make gets confused by the space in $(findstring ...,$(...))
syntax: instead of expanding to the empty string as desired, it
mismatches the parentheses and we are left with a single ).  E.g.:

  % cat >Makefile <<'EOF'
  all:
@echo '$(a $(b))'
EOF
  % make
  )

Since $(x) and ${x} are equivalent in Make, a neat solution is to
just replace one set of parentheses with braces; now there are no
nested parentheses to mismatch in the first place.

2 years agohelp_print_optstring: Fix handling of 'flag' options.
Nick Bowler [Thu, 24 Feb 2022 01:47:55 +0000 (20:47 -0500)]
help_print_optstring: Fix handling of 'flag' options.

When getopt_long options use the 'flag' feature, the 'val' member is
not meaningful as a short option.  So we shouldn't try to format it
as if there is a short option, as this leads to printing garbage.

2 years agofix-gnulib: Patch %reldir% too.
Nick Bowler [Thu, 24 Feb 2022 01:41:35 +0000 (20:41 -0500)]
fix-gnulib: Patch %reldir% too.

Gnulib has recently started producing rules using %reldir%.  This
is cool but since we are postprocessing the automake fragment anyway,
we can easily substitute %reldir% ourselves which avoids requiring
newer Automake just for this.

2 years agofix-gnulib: Fix pattern for variable mangling.
Nick Bowler [Thu, 24 Feb 2022 01:29:23 +0000 (20:29 -0500)]
fix-gnulib: Fix pattern for variable mangling.

Recently, gnulib outputs variables named like SED_HEADER_xxx which do
not contain filenames but are matched by the (unnecessarily broad)
pattern for which variables need substitution.

Fix that up and include a test case to reproduce the issue.

2 years agoAdd object prefixing option for DX_GNULIB_SYMFILES.
Nick Bowler [Sat, 19 Feb 2022 22:56:28 +0000 (17:56 -0500)]
Add object prefixing option for DX_GNULIB_SYMFILES.

This is needed to avoid an Automake limitation when mixing libtool
and non-libtool builds of the same source files.  This prefix should
match the object renaming done by Automake when the subdir-objects
option is used.

2 years agoFix DX_GNULIB_SYMFILES usage in VPATH builds.
Nick Bowler [Sat, 19 Feb 2022 03:09:15 +0000 (22:09 -0500)]
Fix DX_GNULIB_SYMFILES usage in VPATH builds.

A typo in the configure commands prevented VPATH builds from working
as expected.  Fix that and add a small test case to verify such builds.

2 years agofix-gnulib: Reduce build-time impact of symbol renaming.
Nick Bowler [Wed, 16 Feb 2022 03:22:59 +0000 (22:22 -0500)]
fix-gnulib: Reduce build-time impact of symbol renaming.

Often a package will use more gnulib modules than actually needed by a
library, with included utilities also making use of portability features
provided by gnulib.

With symbol renaming computed over all objects, as well as linking
everything into both libraries and programs, this leads to compiling
every required gnulib source 3 times, ouch!  And due to how libtool
convenience libraries work, the unused modules are probably wasting
space in the library to boot.

We can do better.

We can partition the gnulib objects into two groups: those that are
needed by the library (and thus require symbol renaming) and the rest
which are only needed by programs.  Only the first group needs any
special treatment.  The others can be put into an ordinary static
library which is not installed.

A new macro, DX_GNULIB_SYMFILES, provides the machinery to do this.

2 years agoImplement the -a and -v options in join.awk.
Nick Bowler [Tue, 15 Feb 2022 06:04:17 +0000 (01:04 -0500)]
Implement the -a and -v options in join.awk.

So now users of DX_PROG_JOIN can use these options.  Two is better
than none!

2 years agoCheck for stray configure output.
Nick Bowler [Sun, 30 Jan 2022 03:02:47 +0000 (22:02 -0500)]
Check for stray configure output.

Instead of ignoring all configure output in tests, we can use the
--quiet option to suppress informational messages and then ensure
the output is empty.  This should catch stray output from macros.

2 years agoAdd "join" detection macro.
Nick Bowler [Sun, 30 Jan 2022 01:48:17 +0000 (20:48 -0500)]
Add "join" detection macro.

It seems that unconditional use of "join" is not portable.  Alpine
Linux, for example, does not include it.  Add a macro which detects
whether join exists and works, with a fallback to an (incomplete)
awk implementation of the tool.

2 years agohelp: Include <locale.h> if NLS is enabled.
Nick Bowler [Wed, 24 Nov 2021 01:45:02 +0000 (20:45 -0500)]
help: Include <locale.h> if NLS is enabled.

It seems gettext.h, at least the version in gnulib, expects LC_MESSAGES
to be available in some scenarios but does not include <locale.h> which
provides it.

2 years agohelp_print_desc: Allow NULL option to disable localisation.
Nick Bowler [Tue, 23 Nov 2021 02:54:58 +0000 (21:54 -0500)]
help_print_desc: Allow NULL option to disable localisation.

This enables the block-indenting functionality to be used in
other contexts.

2 years agoAdd a script to generate constant tree structures.
Nick Bowler [Thu, 7 Oct 2021 04:46:33 +0000 (00:46 -0400)]
Add a script to generate constant tree structures.

This can be useful for generating compact compile-time representations
of menus or whatever else comes to mind.

2 years agohelp: Add a single-dash long option mode.
Nick Bowler [Thu, 30 Sep 2021 01:58:46 +0000 (21:58 -0400)]
help: Add a single-dash long option mode.

For programs using getopt_long_only with single-dash long options, add a
compile time flag to select a mode that produces more appropriate help
output.  This is typical of command-line options for X applications.

2 years agoAdd "md5" detection macro.
Nick Bowler [Wed, 22 Sep 2021 00:39:39 +0000 (20:39 -0400)]
Add "md5" detection macro.

This macro locates a program that can be used to compute MD5 digests
from shell scripts.  Many systems have such a program, but there are
a handful of variations in the wild.

2 years agoAdd common option formatting routines.
Nick Bowler [Mon, 13 Sep 2021 06:30:47 +0000 (02:30 -0400)]
Add common option formatting routines.

Printing a list of program options for --help output is typically
very consistent in all my programs.  Adapt the cdecl99 code to be a
bit more generic so it can (hopefully) be shared across packages.

3 years agoUpdate some copyright years.
Nick Bowler [Sun, 14 Mar 2021 18:37:59 +0000 (14:37 -0400)]
Update some copyright years.

3 years agofix-gnulib: Fix order-only hack with HP-UX make.
Nick Bowler [Sun, 7 Mar 2021 05:57:08 +0000 (00:57 -0500)]
fix-gnulib: Fix order-only hack with HP-UX make.

HP-UX make gets confused by the space in $(findstring ...,$(...))
syntax: instead of expanding to the empty string as desired, it
mismatches the parentheses and we are left with a single ).  E.g.:

  % cat >Makefile <<'EOF'
  all:
@echo '$(a $(b))'
EOF
  % make
  )

Since $(x) and ${x} are equivalent in Make, a neat solution is to
just replace one set of parentheses with braces; now there are no
nested parentheses to mismatch in the first place.

3 years agoFix glconfig depfiles generation with non-GNU makes.
Nick Bowler [Sun, 7 Mar 2021 05:16:28 +0000 (00:16 -0500)]
Fix glconfig depfiles generation with non-GNU makes.

Just like with Autotest, the generation depends on $MAKE set at
configure time, and this was never tried.  Apply the same fix to
glconfig.mk.

3 years agoAvoid nonportable ${x##y} substitutions in program tests.
Nick Bowler [Tue, 9 Mar 2021 06:13:48 +0000 (01:13 -0500)]
Avoid nonportable ${x##y} substitutions in program tests.

Using ${x##y} is not portable: in particular it is not supported by
Solaris /bin/sh (or heirloom-sh).  Define a new macro DX_BASENAME
which implements the particular substitution in a compatible way,
then use it in the flex, bison and gob2 tests.

Moreover, apparently heirloom-sh does not support "command" either,
so let's suppress the error message it generates (the tests will
still produce a usable result), and adjust the test cases to the
correct expected output in this scenario.

3 years agoFix DX_COMMAND_OUTPUT backslash-newline on heirloom-sh.
Nick Bowler [Tue, 9 Mar 2021 03:36:50 +0000 (22:36 -0500)]
Fix DX_COMMAND_OUTPUT backslash-newline on heirloom-sh.

It seems that heirloom-sh (and presumably Solaris /bin/sh) read just
silently eats backslash-newlines, and escaping the backslash does
nothing useful, the shell just eats both backslashes and the newline.

Attempt to avoid this problem by appending a magic string to
troublesome lines, and stripping it after reading.  This will
obviously fail if the input _actually_ has this sequence but
hopefully that will not be an issue in practice.

3 years agoAvoid nonportable ${x%%y} substitutions in DX_LINGUAS.
Nick Bowler [Tue, 9 Mar 2021 01:39:09 +0000 (20:39 -0500)]
Avoid nonportable ${x%%y} substitutions in DX_LINGUAS.

Using ${x%%y} substitutions is not portable: in particular it is
not supported by Solaris /bin/sh (or heirloom-sh).  Let's use a
more portable construct instead.

3 years agoAllow testsuite to run configure with alternate shells.
Nick Bowler [Tue, 9 Mar 2021 03:06:38 +0000 (22:06 -0500)]
Allow testsuite to run configure with alternate shells.

For portability testing of autoconf macros, it is useful to be able
to have the tests run configure with different shells.  Add a global
knob to do this: just run make check with TEST_SHELL=whatever and
the testsuite will set CONFIG_SHELL in testcases appropriately.

Or configure the whole package with CONFIG_SHELL and that will get
passed down too.

However, avoid running the testsuite itself by default with such a
shell because that's not actually what we're trying to test.

3 years agoFix Autotest depfiles generation with non-GNU makes.
Nick Bowler [Sat, 6 Mar 2021 21:22:50 +0000 (16:22 -0500)]
Fix Autotest depfiles generation with non-GNU makes.

Depfiles generation uses the $MAKE value set at configure time, and
apparently I never actually tried this with non-GNU makes.  So of
course it does not work.  Let's try to improve the situation.

3 years agoFix off-by-one error in gen-options.awk.
Nick Bowler [Sat, 6 Mar 2021 21:18:38 +0000 (16:18 -0500)]
Fix off-by-one error in gen-options.awk.

When an option has no help text, the lopt_get_help function is returning
a description pointer which is one past the end of the help text array,
rather than a pointer to the final 0 byte as intended.  The results are
unpredictable.

3 years agoFix DX_BASEDIR substitution test.
Nick Bowler [Sat, 6 Mar 2021 21:00:26 +0000 (16:00 -0500)]
Fix DX_BASEDIR substitution test.

We changed the DX_BASEDIR substitution but the test case was not updated
to reflect that, oops.  Easily fixed.

3 years agoAdd script for generating miscellaneous string tables.
Nick Bowler [Tue, 2 Mar 2021 04:15:30 +0000 (23:15 -0500)]
Add script for generating miscellaneous string tables.

When building constant C data structures it is often better to
store offsets to a string table rather than pointers.  This is
usually smaller and requires less startup time when programs
are built in PIC mode.

This script helps to generate such string tables from an input
specification, and define constants for each string offsets.

3 years agoAdd a script for generating getopt_long option tables.
Nick Bowler [Fri, 26 Feb 2021 04:58:15 +0000 (23:58 -0500)]
Add a script for generating getopt_long option tables.

Maintaining tables of long options, short options, help text and whatnot
in C code is a little bit tedious, and the simpler ways tend to cause
annoying results on modern systems that build everything in PIC mode.

So let's automate the process of building these tables from a simple
description file format, using big string arrays to reduce the amount
of relocations needed in PIC code.

3 years agoInclude ${top_srcdir} in substituted DX_BASEDIR.
Nick Bowler [Fri, 26 Feb 2021 05:07:09 +0000 (00:07 -0500)]
Include ${top_srcdir} in substituted DX_BASEDIR.

As far as I can tell I've never used this feature.  When I tried to
use this value in a makefile it quickly failed in VPATH builds for
obvious reasons.  So it seems reasonable to include this make
variable in the substitution so things just work.

3 years agoAdd a basic usage test for DX_LINGUAS.
Nick Bowler [Mon, 15 Feb 2021 05:18:26 +0000 (00:18 -0500)]
Add a basic usage test for DX_LINGUAS.

In an effort to avoid more obvious bugs down the road, let's get some
sanity checks to cover very basic use cases of this macro.

3 years agoFix multiple language substitution in DX_LINGUAS.
Nick Bowler [Mon, 15 Feb 2021 04:57:05 +0000 (23:57 -0500)]
Fix multiple language substitution in DX_LINGUAS.

For some reason this macro inserts newlines between successive values
in the calculated POFILES/MOFILES settings.  This causes syntax errors
when these get substituted into makefiles and is very, very broken.

So this macro has basically never worked except for trivial cases.  This
happens when you don't bother to test things.  So let's fix that up and
add a test case to expose this issue.

3 years agoFix redundant MOFILES entries computed by DX_LINGUAS.
Nick Bowler [Mon, 15 Feb 2021 04:44:48 +0000 (23:44 -0500)]
Fix redundant MOFILES entries computed by DX_LINGUAS.

The DX_LINGUAS macro transforms a LINGUAS setting of, for example,
"en_CA" to also include "en".  However, if LINGUAS also includes
"en", this addition results in "en" being output twice.

Add a test case that exposes this issue, and correct the problem.

3 years agofix-gnulib: Unbreak symbol renaming feature.
Nick Bowler [Sun, 24 Jan 2021 03:16:47 +0000 (22:16 -0500)]
fix-gnulib: Unbreak symbol renaming feature.

Unifying the libtool and non-libtool variable names in fix-gnulib
inadvertently broke glconfig.mk, which references the previous
gnulib_lt_objects variable name.  Restore the old variable name
in the libtool case.

3 years agoAdd AC_CANONICAL_HOST to configure.ac.
Nick Bowler [Sat, 23 Jan 2021 22:59:42 +0000 (17:59 -0500)]
Add AC_CANONICAL_HOST to configure.ac.

This will ensure Automake brings in config.guess and config.sub, in case
they are needed by test cases, although I am not aware of any actual
problems with these being missing at the moment.

3 years agoAdd Bison-related configure tests.
Nick Bowler [Sat, 23 Jan 2021 22:23:29 +0000 (17:23 -0500)]
Add Bison-related configure tests.

Recent versions of Bison have made a bunch of incompatible behaviour
changes.  Implement configure tests to identify some issues, so that
build compatibility with multiple versions can be achieved.

As part of this, we introduce a basic macro for finding Bison in the
first place, which will verify support for "modern" features like %code
blocks which are needed by all my Bison-using projects.

4 years agofix-gnulib: Improvements for program-only packages.
Nick Bowler [Wed, 12 Feb 2020 00:48:20 +0000 (19:48 -0500)]
fix-gnulib: Improvements for program-only packages.

When building a program, we do not generally need the Gnulib symbol
renaming support and we do not need to build a libtool convenience
library (which typically takes twice as long).

It appears the object dependencies are incomplete when not using
libtool with Gnulib, so fix that, and add a new "program" mode which
omits the default call to GLSYM_PREFIX (and thus the DX_EXPORTED_SH
machinery does not not pulled in).

In all cases, switch noinst_(LT)LIBRARIES to EXTRA_(LT)LIBRARIES
which should have no negative impact -- but a program can link in
$(gnulib_objects) instead of the library to save a build step and
possibly increase opportunity for parallelism.

When using libtool, library mode is the default, otherwise program
mode is the default.  The script can be forced one way or the other
based on command-line options.

4 years agoTry an additional workaround for GLib inline issue.
Nick Bowler [Sat, 8 Feb 2020 21:36:53 +0000 (16:36 -0500)]
Try an additional workaround for GLib inline issue.

It seems there are a range of GLib versions which #define G_INLINE_FUNC
unconditionally and thus we cannot work around the headers reliance on
obsolete GNU inline semantics by predefining this macro.

On these versions, we can define G_IMPLEMENT_INLINES to disable inline
function usage altogether.  This is less ideal but it will at least
allow compilation to proceed.

4 years agoImprove distribution of Autotest testsuite dependencies.
Nick Bowler [Sat, 8 Feb 2020 16:11:28 +0000 (11:11 -0500)]
Improve distribution of Autotest testsuite dependencies.

A fresh distribution tarball includes a generated testsuite, but
does not have the benefit of rules from automatic dependency tracking.

This means if a file included by the testsuite is modified in the
tarball, the build will not detect that testsuite is out of date
and will not try to rebuild it.

A similar scenario occurs if 'make distclean' is run after building
the test suite.

Since modern Automake uses make rules to generate the dependency stubs,
we can use the distributed testsuite dependencies record to produce
an accurate initial list of prerequisites.  And by ensuring that this
file is updated whenever the testsuite is built, we can handle the
'make distclean' case too.

4 years agoImprove GLib probe against old GLib versions.
Nick Bowler [Fri, 7 Feb 2020 02:15:04 +0000 (21:15 -0500)]
Improve GLib probe against old GLib versions.

The glib_check_version function was not available in older versions
of glib2, so this is a bad choice for the link test.  Let's use
g_get_prgname instead, which is available at least as far back
as glib 2.0.0.

More importantly, with gcc these old glib versions use 'extern inline'
in header files and expect GNU inline semantics.  This generally does
not work with modern gcc, so add an additional configure test which
will detect this problem and work around it.

4 years agoAdd flex detection macro.
Nick Bowler [Wed, 5 Feb 2020 00:24:29 +0000 (19:24 -0500)]
Add flex detection macro.

4 years agoFix comment typo in DX_PROG_GOB2 implementation.
Nick Bowler [Fri, 31 Jan 2020 14:53:31 +0000 (09:53 -0500)]
Fix comment typo in DX_PROG_GOB2 implementation.

4 years agoAdd GOBject Builder detection macro.
Nick Bowler [Mon, 27 Jan 2020 20:29:07 +0000 (15:29 -0500)]
Add GOBject Builder detection macro.

4 years agoAdd configure as a prerequisite for Autotest package.m4.
Nick Bowler [Mon, 27 Jan 2020 22:55:01 +0000 (17:55 -0500)]
Add configure as a prerequisite for Autotest package.m4.

The information put in package.m4, for example the package version,
comes from the configure script.  When these are updated in the
source tree we want to update this too so that the testsuite gets
updated information.

4 years agoAdd library test for libdiscid
Nick Bowler [Sat, 1 Jun 2019 14:27:15 +0000 (10:27 -0400)]
Add library test for libdiscid

And establish a basic scheme to cover these macros in the test suite.

5 years agoImport and adapt GLib test macros from upkg.
Nick Bowler [Sat, 23 Feb 2019 16:13:27 +0000 (11:13 -0500)]
Import and adapt GLib test macros from upkg.

5 years agoApply AS_TR_SH to variable names in library helpers.
Nick Bowler [Sat, 23 Feb 2019 16:08:13 +0000 (11:08 -0500)]
Apply AS_TR_SH to variable names in library helpers.

This should help writing tests for libraries with hyphens in the
names, by automatically translating hyphens in computed varible
names to underscores.

5 years agoNormalize whitespace on detected library flags.
Nick Bowler [Fri, 22 Feb 2019 22:48:21 +0000 (17:48 -0500)]
Normalize whitespace on detected library flags.

It seems that pkg-config sometimes spits out a bunch of trailing
whitespace.  This gets into the substituted variables and makes
them a bit annoying to work with.  Add a step to the library helper
which normalizes the spaces: in addition to removing leading and
trailing spaces this will also remove internal spaces, which I
think should be harmless as there does not appear to be any way
for the user to usefully get quoted spaces into these variables.

5 years agoFix depfiles compatibility with modern Automake.
Nick Bowler [Sun, 6 Jan 2019 16:56:28 +0000 (11:56 -0500)]
Fix depfiles compatibility with modern Automake.

Automake 1.16 changes how depfiles are created.  It is now necessary
to define a rule which creates the stub and additionally we must clean
them explicitly.  This is a bit annoying to do but that's the price of
relying on undocumented internal behaviour, I guess.

The extra rule should be harmless when using Automake 1.15.

5 years agoAdd simple detection macros for libcneartree and libgerbv.
Nick Bowler [Thu, 20 Dec 2018 20:38:35 +0000 (15:38 -0500)]
Add simple detection macros for libcneartree and libgerbv.

6 years agoFix underquoting issue in DX_DO.
Nick Bowler [Thu, 25 Jan 2018 00:29:52 +0000 (19:29 -0500)]
Fix underquoting issue in DX_DO.

The m4_map macro takes a "quoted list of argument descriptions ...
[which are] in turn a quoted list of quoted elements, suitable for
m4_apply."  This is not what actually is being passed in DX_DO,
which is underquoted resulting in various problems.

Add a test case to expose this issue, and switch DX_DO to use
m4_map_args which is a better fit.

Thanks to Eric Blake.

6 years agoAdd libevdev detection macro.
Nick Bowler [Wed, 28 Jun 2017 23:23:54 +0000 (19:23 -0400)]
Add libevdev detection macro.

6 years agoImport libmodplug detection from upkg.
Nick Bowler [Fri, 1 May 2015 01:51:20 +0000 (21:51 -0400)]
Import libmodplug detection from upkg.

Change include to <libmodplug/modplug.h>, as required by newer versions
(and should work the same on older ones...)

6 years agoFix testsuite VPATH builds.
Nick Bowler [Thu, 30 Apr 2015 04:41:19 +0000 (00:41 -0400)]
Fix testsuite VPATH builds.

Need to add -I$(srcdir) to all autom4te invocations, otherwise it will
try to find input files only in builddir.

6 years agoEnsure that all testsuite dependencies are distributed.
Nick Bowler [Sun, 26 Apr 2015 05:49:28 +0000 (01:49 -0400)]
Ensure that all testsuite dependencies are distributed.

Failing to distribute all testsuite dependencies will cause failures
if the testsuite is modified.  Unfortunately, this is not caught by
distcheck because the testsuite is not rebuilt normally.  Therefore,
it is desirable for the dependencies to be picked up automatically
to reduce the possibility of omission.

We could check the M4 traces in a dist-hook, but then Autotest becomes
a dependency for "make dist", even when the testsuite is not modified.
Instead, distribute a record of all dependencies, and use that to
implement the dist-hook.

6 years agoFix testsuite issues caught by distcheck.
Nick Bowler [Sun, 26 Apr 2015 05:47:06 +0000 (01:47 -0400)]
Fix testsuite issues caught by distcheck.

Handle VPATH builds properly by dealing with testsuite in either
builddir or srcdir.  Also clean out configure-generated files on
distclean.

6 years agoMove Autotest makefile bits into includable snippet.
Nick Bowler [Sat, 25 Apr 2015 01:58:05 +0000 (21:58 -0400)]
Move Autotest makefile bits into includable snippet.

This all seems reasonably generic, so let's make it available for use
elsewhere.

6 years agoUpdate DX_COMMAND_OUTPUT to handle newlines and backslashes.
Nick Bowler [Wed, 22 Apr 2015 01:47:44 +0000 (21:47 -0400)]
Update DX_COMMAND_OUTPUT to handle newlines and backslashes.

The 'read' builtin eats backslashes from the input, so this macro fails
to properly handle output containing backslashes.  Since the -r option
is not portable according to the Autoconf manual, fix up the input by
escaping all backslashes.

While we're at it, remove the "feature" which converts newlines to
spaces because it seems rather silly.

6 years agoImport integer packing library.
Nick Bowler [Sat, 14 Mar 2015 02:38:45 +0000 (19:38 -0700)]
Import integer packing library.

This simple library is used in a couple projects, better to maintain
it in one place.

Hook it into the newfangled test suite too.

9 years agoFix DX_BASEDIR hoisting problems in base.m4.
Nick Bowler [Sat, 22 Nov 2014 18:38:20 +0000 (13:38 -0500)]
Fix DX_BASEDIR hoisting problems in base.m4.

Currently, DX_INIT expands to a bunch of text, mostly whitespace.
This is not normally a serious problem, except when DX_BASEDIR
is called at the top level without previously expanding DX_INIT.
Since DX_BASEDIR is intended to be expanded during argument
collection, the result is that DX_INIT's output ends up as part
of the argument where DX_BASEDIR appears.

Fixing this turns out to be somewhat non-trivial.  Both DX_INIT and
DX_BASEDIR need to be changed.

  - First, avoid using AC_REQUIRE in DX_BASEDIR.  This relies on
    diversions which do not work correctly during argument collection.

  - Rewrite DX_INIT so that it expands to no text whatsoever.

  - Finally, the AC_DEFUN_ONCE mechanism appears to insert newlines
    where the macros are called for the first time.  Use m4_ignore
    to eat that inside DX_BASEDIR.

9 years agoFix distribution of dx-stamp.m4.
Nick Bowler [Sat, 22 Nov 2014 17:21:10 +0000 (12:21 -0500)]
Fix distribution of dx-stamp.m4.

The automatic distribution of dx-stamp.m4 depends on m4_include
appearing in the m4 traces.  Normally aclocal does that but it
seems to not be entirely reliable.  The reason we do not simply
use m4_include is because this produces warnings about multiple
inclusion.

Fortunately, this is pretty easy to work around.  Just use m4_pushdef
to redefine m4_include to what we need, so the traces show the file
needs to be distributed.

9 years agofix-ltdl: Fix order-only hack with FreeBSD make.
Nick Bowler [Sat, 22 Nov 2014 17:15:48 +0000 (12:15 -0500)]
fix-ltdl: Fix order-only hack with FreeBSD make.

FreeBSD make does not work well when undefined variables are used in
nested expansions.  When such an expansion appears in the prerequisites
of a target, FreeBSD make exits with a fatal error.  For example:

  A = $(var$(B))
  foo : $(A)

  % make
  Error expanding embedded variable.

This causes the order-only hack to fail because FreeBSD make does not
define .FEATURES.  The workaround is simple: add another variable which
is assigned the value of .FEATURES.  That variable can be used in the
nested expansion to avoid the error.

9 years agofix-gnulib: Fix order-only hack with FreeBSD make.
Nick Bowler [Sat, 22 Nov 2014 17:11:56 +0000 (12:11 -0500)]
fix-gnulib: Fix order-only hack with FreeBSD make.

FreeBSD make does not work well when undefined variables are used in
nested expansions.  When such an expansion appears in the prerequisites
of a target, FreeBSD make exits with a fatal error.  For example:

  A = $(var$(B))
  foo : $(A)

  % make
  Error expanding embedded variable.

This causes the order-only hack to fail because FreeBSD make does not
define .FEATURES.  The workaround is simple: add another variable which
is assigned the value of .FEATURES.  That variable can be used in the
nested expansion to avoid the error.

9 years agoImplement initial test suite.
Nick Bowler [Tue, 10 Mar 2015 04:10:49 +0000 (21:10 -0700)]
Implement initial test suite.

First stab at a new autotest-based test suite for dxcommon.  Start with
a simple test case to expose a longstanding problem in DX_BASEDIR.

9 years agofix-gnulib: Eliminate dependency on List::Compare.
Nick Bowler [Fri, 29 Aug 2014 23:33:32 +0000 (19:33 -0400)]
fix-gnulib: Eliminate dependency on List::Compare.

This library was hardly needed; the code is shorter without it.  Now the
script can run on a stock perl installation.

9 years agoImport GTK2 detection macro.
Nick Bowler [Mon, 9 Jun 2014 23:49:29 +0000 (19:49 -0400)]
Import GTK2 detection macro.

Now that we have this support we can start bringing in
other library tests.

9 years agoAdd libpng detection macro.
Nick Bowler [Mon, 9 Jun 2014 23:46:34 +0000 (19:46 -0400)]
Add libpng detection macro.

I've been carrying around library detection in individual projects for
too long.  This is a from-scratch rewrite of the core probing code but
the actual libpng test is basically the same as before.

The idea is to better leverage M4 macros to reduce duplication, so it
should be easy to add more libraries in the future.

10 years agofix-gnulib: Improve filename mangling.
Nick Bowler [Fri, 21 Jun 2013 19:58:49 +0000 (15:58 -0400)]
fix-gnulib: Improve filename mangling.

This corrects a problem with some of the make rules in the localcharset
module.  Some filenames were not being properly prefixed with lib/ while
others were, leading to some files not being built.

11 years agofix-gnulib: Add a call to AC_CONFIG_LIBOBJ_DIR
Nick Bowler [Wed, 13 Mar 2013 01:03:59 +0000 (21:03 -0400)]
fix-gnulib: Add a call to AC_CONFIG_LIBOBJ_DIR

For some reason, the alloca module uses Autoconf's stock LIBOBJ
machinery and things explode if AC_CONFIG_LIBOBJ_DIR is not set
correctly, because the Gnulib macros sure don't.

Add such a call to the included m4 fragment to fix things up.

The amount of magic and poor documentation around this feature is
astounding.

11 years agofix-gnulib: Strip out useless SUFFIXES assignments.
Nick Bowler [Tue, 12 Mar 2013 22:51:24 +0000 (18:51 -0400)]
fix-gnulib: Strip out useless SUFFIXES assignments.

These are useless because Automake handles trivial cases automatically.

11 years agoAdd some backwards-compatibility helpers for silent-rules.
Nick Bowler [Tue, 8 Jan 2013 23:54:41 +0000 (18:54 -0500)]
Add some backwards-compatibility helpers for silent-rules.

The silent-rules support in Automake has changed over the ages.  Most
glaringly, the output alignment changed between 1.11 and 1.12.  Add a
new macro, DX_AUTOMAKE_COMPAT, which is intended to capture the
compatibility hacks needed to support multiple versions of Automake.
Currently, this means that it will define a variable to help print
silent-rule output that maintains alignment, and it will AC_SUBST
compatible versions, if necessary, of variables substituted in later
versions of Automake's silent-rule support.

Update glconfig.mk to make use of the new feature.

11 years agoFix DX_EXPORTED_SH to AC_SUBST required variables.
Nick Bowler [Wed, 5 Dec 2012 23:22:44 +0000 (18:22 -0500)]
Fix DX_EXPORTED_SH to AC_SUBST required variables.

The exported.sh support wasn't really usable as-is since it was relying
on a symbol defined by cdecl99's configure.ac.  Bring that configuration
into the common macro.

11 years agoexported.sh: Improve error handling.
Nick Bowler [Wed, 29 Aug 2012 00:38:53 +0000 (20:38 -0400)]
exported.sh: Improve error handling.

Use the eval trick to handle errors from commands in the pipeline other
than the last.  In particular, we now detect if nm failed and return an
error status in this case.  While we're rewriting this code, replace
sort | uniq with sort -u as the latter should be fine according to
POSIX.  We can re-add the two-command version if it actually causes
problems.

11 years agoImport exported.sh from cdecl99.
Nick Bowler [Wed, 15 Aug 2012 20:46:33 +0000 (16:46 -0400)]
Import exported.sh from cdecl99.

This script is required for the glconfig.mk snippet to actually
work, but it somehow got forgotten when that snippet was imported.

Bring in the script, and add M4 plumbing to support finding auxilliary
files in the dxcommon source directory.  The result should be totally
automatic, although this unfortunately means that users of fix-gnulib.pl
that don't need or want to use glconfig.mk are stuck with some extra
dependencies (including libtool) to generate the exported.sh script.

Currently, I can't think of a way to keep the automatic glconfig.mk
support (i.e., the only thing users really have to do is include the
snippet for it to work) without this spurious dependency.  So things
may need to change later, but let's just get the support in for now.

11 years agoImport gettext m4/automake bits from cdecl99.
Nick Bowler [Sat, 28 Jul 2012 19:16:42 +0000 (15:16 -0400)]
Import gettext m4/automake bits from cdecl99.

These are pretty package-agnostic, and can be shared pretty easily.

11 years agofix-gnulib: Handle MOSTLYCLEANDIRS.
Nick Bowler [Tue, 24 Jul 2012 23:59:34 +0000 (19:59 -0400)]
fix-gnulib: Handle MOSTLYCLEANDIRS.

Usage of this variable suffers from similar problems as xxxCLEANFILES,
so fix it up in the same way by moving it to the end of the makefile
fragment.  The check needs to be improved a bit as the fragment contains
actual references to this variable, and only want to move the
assignments.

The variable also needs to be set before use, which strangely doesn't
actually happen in the fragment, even though this is a totally internal
thing...

12 years agofix-ltdl: Move all convenience libs to EXTRA_LTLIBRARIES only.
Nick Bowler [Sat, 12 May 2012 00:00:02 +0000 (20:00 -0400)]
fix-ltdl: Move all convenience libs to EXTRA_LTLIBRARIES only.

There's no reason to list these in noinst_LTLIBRARIES in a non-recursive
build, as they will be picked up correctly by ordinary prerequisites.

12 years agofix-ltdl: Delete libobj symlink before attempting to create it.
Nick Bowler [Fri, 11 May 2012 02:17:51 +0000 (22:17 -0400)]
fix-ltdl: Delete libobj symlink before attempting to create it.

There seems to be a (rare) race in parallel builds where make for some
reason decides to update the libobj symlink after it already exists,
which fails.  I can't reproduce the failure, but deleting the symlink
(if one exists) before creating it should avoid the issue.

12 years agofix-ltdl: New script to fix up nonrecursive libltdl.
Nick Bowler [Thu, 10 May 2012 22:11:33 +0000 (18:11 -0400)]
fix-ltdl: New script to fix up nonrecursive libltdl.

Similar in spirit to fix-gnulib, this one improves the nonrecursive
libltdl integration.