Skip to content

Commit

Permalink
Merge pull request #34 from EpitechPromo2027/jabolol/top-level-makefile
Browse files Browse the repository at this point in the history
add: top level project `Makefile`
  • Loading branch information
Jabolol authored Dec 8, 2024
2 parents 631abe3 + fa58068 commit ed8c9e7
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
PROJECT_NAME := glados
BUILD_DIR := dist-newstyle
EXECUTABLE := $(PROJECT_NAME)

BUILD_OUTPUT := $(shell find $(BUILD_DIR) -type f -name $(EXECUTABLE) -perm -111 2>/dev/null)

COLOR_RESET := \033[0m
COLOR_BLUE := \033[1;34m
COLOR_GREEN := \033[1;32m

.PHONY: all
all: build

.PHONY: re
re: fclean all

.PHONY: build
build:
cabal build
@if [ -z "$(BUILD_OUTPUT)" ]; then \
echo "Error: Binary not found. Ensure the project builds correctly."; \
exit 1; \
fi
cp $(BUILD_OUTPUT) ./$(EXECUTABLE)

.PHONY: clean
clean:
cabal clean

.PHONY: fclean
fclean: clean
rm -rf $(BUILD_DIR) $(EXECUTABLE)

.PHONY: test
test:
cabal test

.PHONY: repl
repl:
cabal repl

.PHONY: format
format:
ormolu -i $(shell find lib app -name "*.hs")

.PHONY: help
help:
@echo "$(COLOR_BLUE)Available targets:$(COLOR_RESET)"
@echo " $(COLOR_GREEN)all$(COLOR_RESET) - Build the project"
@echo " $(COLOR_GREEN)re$(COLOR_RESET) - Full clean and rebuild"
@echo " $(COLOR_GREEN)build$(COLOR_RESET) - Build the project and copy the binary to the root level"
@echo " $(COLOR_GREEN)clean$(COLOR_RESET) - Clean build artifacts"
@echo " $(COLOR_GREEN)fclean$(COLOR_RESET) - Full clean, including dist directories"
@echo " $(COLOR_GREEN)test$(COLOR_RESET) - Run tests"
@echo " $(COLOR_GREEN)repl$(COLOR_RESET) - Launch interactive REPL"
@echo " $(COLOR_GREEN)format$(COLOR_RESET) - Format all Haskell files using Fourmolu"
@echo " $(COLOR_GREEN)help$(COLOR_RESET) - Display this help message"

0 comments on commit ed8c9e7

Please # to comment.