Skip to content

Commit b709064

Browse files
committed
Improve verbosity handling and platform detection in makefile
1 parent d69fde5 commit b709064

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

examples/ImGui/makefile

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616
.DEFAULT_GOAL := all
1717

1818
# 0 = Silent Mode; 1 = Color & Details Mode
19-
ifneq ($(filter -j%,$(MAKEFLAGS)),)
19+
VERBOSE ?= 1
20+
21+
# Optional: if the user passes -s (--silent), force VERBOSE=0
22+
ifneq ($(findstring s,$(MAKEFLAGS)),)
2023
VERBOSE := 0
21-
else
22-
VERBOSE := 1
24+
else ifneq ($(filter -j%,$(MAKEFLAGS)),)
25+
VERBOSE := 0
2326
endif
2427

2528
ifeq ($(VERBOSE),1)
@@ -42,6 +45,18 @@ else
4245
HIGHLIGHT :=
4346
endif
4447

48+
# Platform-specific detection for commands
49+
50+
UNAME_S := $(shell uname -s 2>/dev/null || echo Unknown)
51+
52+
ifeq ($(findstring Windows,$(OS)),Windows)
53+
IS_WINDOWS := yes
54+
else ifeq ($(UNAME_S),Darwin)
55+
IS_MACOS := yes
56+
else ifeq ($(UNAME_S),Linux)
57+
IS_LINUX := yes
58+
endif
59+
4560
# ──────────────────────────────────────────────────────────────────────────────
4661
# Main configuration – customize these variables
4762
# ──────────────────────────────────────────────────────────────────────────────
@@ -105,7 +120,7 @@ endif
105120
# Platform detection & common settings
106121
# ──────────────────────────────────────────────────────────────────────────────
107122

108-
ifeq ($(OS),Windows_NT)
123+
ifeq ($(IS_WINDOWS),yes)
109124
OS_NAME := Windows
110125
ifeq ($(USE_CONSOLE),false)
111126
CONSOLEFLAGS := -mwindows
@@ -128,11 +143,10 @@ ifeq ($(OS),Windows_NT)
128143
HOST_ARCH := x86_64
129144
endif
130145
else
131-
UNAME_S := $(shell uname -s)
132-
ifeq ($(UNAME_S),Linux)
146+
ifeq ($(IS_LINUX),yes)
133147
OS_NAME := Linux
134148
endif
135-
ifeq ($(UNAME_S),Darwin)
149+
ifeq ($(IS_MACOS),yes)
136150
OS_NAME := macOS
137151
endif
138152
RM := rm -rf
@@ -258,7 +272,7 @@ $(DEP_DIR)/%.d: ;
258272

259273
.PHONY: clean-banner
260274
clean-banner:
261-
@clear 2>/dev/null || cls
275+
@if [ -t 1 ]; then clear; fi
262276
ifeq ($(VERBOSE),1)
263277
@printf "$(INFO_COLOR)─── Build: $(HIGHLIGHT)$(APP_NAME)$(NO_COLOR)\n"
264278
@printf " $(BOLD)> OS:$(NO_COLOR) %s\n" "$(OS_NAME)"

0 commit comments

Comments
 (0)