prerequisites on data built in commands



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

.



Relevant Pages

  • Re: make problems
    ... For gcc you would need a command ... > in the command statement, I think I don't have to include the path. ... the file to be created and the "$<" translates to the name of the ... first file of the list of prerequisites, ...
    (comp.os.linux.development.apps)
  • Re: Reg installation of Visual Studio.net
    ... [In case anyone else has this problem, you can bypass the Prerequisites ... Setup by entering the command line for the Prerequisites CD by entering ...
    (microsoft.public.dotnet.faqs)
  • Re: How to find out info on this .rpm file?
    ... |What is the command to find out it's contents, ... |what it is, prerequisites, etc. ie. ... rpm also. ... [You're over-crossposting. ...
    (comp.os.linux.setup)
  • Re: Installing VB.NET 2003
    ... You may try to bypass the prerequisites check by following command: ... Luke Zhang ...
    (microsoft.public.dotnet.languages.vb)
  • Re: CL Corrupt Parm
    ... The result of prompting the CMDparameter value is a command string that SBMJOB passes into RQSDTAinternally. ... When the two parms have blanks added out to the *CHAR lengths defined in the CL program, everything runs fine on my system here. ... OTOH, if I simply prompt a CALL command and type the strings _without_ quoting out to the proper lengths, the parms only contain the significant characters. ...
    (comp.sys.ibm.as400.misc)