Cause prog_make targets to include a ``make obj'' rule if the -o flag

is given to crunchgen.
[ This fixes the previous commit which silently added ``make obj'' ]
This commit is contained in:
joe 2000-11-03 15:48:58 +00:00
parent a39072b06d
commit 78809b1a0a
2 changed files with 13 additions and 6 deletions

View File

@ -32,7 +32,7 @@
.Nd generates build environment for a crunched binary
.Sh SYNOPSIS
.Nm \&crunchgen
.Op Fl fql
.Op Fl foql
.Op Fl h Ar makefile-header-name
.Op Fl m Ar makefile-name
.Op Fl c Ar c-file-name
@ -123,6 +123,8 @@ are annoying to pass through environment variables.
Set output Makefile name to
.Ar makefile-name .
The default name is ``<conf-name>.mk''.
.It Fl o
Add ``make obj'' rules to each program make target.
.It Fl q
Quiet operation. Status messages are suppressed.
.El

View File

@ -91,6 +91,7 @@ int goterror = 0;
int verbose, readcache; /* options */
int reading_cache;
int makeobj = 0; /* add 'make obj' rules to the makefile */
int list_mode;
@ -118,9 +119,10 @@ int main(int argc, char **argv)
readcache = 1;
*outmkname = *outcfname = *execfname = '\0';
while((optc = getopt(argc, argv, "lh:m:c:e:fq")) != -1) {
while((optc = getopt(argc, argv, "lh:m:c:e:foq")) != -1) {
switch(optc) {
case 'f': readcache = 0; break;
case 'o': makeobj = 1; break;
case 'q': verbose = 0; break;
case 'm': strcpy(outmkname, optarg); break;
@ -175,7 +177,7 @@ int main(int argc, char **argv)
void usage(void)
{
fprintf(stderr, "%s\n%s\n",
"usage: crunchgen [-fq] [-m <makefile>] [-c <c file>]",
"usage: crunchgen [-foq] [-m <makefile>] [-c <c file>]",
" [-e <exec file>] <conffile>");
exit(1);
}
@ -811,10 +813,13 @@ void prog_makefile_rules(FILE *outmk, prog_t *p)
fprintf(outmk, "%s_OBJS=", p->ident);
output_strlst(outmk, p->objs);
fprintf(outmk, "%s_make:\n", p->ident);
fprintf(outmk, "\t(cd $(%s_SRCDIR) && make obj && \\\n"
"\t\tmake $(OPTS) $(%s_OPTS) depend && \\\n"
fprintf(outmk, "\t(cd $(%s_SRCDIR) && ", p->ident);
if (makeobj)
fprintf(outmk, "make obj && ");
fprintf(outmk, "\\\n");
fprintf(outmk, "\t\tmake $(OPTS) $(%s_OPTS) depend && \\\n"
"\t\tmake $(OPTS) $(%s_OPTS) $(%s_OBJS))\n",
p->ident, p->ident, p->ident, p->ident);
p->ident, p->ident, p->ident);
fprintf(outmk, "%s_clean:\n", p->ident);
fprintf(outmk, "\t(cd $(%s_SRCDIR) && make clean)\n\n", p->ident);
}