prerequisites on data built in commands
- From: "billy" <bp1497@xxxxxxx>
- Date: 5 May 2006 10:18:07 -0700
How do I arrange targets and prerequisites and prerequsisites when to
command creates the prerequsiste and the prerequsite is generated by
the input to the command
short snippett
a : b
prog -in parms -out b
b : c
prog -in parms -out c
....
b & c may be N files .c,.h,.sql,.cobol,.cpp
These have to be compiled.
Since I can't do an eval inside the command to create a rule, how do I
have a rule that is not unknown until the commands for a are executed.
Here's some test code I have started:
prog_1.c
#include <stdio.h>
#include "prog_1.h"
long bogus = 0;
int main(int argc,char** argv)
{
char s[16];
FILE* fp;
sprintf(s,"%s.c",argv[1]);
fp = fopen(s,"w");
fprintf(fp,"#include <stdio.h>\n#include \"%s.h\"\nlong bogus =
0;\n",argv[1]);
fprintf(fp,"int main(int argc,char** argv)\n");
fprintf(fp,"{ printf(\"hello world from %%s\\n\",argv[0]);
return(0);}\n");
close(fp);
sprintf(s,"%s.h",argv[1]);
fp = fopen(s,"w");
fprintf(fp,"#ifndef %s_h\n",argv[1]);
fprintf(fp,"#define %s_h\n",argv[1]);
fprintf(fp,"extern long bogus;\n");
fprintf(fp,"#endif\n");
close(fp);
return(0);
}
prog_1.h
#ifndef prog_1_H
extern long bogus;
#define prog_1_H
#endif
makefile :
..PHONY: all
SRCS := prog_1.c
CREATE := prog_2 prog_3 prog_4
all : prog_1
MAKEDEPEND = /opt/langtools/lbin/cpp.ansi -M -E $< \
| sed -n 's/^\# *[0-9][0-9]* *"\([^"]*\)".*/$*.o: \1/p' \
| sort | uniq > $*.d
MAKEDEPEND2 = /opt/langtools/lbin/cpp.ansi -M -E $$f.c \
| sed -n 's/^\# *[0-9][0-9]* *"\([^"]*\)".*/$*.o: \1/p' \
| sort | uniq > $$f.d
prog_1 : $(SRCS:.c=.o)
@gcc -o $@ $?
@for f in $(CREATE) ; do \
$@ $$f ; \
$(MAKEDEPEND2); \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $$f.d >> $$f.P; \
rm -f $*.d ; \
gcc -c -o $$f $$f.c ; \
done
-include $(addsuffix .P,$(CREATE))
%.o : %.c
@$(MAKEDEPEND); \
cp $*.d $*.P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
rm -f $*.d ; \
gcc -c -o $@ $<
-include $(SRCS:.c=.P)
This uses Tom Tromey's method of auto creating dependencies
.
- Prev by Date: Re: delete multiple lines with perl (was: Re: delete multiple lines with sed)
- Next by Date: void pointer problem
- Previous by thread: Re: delete multiple lines with perl (was: Re: delete multiple lines with sed)
- Next by thread: void pointer problem
- Index(es):
Relevant Pages
|
|