From 1fb2a05ddf244f1869989d6f2824a291ee0ad59b Mon Sep 17 00:00:00 2001 From: HuntedByTheIRS Date: Sun, 28 Jun 2026 17:47:34 -0400 Subject: [PATCH] Add compiler detection + optimizations Added compiler detection: TCC->Clang->GCC Uses -O2 optimizations now Uses -march=native by default, but by using ```make package```, it creates a distrobutable binary instead. --- Makefile | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8e07856..8eaffa4 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,19 @@ VERSION = `git describe --tags --dirty 2>/dev/null || echo 0.2` PREFIX = /usr/local -CC = cc PKG_CONFIG = pkg-config +# Auto-detect compiler: TCC > Clang > GCC +ifeq ($(shell which tcc 2>/dev/null),) + ifeq ($(shell which clang 2>/dev/null),) + CC = gcc + else + CC = clang + endif +else + CC = tcc +endif + # Uncomment to build without XWayland support #XWAYLAND = #XLIBS = @@ -18,7 +28,9 @@ PKGS = wayland-server xkbcommon libinput $(LUA_PKG) $(XLIBS) CFLAGS = `$(PKG_CONFIG) --cflags $(PKGS) wlroots-0.20` \ -I. -Iinclude -Isrc -Iparser -Iprotocols \ -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" \ - $(XWAYLAND) -g -Wall -Wextra -Wno-unused-parameter -O1 -std=c11 $(CFLAGS) + $(XWAYLAND) -g -Wall -Wextra -Wno-unused-parameter -O2 $(MARCH) -std=c11 $(CFLAGS) + +MARCH = -march=native LDLIBS = `$(PKG_CONFIG) --libs $(PKGS) wlroots-0.20` -lm $(LIBS) SMSG_CFLAGS = `$(PKG_CONFIG) --cflags wayland-client` -Wall -Wextra -Wno-unused-parameter @@ -32,6 +44,9 @@ PROTO_OBJS = protocols/peachwm-ipc-unstable-v2-protocol.o \ all: peachwm smsg/smsg +package: + $(MAKE) MARCH= + # Compositor peachwm: src/peachwm.o src/util.o parser/parser.o \