CC=gcc
CFLAGS=-Wall -O2 -I/usr/include/freetype2 -Iinclude/
LIBS=-lX11 -lXft -lXrender -lfontconfig -lfreetype -lpam

SRCS = $(shell cd src && find . -type f -name '*.c')
override OBJ_C     := $(subst .c,.o,$(SRCS))
override OBJS       := $(subst ./,build/,$(OBJ_C))
TARGET = bin/Deb13Shell

vpath %.c

# Default target
all: $(TARGET)

# Rule to link object files into the final executable
$(TARGET): $(OBJS)
	@mkdir -p $(dir $@)
	@$(info $s    LD $(OBJS) ==> $@)
	@$(CC) $(OBJS) $(LIBS) -o $@

# Generic rule to compile .c files into .o files
build/%.o: src/%.c
	@mkdir -p $(dir $@)
	@$(info $s    CC $< ==> $@)
	@$(CC) $(CFLAGS) -c $< -o $@

# Rule to clean up
clean:
	@rm -rf bin build
