Subject: bin/9112: config(8) problems on non-NetBSD systems
To: None <gnats-bugs@gnats.netbsd.org>
From: None <bjh21@cam.ac.uk>
List: netbsd-bugs
Date: 01/03/2000 13:03:46
>Number:         9112
>Category:       bin
>Synopsis:       config(8) problems on non-NetBSD systems
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan  3 13:03:00 2000
>Last-Modified:
>Originator:     Ben Harris
>Organization:
University of Cambridge Computing Service
>Release:        1.4.1
>Environment:
Linux wraith 2.2.12 #6 Tue Dec 7 17:14:36 GMT 1999 i686 unknown


>Description:
The mechanism for building config(8) on non-NetBSD systems has aged somewhat
relative to config(8) itself.  Specifically:

Not all systems define yydebug.
Not all systems provide major(), minor(), makedev() and NODEV, and those
  that do may disagree with NetBSD.
Makefile.boot mentions y.tab.* instead of gram.*.
Makefile.boot gratuitously defines strtoul as strtol, which breaks if you
  _have_ got strtol.

>How-To-Repeat:
cd src/usr.sbin/config
make -f Makefile.boot

>Fix:

diff -ur config/Makefile.boot config.hacked/Makefile.boot
--- config/Makefile.boot        Thu Nov  7 22:59:39 1996
+++ config.hacked/Makefile.boot Sat Jan  1 16:06:03 2000
@@ -9,7 +9,7 @@
 CFLAGS= -I. -DMAKE_BOOTSTRAP
 
 # Uncomment this if your system does not have strtoul (i.e. SunOS)
-STRTOUL= -Dstrtoul=strtol
+#STRTOUL= -Dstrtoul=strtol
 
 # Note: The scanner here uses features specific to "flex" so
 # do not bother even trying to make lex build the scanner.
@@ -20,16 +20,18 @@
 YACC=yacc
 
 OBJS=  files.o hash.o main.o mkheaders.o mkioconf.o mkmakefile.o \
-       mkswap.o pack.o sem.o util.o y.tab.o lex.yy.o strerror.o
+       mkswap.o pack.o sem.o util.o gram.o lex.yy.o strerror.o
 
 config: ${OBJS}
        ${CC} -o $@ ${OBJS}
 
-y.tab.o : y.tab.c
-       ${CC} ${CFLAGS} -c y.tab.c
+gram.o : gram.c
+       ${CC} ${CFLAGS} -c gram.c
 
-y.tab.c y.tab.h : gram.y
+gram.c gram.h : gram.y
        ${YACC} -d gram.y
+       mv -f y.tab.c gram.c
+       mv -f y.tab.h gram.h
 
 lex.yy.o : lex.yy.c
        ${CC} ${CFLAGS} ${STRTOUL} -c lex.yy.c
@@ -39,12 +41,12 @@
 
 ${OBJS} : config.h
 
-y.tab.o mkmakefile.o mkswap.o sem.o : sem.h
-lex.yy.o : y.tab.h
+gram.o mkmakefile.o mkswap.o sem.o : sem.h
+lex.yy.o : gram.h
 
 .c.o:
        ${CC} ${CFLAGS} -c $<
 
 clean:
-       rm -f *.o config lex.yy.c y.tab.[ch]
+       rm -f *.o config lex.yy.c y.tab.[ch] gram.[ch]
 
diff -ur config/config.h config.hacked/config.h
--- config/config.h     Thu Jan 21 13:10:08 1999
+++ config.hacked/config.h      Sat Jan  1 16:09:36 2000
@@ -74,6 +74,21 @@
 #ifndef _PATH_DEVNULL
 #define _PATH_DEVNULL "/dev/null"
 #endif
+#ifndef NODEV
+#define NODEV 0
+#endif
+#ifndef major
+#define        major(x)        ((int32_t)((((x) & 0x000fff00) >>  8)))
+#endif
+#ifndef minor
+#define        minor(x)        ((int32_t)((((x) & 0xfff00000) >> 12) | \
+                                  (((x) & 0x000000ff) >>  0)))
+#endif
+#ifndef makedev
+#define        makedev(x,y)    ((dev_t)((((x) <<  8) & 0x000fff00) | \
+                                (((y) << 12) & 0xfff00000) | \
+                                (((y) <<  0) & 0x000000ff)))
+#endif
 
 
 #define ARRCHR '#'
diff -ur config/main.c config.hacked/main.c
--- config/main.c       Mon Feb  8 22:32:58 1999
+++ config.hacked/main.c        Sat Jan  1 16:11:16 2000
@@ -71,7 +71,9 @@
 
 extern char *optarg;
 extern int optind;
+#ifndef MAKE_BOOTSTRAP
 extern int yydebug;
+#endif
 
 static struct hashtab *mkopttab;
 static struct nvlist **nextopt;
@@ -108,9 +110,11 @@
        while ((ch = getopt(argc, argv, "Dgpvb:s:")) != -1) {
                switch (ch) {
 
+#ifndef MAKE_BOOTSTRAP
                case 'D':
                        yydebug = 1;
                        break;
+#endif
 
                case 'g':
                        /*

>Audit-Trail:
>Unformatted: