mame2003-plus-libretro/Makefile
2015-11-01 19:33:24 -05:00

249 lines
6.2 KiB
Makefile

# set this to mame, mess or the destination you want to build
# TARGET = mame
# TARGET = mess
# TARGET = mmsnd
# example for a tiny compile
# TARGET = tiny
ifeq ($(TARGET),)
TARGET = mame
endif
# uncomment next line to include the debugger
# DEBUG = 1
# uncomment next line to include the symbols for symify
# SYMBOLS = 1
# uncomment next line to use Assembler 68000 engine
# X86_ASM_68000 = 1
# uncomment next line to use Assembler 68020 engine
# X86_ASM_68020 = 1
# uncomment next line to use DRC MIPS3 engine
# X86_MIPS3_DRC = 1
# uncomment next line to use cygwin compiler
# COMPILESYSTEM_CYGWIN = 1
MAMEOS = libretro
# CPU core include paths
VPATH=src $(wildcard src/cpu/*)
# compiler, linker and utilities
AR = @ar
NATIVECC = @gcc
CC = @gcc
LD = @gcc
ASM = @nasm
ASMFLAGS = -f coff
MD = -mkdir
RM = @rm -f
ifeq ($(MAMEOS),msdos)
PREFIX = d
else
PREFIX =
endif
# build the targets in different object dirs, since mess changes
# some structures and thus they can't be linked against each other.
OBJ = obj/mame
DEFS = -DINLINE="static __inline__" -Dasm=__asm__
CFLAGS = -Isrc -Isrc/includes -Isrc/$(MAMEOS) -I$(OBJ)/cpu/m68000 -Isrc/cpu/m68000
RETRO_PROFILE = 0
CFLAGS += -DRETRO_PROFILE=$(RETRO_PROFILE)
ifneq ($(platform), sncps3)
CFLAGS += -Wall -Wno-sign-compare -Wunused \
-Wpointer-arith -Wbad-function-cast -Wcast-align -Waggregate-return \
-Wshadow -Wstrict-prototypes -Wundef \
-Wformat-security -Wwrite-strings \
-Wdisabled-optimization
endif
ifdef SYMBOLS
CFLAGS += -O0 -Wall -Wno-unused -g
else
CFLAGS += -DNDEBUG $(ARCH) -O3 -fomit-frame-pointer -fstrict-aliasing
endif
# extra options needed *only* for the osd files
CFLAGSOSDEPEND = $(CFLAGS)
# the windows osd code at least cannot be compiled with -pedantic
CFLAGSPEDANTIC = $(CFLAGS) -pedantic
dont_link_zlib =
ifeq ($(platform), ps3)
dont_link_zlib= yes
endif
ifeq ($(platform), psp1)
dont_link_zlib= yes
endif
ifeq ($(platform), vita)
dont_link_zlib= yes
endif
ifeq ($(platform), ctr)
dont_link_zlib= yes
endif
ZLIBOBJS :=
# platform .mak files will want to add to this
ifeq ($(dont_link_zlib),yes)
CFLAGS += -Isrc/libretro/includes/zlib
else
ZLIBOBJS := deps/zlib/adler32.c \
deps/zlib/compress.c \
deps/zlib/crc32.c \
deps/zlib/deflate.c \
deps/zlib/gzclose.c \
deps/zlib/gzlib.c \
deps/zlib/gzread.c \
deps/zlib/gzwrite.c \
deps/zlib/inffast.c \
deps/zlib/inflate.c \
deps/zlib/inftrees.c \
deps/zlib/trees.c \
deps/zlib/uncompr.c \
deps/zlib/zutil.c \
deps/zlib/ioapi.c \
deps/zlib/unzip.c
endif
OBJDIRS = obj $(OBJ) $(OBJ)/cpu $(OBJ)/sound $(OBJ)/$(MAMEOS) \
$(OBJ)/drivers $(OBJ)/machine $(OBJ)/vidhrdw $(OBJ)/sndhrdw
ifdef MESS
OBJDIRS += $(OBJ)/mess $(OBJ)/mess/systems $(OBJ)/mess/machine \
$(OBJ)/mess/vidhrdw $(OBJ)/mess/sndhrdw $(OBJ)/mess/tools
endif
ifeq ($(TARGET),mmsnd)
OBJDIRS += $(OBJ)/mmsnd $(OBJ)/mmsnd/machine $(OBJ)/mmsnd/drivers $(OBJ)/mmsnd/sndhrdw
endif
include src/$(MAMEOS)/$(MAMEOS).mak
all: maketree $(EMULATOR)
# include the various .mak files
include src/core.mak
include src/$(TARGET).mak
include src/rules.mak
ifdef DEBUG
DBGDEFS = -DMAME_DEBUG
else
DBGDEFS =
DBGOBJS =
endif
ifdef COMPILESYSTEM_CYGWIN
CFLAGS += -mno-cygwin
LDFLAGS += -mno-cygwin
endif
# combine the various definitions to one
CDEFS = $(DEFS) $(COREDEFS) $(CPUDEFS) $(SOUNDDEFS) $(ASMDEFS) $(DBGDEFS)
DO_ARCHIVE = 0
ifeq ($(platform), wii)
DO_ARCHIVES = 1
endif
ifeq ($(platform), ps3)
DO_ARCHIVES = 1
endif
ifeq ($(platform), psp1)
DO_ARCHIVES = 1
endif
ifeq ($(platform), vita)
DO_ARCHIVES = 1
endif
ifeq ($(platform), ctr)
DO_ARCHIVES = 1
endif
# primary target
$(EMULATOR): $(OBJS) $(COREOBJS) $(OSOBJS) $(ZLIBOBJS) $(DRVLIBS)
ifeq ($(DO_ARCHIVES),1)
@echo Archiving $@...
$(AR) rcs $@ $(OBJS) $(COREOBJS) $(OSOBJS) $(ZLIBOBJS) $(DRVLIBS)
else
@echo Linking $@...
$(LD) $(LDFLAGS) $(OBJS) $(COREOBJS) $(OSOBJS) $(ZLIBOBJS) $(LIBS) $(DRVLIBS) -o $@
endif
$(OBJ)/$(MAMEOS)/%.o: src/$(MAMEOS)/%.c
@echo Compiling $<...
$(CC) $(CDEFS) $(CFLAGSOSDEPEND) $(PLATCFLAGS) -c $< -o $@
$(OBJ)/%.o: src/%.c
@echo Compiling $<...
$(CC) $(CDEFS) $(CFLAGS) $(PLATCFLAGS) -c $< -o $@
# compile generated C files for the 68000 emulator
#$(M68000_GENERATED_OBJS): $(OBJ)/cpu/m68000/m68kmake$(EXE)
#@echo Compiling $(subst .o,.c,$@)...
#$(CC) $(CDEFS) $(CFLAGSPEDANTIC) $(PLATCFLAGS) -c $*.c -o $@
# additional rule, because m68kcpu.c includes the generated m68kops.h :-/
#$(OBJ)/cpu/m68000/m68kcpu.o: $(OBJ)/cpu/m68000/m68kmake$(EXE)
# generate C source files for the 68000 emulator
#$(OBJ)/cpu/m68000/m68kmake$(EXE): src/cpu/m68000/m68kmake.c
#@echo M68K make $<...
#$(NATIVECC) $(CDEFS) $(CFLAGSPEDANTIC) -DDOS -o $(OBJ)/cpu/m68000/m68kmake$(EXE) $<
#@echo Generating M68K source files...
#$(OBJ)/cpu/m68000/m68kmake$(EXE) $(OBJ)/cpu/m68000 src/cpu/m68000/m68k_in.c
# generate asm source files for the 68000/68020 emulators
$(OBJ)/cpu/m68000/68000.asm: src/cpu/m68000/make68k.c
@echo Compiling $<...
$(NATIVECC) $(CDEFS) $(CFLAGSPEDANTIC) -O0 -DDOS -o $(OBJ)/cpu/m68000/make68k$(EXE) $<
@echo Generating $@...
@$(OBJ)/cpu/m68000/make68k$(EXE) $@ $(OBJ)/cpu/m68000/68000tab.asm 00
$(OBJ)/cpu/m68000/68020.asm: src/cpu/m68000/make68k.c
@echo Compiling $<...
$(NATIVECC) $(CDEFS) $(CFLAGSPEDANTIC) -O0 -DDOS -o $(OBJ)/cpu/m68000/make68k$(EXE) $<
@echo Generating $@...
@$(OBJ)/cpu/m68000/make68k$(EXE) $@ $(OBJ)/cpu/m68000/68020tab.asm 20
# generated asm files for the 68000 emulator
$(OBJ)/cpu/m68000/68000.o: $(OBJ)/cpu/m68000/68000.asm
@echo Assembling $<...
$(ASM) -o $@ $(ASMFLAGS) $(subst -D,-d,$(ASMDEFS)) $<
$(OBJ)/cpu/m68000/68020.o: $(OBJ)/cpu/m68000/68020.asm
@echo Assembling $<...
$(ASM) -o $@ $(ASMFLAGS) $(subst -D,-d,$(ASMDEFS)) $<
$(OBJ)/%.a:
@echo Archiving $@...
$(RM) $@
$(AR) cr $@ $^
makedir:
@echo make makedir is no longer necessary, just type make
$(sort $(OBJDIRS)):
$(MD) $@
maketree: $(sort $(OBJDIRS))
clean:
@echo Deleting object tree $(OBJ)...
$(RM) -r $(OBJ)
@echo Deleting $(EMULATOR)...
$(RM) $(EMULATOR)
clean68k:
@echo Deleting 68k files...
$(RM) -r $(OBJ)/cpuintrf.o
$(RM) -r $(OBJ)/drivers/cps2.o
$(RM) -r $(OBJ)/cpu/m68000