44 lines
930 B
Makefile
44 lines
930 B
Makefile
|
# Compiler
|
||
|
CC := /opt/homebrew/opt/llvm/bin/clang
|
||
|
# Compiler flags
|
||
|
CFLAGS := -Wall -Wextra -Werror -Ilibs -fsanitize=address
|
||
|
|
||
|
# Directories
|
||
|
SRCDIR := src
|
||
|
BINDIR := bin
|
||
|
LIBDIR := libs
|
||
|
|
||
|
# Source files
|
||
|
SRCS := $(wildcard $(SRCDIR)/*.c)
|
||
|
# Object files
|
||
|
OBJS := $(patsubst $(SRCDIR)/%.c,$(BINDIR)/%.o,$(SRCS))
|
||
|
|
||
|
# Libraries
|
||
|
LIBS := $(wildcard $(LIBDIR)/*/*.c)
|
||
|
# Library object files
|
||
|
LIBOBJS := $(patsubst %.c,%.o,$(LIBS))
|
||
|
|
||
|
# Target executables
|
||
|
EXECUTABLES := $(patsubst $(SRCDIR)/%,$(BINDIR)/%,$(basename $(wildcard $(SRCDIR)/*/*.c)))
|
||
|
|
||
|
.PHONY: all clean
|
||
|
|
||
|
all: $(EXECUTABLES)
|
||
|
|
||
|
$(BINDIR)/%: $(BINDIR)/%.o $(LIBOBJS)
|
||
|
$(CC) $(CFLAGS) $^ -o $@
|
||
|
|
||
|
$(BINDIR)/%.o: $(SRCDIR)/%.c | $(BINDIR)
|
||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||
|
|
||
|
$(BINDIR):
|
||
|
mkdir -p $(BINDIR)
|
||
|
|
||
|
permissions: $(BINDIR)/djumbai_enqueue/djumbai_enqueue
|
||
|
chown djumbaiq $(BINDIR)/djumbai_enqueue/djumbai_enqueue
|
||
|
chmod u+s $(BINDIR)/djumbai_enqueue/djumbai_enqueue
|
||
|
|
||
|
clean:
|
||
|
rm -rf $(BINDIR)
|
||
|
|