commit e40bd023fb2a04f2d2b49732491373e1f911e8b6 Author: Martin Errenst Date: Sun Aug 27 13:19:39 2017 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cba7efc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +a.out diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c034743 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +CXXFLAGS += -O3 + +GIT_VERSION := $(shell git describe --dirty --always --tags) +COMPILER_VERSION := $(shell ${CXX} --version | head -n1) + +all: get_parameters + ${CXX} ${CXXFLAGS} -DGIT_VERSION="\"${GIT_VERSION}\"" -DUSED_FLAGS="\"${USED_FLAGS}\"" -DUSED_COMPILER="\"${COMPILER_VERSION}\"" main.cpp && ./a.out + +compile_dummy: + ${CXX} ${CXXFLAGS} -frecord-gcc-switches dummy.cpp + +get_parameters: compile_dummy + $(eval USED_FLAGS := $(shell readelf -p .GCC.command.line a.out | grep -v -e dummy.cpp -e "-frecord-gcc-switches" | grep -e "\[.*\]" | cut -d\] -f2- | tr -d "\n")) + +.PHONY: all get_parameters compile_dummy diff --git a/dummy.cpp b/dummy.cpp new file mode 100644 index 0000000..ade4548 --- /dev/null +++ b/dummy.cpp @@ -0,0 +1,3 @@ +int main(){ + return 0; +} diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..36cfa3e --- /dev/null +++ b/main.cpp @@ -0,0 +1,11 @@ +#include + +void print_build_information(){ + std::cout << "Build from revision: " << GIT_VERSION << std::endl; + std::cout << "Compiled with: " << USED_COMPILER << std::endl; + std::cout << "With the following flags: " << USED_FLAGS << std::endl; +} +int main(){ + print_build_information(); + return 0; +}