-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
45 lines (37 loc) · 1.56 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
SOURCE_FOLDER = src
OUTPUT_FOLDER = out
MALLOQUEIRO_FOLDER = Malloqueiro
MALLOQUEIRO_OUTPUT_FOLDER = ${OUTPUT_FOLDER}/${MALLOQUEIRO_FOLDER}
MALLOQUEIRO_SOURCE_FOLDER = ${SOURCE_FOLDER}/${MALLOQUEIRO_FOLDER}
LIB_FOLDER = lib
CXXFLAGS = -O3 -Wall
CXX = g++
all: clean setup compile run
clean:
@echo "----------------- Cleaning output folder"
rm -rf $(OUTPUT_FOLDER)/*
rm -rf $(LIB_FOLDER)/*
setup:
@echo "----------------- Setup"
@if [ ! -d "out/Malloqueiro/" ]; then \
echo "out/Malloqueiro/ folder not found, creating folder and subfolders"; \
mkdir -p "out/Malloqueiro/"; \
fi
@if [ ! -d "lib/" ]; then \
echo "lib/ folder not found, creating folder"; \
mkdir -p "lib/"; \
fi
compile: library
@echo "----------------- Compiling program"
$(CXX) $(SOURCE_FOLDER)/Program.cpp -o $(OUTPUT_FOLDER)/Program.out $(CXXFLAGS) -L${MALLOQUEIRO_OUTPUT_FOLDER}/ -lmalloqueiro
library: setup
@echo "----------------- Linking libraries"
$(CXX) -c ${MALLOQUEIRO_SOURCE_FOLDER}/Malloqueiro.cpp -o ${MALLOQUEIRO_OUTPUT_FOLDER}/Malloqueiro.o $(CXXFLAGS)
$(CXX) -c ${MALLOQUEIRO_SOURCE_FOLDER}/Gerency/MalloqueiroGerency.cpp -o ${MALLOQUEIRO_OUTPUT_FOLDER}/MalloqueiroGerency.o $(CXXFLAGS)
ar rvs ${MALLOQUEIRO_OUTPUT_FOLDER}/libmalloqueiro.a \
${MALLOQUEIRO_OUTPUT_FOLDER}/Malloqueiro.o \
${MALLOQUEIRO_OUTPUT_FOLDER}/MalloqueiroGerency.o
$(CXX) -shared -o ${LIB_FOLDER}/malloqueiro.so ${MALLOQUEIRO_OUTPUT_FOLDER}/libmalloqueiro.a $(CXXFLAGS)
run: compile
@echo "----------------- Running program"
$(OUTPUT_FOLDER)/Program.out