-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
111 lines (93 loc) · 3.31 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
export MAKEFLAGS += --silent -r -j
export flags=-std=c++17 -Wall -Wno-main -Wno-trigraphs -Wno-missing-braces -Wno-stringop-overflow -DPROFILE_$(profile) -fdiagnostics-color=always
export ldflags=-L$(bin)/$(profile) -Wl,-rpath=bin/$(profile)
export lib=ppc$(version-major)-
export profile=release
############# SETTINGS ############
export bin = bin
export src = src
export inc = include
export output = ppc
export mainmodule = main
export version-major=0
export version-minor=0
###################################
ifeq ($(OS),Windows_NT)
export os = Windows
export OS = WINDOWS
else
export os = $(shell uname)
export OS = $(shell echo '$(os)' | tr '[:lower:]' '[:upper:]')
endif
.PHONY: build debug leak lint clear install uninstall version
ifeq ($(profile),release)
flags += -O3
else ifeq ($(profile),debug)
flags += -g
endif
oldbin := $(bin)
export bin := $(bin)/$(profile)
ifeq ($(os),Windows)
export mkdir=if not exist "$$1" mkdir "$$1"
export rmdir=if exist "$$1" rmdir /s /q "$$1"
export echo=echo "$$1"
export so=.dll
export exe=.exe
export CC=gcc
export CXX=g++
export version-build=$(if $(wildcard build.version),$(shell type build.version),0)
export binary = $(bin)/$(output)$(version-major)-windows.exe
build: version
echo ======================== Compiling =========================
make -f scripts/common.mak
if exist "$(subst /,\,$(bin)\$(output).exe)" del "$(subst /,\,$(bin)\$(output).exe)"
mklink /H "$(subst /,\,$(bin)\$(output).exe)" "$(subst /,\,$(binary))" > NUL
echo Done!
clear:
if exist $(subst /,\,$(oldbin)) rmdir /s /q $(subst /,\,$(oldbin))
cleartmp:
if exist $(subst /,\,$(bin)/tmp) rmdir /s /q $(subst /,\,$(bin)/tmp)
.ONESHELL:
install: build
powershell -Command "start-process cmd -verb runas -args '/K pushd %CD%&set bin=$(bin)&set output=$(output)&.\scripts\install.bat&exit'"
# .\scripts\install.bat
uninstall:
.\scripts\uninstall.bat
version:
cmd /c "set /a $(version-build) + 1 > build.version"
else
ldflags += -lpthread
export mkdir=mkdir -p $$1
export rmdir=rm -rf $$1
export echo=echo "$$1"
export so=.so
export version-build=$(if $(wildcard build.version),$(shell cat build.version),0)
export binary = $(bin)/$(output)$(version-major)-linux
build: version
echo ======================== Compiling =========================
make -f scripts/common.mak
ln -f $(binary) $(bin)/$(output)
clear:
rm -r $(oldbin)
cleartmp:
rm -r $(bin)/tmp
install: build
echo Installing ++C compiler to your system...
sudo cp $(bin)/*.so /usr/lib
sudo cp $(binary) /usr/bin/$(output)
sudo chmod +777 /usr/bin/$(output)
sudo chmod +777 $(patsubst $(bin)/%,/usr/lib/%,$(wildcard $(bin)/*.so))
uninstall:
echo Uninstalling ++C compiler from your system...
sudo rm $(patsubst $(bin)/%.so,/usr/lib/%*.so,$(bin)/*.so)
sudo rm /usr/bin/$(output)
version:
echo $$(($(version-build) + 1)) > build.version
leak: build
echo ====================== Leak scanning =======================
$(if $(filter $(os),Windows),cmd /C echo.,echo)
valgrind --tool=memcheck --leak-check=full --track-origins=yes ./$(binary) $(patsubst %,./%,$(wildcard *.ppc))
lint:
echo ========================= Linting ==========================
cppcheck $(src) --track-origins=yes --suppress=unusedFunction --suppress=missingInclude --enable=all
endif