james@bigtex.cactus.org (James Van Artsdalen) (12/12/88)
I've managed to get GNU make 3.26 to work under SysVr3. There are a
number of changed that were made, some of which are needed for all
versions of GNU make, some only for SysV, and some just to make life
easier.
In arscan.c, there is a call to read(2) where an ampersand was omitted.
The program name variable in make.c should be initialized before
error() is called (near the getwd() call to be specific). Also,
the SIGCLD stuff needs to happen *after* getwd(3) is called, otherwise
they'll interfere.
remake.c includes <sys/file.h>, which is wrong for SysV: should include
<fcntl.h> instead.
commands.c ignores SIGCLD before calling child_handler(). This makes
child_handler() hang in an infinite loop. I commented out the
offending signal(2) call since presumably somebody does need that code
or it wouldn't have been added.
SysV doesn't have a "union wait". I swiped the information from the
BSD include file. That file appears to be entirely free of AT&T
license restrictions. Defining the union in the source is bad because
the union is machine specific, but I don't know of any other way
without making larger changes to the make source.
SysV signal handlers don't return anything. Declaring "int" as the
return value is misleading and causes needless errors.
SysV doesn't have the wait3() call.
SysVr3 doesn't use "ndir.h" or "struct direct". It uses <dirent.h>
and "struct dirent".
malloc(3c) & friends ought to return "void *", not "char *". Declare
it as such when using GNU C. Has the side effect of not interfering
with prototypes in the include files. I also include <malloc.h> in
several additional files in the hopes of getting a declaration for
alloc(3c). This is a good thing even for BSD, because you'll likely
find a #define alloca __builtin_alloca for those using GNU C.
In many places, functions are needlessly declared to return "int".
The compiler is going to assume this anyway, so the declaration buys
nothing. Since it interferes with attempts to provide ANSI prototypes
in the include files, why not omit the declaration? Can't hurt.
COFLAGS should default to -q. Much cleaner looking.
*** /tmp/,RCSt1a15391 Sun Dec 11 23:45:12 1988
--- arscan.c Sun Dec 11 23:35:45 1988
***************
*** 118,124 ****
#endif /* not USG */
! extern int open (), read (), close (), write (), fstat ();
extern long int lseek ();
extern int atoi (), strcmp ();
--- 118,124 ----
#endif /* not USG */
! /* extern int open (), read (), close (), write (), fstat (); */
extern long int lseek ();
extern int atoi (), strcmp ();
***************
*** 172,178 ****
#else
{
int buf;
! register int nread = read(desc, buf, sizeof(int));
if (nread != sizeof(int) || buf != ARMAG)
{
close (desc);
--- 172,178 ----
#else
{
int buf;
! register int nread = read(desc, &buf, sizeof(int));
if (nread != sizeof(int) || buf != ARMAG)
{
close (desc);
***************
*** 186,192 ****
#ifdef SARMAG
register long int member_offset = SARMAG;
#else
! register long int member_offset = sizeof int;
#endif
while (1)
--- 186,192 ----
#ifdef SARMAG
register long int member_offset = SARMAG;
#else
! register long int member_offset = sizeof(int);
#endif
while (1)
***************
*** 224,230 ****
while (p > name && *--p == ' ') *p = 0;
}
! sscanf (member_header.ar_mode, "%o", &eltmode);
eltsize = atoi (member_header.ar_size);
fnval =
--- 224,230 ----
while (p > name && *--p == ' ') *p = 0;
}
! sscanf ((char *)member_header.ar_mode, "%o", &eltmode);
eltsize = atoi (member_header.ar_size);
fnval =
*** /tmp/,RCSt1a15391 Sun Dec 11 23:45:16 1988
--- commands.c Sun Dec 11 23:38:50 1988
***************
*** 18,26 ****
--- 18,36 ----
#include "commands.h"
#include "file.h"
#include "variable.h"
+
+ #ifndef USG
#include <sys/wait.h>
+ #else
+ #define WIFSIGNALED(x) ((x).w_termsig != 0)
+ #define WIFEXITED(x) ((x).w_termsig == 0)
+ #endif
+
+ #ifndef USG
#include <sys/time.h>
#include <sys/resource.h>
+ #endif
+
#include <sys/fcntl.h>
***************
*** 109,125 ****
--- 119,157 ----
If SIG is < 0, - SIG is the maximum number of children to bury (record
status of and remove from the chain). */
+ #ifndef USG
int
+ #else
+ void
+ #endif
child_handler (sig)
int sig;
{
+ #ifndef USG
union wait status;
+ #else
+ union wait {
+ int w_status;
+ struct {
+ unsigned short w_Termsig:7;
+ unsigned short w_Coredump:1;
+ unsigned short w_Retcode:8;
+ } w_T;
+ #define w_termsig w_T.w_Termsig
+ #define w_coredump w_T.w_Coredump
+ #define w_retcode w_T.w_Retcode
+ } status;
+ #endif
register int pid;
unsigned int dead_children = 0;
+ #ifndef USG
while ((sig <= 0
? (pid = wait (&status))
: (pid = wait3 (&status, WNOHANG, (struct rusage *) 0)))
+ #else
+ while ((pid = wait ((int *) &status))
+ #endif
> 0)
{
register struct child *lastc, *c;
***************
*** 131,137 ****
--- 163,173 ----
= (WIFEXITED (status) && status.w_retcode == 127) ? -1 : 0;
if (sig < 0 && ++dead_children > -sig)
+ #ifndef USG
return 0;
+ #else
+ return;
+ #endif
else
continue;
}
***************
*** 246,256 ****
--- 282,300 ----
/* See if we have reached our quota for blocking. */
if (sig < 0 && ++dead_children == -sig)
+ #ifndef USG
return 0;
+ #else
+ return;
+ #endif
}
}
+ #ifndef USG
return 0;
+ #else
+ return;
+ #endif
}
***************
*** 262,271 ****
--- 306,317 ----
unsigned int n;
{
/* Ignore child termination signals so child_handler won't be called. */
+ #if 0
#ifdef SIGCHLD
(void) signal (SIGCHLD, SIG_IGN);
#else
(void) signal (SIGCLD, SIG_IGN);
+ #endif
#endif
/* Call child_handler to do the work. */
*** /tmp/,RCSt1a15391 Sun Dec 11 23:45:17 1988
--- commands.h Sun Dec 11 21:03:07 1988
***************
*** 30,36 ****
--- 30,40 ----
extern void print_commands ();
+ #ifndef USG
extern int child_handler ();
+ #else
+ extern void child_handler ();
+ #endif
extern void wait_for_children ();
*** /tmp/,RCSt1a15391 Sun Dec 11 23:45:19 1988
--- dir.c Sun Dec 11 21:08:40 1988
***************
*** 16,22 ****
#include "make.h"
#ifdef USG
! #include "ndir.h" /* Get ndir.h from the Emacs distribution. */
#else /* not USG */
#include <sys/dir.h>
#endif /* USG */
--- 16,23 ----
#include "make.h"
#ifdef USG
! #include <dirent.h> /* Get ndir.h from the Emacs distribution. */
! #include <malloc.h>
#else /* not USG */
#include <sys/dir.h>
#endif /* USG */
***************
*** 122,128 ****
--- 123,133 ----
register char *p;
register struct directory *dir;
register struct dirfile *df;
+ #ifndef USG
register struct direct *d;
+ #else
+ register struct dirent *d;
+ #endif
dir = find_directory (dirname);
***************
*** 156,162 ****
--- 161,171 ----
/* Enter the file in the hash table. */
register unsigned int newhash = 0;
register unsigned int i;
+ #ifndef USG
for (i = 0; i < d->d_namlen; ++i)
+ #else
+ for (i = 0; i < strlen(d->d_name); ++i)
+ #endif
{
newhash += d->d_name[i];
newhash = (newhash << 7) + (newhash >> 20);
***************
*** 165,171 ****
--- 174,184 ----
df = (struct dirfile *) xmalloc (sizeof (struct dirfile));
df->next = dir->files[newhash];
dir->files[newhash] = df;
+ #ifndef USG
df->name = savestring (d->d_name, d->d_namlen);
+ #else
+ df->name = savestring (d->d_name, strlen(d->d_name));
+ #endif
df->impossible = 0;
/* Check if the name matches the one we're searching for. */
*** /tmp/,RCSt1a15391 Sun Dec 11 23:45:25 1988
--- glob.c Sun Dec 11 21:13:02 1988
***************
*** 101,107 ****
#include <sys/types.h>
#ifdef USG
! #include <ndir.h>
#include <memory.h>
#include <string.h>
#define bcopy(s, d, n) ((void) memcpy ((d), (s), (n)))
--- 101,107 ----
#include <sys/types.h>
#ifdef USG
! #include <dirent.h>
#include <memory.h>
#include <string.h>
#define bcopy(s, d, n) ((void) memcpy ((d), (s), (n)))
***************
*** 117,126 ****
--- 117,135 ----
#ifdef sparc
#include <alloca.h>
#else
+ #ifndef USG
extern char *alloca ();
+ #else
+ #include <malloc.h> /* Try for alloca declaration in malloc.h */
+ #endif /* USG */
#endif /* sparc */
+ #ifndef __GNUC__
extern char *malloc (), *realloc ();
+ #else
+ extern void *malloc (), *realloc ();
+ #endif
+
extern void free ();
#ifndef NULL
***************
*** 322,328 ****
--- 331,341 ----
};
DIR *d;
+ #ifndef USG
register struct direct *dp;
+ #else
+ register struct dirent *dp;
+ #endif
struct globval *lastlink;
register struct globval *nextlink;
register char *nextname;
***************
*** 351,357 ****
--- 364,374 ----
{
nextlink = (struct globval *) alloca (sizeof (struct globval));
nextlink->next = lastlink;
+ #ifndef USG
nextname = (char *) malloc (dp->d_namlen + 1);
+ #else
+ nextname = (char *) malloc (strlen(dp->d_name) + 1);
+ #endif
if (!nextname)
{
lose = 1;
***************
*** 359,365 ****
--- 376,386 ----
}
lastlink = nextlink;
nextlink->name = nextname;
+ #ifndef USG
bcopy (dp->d_name, nextname, dp->d_namlen + 1);
+ #else
+ bcopy (dp->d_name, nextname, strlen(dp->d_name) + 1);
+ #endif
count++;
}
}
*** /tmp/,RCSt1a15391 Sun Dec 11 23:45:30 1988
--- make.c Sun Dec 11 23:31:55 1988
***************
*** 24,30 ****
--- 24,34 ----
extern char *version_string;
+ #ifndef USG
extern int fatal_error_signal ();
+ #else
+ extern void fatal_error_signal ();
+ #endif
extern struct dep *read_all_makefiles ();
***************
*** 37,43 ****
extern void exit ();
extern long int atol ();
extern time_t time ();
! extern int mktemp ();
static void log_working_directory ();
static void print_data_base (), print_version ();
--- 41,47 ----
extern void exit ();
extern long int atol ();
extern time_t time ();
! /* extern int mktemp (); */
static void log_working_directory ();
static void print_data_base (), print_version ();
***************
*** 257,262 ****
--- 261,287 ----
reading_filename = 0;
reading_lineno_ptr = 0;
+ /* Figure out where this program lives. */
+
+ if (argv[0] == 0 || argv[0][0] == '\0')
+ program = "make";
+ else
+ {
+ program = rindex (argv[0], '/');
+ if (program == 0)
+ program = argv[0];
+ else
+ ++program;
+ }
+
+ /* Figure out where we are. */
+
+ if (getwd (current_directory) == 0)
+ {
+ error ("getwd: %s", current_directory);
+ current_directory[0] = '\0';
+ }
+
if (signal (SIGHUP, fatal_error_signal) == SIG_IGN)
(void) signal (SIGHUP, SIG_IGN);
if (signal (SIGQUIT, fatal_error_signal) == SIG_IGN)
***************
*** 296,322 ****
(void) signal (SIGCLD, child_handler);
#endif
- /* Figure out where we are. */
-
- if (getwd (current_directory) == 0)
- {
- error ("getwd: %s", current_directory);
- current_directory[0] = '\0';
- }
-
- /* Figure out where this program lives. */
-
- if (argv[0] == 0 || argv[0][0] == '\0')
- program = "make";
- else
- {
- program = rindex (argv[0], '/');
- if (program == 0)
- program = argv[0];
- else
- ++program;
- }
-
/* Read in variables from the environment. It is important that this be
done before `MAKE' and `MAKEOVERRIDES' are figured out so their
definitions will not be ones from the environment. */
--- 321,326 ----
***************
*** 1233,1239 ****
--- 1237,1247 ----
}
/* Like malloc but get fatal error if memory is exhausted. */
+ #ifndef __GNUC__
extern char *malloc (), *realloc ();
+ #else
+ extern void *malloc (), *realloc ();
+ #endif
char *
xmalloc (size)
*** /tmp/,RCSt1a15391 Sun Dec 11 23:45:36 1988
--- read.c Sun Dec 11 21:15:34 1988
***************
*** 18,24 ****
#include "dep.h"
#include "file.h"
#include "variable.h"
!
static void read_makefile ();
static unsigned int readline (), do_define ();
--- 18,24 ----
#include "dep.h"
#include "file.h"
#include "variable.h"
! #include <malloc.h> /* Try for alloca declaration in malloc.h */
static void read_makefile ();
static unsigned int readline (), do_define ();
*** /tmp/,RCSt1a15391 Sun Dec 11 23:45:40 1988
--- remake.c Sun Dec 11 21:06:20 1988
***************
*** 17,26 ****
#include "commands.h"
#include "dep.h"
#include "file.h"
- #include <sys/file.h>
! extern int open (), fstat (), read (), lseek (), write (), close ();
extern time_t time ();
extern int try_implicit_rule ();
--- 17,30 ----
#include "commands.h"
#include "dep.h"
#include "file.h"
+ #ifndef USG
+ #include <sys/file.h>
+ #else
+ #include <sys/fcntl.h>
+ #endif
! /* extern int open (), fstat (), read (), lseek (), write (), close (); */
extern time_t time ();
extern int try_implicit_rule ();
*** /tmp/,RCSt1a15391 Sun Dec 11 23:45:47 1988
--- rule.c Sun Dec 11 23:44:03 1988
***************
*** 18,25 ****
#include "dep.h"
#include "file.h"
#include "variable.h"
-
static int pattern_search ();
static void new_pattern_rule (), freerule ();
--- 18,25 ----
#include "dep.h"
#include "file.h"
#include "variable.h"
+ #include <malloc.h>
static int pattern_search ();
static void new_pattern_rule (), freerule ();
***************
*** 261,266 ****
--- 261,267 ----
"CWEAVE", "cweave",
"TANGLE", "tangle",
"CTANGLE", "ctangle",
+ "COFLAGS", "-q",
0, 0
};
*** /tmp/,RCSt1a15391 Sun Dec 11 23:45:49 1988
--- vpath.c Sun Dec 11 21:04:30 1988
***************
*** 16,22 ****
#include "make.h"
#include "file.h"
#include "variable.h"
!
/* Structure used to represent a selective VPATH searchpath. */
--- 16,22 ----
#include "make.h"
#include "file.h"
#include "variable.h"
! #include <malloc.h> /* Try for declaration of alloca */
/* Structure used to represent a selective VPATH searchpath. */
--
James R. Van Artsdalen james@bigtex.cactus.org "Live Free or Die"
Dell Computer Co 9505 Arboretum Blvd Austin TX 78759 512-338-8789