-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
44 lines (33 loc) · 984 Bytes
/
Makefile
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
###### VARIABLES #############
# Directories
INCDIR := include
SRCDIR := src
OBJDIR := src/obj
# Compiler and options
CC := g++
FLAGS := -lpanel -lmenu -lncurses -lpthread -I$(INCDIR) -std=c++17 -g -ftrapv -Woverflow -Wconversion -Wpedantic -Wextra -Wall -Wdouble-promotion -Wformat=2
# Target executable
TARGET := among_stars
#############################
# Needed files
DEP := $(shell find $(INCDIR) -type f -name *.hpp)
SRC := $(shell find $(SRCDIR) -type f -name *.cpp)
OBJ := $(patsubst $(SRCDIR)/%, $(OBJDIR)/%, $(SRC:.cpp=.o))
# Non-file targets
.PHONY: all dir remove clean run
all: dir $(TARGET)
# Object-files rule
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp $(DEP)
$(CC) -c -o $@ $< $(FLAGS)
$(TARGET): $(OBJ)
$(CC) -o $(TARGET) $^ $(FLAGS)
@echo "\nBUILD SUCCESSFUL. start the program using 'make run' or ./$(TARGET)"
remove:
-@rm $(TARGET)
clean: remove
-@rm -rf $(OBJDIR)/*.o
@echo "Cleared executable and object files!"
dir:
@mkdir -p $(OBJDIR)
run:
@./$(TARGET)