diff --git a/Makefile b/Makefile index 9a63056..8f0ca84 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,26 @@ +# Aux functions +rwildcard = $(foreach d, $(wildcard $(1:=/*)), $(call rwildcard ,$d, $2) $(filter $(subst *, %, $2), $d)) + +# Compiler CXX = gcc CC = $(CROSS_COMPILE)$(CXX) -INCDIR = include -CFLAGS = -O3 -Wall -Wextra -g -I $(INCDIR)/intf -I "src/intf" +# Compiler flags +CFLAGS = -O3 -Wall -Wextra -g LFLAGS = -lm +# Files and directories SRCDIR = src OBJDIR = temp BINDIR = build OUTFILE = noja -rwildcard = $(foreach d, $(wildcard $(1:=/*)), $(call rwildcard ,$d, $2) $(filter $(subst *, %, $2), $d)) - -SRC = $(call rwildcard, $(SRCDIR), *.c) -OBJS = $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRC)) +# Find all files +SRC = $(call rwildcard, $(SRCDIR), *.c) +OBJS = $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRC)) +# Compile everything to object files $(OBJDIR)/%.o: $(SRCDIR)/%.c @ echo $(shell tput setaf 3) [C] $(shell tput setaf 5) [SRC] $(shell tput setaf 7) $^ @ mkdir -p $(@D) @@ -31,5 +36,5 @@ build: @ $(CC) -o $(BINDIR)/$(OUTFILE) $(OBJS) $(LFLAGS) clean: - @ rm -rf $(BINDIR) - @ rm -rf $(OBJDIR) + @ rm -rf $(BINDIR) + @ rm -rf $(OBJDIR)