-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
134 lines (109 loc) · 4.48 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
123
124
125
126
127
128
129
130
131
132
133
134
# C Makefile using gcc, gdb and valgrind.
# Modified version of Makefile using g++ & gdb by Roberto Nicolas Savinelli <[email protected]>
# Tomas Agustin Sanchez <[email protected]>
# ! Avoid modifying this section - (Unless you know what you are doing) --------------------------------------------------------------
# Build directory - executables files will be stored in this directory
BUILD_DIR=build
# Log directory - log files will be stored in this directory
LOG_DIR=log
# Shared Library directory - shared source files are located in this directory
LIB_DIR=lib
# Shared object directory - shared compiled file objects will be stored in this directory
OBJ_DIR=shared
# Commons name - Operating System Course Library name.
COMMONS=so-commons-library
# Compile script - Custom make directive
MAKE_COMPILE = $(MAKE) compile --no-print-directory
# Test script - Custom make test directive
MAKE_TEST = $(MAKE) test --no-print-directory
# Test Scrpt for each application - Loop for all modules applying test directive.
# ? [modules].forEach( module => makeTest(module))
TEST_ALL=$(foreach dir, $(DIRS), cd $(dir) && $(MAKE_TEST) && cd .. &&)
# * Add your modules directories in this section -------------------------------------------------------------------------------------
# Modules directories - with their own makefile
# TODO: Add additional module directories below here
# ? eg. MEMORY_DIR=memory
KERNEL_DIR=kernel
CONSOLE_DIR=console
MEMORY_DIR=memory
CPU_DIR=cpu
# * DO NOT FORGET TO ADD YOUR DIRECTORIES HERE ---------------------------------------------------------------------------------------
# Directories list
# ! Allways add your listed above directories here
# ? eg. DIRS =$(SERVER_DIR) $(CLIENT_DIR) $(MEMORY_DIR)
# TODO: Add the listed directories
DIRS = $(KERNEL_DIR) $(CPU_DIR) $(MEMORY_DIR) $(CONSOLE_DIR)
# * DO NOT FORGET TO ADD YOUR RULES IN ALL --------------------------------------------------------------------------------------------
# All rules
# ! Allways add your rule for modules in here
# ? eg. all: server client memory filesystem etc
# TODO: add your rules
all: lib kernel cpu memory console
# This targets are not files
# ! Allways add your rules for modules in here too
# ? eg. .PHONY: server client memory filesystem etc [...] clean install test
# TODO: add your rules here
.PHONY: kernel clean install test lib memory console cpu
# ! AVOID MODIFYING THIS SECTION ------------------------------------------------------------------------------------------------------
# This rule will be executed to build the different modules
compile:
@mkdir -p $(BUILD_DIR)
@mkdir -p $(LOG_DIR)
@touch $(LOG_DIR)/$(KERNEL_DIR).log
@touch $(LOG_DIR)/$(CONSOLE_DIR).log
@touch $(LOG_DIR)/$(CPU_DIR).log
@touch $(LOG_DIR)/$(MEMORY_DIR).log
$(MAKE) all --no-print-directory
# This rule
test:
$(TEST_ALL) true
# This rule will be executed remove the generated executables and objects files
clean:
rm -fr $(BUILD_DIR)
rm -fr $(OBJ_DIR)
# ? WATCH OUT MODIFYING THIS INSTALL SECTION --------------------------------------------------------------------------------------------------
# ! Requieres root user
# Customize the needed dependencies here.
install:
@echo Installing dependencies...
# TODO: Install required libraries here.
@echo "\nInstalling readline"
apt-get install libreadline-dev
@echo "\nReadline installed!\n"
@echo "\nInstalling commons libraries...\n"
@echo $(PWD)
rm -rf $(COMMONS)
git clone "https://github.com/sisoputnfrba/$(COMMONS).git" $(COMMONS)
cd $(COMMONS) && sudo make uninstall --no-print-directory && sudo make install --no-print-directory && cd ..
rm -rf $(COMMONS)
@echo "\nCommons installed\n"
@echo Completed
install-python:
@echo Installing Python...
apt-get install python3
@echo "Python installed!"
deploy:
@echo Creating Swap File
@mkdir -p ../swap
$(MAKE) all --no-print-directory
$(MAKE) install-sh --no-print-directory
install-sh:
chmod +x $(PWD)/*.sh
# ! Requieres root user
#Compile the shared library
lib:
@echo "Building shared libraries...\n"
rm -fr $(OBJ_DIR)
cd $(LIB_DIR) && $(MAKE) test --no-print-directory && cd ..
@echo "Shared libraries built!\n"
# TODO: Add modules rules below -------------------------------------------------------------------------------------------------------------------
# ? memory:
# ? cd $(MEMORY_DIR) && $(MAKE_COMPILE)
kernel:
cd $(KERNEL_DIR) && $(MAKE_COMPILE)
cpu:
cd $(CPU_DIR) && $(MAKE_COMPILE)
memory:
cd $(MEMORY_DIR) && $(MAKE_COMPILE)
console:
cd $(CONSOLE_DIR) && $(MAKE_COMPILE)