2024-03-25 03:02:14 -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))
|
|
|
|
|
|
|
|
OBJECTS := $(C_OBJECTS)
|
|
|
|
ENAME = ClassiCube
|
|
|
|
DEL = rm -f
|
|
|
|
CFLAGS = -g -pipe -fno-math-errno
|
|
|
|
LDFLAGS = -g -rdynamic
|
2018-10-14 02:31:13 -04:00
|
|
|
|
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
|
|
|
|
LDFLAGS = -s WASM=1 -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_STACK=1Mb --js-library $(SOURCE_DIR)/interop_web.js
|
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-04-12 18:52:20 -04:00
|
|
|
CC = gcc
|
|
|
|
OEXT = .exe
|
|
|
|
CFLAGS = -g -pipe -DUNICODE -fno-math-errno
|
|
|
|
LDFLAGS = -g
|
|
|
|
LIBS = -mwindows -lwinmm -limagehlp
|
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-04-12 18:52:20 -04:00
|
|
|
CFLAGS = -g -pipe -fno-math-errno -DCC_BUILD_ICON
|
|
|
|
LIBS = -lX11 -lXi -lpthread -lGL -ldl
|
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-04-12 18:52:20 -04:00
|
|
|
CFLAGS = -g -pipe -fno-math-errno
|
|
|
|
LIBS = -lsocket -lX11 -lXi -lGL
|
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-04-12 18:52:20 -04:00
|
|
|
OBJECTS += $(BUILD_DIR)/interop_cocoa.o
|
|
|
|
CFLAGS = -g -pipe -fno-math-errno -DCC_BUILD_ICON
|
|
|
|
LIBS =
|
|
|
|
LDFLAGS = -rdynamic -framework Cocoa -framework OpenGL -framework IOKit -lobjc
|
2021-11-14 02:59:39 -05:00
|
|
|
endif
|
|
|
|
|
2019-04-07 08:28:03 -04:00
|
|
|
ifeq ($(PLAT),freebsd)
|
2024-04-12 18:52:20 -04:00
|
|
|
CFLAGS = -g -pipe -I /usr/local/include -fno-math-errno -DCC_BUILD_ICON
|
|
|
|
LDFLAGS = -L /usr/local/lib -rdynamic
|
|
|
|
LIBS = -lexecinfo -lGL -lX11 -lXi -lpthread
|
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-04-12 18:52:20 -04:00
|
|
|
CFLAGS = -g -pipe -I /usr/X11R6/include -I /usr/local/include -fno-math-errno -DCC_BUILD_ICON
|
|
|
|
LDFLAGS = -L /usr/X11R6/lib -L /usr/local/lib -rdynamic
|
|
|
|
LIBS = -lexecinfo -lGL -lX11 -lXi -lpthread
|
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-04-12 18:52:20 -04:00
|
|
|
CFLAGS = -g -pipe -I /usr/X11R7/include -I /usr/pkg/include -fno-math-errno -DCC_BUILD_ICON
|
|
|
|
LDFLAGS = -L /usr/X11R7/lib -L /usr/pkg/lib -rdynamic
|
|
|
|
LIBS = -lexecinfo -lGL -lX11 -lXi -lpthread
|
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-04-12 18:52:20 -04:00
|
|
|
CFLAGS = -g -pipe -I /usr/local/include -fno-math-errno -DCC_BUILD_ICON
|
|
|
|
LDFLAGS = -L /usr/local/lib -rdynamic
|
|
|
|
LIBS = -lexecinfo -lGL -lX11 -lXi -lpthread
|
2020-05-05 06:03:35 -04:00
|
|
|
endif
|
|
|
|
|
2019-11-11 02:23:50 -05:00
|
|
|
ifeq ($(PLAT),haiku)
|
2024-04-12 18:52:20 -04:00
|
|
|
OBJECTS += $(BUILD_DIR)/interop_BeOS.o
|
|
|
|
CFLAGS = -g -pipe -fno-math-errno
|
|
|
|
LDFLAGS = -g
|
|
|
|
LIBS = -lGL -lnetwork -lstdc++ -lbe -lgame -ltracker
|
2019-11-11 02:23:50 -05:00
|
|
|
endif
|
|
|
|
|
2023-06-29 05:45:27 -04:00
|
|
|
ifeq ($(PLAT),beos)
|
2024-04-12 18:52:20 -04:00
|
|
|
OBJECTS += $(BUILD_DIR)/interop_BeOS.o
|
|
|
|
CFLAGS = -g -pipe
|
|
|
|
LDFLAGS = -g
|
|
|
|
LIBS = -lGL -lnetwork -lstdc++ -lbe -lgame -ltracker
|
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
|
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
|
2023-03-23 07:21:46 -04:00
|
|
|
endif
|
|
|
|
|
2019-04-05 15:44:56 -04:00
|
|
|
ifeq ($(OS),Windows_NT)
|
2024-04-12 18:52:20 -04:00
|
|
|
DEL = del
|
2019-04-05 15:44:56 -04:00
|
|
|
endif
|
|
|
|
|
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-04-01 13:23:30 -04:00
|
|
|
|
2023-08-19 19:28:49 -04:00
|
|
|
# consoles builds require special handling, so are moved to
|
|
|
|
# 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
|
2023-04-20 07:52:49 -04:00
|
|
|
|
2018-10-14 02:31:13 -04:00
|
|
|
clean:
|
2019-04-05 14:52:01 -04:00
|
|
|
$(DEL) $(OBJECTS)
|
|
|
|
|
2024-04-12 18:52:20 -04:00
|
|
|
|
2024-03-25 03:02:14 -04:00
|
|
|
$(ENAME): $(BUILD_DIR) $(OBJECTS)
|
2019-04-05 14:52:01 -04:00
|
|
|
$(CC) $(LDFLAGS) -o $@$(OEXT) $(OBJECTS) $(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
|
|
|
|
$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
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
|
2021-11-14 06:07:31 -05:00
|
|
|
$(CC) $(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-03-25 03:02:14 -04:00
|
|
|
$(BUILD_DIR)/interop_cocoa.o: $(SOURCE_DIR)/interop_cocoa.m
|
2019-11-13 02:47:45 -05:00
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
2022-11-10 05:14:40 -05:00
|
|
|
|
2024-03-25 03:02:14 -04:00
|
|
|
$(BUILD_DIR)/interop_BeOS.o: $(SOURCE_DIR)/interop_BeOS.cpp
|
2022-11-10 05:14:40 -05:00
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|