Subject: why __USE_BSD with pkgsrc? -DHAVE_STRERROR ??
To: None <tech-pkg@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-pkg
Date: 12/26/2002 15:32:13
I now have problems building pkg_install and bmake under Linux.

Now I notice that archivers/gcpio won't build:

cc -c  -I/usr/include -DRETSIGTYPE=void -DMAJOR_IN_SYSMACROS=1
-DHAVE_SYS_MTIO_H=1 -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1
-DHAVE_FCNTL_H=1 -DHAVE_UTIME_H=1 -DC_ALLOCA=1 -DSTACK_DIRECTION=0
-DHAVE_DIRENT_H=1 -I. -g -I/usr/include error.c
error.c: In function `private_strerror':
error.c:71: conflicting types for `sys_errlist'
/usr/include/stdio.h:552: previous declaration of `sys_errlist'
*** Error code 1

My glibc stdio.h has:

/* These variables normally should not be used directly.  The `strerror'
   function provides all the needed functionality.  */
#ifdef  __USE_BSD
extern int sys_nerr;
extern __const char *__const sys_errlist[];
#endif
#ifdef  __USE_GNU
extern int _sys_nerr;
extern __const char *__const _sys_errlist[];
#endif

The cpio error.c has:

#if HAVE_STRERROR || _LIBC
# ifndef strerror               /* On some systems, strerror is a macro */
char *strerror ();
# endif
#else
static char *
private_strerror (errnum)
     int errnum;
{
  extern char *sys_errlist[];
  extern int sys_nerr;

  if (errnum > 0 && errnum <= sys_nerr)
    return sys_errlist[errnum];
  return "Unknown system error";
}


So I added
-DHAVE_STRERROR
to the DEFS line in the Makefile.in.

Is it okay to always force -DHAVE_STRERROR for gcpio in pkgsrc?

Then it died later with:

cc -c  -I/usr/include -DRETSIGTYPE=void -DMAJOR_IN_SYSMACROS=1
-DHAVE_SYS_MTIO_H=1 -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1
-DHAVE_FCNTL_H=1 -DHAVE_UTIME_H=1 -DC_ALLOCA=1 -DSTACK_DIRECTION=0
-DHAVE_DIRENT_H=1  -DHAVE_STRERROR -I. -g -I/usr/include mkdir.c
mkdir.c: In function `mkdir':
mkdir.c:56: argument `dpath' doesn't match prototype
/usr/include/sys/stat.h:268: prototype declaration
mkdir.c:56: argument `dmode' doesn't match prototype
/usr/include/sys/stat.h:268: prototype declaration
*** Error code 1


I will have to look at this later. I am taking one of my sons camping :)

   Jeremy C. Reed
   http://bsd.reedmedia.net/