0

I have a directory of .pc files, and I am trying to compile to .o files with a Makefile. Oracle Pro*C precompiles the .pc files into .c. Then gcc compiles the .c files to .o. These are the rules:

%.c: %.pc
    $(PROC) $(PROCPLSFLAGS)  INCLUDE=$(SRCHOME) iname=$<
%.o: %.c 
    $(CC) $(INCLUDE) $(CFLAGS) $(PRECOMPPUBLIC) -c $<

The problem occurs when I try to build a .o file. The .c file is generated correctly, but the $(CC) line cannot find the .c file until I run make a second time. When I run the Makefile without any arguments to build the entire directory, I need to run make twice for each .pc file in the directory. How can I fix the Makefile so that it only needs to run once?

Joe
  • 41,484
  • 20
  • 104
  • 125
slec
  • 539
  • 6
  • 7
  • 4
    What you have shown us should already do what you want it to do, which means the problem is in something you haven't shown us. Please attempt to construct a [MCVE] by starting with your full makefile and then deleting bits from it until you can no longer reproduce the problem yourself. Then put back the last bit and post that makefile. – zwol Mar 06 '18 at 02:47
  • maybe like this> (rule 1) .pc.c $(PROC) $(PROCPLSFLAGS) INCLUDE=$(SRCHOME) iname=$*.pc (rule2) .c.o: $(CC) $(INCLUDE) $(CFLAGS) $(PRECOMPPUBLIC) $* – access_granted Mar 06 '18 at 03:41

0 Answers0