Subject: misc/21344: tools/compat build fails: unable to find reentrant.h
To: None <>
From: None <>
List: netbsd-bugs
Date: 04/27/2003 22:45:34
>Number:         21344
>Category:       misc
>Synopsis:       tools/compat build fails: unable to find reentrant.h
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 27 22:46:00 UTC 2003
>Originator:     John Gordon
>Release:        current
CYGWIN_NT-5.1 vaio 1.3.22(0.78/3/2) 2003-03-18 09:20 i686 unknown unknown Cygwin
When building under Cygwin, the build fails trying to compile lib/libc/stdio/gettemp.c because it cannot find reentrant.h (which is inluded directly into this source file, and many others in the stdio directory).

The error is as follows:

gcc -D_XOPEN_SOURCE -O  -I. -I./include -I/cygdrive/d/NetBSD/src/tools/compat -DHAVE_CONFIG_H  -D_FILE_OFFSET_BITS=64 -D__DBINTERFACE_PRIVATE -c -o gettemp.lo.o
/cygdrive/d/NetBSD/src/lib/libc/stdio/gettemp.c:62:23: reentrant.h: No such file or directory
*** Error code 1

nbmake: stopped in /cygdrive/d/NetBSD/src/tools/compat
*** Error code 1

nbmake: stopped in /cygdrive/d/NetBSD/src/tools/compat
*** Error code 1

nbmake: stopped in /cygdrive/d/NetBSD/src/tools

ERROR: failed to make tools

Further research revealed that the reason this appears on Cygwin and not on a NetBSD system is that on NetBSD all three macros guarding this file (HAVE_CONFIG_H, HAVE_MKSTEMP and HAVE_MKDTEMP) are defined for NetBSD, but not for Cygwin. If any one of these is not defined (in the Cygwin case HAVE_MKDTEMP) then the build will fail since there is no include path that will make lib/libc/include visible. This should be the same on any system where any of these three macros remains undefined.
Compiling on Cygwin using the following command:

$ HOST_CC=gcc-2 HOST_CFLAGS="-D_XOPEN_SOURCE -O" bash ./ -T /cygdrive/d/NetBSD/i386/tools -O /cygdrive/d/NetBSD/i386/obj -D /cygdrive/d/NetBSD/i386/root -U -m i386 tools

You will need to have gcc version 2.95.x installed for this.

An alternative strategy would be to simply undefine HAVE_MKDTEMP in the compat directory's config.h file.
The following patch fixes this problem by adding the missing include directory to the include path:

Index: tools/compat/Makefile
RCS file: /cvsroot/src/tools/compat/Makefile,v
retrieving revision 1.22
diff -c -r1.22 Makefile
*** tools/compat/Makefile       2003/03/14 03:38:42     1.22
--- tools/compat/Makefile       2003/04/27 22:44:25
*** 24,29 ****
--- 24,30 ----
  # other file ops, on many systems, without changing function names.

  CPPFLAGS+=    -I. -I./include -I${.CURDIR} -DHAVE_CONFIG_H \
+               -I$(NETBSDSRCDIR)/lib/libc/include \

  .PATH:                ${.CURDIR}/../../lib/libc/gen \