Subject: bin/10714: add HP-UX (10.20) support to BSD make
To: None <gnats-bugs@gnats.netbsd.org>
From: SUNAGAWA Keiki <kei_sun@ba2.so-net.ne.jp>
List: netbsd-bugs
Date: 07/30/2000 09:10:17
>Number:         10714
>Category:       bin
>Synopsis:       add HP-UX (10.20) support to BSD make
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 30 09:11:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     SUNAGAWA Keiki
>Release:        2000-07-31
>Organization:
home
>Environment:
	
System: NetBSD azarin 1.4P NetBSD 1.4P (AZARIN) #84: Wed Dec 1 21:54:14 JST 1999 kei@azarin:/a/anoncvs/netbsd/src/sys/arch/macppc/compile/AZARIN macppc

>Description:
	BSD make has support for HP-UX in it, but it's so outdated.  Though
	10.20 is not the latest version, it's far more POSIX-based than older,
	funky 9.x.

>How-To-Repeat:
	mount NetBSD source tree on HP-UX box and want to build BSD make.
>Fix:
	Apply the patch.  Note that this removes HP-UX related stuff which is
	no longer needed and causes compile errors on 10.20.  Since 9.x is not
	y2k complient, I believe it doesn't make any serious problem.

Index: Makefile
===================================================================
RCS file: /a/rsync/netbsd.org/basesrc/usr.bin/make/Makefile,v
retrieving revision 1.20
diff -c -r1.20 Makefile
*** Makefile	1999/08/04 16:44:07	1.20
--- Makefile	2000/07/26 09:22:58
***************
*** 11,16 ****
--- 11,17 ----
  	lstInit.c lstInsert.c lstIsAtEnd.c lstIsEmpty.c lstLast.c \
  	lstMember.c lstNext.c lstOpen.c lstRemove.c lstReplace.c lstSucc.c
  .PATH:	${.CURDIR}/lst.lib
+ CLEANFILES+=	bmake
  
  .if make(install)
  SUBDIR=	PSD.doc
Index: Makefile.boot
===================================================================
RCS file: /a/rsync/netbsd.org/basesrc/usr.bin/make/Makefile.boot,v
retrieving revision 1.11
diff -c -r1.11 Makefile.boot
*** Makefile.boot	1999/04/03 04:50:16	1.11
--- Makefile.boot	2000/07/26 12:57:04
***************
*** 13,18 ****
--- 13,21 ----
  
  MACHINE=sun
  MACHINE_ARCH=sparc
+ # tested on HP-UX 10.20
+ #MACHINE=hp700
+ #MACHINE_ARCH=hppa
  CFLAGS= -I.\
  	-DTARGET_MACHINE=\"${MACHINE}\" \
  	-DTARGET_MACHINE_ARCH=\"${MACHINE_ARCH}\" \
Index: util.c
===================================================================
RCS file: /a/rsync/netbsd.org/basesrc/usr.bin/make/util.c,v
retrieving revision 1.25
diff -c -r1.25 util.c
*** util.c	2000/05/04 18:29:53	1.25
--- util.c	2000/07/26 12:50:44
***************
*** 70,76 ****
  
  #endif
  
! #if defined(sun) || defined(__hpux) || defined(__sgi)
  
  int
  setenv(name, value, dum)
--- 70,76 ----
  
  #endif
  
! #if defined(sun) || defined(__hpux__) || defined(__sgi)
  
  int
  setenv(name, value, dum)
***************
*** 105,111 ****
  }
  #endif
  
! #ifdef __hpux
  #include <sys/types.h>
  #include <sys/param.h>
  #include <sys/syscall.h>
--- 105,111 ----
  }
  #endif
  
! #ifdef __hpux__
  #include <sys/types.h>
  #include <sys/param.h>
  #include <sys/syscall.h>
***************
*** 118,174 ****
  #include <unistd.h>
  
  
- int
- killpg(pid, sig)
-     int pid, sig;
- {
-     return kill(-pid, sig);
- }
- 
- void
- srandom(seed)
-     long seed;
- {
-     srand48(seed);
- }
- 
- long
- random()
- {
-     return lrand48();
- }
- 
- /* turn into bsd signals */
- void (*
- signal(s, a)) __P((int))
-     int     s;
-     void (*a) __P((int));
- {
-     struct sigvec osv, sv;
- 
-     (void) sigvector(s, (struct sigvec *) 0, &osv);
-     sv = osv;
-     sv.sv_handler = a;
- #ifdef SV_BSDSIG
-     sv.sv_flags = SV_BSDSIG;
- #endif
- 
-     if (sigvector(s, &sv, (struct sigvec *) 0) == -1)
-         return (BADSIG);
-     return (osv.sv_handler);
- }
- 
- #if !defined(BSD) && !defined(d_fileno)
- # define d_fileno d_ino
- #endif
- 
- #ifndef DEV_DEV_COMPARE
- # define DEV_DEV_COMPARE(a, b) ((a) == (b))
- #endif
- #define ISDOT(c) ((c)[0] == '.' && (((c)[1] == '\0') || ((c)[1] == '/')))
- #define ISDOTDOT(c) ((c)[0] == '.' && ISDOT(&((c)[1])))
- 
- 
  /* strrcpy():
   *	Like strcpy, going backwards and returning the new pointer
   */
--- 118,123 ----
***************
*** 185,290 ****
  } /* end strrcpy */
  
  
- char   *
- getwd(pathname)
-     char   *pathname;
- {
-     DIR    *dp;
-     struct dirent *d;
-     extern int errno;
- 
-     struct stat st_root, st_cur, st_next, st_dotdot;
-     char    pathbuf[MAXPATHLEN], nextpathbuf[MAXPATHLEN * 2];
-     char   *pathptr, *nextpathptr, *cur_name_add;
- 
-     /* find the inode of root */
-     if (stat("/", &st_root) == -1) {
- 	(void) snprintf(pathname, sizeof(pathname),
- 			"getwd: Cannot stat \"/\" (%s)", strerror(errno));
- 	return (NULL);
-     }
-     pathbuf[MAXPATHLEN - 1] = '\0';
-     pathptr = &pathbuf[MAXPATHLEN - 1];
-     nextpathbuf[MAXPATHLEN - 1] = '\0';
-     cur_name_add = nextpathptr = &nextpathbuf[MAXPATHLEN - 1];
- 
-     /* find the inode of the current directory */
-     if (lstat(".", &st_cur) == -1) {
- 	(void) snprintf(pathname, sizeof(pathname),
- 			"getwd: Cannot stat \".\" (%s)", strerror(errno));
- 	return (NULL);
-     }
-     nextpathptr = strrcpy(nextpathptr, "../");
- 
-     /* Descend to root */
-     for (;;) {
- 
- 	/* look if we found root yet */
- 	if (st_cur.st_ino == st_root.st_ino &&
- 	    DEV_DEV_COMPARE(st_cur.st_dev, st_root.st_dev)) {
- 	    (void) strcpy(pathname, *pathptr != '/' ? "/" : pathptr);
- 	    return (pathname);
- 	}
- 
- 	/* open the parent directory */
- 	if (stat(nextpathptr, &st_dotdot) == -1) {
- 	    (void) snprintf(pathname, sizeof(pathname),
- 			    "getwd: Cannot stat directory \"%s\" (%s)",
- 			    nextpathptr, strerror(errno));
- 	    return (NULL);
- 	}
- 	if ((dp = opendir(nextpathptr)) == NULL) {
- 	    (void) snprintf(pathname, sizeof(pathname),
- 			    "getwd: Cannot open directory \"%s\" (%s)",
- 			    nextpathptr, strerror(errno));
- 	    return (NULL);
- 	}
- 
- 	/* look in the parent for the entry with the same inode */
- 	if (DEV_DEV_COMPARE(st_dotdot.st_dev, st_cur.st_dev)) {
- 	    /* Parent has same device. No need to stat every member */
- 	    for (d = readdir(dp); d != NULL; d = readdir(dp))
- 		if (d->d_fileno == st_cur.st_ino)
- 		    break;
- 	}
- 	else {
- 	    /*
- 	     * Parent has a different device. This is a mount point so we
- 	     * need to stat every member
- 	     */
- 	    for (d = readdir(dp); d != NULL; d = readdir(dp)) {
- 		if (ISDOT(d->d_name) || ISDOTDOT(d->d_name))
- 		    continue;
- 		(void) strcpy(cur_name_add, d->d_name);
- 		if (lstat(nextpathptr, &st_next) == -1) {
- 		    (void) snprintf(pathname, sizeof(pathname),
- 			"getwd: Cannot stat \"%s\" (%s)",
- 			d->d_name, strerror(errno));
- 		    (void) closedir(dp);
- 		    return (NULL);
- 		}
- 		/* check if we found it yet */
- 		if (st_next.st_ino == st_cur.st_ino &&
- 		    DEV_DEV_COMPARE(st_next.st_dev, st_cur.st_dev))
- 		    break;
- 	    }
- 	}
- 	if (d == NULL) {
- 	    (void) snprintf(pathname, sizeof(pathname), 
- 		"getwd: Cannot find \".\" in \"..\"");
- 	    (void) closedir(dp);
- 	    return (NULL);
- 	}
- 	st_cur = st_dotdot;
- 	pathptr = strrcpy(pathptr, d->d_name);
- 	pathptr = strrcpy(pathptr, "/");
- 	nextpathptr = strrcpy(nextpathptr, "../");
- 	(void) closedir(dp);
- 	*cur_name_add = '\0';
-     }
- } /* end getwd */
- 
- 
  char    *sys_siglist[] = {
          "Signal 0",
          "Hangup",                       /* SIGHUP    */
--- 134,139 ----
***************
*** 321,340 ****
          "DIL signal"                    /* SIGDIL    */
  };
  
- int
- utimes(file, tvp)
-     char *file;
-     struct timeval tvp[2];
- {
-     struct utimbuf t;
- 
-     t.actime  = tvp[0].tv_sec;
-     t.modtime = tvp[1].tv_sec;
-     return(utime(file, &t));
- }
- 
  
! #endif /* __hpux */
  
  #if defined(sun) && defined(__svr4__)
  #include <signal.h>
--- 170,177 ----
          "DIL signal"                    /* SIGDIL    */
  };
  
  
! #endif /* __hpux__ */
  
  #if defined(sun) && defined(__svr4__)
  #include <signal.h>
***************
*** 435,441 ****
  }
  
  #if !defined(__SVR4) && !defined(__linux__) && !defined(ultrix) \
! 	&& !defined(__sgi) && !defined(__osf__)
  
  int
  strftime(buf, len, fmt, tm)
--- 272,278 ----
  }
  
  #if !defined(__SVR4) && !defined(__linux__) && !defined(ultrix) \
! 	&& !defined(__sgi) && !defined(__osf__) && !defined(__hpux__)
  
  int
  strftime(buf, len, fmt, tm)
>Release-Note:
>Audit-Trail:
>Unformatted: