Skip to content

Commit afa520f

Browse files
committed
Add targets to show OS and compiler info
1 parent 9dd50cc commit afa520f

1 file changed

Lines changed: 40 additions & 3 deletions

File tree

Makefile

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,47 @@ TEST := $(TESTS_DIR)/test.sh
3838

3939
# --- Rules --------------------------------------------------------------------
4040

41+
.PHONY: all show show-os show-compiler release debug run run-release run-debug \
42+
test test-release test-debug clean clean-release clean-debug help
43+
4144
all: $(TARGET)
4245

46+
show:
47+
$(MAKE) show-os
48+
$(MAKE) show-compiler
49+
50+
show-compiler:
51+
$(shell which $(CXX)) --version
52+
53+
show-os:
54+
@if [ -n "$$OS" ] && [ "$$OS" = "Windows_NT" ]; then \
55+
echo "Operating System: Windows (native CMD/PowerShell)"; \
56+
echo "Windows Version:"; ver; \
57+
else \
58+
unameOut=$$(uname -s); \
59+
if [ "$$unameOut" = "Darwin" ]; then \
60+
echo "Operating System: macOS"; \
61+
echo "Version:"; sw_vers; \
62+
elif [ "$$unameOut" = "Linux" ]; then \
63+
echo "Operating System: Linux"; \
64+
if [ -f /etc/os-release ]; then \
65+
echo "Version:"; cat /etc/os-release; \
66+
else \
67+
uname -a; \
68+
fi; \
69+
elif echo "$$unameOut" | grep -qiE 'MINGW|MSYS|CYGWIN'; then \
70+
echo "Operating System: Windows (Git Bash/MSYS/Cygwin)"; \
71+
winver=$$(cmd.exe /c ver); \
72+
echo "Windows Version:"; echo "$$winver"; \
73+
else \
74+
echo "Operating System: Unknown"; \
75+
uname -a; \
76+
fi \
77+
fi
78+
4379
# build program
4480
$(TARGET): $(OBJ) | $(BINSTAMP)
81+
$(MAKE) show
4582
$(CXX) $(CXXFLAGS) -o $@ $^
4683

4784
# generate object files and dependency files
@@ -108,6 +145,9 @@ help:
108145
@echo " clean - Remove release and debug build files"
109146
@echo " clean-release - Remove release build files"
110147
@echo " clean-debug - Remove debug build files"
148+
@echo " show - Show operating system and compiler info"
149+
@echo " show-os - Show operating system info"
150+
@echo " show-compiler - Show compiler info"
111151
@echo " help - Show this help message and exit"
112152
@echo
113153
@echo "Variables:"
@@ -123,6 +163,3 @@ help:
123163
@echo " make test-debug # Build and test debug version"
124164
@echo " make CXX=g++ # Build with g++ compiler"
125165
@echo " make CXX_STANDARD=c++20 # Build with C++20 standard"
126-
127-
.PHONY: all release debug run run-release run-debug test test-release \
128-
test-debug clean clean-release clean-debug help

0 commit comments

Comments
 (0)