-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
122 lines (102 loc) · 3.44 KB
/
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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Define the version number
VERSION_NO = 1.1
# Compiler configurations
COMPILER = g++
DEBUG_FLAGS = -g -Wall -Wextra -Wpedantic
RELEASE_FLAGS = -O3
COMPILER_FLAGS = -Wl,--no-as-needed -ldl -std=c++17 -fPIC
DLL_COMPILER_FLAGS = -shared
DEBUG_OUT_FILENAME = Coda_debug
RELEASE_OUT_FILENAME = Coda
# Output filenames for packages
OS_OUT_FILENAME = OS.so
RANDOM_OUT_FILENAME = Random.so
MATHS_OUT_FILENAME = Maths.so
# Define main project and package files
MAIN_PROJECT = Application/Application.cpp \
Error/Raiser.cpp \
Error/Manager.cpp \
Frontend/Importer/Importer.cpp \
Frontend/Lexer/Handlers.cpp \
Frontend/Node/Node.cpp \
Frontend/Lexer/Lexer.cpp \
Frontend/Parser/ParseBinary.cpp \
Frontend/Parser/ParseControlStatement.cpp \
Frontend/Parser/ParseGeneral.cpp \
Frontend/Parser/ParseObjectType.cpp \
Frontend/Parser/Parser.cpp \
Frontend/Tokens/Constants.cpp \
Frontend/Tokens/Token.cpp \
Main.cpp \
Runtime/Environment/Environment.cpp \
Runtime/Interpreter/EvaluateBinary.cpp \
Runtime/Interpreter/EvaluateControlStructure.cpp \
Runtime/Interpreter/EvaluateGeneral.cpp \
Runtime/Interpreter/EvaluateObjectType.cpp \
Runtime/Interpreter/Handler.cpp \
Runtime/Interpreter/Interpreter.cpp \
Runtime/NativeFunctions/NativeFunction.cpp \
Runtime/RuntimeValue/Value.cpp \
Utils/ArgParser.cpp \
Utils/FileReader.cpp
OS_PACKAGE =dll/OS/FileSystem.cpp \
dll/OS/OS.cpp \
RANDOM_PACKAGE = dll/Random/Random.cpp
MATHS_PACKAGE = dll/Maths/Basic.cpp\
dll/Maths/BasicFunctions.cpp\
dll/Maths/Trignometry.cpp
# Define directories for debug and release modes
DEBUG_OBJDIR = ./bin/Debug/Linux/
RELEASE_OBJDIR = ./bin/Release/Linux/
# Set object directory based on mode
ifeq ($(MODE),release)
OBJDIR = $(RELEASE_OBJDIR)
COMPILER_FLAGS += $(RELEASE_FLAGS)
OUT_FILENAME = $(RELEASE_OUT_FILENAME)
else
OBJDIR = $(DEBUG_OBJDIR)
COMPILER_FLAGS += $(DEBUG_FLAGS)
OUT_FILENAME = $(DEBUG_OUT_FILENAME)
endif
# Generate object paths for main, OS, Random, and Maths files
MAIN_OBJECTS = $(patsubst %.cpp,$(OBJDIR)%.o,$(MAIN_PROJECT))
OS_OBJECTS = $(patsubst %.cpp,$(OBJDIR)%.o,$(OS_PACKAGE))
RANDOM_OBJECTS = $(patsubst %.cpp,$(OBJDIR)%.o,$(RANDOM_PACKAGE))
MATHS_OBJECTS = $(patsubst %.cpp,$(OBJDIR)%.o,$(MATHS_PACKAGE))
# Build targets
all: $(OBJDIR) $(MAIN_OBJECTS)
$(COMPILER) $(COMPILER_FLAGS) $(MAIN_OBJECTS) -o $(OBJDIR)$(OUT_FILENAME)
os: $(OBJDIR) $(OS_OBJECTS)
$(COMPILER) $(COMPILER_FLAGS) $(DLL_COMPILER_FLAGS) $(OS_OBJECTS) -o $(OBJDIR)$(OS_OUT_FILENAME)
cp -f $(CURDIR)/dll/OS/os.coda $(OBJDIR)os.coda
random: $(OBJDIR) $(RANDOM_OBJECTS)
$(COMPILER) $(COMPILER_FLAGS) $(DLL_COMPILER_FLAGS) $(RANDOM_OBJECTS) -o $(OBJDIR)$(RANDOM_OUT_FILENAME)
cp -f $(CURDIR)/dll/Random/random.coda $(OBJDIR)random.coda
maths: $(OBJDIR) $(MATHS_OBJECTS)
$(COMPILER) $(COMPILER_FLAGS) $(DLL_COMPILER_FLAGS) $(MATHS_OBJECTS) -o $(OBJDIR)$(MATHS_OUT_FILENAME)
cp -f $(CURDIR)/dll/Maths/maths.coda $(OBJDIR)maths.coda
# Rule for creating object files
$(OBJDIR)%.o: %.cpp
mkdir -p $(dir $@)
$(COMPILER) $(COMPILER_FLAGS) $(DLL_COMPILER_FLAGS) -c $< -o $@
$(OBJDIR):
mkdir -p $(OBJDIR)
# Target for publishing
package:
make MODE=release
make random MODE=release
make maths MODE=release
make os MODE=release
tar -cvzf Coda_v$(VERSION_NO).tar.gz -C $(RELEASE_OBJDIR) \
$(RELEASE_OUT_FILENAME) \
$(OS_OUT_FILENAME) \
$(RANDOM_OUT_FILENAME) \
$(MATHS_OUT_FILENAME) \
os.coda \
random.coda \
maths.coda
# Clean up target
clean:
rm -fr ./bin
rm -f *.o
rm -f *.out