ppc-lang/Makefile

112 lines
3.4 KiB
Makefile
Raw Normal View History

2022-10-04 20:45:08 +00:00
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
2022-10-28 11:55:24 +00:00
export ldflags=-L$(bin)/$(profile) -Wl,-rpath=bin/$(profile)
2023-01-27 16:40:44 +00:00
export lib=ppc-$(version-major).$(version-minor)-
2022-09-19 07:34:19 +00:00
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
2023-01-26 17:36:33 +00:00
export version-build=1
2022-09-19 07:34:19 +00:00
###################################
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
2022-10-28 08:00:29 +00:00
oldbin := $(bin)
2022-09-19 07:34:19 +00:00
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++
2023-01-26 17:36:33 +00:00
# export version-build=$(if $(wildcard build.version),$(shell type build.version),0)
2023-01-27 16:40:44 +00:00
export binary = $(bin)/$(output)-$(version-major).$(version-minor)-windows.exe
2022-09-19 07:34:19 +00:00
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
2022-10-04 20:45:08 +00:00
echo Done!
2022-09-19 07:34:19 +00:00
clear:
if exist $(subst /,\,$(oldbin)) rmdir /s /q $(subst /,\,$(oldbin))
2022-10-28 08:00:29 +00:00
cleartmp:
if exist $(subst /,\,$(bin)/tmp) rmdir /s /q $(subst /,\,$(bin)/tmp)
2022-09-19 07:34:19 +00:00
.ONESHELL:
install: build
powershell -Command "start-process cmd -verb runas -args '/K pushd %CD%&set bin=$(bin)&set output=$(output)&.\scripts\install.bat&exit'"
uninstall:
.\scripts\uninstall.bat
2023-01-26 17:36:33 +00:00
# version:
# cmd /c "set /a $(version-build) + 1 > build.version"
2022-09-19 07:34:19 +00:00
else
2022-09-19 07:34:19 +00:00
ldflags += -lpthread
export mkdir=mkdir -p $$1
export rmdir=rm -rf $$1
export echo=echo "$$1"
export so=.so
2023-01-26 17:36:33 +00:00
# export version-build=$(if $(wildcard build.version),$(shell cat build.version),0)
2023-01-27 16:40:44 +00:00
export binary = $(bin)/$(output)-$(version-major).$(version-minor)-linux
2022-09-19 07:34:19 +00:00
build: version
echo ======================== Compiling =========================
make -f scripts/common.mak
ln -f $(binary) $(bin)/$(output)
clear:
rm -r $(oldbin)
2022-11-24 12:25:59 +00:00
cleartmp:
2022-10-28 08:00:29 +00:00
rm -r $(bin)/tmp
2022-09-19 07:34:19 +00:00
install: build
echo Installing ++C compiler to your system...
sudo cp $(bin)/*.so /usr/lib
sudo cp $(binary) /usr/bin/$(output)
2022-09-19 07:34:19 +00:00
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)
2023-01-26 17:36:33 +00:00
# version:
# echo $$(($(version-build) + 1)) > build.version
2022-09-19 07:34:19 +00:00
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