forked from ucupsss/SMG-Tubes-IF2224-2026
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (53 loc) · 1.46 KB
/
Copy pathMakefile
File metadata and controls
69 lines (53 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Makefile for Arion Compiler
CXX := g++
CXXFLAGS := -std=c++17 -Wall -Wextra -pedantic -MMD -MP
CPPFLAGS := -Iinclude
SRC_DIR := src
ifeq ($(OS),Windows_NT)
PLATFORM := windows
EXE_EXT := .exe
PATH_SEP := \\
MKDIR = if not exist "$(subst /,\,$1)" mkdir "$(subst /,\,$1)"
RMDIR = if exist "$(subst /,\,$1)" rmdir /s /q "$(subst /,\,$1)"
RMFILE = if exist "$(subst /,\,$1)" del /f /q "$(subst /,\,$1)"
RUN_PREFIX :=
else
PLATFORM := linux
EXE_EXT :=
PATH_SEP := /
MKDIR = mkdir -p "$1"
RMDIR = rm -rf "$1"
RMFILE = rm -f "$1"
RUN_PREFIX := ./
endif
OBJ_DIR := build/$(PLATFORM)
BIN_DIR := bin/$(PLATFORM)
TARGET := $(BIN_DIR)/arion_compiler$(EXE_EXT)
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
OBJS := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRCS))
DEPS := $(OBJS:.o=.d)
.PHONY: all build run clean rebuild directories
all: build
build: directories $(TARGET)
directories:
@$(call MKDIR,$(OBJ_DIR))
@$(call MKDIR,$(BIN_DIR))
$(TARGET): $(OBJS)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $^ -o $@
@echo "Build successful! Executable is at $(TARGET)"
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
@$(call MKDIR,$(dir $@))
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
run: build
$(RUN_PREFIX)$(TARGET)
clean:
@$(call RMDIR,$(OBJ_DIR))
@$(call RMFILE,$(TARGET))
@echo "Cleaned up $(OBJ_DIR) and $(TARGET)"
clean-all:
@$(call RMDIR,build)
@$(call RMDIR,bin/windows)
@$(call RMDIR,bin/linux)
@echo "Cleaned up all build artifacts"
rebuild: clean build
-include $(DEPS)