aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.116
-rw-r--r--build.c11
2 files changed, 14 insertions, 13 deletions
diff --git a/build.1 b/build.1
index 10ae999..63e46e7 100644
--- a/build.1
+++ b/build.1
@@ -55,8 +55,9 @@ searches for a
.Em target :
.Bl -tag -width indent
.It target
-.br
">" <filename without whitespace>
+.br
+"-o " <filename without whitespace>
.El
.Pp
The last target found will be counted
@@ -89,7 +90,7 @@ starts with the following text,
.Bd -literal -offset indent
/**
* To build this program, use the following invocation:
- * $ cc -O2 -o prg prg.c # > prg
+ * $ cc -O2 -o prg prg.c
*/
.Ed
.Pp
@@ -99,19 +100,16 @@ $ build prg.c
.Ed
.Pp
will build
-.Pa prg .
-(Because
-.Xr cc 1
-does not print the built file on standard output,
-a commented
-.Ql > prg
-is necessary to set the target correctly.
+.Pa prg ,
+if it is older than
+.Pa prg.c .
.Pp
Assuming that the file
.Pa doc.t
starts with the following text,
.Bd -literal -offset indent
\&.\\" This document is built with the following shell commands:
+\&.\\" $ export LC_ALL=en_US.UTF-8
\&.\\" $ refer -p refs doc.t | troff -ms | dpost > doc.ps
\&.\\" $ ps2pdf doc.ps > doc.pdf
\&.\\" $ rm doc.ps
diff --git a/build.c b/build.c
index 16b53e2..267f674 100644
--- a/build.c
+++ b/build.c
@@ -100,10 +100,13 @@ main(int argc, char *argv[])
/* Find target inside command. */
for(b = b+3; *b; b++){
- if(!(*b+1)) continue;
- if(*b != '>') continue;
- strncpy(tgt, b+1, MAXTGT-1);
-
+ if(*(b+1) && *(b+2) && *(b+3)
+ && strncmp(b, "-o ", 3) == 0)
+ strncpy(tgt, b+3,
+ MAXTGT-1);
+ else if(*(b+1) && *b == '>')
+ strncpy(tgt, b+1,
+ MAXTGT-1);
}
ddd("%s: command line '%s'\n",