Thursday, August 27, 2015

Fun With Makefiles

I have stuff  in two directories, vhal and milltop.  I want a dependency on a .h and .c file in the vhal directory.

(INCL)=../vhal
CC=gcc
DEPS=../vhal/vhal.h ../vhal/parseargs.c

all: milltop ../vhal/parseargs.c $(INCL)vhal.h milltop.ngc

milltop: milltop.c $(DEPS)
    $(CC) -o $@ -g milltop.c -I$(INCL)

milltop.ngc: milltop
    ./milltop -mr0.25 -pt3.203 -f3.0 -w0.522 -l3.055 -h2.686 -mof 0.25 >milltop.ngc
Why does it think that there is nothing after the -I argument?  Once upon a time, I would have made milltop dependent on milltop.c, vhal.h, and parseargs.o but I am not seeing the %.o: %.c dependency rules in example Makefiles.

2 comments:

  1. I'm not a make expert, but shouldn't the first line be

    INCL=../vhal

    ReplyDelete
  2. Take the parens off the (INCL) at line 1.

    ReplyDelete