From: Bruno Haible Date: Sun, 3 Nov 2024 20:18:29 +0000 (+0100) Subject: crc: Fix build rules with Automake's option 'subdir-objects'. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=29a14761ab5a37b3f6ad81bf2bb563cacada2a96;p=gnulib.git crc: Fix build rules with Automake's option 'subdir-objects'. Reported by Pádraig Brady in . * build-aux/prefix-gnulib-mk: Add comments. (usage): Mark this usage as deprecated. * modules/crc (Makefile.am): Use %reldir%. Write $(srcdir)/. instead of $(srcdir). --- diff --git a/ChangeLog b/ChangeLog index 6ab3a1ca83..1381089ad8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2024-11-03 Bruno Haible + + crc: Fix build rules with Automake's option 'subdir-objects'. + Reported by Pádraig Brady in + . + * build-aux/prefix-gnulib-mk: Add comments. + (usage): Mark this usage as deprecated. + * modules/crc (Makefile.am): Use %reldir%. Write $(srcdir)/. instead of + $(srcdir). + 2024-11-01 Bruno Haible select: Document a Haiku bug. diff --git a/build-aux/prefix-gnulib-mk b/build-aux/prefix-gnulib-mk index a6de78bf2c..4387d50f0d 100755 --- a/build-aux/prefix-gnulib-mk +++ b/build-aux/prefix-gnulib-mk @@ -1,8 +1,6 @@ #!/bin/sh #! -*-perl-*- -# Rewrite a gnulib.mk, adding prefixes to work with automake's subdir-objects. - # Copyright (C) 2012-2024 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation @@ -33,6 +31,47 @@ my $VERSION = '2024-07-04 10:56'; # UTC # If you change this file with Emacs, please let the write hook # do its job. Otherwise, update this string manually. +# Overview +# ======== +# +# Automake is usually used with a separate Makefile.am in each subdirectory +# that contains sources. The advantage is that the build infrastructure of +# the package is composable. +# +# An alternative way to use Automake is to have a Makefile.am at the top-level +# only, and each subdirectory contains a Makefile.am fragment, called +# .mk, that is included by the top-level Makefile.am. +# This is called "non-recursive Automake" and is explained in +# . This way makes it +# easier to use a library in one subdirectory from sources in another +# subdirectory, and still have 'make' check dependencies in an optimal way. +# +# The "non-recursive Automake" is activated through the Automake option +# 'subdir-objects'. +# +# There are two ways to support this mode with Gnulib: +# (a) The gnulib-tool option --automake-subdir. +# (b) The deprecated 'non-recursive-gnulib-prefix-hack' module. +# Both make use of this script. This script rewrites the a Makefile.am portion +# made for the usual way, so that it can be used in the non-recursive way. +# +# This script can be invoked in two ways: +# (a) Through an invocation of build-aux/prefix-gnulib-mk from within +# gnulib-tool, with options such as +# --from-gnulib-tool --lib-name=libgnu --prefix=lib/ +# (b) Through an invocation of build-aux/prefix-gnulib-mk from the package's +# build system (deprecated). +# +# The official way to write Makefile.am snippets that supports both ways is +# through the %reldir% token, that is explained in +# . +# Doing this would, however, lead to hundreds of occurrences of %reldir%, +# which is not pretty to work with. Therefore, what Gnulib does is: +# - This script adds the prefix (e.g. 'lib/') in most places, based on +# simple patterns (e.g. before source file names and after $(MKDIR_P)). +# - In other places, that are not covered by this script, we use %reldir% +# explicitly. + use strict; use IO::File; use Getopt::Long; @@ -55,7 +94,7 @@ sub usage ($) else { print $STREAM <