Subject: Re: bug#75451: scratch/igc: Enable CHECK_STRUCTS

From: Stefan Kangas <[email-masked]>
Date: Fri, 17 Jan 2025 08:36:45 -0800

Pip Cet <[email-masked]> writes:

> You're right.  Let's start by fixing the build on Solaris 10.
>
> Here's a WIP patch which *almost* fixes the build (with
> --enable-checking=all) there.  The problem is that "ar" doesn't work,
> and AC_PROG_AR, which I naively assumed would define @AR@, doesn't exist
> either, on that system.  So you still have to build with "gmake AR=gar",
> I guess.  (I also have to trick the makeinfo detection into letting me
> build Emacs, but that's a well-known unrelated problem).

LGTM with an optional nit below.

> commit 738f12b467016e59086bad7c38f86b59b85f662e (HEAD)
> Author: Pip Cet <[email-masked]>
> Date:   Thu Jan 16 13:42:03 2025 +0000
>
>     Fix build on Solaris 10 (bug#75451)
>
>     * autogen.sh: Avoid bashism.
>     * configure.ac (AC_PROG_AWK): Use.
>     * src/Makefile.in (AWK): Set.
>     (dmpstruct.h): Use "$(AWK)", not "awk".
>     * src/dired.c (DT_UNKNOWN, DT_DIR, DT_LNK): Define all three constants
>     or none of them.
>
> diff --git a/autogen.sh b/autogen.sh
> index 00c20c73263..3d641b6e1f9 100755
> --- a/autogen.sh
> +++ b/autogen.sh
> @@ -115,7 +115,7 @@ do_check=
>  do_autoconf=false
>  do_git=false
>
> -for arg; do
> +for arg in "$@"; do
>      case $arg in
>        --help)
>  	exec echo "$0: usage: $0 [--no-check] [target...]
> diff --git a/configure.ac b/configure.ac
> index f78997ede24..269cbf70b60 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -2004,6 +2004,8 @@ AC_DEFUN
>
>  dnl Some other nice autoconf tests.
>  AC_PROG_INSTALL
> +dnl use "gawk", not "awk", where appropriate
> +AC_PROG_AWK

Should this perhaps say

    dnl use "gawk" where possible

instead?

>  dnl These are commented out, since gl_EARLY and/or Autoconf already does them.
>  dnl AC_PROG_MKDIR_P
>  dnl if test "x$RANLIB" = x; then
> diff --git a/src/Makefile.in b/src/Makefile.in
> index 784aadd1689..d987124d29d 100644
> --- a/src/Makefile.in
> +++ b/src/Makefile.in
> @@ -60,6 +60,7 @@ LDFLAGS =
>  EXEEXT = @EXEEXT@
>  version = @version@
>  MKDIR_P = @MKDIR_P@
> +AWK = @AWK@
>  # Don't use LIBS.  configure puts stuff in it that either shouldn't be
>  # linked with Emacs or is duplicated by the other stuff below.
>  # LIBS = @LIBS@
> @@ -543,7 +544,7 @@ pdumper.o:
>  endif
>  dmpstruct.h: $(srcdir)/dmpstruct.awk
>  dmpstruct.h: $(libsrc)/make-fingerprint$(EXEEXT) $(dmpstruct_headers)
> -	$(AM_V_GEN)POSIXLY_CORRECT=1 awk -f $(srcdir)/dmpstruct.awk \
> +	$(AM_V_GEN)POSIXLY_CORRECT=1 $(AWK) -f $(srcdir)/dmpstruct.awk \
>  		$(dmpstruct_headers) > $@
>
>  AUTO_DEPEND = @AUTO_DEPEND@
> diff --git a/src/dired.c b/src/dired.c
> index 89d6033f9b9..bff83ca0c95 100644
> --- a/src/dired.c
> +++ b/src/dired.c
> @@ -79,7 +79,15 @@ dirent_namelen (struct dirent *dp)
>  }
>
>  #ifndef HAVE_STRUCT_DIRENT_D_TYPE
> -enum { DT_UNKNOWN, DT_DIR, DT_LNK };
> +enum {
> +#if !defined (DT_UNKNOWN) && !defined (DT_DIR) && !defined (DT_LNK)
> +  DT_UNKNOWN,
> +  DT_DIR,
> +  DT_LNK,
> +#elif defined (DT_UNKNOWN) || defined (DT_DIR) || defined (DT_LNK)
> +#error "Cannot determine DT_UNKNOWN, DT_DIR, DT_LNK"
> +#endif
> +};
>  #endif
>
>  /* Return the file type of DP.  */