Reputation: 89
I'm using a makefile to build several programs. Here's the code:
SRCS = prog1.c prog2.c prog3.c
TARG = all
CC = gcc
OPTS = -O
LIBS = -lm
OBJS = $(SRCS:.c=.o)
all: $(TARG)
$(TARG): $(OBJS)
$(CC) -o $(TARG) $(OBJS) $(LIBS)
%.o: %.c
$(CC) $(OPTS) -c $< -o $@
clean:
rm -f $(OBJS) $(TARG)
This makefile perfectly generates three prog.o files, but I'm getting one error that is confusing me:
Makefile:12: recipe for target 'all' failed
I've done a fair amount of searching and can't find anything relating to my particular problem, so I was wondering if anyone had some insight into what is going on here. Thanks a bunch!
Upvotes: 1
Views: 57
Reputation: 72469
You have cyclic dependency of all
depending on all
(because TARG
expands to all
). The dependency graph must be a DAG. change
TARG = all
to
TARG = something
Upvotes: 2
Reputation: 361585
With TARG = all
, you have:
all: all
all: $(OBJS)
Name your program something else, not all
.
Upvotes: 2