static char *sccsid
= "@(#)main.c 4.6 (Berkeley) 84/11/26";
command make to update programs.
Flags: 'd' print out debugging comments
'p' print out a version of the input graph
's' silent mode--don't print out commands
'f' the next argument is the name of the description file;
"makefile" is the default
'i' ignore error codes from the shell
'S' stop after any command fails (normally do parallel work)
'n' don't issue, just print, commands
't' touch (update time of) files but don't issue command
'q' don't do anything, but check if object is up to date;
returns exit code 0 if up to date, -1 if not
struct nameblock
*mainname
= NULL
;
struct nameblock
*firstname
= NULL
;
struct lineblock
*sufflist
= NULL
;
struct varblock
*firstvar
= NULL
;
struct pattern
*firstpat
= NULL
;
struct dirhdr
*firstod
= NULL
;
int ignerr
= NO
; /* default is to stop on error */
char *prompt
= ">"; /* other systems -- pick what you want */
char *prompt
= ""; /* other systems -- pick what you want */
char options
[26 + 1] = { '-' };
register struct nameblock
*p
;
static char onechar
[2] = "X";
funny
['\0'] = (META
| TERMINAL
);
for(s
= "=|^();&<>*?[]:$`'\"\\\n" ; *s
; ++s
)
for(s
= "\n\t :;&>|" ; *s
; ++s
)
if(argv
[i
]!=0 && argv
[i
][0]!='-' && eqsign(argv
[i
]))
if (argv
[i
]!=0 && argv
[i
][0]=='-') {
for (j
=1 ; (c
=argv
[i
][j
])!='\0' ; ++j
) {
op
--; /* don't pass this one */
fatal("No description argument after -f flag");
fatal1("Cannot open %s", argv
[i
+1]);
onechar
[0] = c
; /* to make lint happy */
fatal1("Unknown flag argument %s", onechar
);
if (strcmp(options
, "-") == 0)
setvar("MFLAGS", options
); /* MFLAGS=options to make */
if( rddescf("makefile") ) rddescf("Makefile");
if(prtrflag
) printdesc(NO
);
if( srchname(".IGNORE") ) ++ignerr
;
if( srchname(".SILENT") ) silflag
= 1;
if(p
=srchname(".SUFFIXES")) sufflist
= p
->linep
;
if( !sufflist
) fprintf(stderr
,"No suffix list.\n");
sigivalue
= (int) signal(SIGINT
, SIG_IGN
) & 01;
sigqvalue
= (int) signal(SIGQUIT
, SIG_IGN
) & 01;
if(dbgflag
) printdesc(YES
);
If no file arguments have been encountered, make the first
name encountered that doesn't start with a dot
fatal("No arguments or description file");
doname(mainname
, 0, &tjunk
);
if(dbgflag
) printdesc(YES
);
struct varblock
*varptr();
if(okdel
&& !noexflag
&& !touchflag
&&
(p
= varptr("@")->varval
) &&
(stat(p
, &sbuf
) >= 0 && (sbuf
.st_mode
&S_IFMT
) == S_IFREG
) &&
fprintf(stderr
, "\n*** %s removed.", p
);
register struct lineblock
*lp
;
register struct depblock
*dp
;
register struct nameblock
*np
;
if(np
= srchname(".PRECIOUS"))
for(lp
= np
->linep
; lp
; lp
= lp
->nxtlineblock
)
for(dp
= lp
->depp
; dp
; dp
= dp
->nxtdepblock
)
if(! unequal(p
, dp
->depname
->namep
))
char **linesptr
= builtin
;
/* read and parse description */
if ( (k
=fopen( concat(nlog
,"/makecomm",s
), "r")) != NULL
)
else if ( (k
=fopen( concat(nlog
,"/Makecomm",s
), "r")) != NULL
)
if ( (k
=fopen("makecomm", "r")) != NULL
)
else if ( (k
=fopen("Makecomm", "r")) != NULL
)
if(! unequal(descfile
, "-"))
if( (k
= fopen(descfile
,"r")) != NULL
)
fatal("Description file error");
printf("Open directories:\n");
for (od
= firstod
; od
; od
= od
->nxtopendir
)
printf("\t%d: %s\n", od
->dirfc
->dd_fd
, od
->dirn
);
if(firstvar
!= 0) printf("Macros:\n");
for(vp
= firstvar
; vp
; vp
= vp
->nxtvarblock
)
printf("\t%s = %s\n" , vp
->varname
, vp
->varval
);
for(p
= firstname
; p
; p
= p
->nxtnameblock
)
printf("\n\n%s",p
->namep
);
if(p
->linep
!= 0) printf(":");
if(prntflag
) printf(" done=%d",p
->done
);
if(p
==mainname
) printf(" (MAIN NAME)");
for(lp
= p
->linep
; lp
; lp
= lp
->nxtlineblock
)
printf("\n depends on:");
for(; dp
; dp
= dp
->nxtdepblock
)
printf(" %s ", dp
->depname
->namep
);
printf("\n commands:\n");
for( ; sp
!=0 ; sp
= sp
->nxtshblock
)
printf("\t%s\n", sp
->shbp
);