Makefile now detects OS.

This commit is contained in:
2026-02-14 11:20:27 -08:00
parent 084d4cc8b6
commit 1072c58e51
2 changed files with 28 additions and 10 deletions

View File

@@ -1,18 +1,36 @@
ifeq ($(OS),Windows_NT)
DETECTED_OS := windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
DETECTED_OS := macos
else ifeq ($(UNAME_S),Linux)
DETECTED_OS := linux
else
DETECTED_OS := unknown
endif
endif
CC = clang CC = clang
UFLAGS = UFLAGS =
FLAGS = -Wall -Wextra -ggdb -fno-caret-diagnostics -fno-show-column FLAGS = -Wall -Wextra -ggdb -fno-caret-diagnostics -fno-show-column
#-std=c99 -pedantic #-std=c99 -pedantic
# MacOS ifeq ($(DETECTED_OS),macos)
INCLUDE = $(shell pkg-config --cflags raylib) INCLUDE = $(shell pkg-config --cflags raylib)
LIBS = $(shell pkg-config --libs raylib) LIBS = $(shell pkg-config --libs raylib)
FRAMEWORKS = -framework IOKit -framework Cocoa -framework OpenGL FRAMEWORKS = -framework IOKit -framework Cocoa -framework OpenGL
else ifeq ($(DETECTED_OS),linux)
# Linux INCLUDE = -I./third_party/raylib/src/
# INCLUDE = -I./third_party/raylib/src/ LIBS = ./third_party/raylib/src/libraylib.a -lm
# LIBS = ./third_party/raylib/src/libraylib.a -lm FRAMEWORKS =
# FRAMEWORKS = else ifeq ($(DETECTED_OS),windows)
INCLUDE =
LIBS =
FRAMEWORKS =
endif
EXE=main EXE=main

2
main.c
View File

@@ -450,7 +450,7 @@ int main(int argc, char *argv[])
} }
} }
if (fflush(f) != 0) if(fflush(f) != 0)
perror("fflush"); perror("fflush");
last_save = now_s; last_save = now_s;