diff options
author | John Ankarström <john@ankarstrom.se> | 2021-07-11 13:11:53 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-07-11 13:11:53 +0200 |
commit | 68cd2dc506e7440baf1fa5467b84212a8a6a4913 (patch) | |
tree | 30a454f36c0c66e45ed1dbbbb6ec25b537b10ebb | |
parent | 0596b07e2470d9e0444df5ea1a08997367202c18 (diff) | |
download | build-68cd2dc506e7440baf1fa5467b84212a8a6a4913.tar.gz |
Support "-o " targets
-rw-r--r-- | build.1 | 16 | ||||
-rw-r--r-- | build.c | 11 |
2 files changed, 14 insertions, 13 deletions
@@ -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 @@ -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", |