I am trying to create a framework where each folder in the source directory becomes a library. I haven't gotten to the .d dependencies yet, I am stuck trying to get the LLIST (library list) expansion to work.
My makefile is as follows:
# Directories
OBJDIR = obj
TGTDIR = target
INCDIR = include
SRCDIR = src
TSTDIR = tests
LIBDIR = lib
DEPDIR = .d
DIRS = $(OBJDIR) $(TGTDIR) $(INCDIR) $(LIBDIR) $(DEPDIR)
# Target name
TGT = caffeine
LLIST = utils middleware
OBJS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(wildcard $(SRCDIR)/**/*.c))
INCS := $(patsubst $(SRCDIR)/%.h, $(INCDIR)/%.h, $(wildcard $(SRCDIR)/**/*.h))
.PHONY: all
all: $(TGTDIR)/$(TGT)
$(TGTDIR)/$(TGT): $(LIBDIR)/$(LLIST).so
touch $@
$(LIBDIR)/$(LLIST).so: $(OBJDIR)/$(LLIST)/%.o
touch $@
$(OBJDIR)/$(LLIST)/%.o: $(SRCDIR)/$(LLIST)/%.c
touch $@
.PHONY: folders
folders:
mkdir -p $(DIRS)
.PHONY: clean
clean:
rm -rf $(DIRS)
The error I'm receiving is.
makefile:35: *** mixed implicit and normal rules: deprecated syntax
Which is this line.
$(OBJDIR)/$(LLIST)/%.o: $(SRCDIR)/$(LLIST)/%.c
To add for clarity the folder structure is as follows.
src
|-utils
|-utils.h
|-utils.c
|-hash.c
|-json.c
|-middleware
|-middleware.h
|-middleware.c
|-req.c
|-res.c