ClassiCube/Makefile

213 lines
5.2 KiB
Makefile
Raw Normal View History

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
# 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)
ifeq ($(OS),Windows_NT)
PLAT = mingw
else
PLAT = $(shell uname -s | tr '[:upper:]' '[:lower:]')
endif
2019-04-05 14:52:01 -04:00
endif
2018-10-14 02:31:13 -04:00
ifeq ($(PLAT),web)
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
endif
2019-04-05 14:52:01 -04:00
ifeq ($(PLAT),mingw)
CC = gcc
OEXT = .exe
CFLAGS = -g -pipe -DUNICODE -fno-math-errno
LDFLAGS = -g
LIBS = -mwindows -lwinmm -limagehlp
endif
2019-04-05 14:52:01 -04:00
ifeq ($(PLAT),linux)
CFLAGS = -g -pipe -fno-math-errno -DCC_BUILD_ICON
LIBS = -lX11 -lXi -lpthread -lGL -ldl
endif
ifeq ($(PLAT),sunos)
CFLAGS = -g -pipe -fno-math-errno
LIBS = -lsocket -lX11 -lXi -lGL
endif
2019-04-06 03:44:53 -04:00
ifeq ($(PLAT),darwin)
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
endif
ifeq ($(PLAT),freebsd)
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
endif
2019-04-06 03:44:53 -04:00
ifeq ($(PLAT),openbsd)
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
endif
2019-04-06 03:44:53 -04:00
ifeq ($(PLAT),netbsd)
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
endif
ifeq ($(PLAT),dragonfly)
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
endif
2019-11-11 02:23:50 -05:00
ifeq ($(PLAT),haiku)
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)
OBJECTS += $(BUILD_DIR)/interop_BeOS.o
CFLAGS = -g -pipe
LDFLAGS = -g
LIBS = -lGL -lnetwork -lstdc++ -lbe -lgame -ltracker
TRACK_DEPENDENCIES=0
2023-06-29 05:45:27 -04:00
endif
2022-10-18 06:27:16 -04:00
ifeq ($(PLAT),serenityos)
LIBS = -lgl -lSDL2
2022-10-18 06:27:16 -04:00
endif
ifeq ($(PLAT),irix)
CC = gcc
LIBS = -lGL -lX11 -lXi -lpthread -ldl
endif
ifeq ($(OS),Windows_NT)
DEL = del
endif
2019-04-05 14:52:01 -04:00
default: $(PLAT)
web:
$(MAKE) $(ENAME) PLAT=web
2019-04-05 14:52:01 -04:00
linux:
$(MAKE) $(ENAME) PLAT=linux
2019-04-05 14:52:01 -04:00
mingw:
$(MAKE) $(ENAME) PLAT=mingw
sunos:
$(MAKE) $(ENAME) PLAT=sunos
darwin:
$(MAKE) $(ENAME) PLAT=darwin
2019-04-06 03:44:53 -04:00
freebsd:
$(MAKE) $(ENAME) PLAT=freebsd
2019-04-06 03:44:53 -04:00
openbsd:
$(MAKE) $(ENAME) PLAT=openbsd
2019-04-06 03:44:53 -04:00
netbsd:
$(MAKE) $(ENAME) PLAT=netbsd
dragonfly:
$(MAKE) $(ENAME) PLAT=dragonfly
haiku:
$(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:
$(MAKE) $(ENAME) PLAT=serenityos
irix:
$(MAKE) $(ENAME) PLAT=irix
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:
$(MAKE) -f misc/dreamcast/Makefile
2024-04-18 05:18:05 -04:00
saturn:
$(MAKE) -f misc/saturn/Makefile
psp:
$(MAKE) -f misc/psp/Makefile
vita:
$(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:
$(MAKE) -f misc/ps2/Makefile
ps3:
$(MAKE) -f misc/ps3/Makefile
xbox:
$(MAKE) -f misc/xbox/Makefile
xbox360:
$(MAKE) -f misc/xbox360/Makefile
2023-10-28 07:07:22 -04:00
n64:
$(MAKE) -f misc/n64/Makefile
ds:
$(MAKE) -f misc/ds/Makefile
2024-03-14 17:44:05 -04:00
3ds:
$(MAKE) -f misc/3ds/Makefile
2024-03-14 17:44:05 -04:00
gamecube:
$(MAKE) -f misc/gc/Makefile
wii:
$(MAKE) -f misc/wii/Makefile
2024-03-14 17:44:05 -04:00
wiiu:
$(MAKE) -f misc/wiiu/Makefile
2024-03-08 10:53:48 -05:00
switch:
$(MAKE) -f misc/switch/Makefile
2024-04-01 13:23:30 -04:00
os/2:
$(MAKE) -f misc/os2/Makefile
macclassic_68k:
$(MAKE) -f misc/macclassic/Makefile_68k
macclassic_ppc:
$(MAKE) -f misc/macclassic/Makefile_ppc
2018-10-14 02:31:13 -04:00
clean:
2019-04-05 14:52:01 -04:00
$(DEL) $(OBJECTS)
$(ENAME): $(BUILD_DIR) $(OBJECTS)
2019-04-05 14:52:01 -04:00
$(CC) $(LDFLAGS) -o $@$(OEXT) $(OBJECTS) $(LIBS)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
2019-04-05 14:52:01 -04:00
# === Compiling with dependency tracking ===
# NOTE: Tracking dependencies might not work on older systems - disable this if so
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))
# === Compiling WITHOUT dependency tracking ===
else
$(C_OBJECTS): $(BUILD_DIR)/%.o : $(SOURCE_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
endif
# === Platform specific file compiling ===
$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.m
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.cpp
$(CC) $(CFLAGS) -c $< -o $@