CC = gcc
INCLUDES = \
	-Isrc \
	-Iinclude 

CFLAGS = -Wall -Wpedantic -std=c90
BINDIR = build
OBJDIR = build/obj


SOURCES = $(wildcard src/*.c) $(wildcard src/*.c)

# Set the object file names, with the source directory stripped
# from the path, and the build path prepended in its place			
OBJECTS = $(SOURCES:%.c=$(OBJDIR)/%.o)

all: dirs lib

lib: libvnhsic.a

libvnhsic.a: $(OBJECTS)
	ar -cvq $(BINDIR)/libvnhsic.a $(OBJECTS)

# Create the directories used in the build
.PHONY: dirs
dirs:
	@mkdir -p $(OBJDIR)
	@mkdir -p $(BINDIR)
	@mkdir -p $(dir $(OBJECTS))

$(OBJDIR)/%.o: %.c
	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

clean:
	rm -f $(BINDIR)/libvnhsic.a
	rm -f $(OBJECTS)
