bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: errno --> errno name ?


From: Bruce Korb
Subject: Re: errno --> errno name ?
Date: Sun, 14 Aug 2011 07:37:48 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110616 SUSE/3.1.11 Thunderbird/3.1.11

On 08/14/11 03:35, Bruno Haible wrote:
Does the .h file need to be generated? It is much more convenient to
rely on a .h file that is platform independent.

The formatting string depends upon the maximum errno name length.
If one can presume 16, then there's no need....  It seems to be 15
on Linux:
   93 (EPROTONOSUPPORT) == Protocol not supported
   94 (ESOCKTNOSUPPORT) == Socket type not supported
  131 (ENOTRECOVERABLE) == State not recoverable

Also, the rule is not very robust and lacks dependencies: If one some
platform, the generation of the file fails, then you change mk-err-names.sh,
then retry "make", nothing will happen, because
   1. err-names.c does not depend on mk-err-names.sh,

It depends upon the .h and the .h depends on the script.

   2. The "test -f $@ || ..." idiom will not rerun mk-err-names.sh.

Nope.  It gets re-run in the make of err-names.h.
This idiom will cause the script to run only if there is some
way that the .c rule fires after the .h rule.  The .h rule is the real rule.

Makefile.am:
GEN_ERRNO_FILES         = err-names.c err-names.h
BUILT_SOURCES          += $(GEN_ERRNO_FILES)
MOSTLYCLEANFILES       += $(GEN_ERRNO_FILES)
nodist_include_HEADERS += err-names.h
ENV_FOR_ERRNO           = CC="$(CC) $(AM_CPPFLAGS) $(CPPFLAGS)" \
        srcdir="$(srcdir)"

err-names.c : err-names.h
        @test -f $@ || $(ENV_FOR_ERRNO) $(SHELL) mk-err-names.sh

err-names.h : mk-err-names.sh
        $(ENV_FOR_ERRNO) $(SHELL) mk-err-names.sh

I would recommend to use the well-tested idiom for generated files, like in
modules/unistd and many other places.

Please feel free to tweak it.  I think that might be easier than
seeing if I get exactly what you mean, retrying and cycling again.

Also, the rule does not work in VPATH builds where $(srcdir) != ".".

Okay, need to pass through CC and srcdir both.  See above.  Note also
that by changing the script so that the files get created in the
source directory, you also make it possible to fail because the source
directory isn't necessarily writable.  I think the source ought
to be generated in the "build" directory.  I don't exactly see how
the VPATH build fails.  Build directory sources should be found,
even in VPATH builds.

err-names.h : mk-err-names.sh $(EXE).c
        CC="$(CC)" $(SHELL) mk-err-names.sh

$(EXE) is undefined.

:)  cut-n-paste error.

Attachment: errno.txz
Description: application/xz-compressed-tar


reply via email to

[Prev in Thread] Current Thread [Next in Thread]