Reputation: 14256
I've been working on this for two days and still haven't been able to get this makefile to work.
This is what I currently have:
INCDIR = inc/pvt inc/pub
SRCDIR = src
OBJDIR = obj
LIBDIR = lib
CC=gcc
CFLAGS := $(foreach d, $(INCDIR), -I$d)
_SRC = teos_event.c teos_init.c teos_linkedlist.c teos_log.c teos_sem.c teos_task.c
_OBJ := $(subst $(SRCDIR),$(OBJDIR),$(_SRC:%.c=%.o))
OBJ := $(patsubst %,$(OBJDIR)/%,$(_OBJ))
build: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) -fmax-errors=1
$(OBJDIR)/%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS) -fmax-errors=1
$(OBJ): $(DEPS)
This is the output I get when I run make:
gcc -o build obj/teos_event.o obj/teos_init.o obj/teos_linkedlist.o obj/teos_log
.o obj/teos_sem.o obj/teos_task.o -Iinc/pvt -Iinc/pub -fmax-errors=1
gcc: error: obj/teos_event.o: No such file or directory
gcc: error: obj/teos_init.o: No such file or directory
gcc: error: obj/teos_linkedlist.o: No such file or directory
gcc: error: obj/teos_log.o: No such file or directory
gcc: error: obj/teos_sem.o: No such file or directory
gcc: error: obj/teos_task.o: No such file or directory
gcc: fatal error: no input files
compilation terminated.
makefile:40: recipe for target 'build' failed
make: *** [build] Error 1
I'm trying to get it to build without makefile errors. Any help would be great.
Upvotes: 0
Views: 2000
Reputation: 99084
Did you not notice that it isn't building teos_event.o
?
Change this:
$(OBJDIR)/%.o: %.c
...
to this:
$(OBJDIR)/%.o: $(SRCDIR)/%.c
...
Upvotes: 1