CC := clang YACC := bison LEX := flex CFLAGS := -std=c17 -Wpedantic -Wall -Wextra BUILD := ./build INCLUDE := -I./ OBJ_DIR := $(BUILD)/objects APP_DIR := $(BUILD)/bin TARGET := day_4 SRC := $(wildcard ./*.cpp) lexer.c parser.c OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o) # targets all: build $(APP_DIR)/$(TARGET) run: all $(APP_DIR)/$(TARGET) flex: $(LEX) --outfile=lexer.c --header-file=lexer.h lexer.l bison: $(YACC) --output=parser.c parser.y generate: flex bison $(OBJ_DIR)/%.o: %.c @mkdir -p $(@D) $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< $(APP_DIR)/$(TARGET): flex bison $(OBJECTS) @mkdir -p $(@D) $(CC) $(CFLAGS) $(INCLUDE) $(LDFLAGS) -o $(APP_DIR)/$(TARGET) $(OBJECTS) .PHONY: all build clean debug release build: @mkdir -p $(APP_DIR) @mkdir -p $(OBJ_DIR) debug: CFLAGS += -DDEBUG -g debug: all sanitize: CFLAGS += -DDEBUG -g -fsanitize=address sanitize: all release: CFLAGS += -O2 release: all clean: -@rm -rvf $(BUILD) -@rm -rvf {lexer.c,parser.c} {lexer.h,parser.h}