2021-08-14 09:42:57 +02:00
|
|
|
# Makefile for the fx-CG 50 / Graph 90+E version of CGDoom.
|
|
|
|
# Two target platforms: fx-CG and native (SDL2).
|
|
|
|
|
|
|
|
### Project structure.
|
|
|
|
|
|
|
|
NAME := CGDoom
|
2021-08-14 11:55:20 +02:00
|
|
|
SRC := $(wildcard cgdoom/*.c)
|
2021-08-14 09:42:57 +02:00
|
|
|
|
|
|
|
CFLAGS := -I cgdoom
|
|
|
|
# Extra optimization passes just in case
|
|
|
|
CFLAGS += -O3 -fgcse-sm -fgcse-las -fgcse-after-reload -fmerge-all-constants
|
|
|
|
# We remove some warnings that come up a lot in Doom
|
2021-08-14 15:10:56 +02:00
|
|
|
CFLAGS += -Wall -Wextra -Wno-sign-compare -Wno-unused-but-set-variable -Wno-unused-but-set-parameter -Wno-implicit-fallthrough -Wno-misleading-indentation
|
2021-08-14 09:42:57 +02:00
|
|
|
|
|
|
|
LDFLAGS :=
|
|
|
|
|
|
|
|
### fx-CG 50 build.
|
|
|
|
|
|
|
|
CG_CC := sh-elf-gcc
|
|
|
|
CG_OBJCOPY := sh-elf-objcopy
|
|
|
|
|
|
|
|
# The libfxcg install folder (adjust to your needs)
|
|
|
|
LIBFXCG_ROOT := ../..
|
|
|
|
|
|
|
|
# Platform selection
|
|
|
|
CG_CFLAGS := $(CFLAGS) -I src-cg -m4a-nofpu -mb -mhitachi
|
|
|
|
# Enforce strict access size in volatile bitfields, needed for PRAM mainly
|
|
|
|
CG_CFLAGS += -fstrict-volatile-bitfields
|
|
|
|
# We use libfxcg and libc within the libfxcg repository
|
|
|
|
CG_CFLAGS += -I $(LIBFXCG_ROOT)/include -D_FXCG_MINICOMPAT
|
|
|
|
|
|
|
|
# Libraries specific to libfxcg and the cross-compiler
|
|
|
|
CG_LDFLAGS := $(LDFLAGS) -L $(LIBFXCG_ROOT)/lib -lfxcg -lgcc
|
|
|
|
# The build is mostly free-standing, with the libfxcg linker script
|
|
|
|
CG_LDFLAGS += -nostartfiles -T $(LIBFXCG_ROOT)/toolchain/prizm.x
|
|
|
|
# Generate a map of every function and global variable for debugging
|
|
|
|
CG_LDFLAGS += -Wl,-Map=build-cg/$(NAME).map
|
|
|
|
|
2021-08-14 15:10:56 +02:00
|
|
|
CG_SRC := $(wildcard src-cg/*.c src-cg/*.s)
|
|
|
|
CG_OBJ := $(SRC:cgdoom/%=build-cg/%.o) $(CG_SRC:src-cg/%=build-cg/%.o)
|
2021-08-14 09:42:57 +02:00
|
|
|
|
|
|
|
### Native SDL2 build.
|
|
|
|
|
|
|
|
CC ?= gcc
|
|
|
|
|
|
|
|
SDL2_CFLAGS := $(CFLAGS) -I src-sdl2 -DCG_EMULATOR $(pkg-config sdl2 --cflags)
|
2021-09-20 10:24:18 +02:00
|
|
|
SDL2_CFLAGS += -O0 -g
|
|
|
|
SDL2_LDFLAGS := $(LDFLAGS) $(shell pkg-config sdl2 --libs)
|
2021-08-14 09:42:57 +02:00
|
|
|
|
2021-08-14 15:10:56 +02:00
|
|
|
SDL2_SRC := $(wildcard src-sdl2/*.c)
|
|
|
|
SDL2_OBJ := $(SRC:cgdoom/%=build-sdl2/%.o) $(SDL2_SRC:src-sdl2/%=build-sdl2/%.o)
|
2021-08-14 09:42:57 +02:00
|
|
|
|
|
|
|
### Build rules.
|
|
|
|
|
2021-08-14 15:10:56 +02:00
|
|
|
all: all-cg
|
2021-08-14 09:42:57 +02:00
|
|
|
|
|
|
|
#~
|
|
|
|
|
2021-08-14 15:10:56 +02:00
|
|
|
all-cg: $(NAME).g3a
|
2021-08-14 09:42:57 +02:00
|
|
|
|
|
|
|
$(NAME).g3a: build-cg/$(NAME).bin
|
2021-10-01 20:52:05 +02:00
|
|
|
mkg3a -n CGDoom -i uns:icon-uns.png -i sel:icon-sel.png $< $@
|
2021-08-14 09:42:57 +02:00
|
|
|
|
|
|
|
build-cg/%.s.o: cgdoom/%.s | build-cg/
|
|
|
|
$(CG_CC) $(CG_CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
build-cg/%.c.o: cgdoom/%.c | build-cg/
|
|
|
|
$(CG_CC) $(CG_CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
build-cg/%.c.o: src-cg/%.c | build-cg/
|
|
|
|
$(CG_CC) $(CG_CFLAGS) -c $< -o $@
|
|
|
|
|
2021-08-14 15:10:56 +02:00
|
|
|
build-cg/%.s.o: src-cg/%.s | build-cg/
|
|
|
|
$(CG_CC) $(CG_CFLAGS) -c $< -o $@
|
|
|
|
|
2021-08-14 09:42:57 +02:00
|
|
|
build-cg/$(NAME).elf: $(CG_OBJ)
|
|
|
|
$(CG_CC) $(CG_CFLAGS) $(CG_LDFLAGS) $^ -o $@
|
|
|
|
|
|
|
|
build-cg/$(NAME).bin: build-cg/$(NAME).elf
|
|
|
|
$(CG_OBJCOPY) -O binary $< $@
|
|
|
|
|
|
|
|
#~
|
|
|
|
|
|
|
|
all-sdl2: $(NAME)
|
|
|
|
|
|
|
|
$(NAME): $(SDL2_OBJ)
|
|
|
|
$(CC) $(SDL2_CFLAGS) $(SDL2_LDFLAGS) $^ -o $@
|
|
|
|
|
|
|
|
build-sdl2/%.c.o: cgdoom/%.c | build-sdl2/
|
|
|
|
$(CC) $(SDL2_CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
build-sdl2/%.c.o: src-sdl2/%.c | build-sdl2/
|
|
|
|
$(CC) $(SDL2_CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
#~
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf build-cg/ build-sdl2/
|
|
|
|
|
|
|
|
%/:
|
|
|
|
@ mkdir -p $@
|
|
|
|
|
|
|
|
.PRECIOUS: %/ build-cg/%.d build-sdl2/%.d
|
|
|
|
|
|
|
|
include $(wildcard build-cg/*.d build-sdl2/*.d)
|