Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Custom GNU C++20 compiler.
- GPP:=g++ -std=gnu++20 -O2 -ftabstop=1 -Werror -DLOCAL
- # Compilation flags for compile-time diagnostics.
- DIAGNOSE:=-Wall -Wextra -Wshadow -Wconversion -Wold-style-cast -Wfloat-equal\
- -Walloca -Wvla -Wzero-as-null-pointer-constant -Wlogical-op -Wduplicated-cond\
- -Wduplicated-branches -Wredundant-decls -Wredundant-tags -Wmismatched-tags\
- -Wctor-dtor-privacy -Wextra-semi -Wundef
- # Compilation flags for run-time sanity checks.
- SANITIZE:=-g -fno-sanitize-recover=all -fsanitize=undefined\
- -fsanitize=float-cast-overflow -fsanitize=float-divide-by-zero\
- -fsanitize=address -D_GLIBCXX_SANITIZE_VECTOR -D_GLIBCXX_DEBUG
- # Command for the creation of new directories.
- MKDIR:=mkdir -p --
- # Command for the removal of existing directories.
- RMDIR:=rm -rf --
- # Directory of the executables.
- BINDIR:=bin/
- # Name of the default executable.
- BINFILE:=main
- # Name of the sanitized executable.
- BINFILESAN:=mainsan
- # Path to the default executable.
- BINPATH:=${BINDIR}${BINFILE}
- # Path to the sanitized executable.
- BINPATHSAN:=${BINDIR}${BINFILESAN}
- # Directory of the source code.
- SRCDIR:=src/
- # Main source file extension.
- MAINEXT:=.cpp
- # Name of the main source file.
- MAINFILE:=main${MAINEXT}
- # Path to the main source file.
- MAINPATH:=${SRCDIR}${MAINFILE}
- # Header file extension.
- HDREXT:=.hpp
- # Paths to all header files.
- HDRTREE:=$(shell find ${SRCDIR} -name '*${HDREXT}')
- # Directory of the base header files.
- BASEDIR:=${SRCDIR}base/
- # Name of the base header index file.
- BASEFILE:=index${HDREXT}
- # Path to the base header index file.
- BASEPATH:=${BASEDIR}${BASEFILE}
- # Paths to all base header files.
- BASETREE:=$(shell find ${BASEDIR} -name '*${HDREXT}')
- # Directory of the precompiled headers.
- PRECOMPDIR:=${BASEPATH}.gch/
- # Name of the default precompiled header.
- PRECOMPFILE:=base_precompiled_header
- # Name of the sanitized precompiled header.
- PRECOMPFILESAN:=base_precompiled_header_sanitized
- # Path to the default precompiled header.
- PRECOMPPATH:=${PRECOMPDIR}${PRECOMPFILE}
- # Path to the sanitized precompiled header.
- PRECOMPPATHSAN:=${PRECOMPDIR}${PRECOMPFILESAN}
- # Precompile the base headers with compile-time diagnostics, build the default
- # executable, and run it. This is the default target.
- .PHONY:all
- all:prepare build run
- # Precompile the base headers with both compile-time diagnostics and run-time
- # sanity checks, build the sanitized executable, and run it.
- .PHONY:allsan san
- allsan san:preparesan buildsan runsan
- # Precompile the base headers for the default executable.
- .PHONY:prepare
- prepare:${PRECOMPPATH}
- # Precompile the base headers for the sanitized executable.
- .PHONY:preparesan
- preparesan:${PRECOMPPATHSAN}
- # Build the default executable.
- .PHONY:build
- build:${BINPATH}
- # Build the sanitized executable.
- .PHONY:buildsan
- buildsan:${BINPATHSAN}
- # Run the default executable.
- .PHONY:run
- ifeq (,$(wildcard ${BINPATH}))
- run:${BINPATH}
- else
- run:
- endif
- @${BINPATH}
- # Run the sanitized executable.
- .PHONY:runsan
- ifeq (,$(wildcard ${BINPATHSAN}))
- runsan:${BINPATHSAN}
- else
- runsan:
- endif
- @${BINPATHSAN}
- # Delete all existing executables and precompiled headers.
- .PHONY:clean
- clean:
- @${RMDIR} ${BINDIR} ${PRECOMPDIR}
- # Run the precompilation of the base headers for the default executable.
- ${PRECOMPPATH}:${BASETREE}
- @${MKDIR} ${PRECOMPDIR}
- @${GPP} ${DIAGNOSE} -iquote${SRCDIR} ${BASEPATH} -o $@
- # Run the precompilation of the base headers for the sanitized executable.
- ${PRECOMPPATHSAN}:${BASETREE}
- @${MKDIR} ${PRECOMPDIR}
- @${GPP} ${DIAGNOSE} ${SANITIZE} -iquote${SRCDIR} ${BASEPATH} -o $@
- # Run the compilation of the default executable.
- ${BINPATH}:${MAINPATH} ${HDRTREE}
- @${MKDIR} ${BINDIR}
- @${GPP} ${DIAGNOSE} -iquote${SRCDIR} $< -o $@
- # Run the compilation of the sanitized executable.
- ${BINPATHSAN}:${MAINPATH} ${HDRTREE}
- @${MKDIR} ${BINDIR}
- @${GPP} ${DIAGNOSE} ${SANITIZE} -iquote${SRCDIR} $< -o $@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement