SOURCES = Test.cpp BUILD_DIR = build CXXFLAGS = -std=c++14 WHICH_UNAME := $(shell which -a uname) ifeq ($(WHICH_UNAME), /usr/bin/uname) UNAME := $(shell uname) else UNAME := Docker TARGETS := docker endif # LINUX version ifeq ($(UNAME), Linux) TARGETS := $(BUILD_DIR)/hello-linux-64 $(BUILD_DIR)/hello-win64.exe $(BUILD_DIR)/hello-macosx.bin LINUX_CXX := x86_64-linux-gnu-g++ WIN32_CXX := x86_64-w64-mingw32-g++ MACOSX_CXX := x86_64-apple-darwin19-c++ endif # WINDOWS version ifeq ($(UNAME), MINGW64_NT-10.0) TARGETS := $(BUILD_DIR)/hello-win64.exe WIN32_CXX := x86_64-w64-mingw32-g++ endif # MACOSX version ifeq ($(UNAME), Darwin) TARGETS := $(BUILD_DIR)/hello-macosx.bin MACOSX_CXX := x86_64-apple-darwin22-c++-13 endif all: $(TARGETS) @echo "all..." @echo $(UNAME) .PRECIOUS: $(BUILD_DIR)/ $(BUILD_DIR)%/ $(BUILD_DIR)/: @echo "dir1..." @mkdir -p $@ $(BUILD_DIR)%/: @echo "dir2..." @mkdir -p $@ .SECONDEXPANSION: $(BUILD_DIR)/hello-linux-64: Test.cpp $$(@D)/ @echo "Building Linux binary..." @$(LINUX_CXX) $< -o $@ $(BUILD_DIR)/hello-win64.exe: Test.cpp $$(@D)/ @echo "Building Windows binary..." @$(WIN32_CXX) $< -o $@ $(BUILD_DIR)/hello-macosx.bin: Test.cpp $$(@D)/ @echo "Building MacOSX binary..." @$(MACOSX_CXX) $< -o $@ tidy: $(BUILD_DIR)/tidy.xml $(BUILD_DIR)/tidy.xml: $$(@D)/ @chmod u+x ./clang-tidy-to-junit.py @clang-tidy -checks='c*,l*,m*' $(SOURCES) -- $(CXXFLAGS) | ./clang-tidy-to-junit.py $(PWD)/ > $@ test: $(BUILD_DIR)/tests.xml $(BUILD_DIR)/tests.xml: $$(@D)/ @echo '<?xml version="1.0" encoding="UTF-8" ?>' > $@ @echo '<testsuites id="1" name="Clang-Tidy" tests="1" errors="0" failures="0" time="0">' >> $@ @echo '</testsuites>' >> $@ docker: @echo "Running in docker..." publish: @echo "Publish..." .PHONY: test $(BUILD_DIR)/tests.xml