2024-07-10 04:25:48 -04:00
|
|
|
SOURCE_DIR = src
|
|
|
|
BUILD_DIR = build
|
|
|
|
C_SOURCES = $(wildcard $(SOURCE_DIR)/*.c)
|
|
|
|
C_OBJECTS = $(patsubst $(SOURCE_DIR)/%.c, $(BUILD_DIR)/%.o, $(C_SOURCES))
|
2024-03-25 03:02:14 -04:00
|
|
|
|
2024-07-10 04:25:48 -04:00
|
|
|
OBJECTS = $(C_OBJECTS)
|
2024-03-25 03:02:14 -04:00
|
|
|
ENAME = ClassiCube
|
2024-06-17 05:54:29 -04:00
|
|
|
CFLAGS = -g -pipe -fno-math-errno -Werror -Wno-error=missing-braces -Wno-error=strict-aliasing -Wno-error=maybe-uninitialized
|
2024-03-25 03:02:14 -04:00
|
|
|
LDFLAGS = -g -rdynamic
|
2018-10-14 02:31:13 -04:00
|
|
|
|
2024-06-10 09:06:24 -04:00
|
|
|
ifndef RM
|
|
|
|
# No prefined RM variable, try to guess OS default
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
RM = del
|
|
|
|
else
|
|
|
|
RM = rm -f
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2024-04-12 18:52:20 -04:00
|
|
|
# Enables dependency tracking (https://make.mad-scientist.net/papers/advanced-auto-dependency-generation/)
|
|
|
|
# This ensures that changing a .h file automatically results in the .c files using it being auto recompiled when next running make
|
|
|
|
# On older systems the required GCC options may not be supported - in which case just change TRACK_DEPENDENCIES to 0
|
|
|
|
TRACK_DEPENDENCIES=1
|
|
|
|
|
2019-04-06 03:44:53 -04:00
|
|
|
ifndef $(PLAT)
|
2019-04-05 15:44:56 -04:00
|
|
|
ifeq ($(OS),Windows_NT)
|
2024-03-25 03:02:14 -04:00
|
|
|
PLAT = mingw
|
2019-04-05 15:44:56 -04:00
|
|
|
else
|
2024-03-25 03:02:14 -04:00
|
|
|
PLAT = $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
2019-04-05 15:44:56 -04:00
|
|
|
endif
|
2019-04-05 14:52:01 -04:00
|
|
|
endif
|
2018-10-14 02:31:13 -04:00
|
|
|
|
2019-04-07 08:28:03 -04:00
|
|
|
ifeq ($(PLAT),web)
|
2024-04-12 18:52:20 -04:00
|
|
|
CC = emcc
|
|
|
|
OEXT = .html
|
|
|
|
CFLAGS = -g
|
2024-07-10 04:25:48 -04:00
|
|
|
LDFLAGS = -g -s WASM=1 -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_STACK=1Mb --js-library $(SOURCE_DIR)/interop_web.js
|
|
|
|
BUILD_DIR = build-web
|
2019-04-07 08:28:03 -04:00
|
|
|
endif
|
2019-04-05 14:52:01 -04:00
|
|
|
|
2019-04-07 08:28:03 -04:00
|
|
|
ifeq ($(PLAT),mingw)
|
2024-06-17 05:54:29 -04:00
|
|
|
CC = gcc
|
|
|
|
OEXT = .exe
|
|
|
|
CFLAGS += -DUNICODE
|
|
|
|
LDFLAGS = -g
|
|
|
|
LIBS = -mwindows -lwinmm -limagehlp
|
2024-07-10 04:25:48 -04:00
|
|
|
BUILD_DIR = build-win
|
2019-04-07 08:28:03 -04:00
|
|
|
endif
|
2019-04-05 14:52:01 -04:00
|
|
|
|
2019-04-07 08:28:03 -04:00
|
|
|
ifeq ($(PLAT),linux)
|
2024-06-17 05:54:29 -04:00
|
|
|
CFLAGS += -DCC_BUILD_ICON
|
|
|
|
LIBS = -lX11 -lXi -lpthread -lGL -ldl
|
2024-07-10 04:25:48 -04:00
|
|
|
BUILD_DIR = build-linux
|
2019-04-07 08:28:03 -04:00
|
|
|
endif
|
2019-04-05 15:44:56 -04:00
|
|
|
|
2019-04-07 08:28:03 -04:00
|
|
|
ifeq ($(PLAT),sunos)
|
2024-06-17 05:54:29 -04:00
|
|
|
CFLAGS += -DCC_BUILD_ICON
|
|
|
|
LIBS = -lsocket -lX11 -lXi -lGL
|
2024-07-10 04:25:48 -04:00
|
|
|
BUILD_DIR = build-solaris
|
2019-04-07 08:28:03 -04:00
|
|
|
endif
|
2019-04-06 03:44:53 -04:00
|
|
|
|
2024-02-05 02:15:02 -05:00
|
|
|
ifeq ($(PLAT),darwin)
|
2024-06-04 06:09:59 -04:00
|
|
|
OBJECTS += $(BUILD_DIR)/Window_cocoa.o
|
2024-06-17 05:54:29 -04:00
|
|
|
CFLAGS += -DCC_BUILD_ICON
|
2024-04-12 18:52:20 -04:00
|
|
|
LIBS =
|
2024-06-17 05:54:29 -04:00
|
|
|
LDFLAGS = -rdynamic -framework Cocoa -framework OpenGL -framework IOKit -lobjc
|
2024-07-10 04:25:48 -04:00
|
|
|
BUILD_DIR = build-macos
|
2021-11-14 02:59:39 -05:00
|
|
|
endif
|
|
|
|
|
2019-04-07 08:28:03 -04:00
|
|
|
ifeq ($(PLAT),freebsd)
|
2024-06-17 05:54:29 -04:00
|
|
|
CFLAGS += -I /usr/local/include -DCC_BUILD_ICON
|
|
|
|
LDFLAGS = -L /usr/local/lib -rdynamic
|
|
|
|
LIBS = -lexecinfo -lGL -lX11 -lXi -lpthread
|
2024-07-10 04:25:48 -04:00
|
|
|
BUILD_DIR = build-freebsd
|
2019-04-07 08:28:03 -04:00
|
|
|
endif
|
2019-04-06 03:44:53 -04:00
|
|
|
|
2019-04-07 08:28:03 -04:00
|
|
|
ifeq ($(PLAT),openbsd)
|
2024-06-17 05:54:29 -04:00
|
|
|
CFLAGS += -I /usr/X11R6/include -I /usr/local/include -DCC_BUILD_ICON
|
|
|
|
LDFLAGS = -L /usr/X11R6/lib -L /usr/local/lib -rdynamic
|
|
|
|
LIBS = -lexecinfo -lGL -lX11 -lXi -lpthread
|
2024-07-10 04:25:48 -04:00
|
|
|
BUILD_DIR = build-openbsd
|
2019-04-07 08:28:03 -04:00
|
|
|
endif
|
2019-04-06 03:44:53 -04:00
|
|
|
|
2019-04-07 08:28:03 -04:00
|
|
|
ifeq ($(PLAT),netbsd)
|
2024-06-17 05:54:29 -04:00
|
|
|
CFLAGS += -I /usr/X11R7/include -I /usr/pkg/include -DCC_BUILD_ICON
|
|
|
|
LDFLAGS = -L /usr/X11R7/lib -L /usr/pkg/lib -rdynamic
|
|
|
|
LIBS = -lexecinfo -lGL -lX11 -lXi -lpthread
|
2024-07-10 04:25:48 -04:00
|
|
|
BUILD_DIR = build-netbsd
|
2019-04-07 08:28:03 -04:00
|
|
|
endif
|
2019-04-05 15:44:56 -04:00
|
|
|
|
2020-05-05 06:03:35 -04:00
|
|
|
ifeq ($(PLAT),dragonfly)
|
2024-06-17 05:54:29 -04:00
|
|
|
CFLAGS += -I /usr/local/include -DCC_BUILD_ICON
|
|
|
|
LDFLAGS = -L /usr/local/lib -rdynamic
|
|
|
|
LIBS = -lexecinfo -lGL -lX11 -lXi -lpthread
|
2024-07-10 04:25:48 -04:00
|
|
|
BUILD_DIR = build-flybsd
|
2020-05-05 06:03:35 -04:00
|
|
|
endif
|
|
|
|
|
2019-11-11 02:23:50 -05:00
|
|
|
ifeq ($(PLAT),haiku)
|
2024-06-04 06:09:59 -04:00
|
|
|
OBJECTS += $(BUILD_DIR)/Platform_BeOS.o $(BUILD_DIR)/Window_BeOS.o
|
2024-04-12 18:52:20 -04:00
|
|
|
CFLAGS = -g -pipe -fno-math-errno
|
|
|
|
LDFLAGS = -g
|
|
|
|
LIBS = -lGL -lnetwork -lstdc++ -lbe -lgame -ltracker
|
2024-07-10 04:25:48 -04:00
|
|
|
BUILD_DIR = build-haiku
|
2019-11-11 02:23:50 -05:00
|
|
|
endif
|
|
|
|
|
2023-06-29 05:45:27 -04:00
|
|
|
ifeq ($(PLAT),beos)
|
2024-06-04 06:09:59 -04:00
|
|
|
OBJECTS += $(BUILD_DIR)/Platform_BeOS.o $(BUILD_DIR)/Window_BeOS.o
|
2024-04-12 18:52:20 -04:00
|
|
|
CFLAGS = -g -pipe
|
|
|
|
LDFLAGS = -g
|
|
|
|
LIBS = -lGL -lnetwork -lstdc++ -lbe -lgame -ltracker
|
2024-07-10 04:25:48 -04:00
|
|
|
BUILD_DIR = build-beos
|
2024-04-16 07:24:31 -04:00
|
|
|
TRACK_DEPENDENCIES=0
|
2023-06-29 05:45:27 -04:00
|
|
|
endif
|
|
|
|
|
2022-10-18 06:27:16 -04:00
|
|
|
ifeq ($(PLAT),serenityos)
|
2024-04-12 18:52:20 -04:00
|
|
|
LIBS = -lgl -lSDL2
|
2024-07-10 04:25:48 -04:00
|
|
|
BUILD_DIR = build-serenity
|
2022-10-18 06:27:16 -04:00
|
|
|
endif
|
|
|
|
|
2023-03-23 07:21:46 -04:00
|
|
|
ifeq ($(PLAT),irix)
|
2024-04-12 18:52:20 -04:00
|
|
|
CC = gcc
|
|
|
|
LIBS = -lGL -lX11 -lXi -lpthread -ldl
|
2024-07-10 04:25:48 -04:00
|
|
|
BUILD_DIR = build-irix
|
2023-03-23 07:21:46 -04:00
|
|
|
endif
|
|
|
|
|
2024-07-10 04:25:48 -04:00
|
|
|
|
2024-06-06 04:40:00 -04:00
|
|
|
ifdef SDL2
|
|
|
|
CFLAGS += -DCC_WIN_BACKEND=CC_WIN_BACKEND_SDL2
|
|
|
|
LIBS += -lSDL2
|
|
|
|
endif
|
|
|
|
ifdef SDL3
|
|
|
|
CFLAGS += -DCC_WIN_BACKEND=CC_WIN_BACKEND_SDL3
|
|
|
|
LIBS += -lSDL3
|
|
|
|
endif
|
2024-06-10 10:16:51 -04:00
|
|
|
|
2024-06-10 09:06:24 -04:00
|
|
|
ifdef TERMINAL
|
|
|
|
CFLAGS += -DCC_WIN_BACKEND=CC_WIN_BACKEND_TERMINAL -DCC_GFX_BACKEND=CC_GFX_BACKEND_SOFTGPU
|
2024-06-10 10:16:51 -04:00
|
|
|
LIBS := $(subst mwindows,mconsole,$(LIBS))
|
2024-06-10 09:06:24 -04:00
|
|
|
endif
|
2024-08-02 21:07:45 -04:00
|
|
|
ifdef RELEASE
|
|
|
|
CFLAGS += -O1
|
|
|
|
endif
|
2024-06-06 04:40:00 -04:00
|
|
|
|
2019-04-05 14:52:01 -04:00
|
|
|
default: $(PLAT)
|
|
|
|
|
|
|
|
web:
|
2022-10-20 04:15:35 -04:00
|
|
|
$(MAKE) $(ENAME) PLAT=web
|
2019-04-05 14:52:01 -04:00
|
|
|
linux:
|
2022-10-20 04:15:35 -04:00
|
|
|
$(MAKE) $(ENAME) PLAT=linux
|
2019-04-05 14:52:01 -04:00
|
|
|
mingw:
|
2022-10-20 04:15:35 -04:00
|
|
|
$(MAKE) $(ENAME) PLAT=mingw
|
2019-08-15 09:18:32 -04:00
|
|
|
sunos:
|
2022-10-20 04:15:35 -04:00
|
|
|
$(MAKE) $(ENAME) PLAT=sunos
|
2024-02-05 02:15:02 -05:00
|
|
|
darwin:
|
|
|
|
$(MAKE) $(ENAME) PLAT=darwin
|
2019-04-06 03:44:53 -04:00
|
|
|
freebsd:
|
2022-10-20 04:15:35 -04:00
|
|
|
$(MAKE) $(ENAME) PLAT=freebsd
|
2019-04-06 03:44:53 -04:00
|
|
|
openbsd:
|
2022-10-20 04:15:35 -04:00
|
|
|
$(MAKE) $(ENAME) PLAT=openbsd
|
2019-04-06 03:44:53 -04:00
|
|
|
netbsd:
|
2022-10-20 04:15:35 -04:00
|
|
|
$(MAKE) $(ENAME) PLAT=netbsd
|
2020-05-05 06:03:35 -04:00
|
|
|
dragonfly:
|
2022-10-20 04:15:35 -04:00
|
|
|
$(MAKE) $(ENAME) PLAT=dragonfly
|
2019-11-11 04:19:40 -05:00
|
|
|
haiku:
|
2022-10-20 04:15:35 -04:00
|
|
|
$(MAKE) $(ENAME) PLAT=haiku
|
2023-06-29 05:45:27 -04:00
|
|
|
beos:
|
|
|
|
$(MAKE) $(ENAME) PLAT=beos
|
2022-10-18 06:27:16 -04:00
|
|
|
serenityos:
|
2022-10-20 04:15:35 -04:00
|
|
|
$(MAKE) $(ENAME) PLAT=serenityos
|
2023-03-23 07:21:46 -04:00
|
|
|
irix:
|
|
|
|
$(MAKE) $(ENAME) PLAT=irix
|
2024-06-10 09:06:24 -04:00
|
|
|
|
|
|
|
# Default overrides
|
2024-06-06 04:40:00 -04:00
|
|
|
sdl2:
|
|
|
|
$(MAKE) $(ENAME) SDL2=1
|
|
|
|
sdl3:
|
|
|
|
$(MAKE) $(ENAME) SDL3=1
|
2024-06-10 09:06:24 -04:00
|
|
|
terminal:
|
|
|
|
$(MAKE) $(ENAME) TERMINAL=1
|
2024-08-02 21:07:45 -04:00
|
|
|
release:
|
|
|
|
$(MAKE) $(ENAME) RELEASE=1
|
2024-04-01 13:23:30 -04:00
|
|
|
|
2024-06-02 06:17:21 -04:00
|
|
|
# Some builds require more complex handling, so are moved to
|
2023-08-19 19:28:49 -04:00
|
|
|
# separate makefiles to avoid having one giant messy makefile
|
2024-03-14 17:44:05 -04:00
|
|
|
dreamcast:
|
2024-04-16 07:24:31 -04:00
|
|
|
$(MAKE) -f misc/dreamcast/Makefile
|
2024-04-18 05:18:05 -04:00
|
|
|
saturn:
|
|
|
|
$(MAKE) -f misc/saturn/Makefile
|
2022-12-04 00:27:46 -05:00
|
|
|
psp:
|
2024-04-16 07:24:31 -04:00
|
|
|
$(MAKE) -f misc/psp/Makefile
|
2023-09-08 07:39:37 -04:00
|
|
|
vita:
|
2024-04-16 07:24:31 -04:00
|
|
|
$(MAKE) -f misc/vita/Makefile
|
2024-03-27 01:31:01 -04:00
|
|
|
ps1:
|
|
|
|
cmake --preset default misc/ps1
|
|
|
|
cmake --build misc/ps1/build
|
2023-11-22 04:56:11 -05:00
|
|
|
ps2:
|
2024-04-16 07:24:31 -04:00
|
|
|
$(MAKE) -f misc/ps2/Makefile
|
|
|
|
ps3:
|
|
|
|
$(MAKE) -f misc/ps3/Makefile
|
2023-09-08 07:39:37 -04:00
|
|
|
xbox:
|
2024-04-16 07:24:31 -04:00
|
|
|
$(MAKE) -f misc/xbox/Makefile
|
2023-09-08 07:39:37 -04:00
|
|
|
xbox360:
|
2024-04-16 07:24:31 -04:00
|
|
|
$(MAKE) -f misc/xbox360/Makefile
|
2023-10-28 07:07:22 -04:00
|
|
|
n64:
|
2024-04-16 07:24:31 -04:00
|
|
|
$(MAKE) -f misc/n64/Makefile
|
|
|
|
ds:
|
|
|
|
$(MAKE) -f misc/ds/Makefile
|
2024-03-14 17:44:05 -04:00
|
|
|
3ds:
|
2024-04-16 07:24:31 -04:00
|
|
|
$(MAKE) -f misc/3ds/Makefile
|
2024-03-14 17:44:05 -04:00
|
|
|
gamecube:
|
2024-04-16 07:24:31 -04:00
|
|
|
$(MAKE) -f misc/gc/Makefile
|
|
|
|
wii:
|
|
|
|
$(MAKE) -f misc/wii/Makefile
|
2024-03-14 17:44:05 -04:00
|
|
|
wiiu:
|
2024-04-16 07:24:31 -04:00
|
|
|
$(MAKE) -f misc/wiiu/Makefile
|
2024-03-08 10:53:48 -05:00
|
|
|
switch:
|
2024-04-16 07:24:31 -04:00
|
|
|
$(MAKE) -f misc/switch/Makefile
|
2024-04-01 13:23:30 -04:00
|
|
|
os/2:
|
2024-04-16 07:24:31 -04:00
|
|
|
$(MAKE) -f misc/os2/Makefile
|
2024-06-03 08:54:45 -04:00
|
|
|
macclassic_68k:
|
|
|
|
$(MAKE) -f misc/macclassic/Makefile_68k
|
|
|
|
macclassic_ppc:
|
|
|
|
$(MAKE) -f misc/macclassic/Makefile_ppc
|
2023-04-20 07:52:49 -04:00
|
|
|
|
2018-10-14 02:31:13 -04:00
|
|
|
clean:
|
2024-06-10 09:06:24 -04:00
|
|
|
$(RM) $(OBJECTS)
|
2019-04-05 14:52:01 -04:00
|
|
|
|
2024-04-12 18:52:20 -04:00
|
|
|
|
2024-03-25 03:02:14 -04:00
|
|
|
$(ENAME): $(BUILD_DIR) $(OBJECTS)
|
2024-06-30 08:25:37 -04:00
|
|
|
$(CC) $(LDFLAGS) -o $@$(OEXT) $(OBJECTS) $(EXTRA_LIBS) $(LIBS)
|
2024-03-25 03:02:14 -04:00
|
|
|
$(BUILD_DIR):
|
|
|
|
mkdir -p $(BUILD_DIR)
|
2019-04-05 14:52:01 -04:00
|
|
|
|
2024-04-12 18:52:20 -04:00
|
|
|
|
2024-04-16 07:24:31 -04:00
|
|
|
# === Compiling with dependency tracking ===
|
|
|
|
# NOTE: Tracking dependencies might not work on older systems - disable this if so
|
2024-04-12 18:52:20 -04:00
|
|
|
ifeq ($(TRACK_DEPENDENCIES), 1)
|
|
|
|
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d
|
|
|
|
DEPFILES := $(patsubst $(SOURCE_DIR)/%.c, $(BUILD_DIR)/%.d, $(C_SOURCES))
|
|
|
|
$(DEPFILES):
|
|
|
|
|
|
|
|
$(C_OBJECTS): $(BUILD_DIR)/%.o : $(SOURCE_DIR)/%.c $(BUILD_DIR)/%.d
|
2024-06-30 08:25:37 -04:00
|
|
|
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(DEPFLAGS) -c $< -o $@
|
2024-04-12 18:52:20 -04:00
|
|
|
|
|
|
|
include $(wildcard $(DEPFILES))
|
2024-04-16 07:24:31 -04:00
|
|
|
# === Compiling WITHOUT dependency tracking ===
|
2024-04-12 18:52:20 -04:00
|
|
|
else
|
2024-03-25 03:02:14 -04:00
|
|
|
$(C_OBJECTS): $(BUILD_DIR)/%.o : $(SOURCE_DIR)/%.c
|
2024-06-30 08:25:37 -04:00
|
|
|
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
|
2024-04-12 18:52:20 -04:00
|
|
|
endif
|
2021-11-14 06:07:31 -05:00
|
|
|
|
2024-04-16 07:24:31 -04:00
|
|
|
# === Platform specific file compiling ===
|
2024-05-29 06:46:46 -04:00
|
|
|
$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.m
|
2024-06-30 08:25:37 -04:00
|
|
|
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
|
2022-11-10 05:14:40 -05:00
|
|
|
|
2024-05-29 06:46:46 -04:00
|
|
|
$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.cpp
|
2024-06-30 08:25:37 -04:00
|
|
|
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
|
2024-06-26 08:40:11 -04:00
|
|
|
|
2024-06-30 08:25:37 -04:00
|
|
|
# EXTRA_CFLAGS and EXTRA_LIBS are not defined in the makefile intentionally -
|
2024-06-26 08:40:11 -04:00
|
|
|
# define them on the command line as a simple way of adding CFLAGS/LIBS
|