76 lines
2.1 KiB
Makefile
76 lines
2.1 KiB
Makefile
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
|
|
|
|
UFLAGS =
|
|
# NOTE: This project's code bases itself on C89 (plain C) standard, however
|
|
# allowing a few convenient features of newer standards. Mid-scope
|
|
# variable declarations, comments that begin with '//', long long,
|
|
# designated initializers, compound literals, and anonymous structures
|
|
# are allowed as they are convenient. Everything else that has come out
|
|
# of modern standards is pretty much destructive and should not be used.
|
|
FLAGS = -Wall -Wextra \
|
|
-Wincompatible-pointer-types \
|
|
-Wint-conversion -Wimplicit-int-float-conversion -Wformat \
|
|
-Wno-strict-prototypes -Wno-missing-field-initializers \
|
|
-Wno-unused-function -Wno-unused-parameter -Wno-unused-variable \
|
|
-Wno-unused-but-set-variable \
|
|
-fno-caret-diagnostics -fno-show-column
|
|
|
|
ifeq ($(DETECTED_OS),macos)
|
|
UFLAGS = -glldb
|
|
INCLUDE = -I./sdl/include/
|
|
LIBS = ./sdl/lib/arm-macos/libSDL2.a -lm
|
|
FRAMEWORKS = -framework Cocoa -framework IOKit -framework CoreAudio \
|
|
-framework AudioToolbox -framework ForceFeedback \
|
|
-framework Carbon -framework GameController \
|
|
-framework Metal -framework QuartzCore \
|
|
-framework CoreHaptics
|
|
else ifeq ($(DETECTED_OS),linux)
|
|
UFLAGS = -ggdb -D_POSIX_C_SOURCE=200809L
|
|
INCLUDE = -I./sdl/include/
|
|
LIBS = ./sdl/lib/x86_64-linux/libSDL2.a -lm -lX11
|
|
FRAMEWORKS =
|
|
else ifeq ($(DETECTED_OS),windows)
|
|
INCLUDE =
|
|
LIBS =
|
|
FRAMEWORKS =
|
|
else
|
|
INCLUDE =
|
|
LIBS =
|
|
FRAMEWORKS =
|
|
endif
|
|
|
|
EXE=handmadehero
|
|
|
|
default: libhandmade $(EXE)
|
|
|
|
libhandmade: handmade.c
|
|
@ $(CC) $(FLAGS) $(UFLAGS) -fPIC -shared $(INCLUDE) $^ $(LIBS) \
|
|
$(FRAMEWORKS) -o libhandmade.so
|
|
|
|
$(EXE): sdl_handmade.c libhandmade
|
|
@ $(CC) $(FLAGS) $(UFLAGS) $(INCLUDE) sdl_handmade.c $(LIBS) \
|
|
$(FRAMEWORKS) -o $@
|
|
|
|
run:
|
|
@ ./$(EXE)
|
|
|
|
tags: $(OBJS)
|
|
ctags -R *.h *.c
|
|
|
|
clean:
|
|
@rm -rf $(EXE) $(EXE).dSYM libhandmade.so libhandmade.so.dSYM
|