PRGNAME = multirexz80_sdl CC = /opt/rs97-toolchain/bin/mipsel-linux-gcc # Possible choices : rs97, k3s (PAP K3S), sdl, amini, fbdev PORT = gameta # Possible choices : alsa, pulse (pulseaudio), oss, sdl12 (SDL 1.2 sound output), portaudio, libao SOUND_OUTPUT = oss # PSG backend: only the MAME-derived SN76489 core is shipped. PSG_ENGINE ?= mame_sn76489 ifneq ($(origin SOUND_ENGINE), undefined) PSG_ENGINE := $(SOUND_ENGINE) endif # Possible choices : z80 (accurate), eighty (EightyZ80's core, GPLv2) Z80_CORE = z80 SCALE2X_UPSCALER = 1 PROFILE_DIR ?= . PROFILE = 0 ZIP_SUPPORT = 1 STATIC_MEMORY ?= 0 STATIC_MEMORY_BYTES ?= 16777216 ENABLE_ARCADE ?= 1 ENABLE_COLECO ?= 1 ENABLE_SORDM5 ?= 1 FEATURE_DEFS := -DMULTIREXZ80_ENABLE_ARCADE=$(ENABLE_ARCADE) -DMULTIREXZ80_ENABLE_COLECO=$(ENABLE_COLECO) -DMULTIREXZ80_ENABLE_SORDM5=$(ENABLE_SORDM5) SRCDIR = ./source ./source/other/eeprom/93c46 ./source/other/decode ./source/video/sms_vdp ./source/video/tms9918 ./source/sound/mixer ./source/sound/opll ./source/sound/opl1 ./source/cpu_cores/$(Z80_CORE) ./source/unzip SRCDIR += ./source/scalers ./source/ports/$(PORT) ./source/ports/sdl12_common ./source/sound/psg/$(PSG_ENGINE) ./source/sound_output/$(SOUND_OUTPUT) ifeq ($(ENABLE_COLECO),1) SRCDIR += ./source/platform/coleco endif ifeq ($(ENABLE_SORDM5),1) SRCDIR += ./source/platform/sord_m5 endif ifeq ($(ENABLE_ARCADE),1) SRCDIR += ./source/video/sega_system1 ./source/video/snk_ikari_psychos ./source/video/taito_l else SRCDIR += ./source/platform/arcade_disabled endif VPATH = $(SRCDIR) SRC_C = $(foreach dir, $(SRCDIR), $(wildcard $(dir)/*.c)) SRC_CP = $(foreach dir, $(SRCDIR), $(wildcard $(dir)/*.cpp)) OBJ_C = $(notdir $(patsubst %.c, %.o, $(SRC_C))) OBJ_CP = $(notdir $(patsubst %.cpp, %.o, $(SRC_CP))) OBJS = $(OBJ_C) $(OBJ_CP) CFLAGS = -Ofast -fdata-sections -ffunction-sections -mno-fp-exceptions -mno-check-zero-division -mframe-header-opt -fsingle-precision-constant -fno-common -mips32 -fno-PIC -mno-abicalls -flto CFLAGS += -mbranch-likely -mbranch-cost=2 # MultiRexZ80 suffers from alignment issues so setting these to 1 helps. CFLAGS += -falign-functions=1 -falign-jumps=1 -falign-loops=1 -falign-labels=1 CFLAGS += -fipa-pta -fsection-anchors -fdelete-dead-exceptions CFLAGS += -DALIGN_DWORD CFLAGS += $(FEATURE_DEFS) -DLSB_FIRST -std=gnu99 CFLAGS += -Isource -Isource/other/eeprom/93c46 -Isource/other/decode -Isource/platform/coleco -Isource/platform/sord_m5 -Isource/video/sms_vdp -Isource/video/tms9918 -Isource/video/sega_system1 -Isource/video/snk_ikari_psychos -Isource/video/taito_l -Isource/sound/mixer -Isource/sound/opll -Isource/sound/opl1 -Isource/sound/psg/$(PSG_ENGINE) -Isource/cpu_cores/$(Z80_CORE) -Isource/scalers -Isource/ports/$(PORT) -Isource/ports/sdl12_common -Isource/unzip -Isource/sdl -Isource/sound_output SRCDIR += ./source/text/fb CFLAGS += -Isource/text/fb ifeq ($(PROFILE), YES) CFLAGS += -fprofile-generate=$(PROFILE_DIR) else ifeq ($(PROFILE), APPLY) CFLAGS += -fprofile-use=$(PROFILE_DIR) -fbranch-probabilities endif ifeq ($(PSG_ENGINE), mame_sn76489) CFLAGS += -DMAME_PSG endif ifeq ($(ZIP_SUPPORT), 0) CFLAGS += -DNOZIP_SUPPORT endif ifeq ($(STATIC_MEMORY), 1) CFLAGS += -DMULTIREXZ80_STATIC_MEMORY -DMULTIREXZ80_STATIC_MEMORY_BYTES=$(STATIC_MEMORY_BYTES) endif ifeq ($(SCALE2X_UPSCALER), 1) CFLAGS += -DSCALE2X_UPSCALER CFLAGS += -Isource/scale2x SRCDIR += ./source/scale2x endif SDL_STATIC_LIBS ?= -lasound LDFLAGS = -nodefaultlibs -lc -lgcc -lSDL -no-pie -Wl,--as-needed -Wl,--gc-sections -s -flto $(SDL_STATIC_LIBS) ifeq ($(SOUND_OUTPUT), portaudio) LDFLAGS += -lportaudio endif ifeq ($(SOUND_OUTPUT), libao) LDFLAGS += -lao endif ifeq ($(SOUND_OUTPUT), alsa) LDFLAGS += -lasound endif ifeq ($(SOUND_OUTPUT), pulse) LDFLAGS += -lpulse -lpulse-simple endif # Rules to make executable $(PRGNAME): $(OBJS) $(CC) $(CFLAGS) -o $(PRGNAME) $^ $(LDFLAGS) $(OBJ_C) : %.o : %.c $(CC) $(CFLAGS) -c -o $@ $< clean: rm -f $(PRGNAME) *.o