This repository was archived by the owner on Nov 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (75 loc) · 2.44 KB
/
Makefile
File metadata and controls
94 lines (75 loc) · 2.44 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
###################################################################################################################
# This Makefile is for the Shell project
###################################################################################################################
PROJECT = Shell
CONFIG = Debug
STD = c++14
SRC = src
INC = inc
OBJ = obj
BIN = bin
TST = test
MSC = misc
DIR = |-
NC = \033[1;0m
RED = \033[1;31m
GREEN = \033[1;32m
YELLOW = \033[1;33m
BLUE = \033[1;34m
CFLS = $(wildcard $(SRC)/*.cpp)
TFLS = $(wildcard $(TST)/$(SRC)/*.cpp)
OBJS = $(patsubst %,$(OBJ)/%, $(notdir $(CFLS:.cpp=.o)))
TOBJS = $(patsubst %,$(TST)/$(OBJ)/%, $(notdir $(TFLS:.cpp=.o)))
EXE = $(BIN)/$(PROJECT).exe
TEXE = $(TST)/tested.exe
TINC = $(TST)/$(MSC)/testing.hpp
CC = g++
CFLAGS = -std=$(STD) -Wall -g -I$(INC)
RFLAG = -lreadline
$(EXE) : $(OBJS)
@echo "$(YELLOW)Linking...$(NC)"
$(CC) -o $@ $^ $(RFLAG)
@echo "$(GREEN)Finished!$(NC)"
$(OBJ)/%.o : $(CFLS)
@echo "$(RED)Compiling...$(NC)"
$(CC) $(CFLAGS) -c $< -o $@
$(TEXE): $(TOBJS)
@echo "$(YELLOW)Linking Test...$(NC)"
$(CC) -o $@ $^
@echo "$(GREEN)Finished Test!$(NC)"
$(TST)/$(OBJ)%.o : $(TFLS)
@echo "$(RED)Compiling Test...$(NC)"
$(CC) $(CFLAGS) -c $< -o $@
.PHONY: help run clean test tclean
prerun :
touch $(INC)/testing.hpp
pretest :
cp -f $(TINC) $(INC)
run : prerun $(EXE)
$(EXE)
test : pretest $(TEXE)
$(TEXE)
crun : clean run
ctest : tclean test
clean :
rm -f $(OBJS) $(EXE) $(INC)/testing.hpp
tclean :
rm -f $(TOBJS) $(TEXE)
help :
@echo "$(GREEN)Project: $(BLUE)$(PROJECT)$(NC)"
@echo "$(GREEN)File System Hierarchy:$(NC)"
@echo "$(RED)$(PROJECT):$(NC)"
@echo "$(DIR)$(RED)$(SRC):$(NC)\t*.cpp, *.c and .cc files"
@echo "$(DIR)$(RED)$(INC):$(NC)\t*.h and *.hpp files"
@echo "$(DIR)$(RED)$(OBJ):$(NC)\t*.o and *.obj files"
@echo "$(DIR)$(RED)$(SRC):$(NC)\t*.exe and *.dll files"
@echo "$(DIR)$(RED)$(TST):$(NC)\tTest driven files"
@echo " $(DIR)$(RED)$(SRC):$(NC)\tTest scripts"
@echo " $(DIR)$(RED)$(OBJ):$(NC)\t*.o and *obj for compiled tests"
@echo " $(DIR)$(RED)$(MSC):$(NC)\tAny and all miscellaneous files"
@echo "$(YELLOW)run: $(NC) compiles, links, and executes the program"
@echo "$(YELLOW)clean: $(NC) clean file system; obj and bin folder"
@echo "$(YELLOW)crun: $(NC) clean than run"
@echo "$(YELLOW)test: $(NC) compiles, links, and executes the program test units"
@echo "$(YELLOW)tclean: $(NC) clean file system; tests folder"
@echo "$(YELLOW)ctest: $(NC) clean than test"