Subject: pkg_install on Linux wants optind defined
To: None <tech-pkg@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-pkg
Date: 09/04/2003 20:18:06
I have a few problems with pkg_install under Linux; I'll send in separate
emails.

bmake in pkg_install doesn't fail, but it seems like it should, since
it has these errors:

cc -DHAVE_CONFIG_H -DBINDIR=\"/usr/sbin\" -DHAVE_CONFIG_H
-DBINDIR=\"/usr/sbin\"
 -I/usr/include/libnbcompat  -I/usr/include -I. -I. -I../lib -g
-I/usr/include/libnbcompat -I/usr/include -c main.c
main.c: In function `main':
main.c:163: error: `optind' undeclared (first use in this function)
main.c:163: error: (Each undeclared identifier is reported only once
main.c:163: error: for each function it appears in.)
*** Error code 1

Stop.
bmake: stopped in
/tmp/pkgsrc/pkgtools/pkg_install/work.tahoma/pkg_install-20030824/add
cc -DHAVE_CONFIG_H -DHAVE_CONFIG_H -I/usr/include/libnbcompat
-I/usr/include -I
. -I. -I../lib -g -I/usr/include/libnbcompat -I/usr/include -c main.c
main.c: In function `main':
main.c:397: error: `optind' undeclared (first use in this function)
main.c:397: error: (Each undeclared identifier is reported only once
main.c:397: error: for each function it appears in.)
*** Error code 1

Stop.
bmake: stopped in
/tmp/pkgsrc/pkgtools/pkg_install/work.tahoma/pkg_install-20030824/admin
cc -DHAVE_CONFIG_H -DHAVE_CONFIG_H -I/usr/include/libnbcompat
-I/usr/include -I
. -I. -I../lib -g -I/usr/include/libnbcompat -I/usr/include -c main.c
main.c: In function `main':
main.c:211: error: `optind' undeclared (first use in this function)
main.c:211: error: (Each undeclared identifier is reported only once
main.c:211: error: for each function it appears in.)
*** Error code 1



(None of the resultingbinaries were made, but .build_done cookie was made
and the install target worked, but it failed because tried to do -K with
old command, because new command was not installed.)

My /usr/include/libnbcompat/nbcompat/nbconfig.h has:

/* Define to 1 if optind is declared in <stdlib.h> or <unistd.h> */
#ifndef HAVE_OPTIND_D
#define HAVE_OPTIND_D 1
#endif


HAVE_OPTIND_D is not defined in my work*/pkg_install* source.

optind is defined in my /usr/include/getopt.h


My ../libnbcompat/work.tahoma/libnbcompat-20030828/config.log has:
#define HAVE_OPTIND_D 1


My workaround was to manually add to end of lib/config.h for pkg_install:
#define HAVE_OPTIND_D 0

That built fine ...

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