mame2003-plus-libretro/Makefile

358 lines
10 KiB
Makefile
Raw Normal View History

DEBUG=0
DEBUGGER=0
2016-01-23 17:17:29 +00:00
CORE_DIR := src
TARGET_NAME := mame2003
ifeq ($(platform),)
platform = unix
ifeq ($(shell uname -a),)
platform = win
else ifneq ($(findstring MINGW,$(shell uname -a)),)
platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
platform = osx
else ifneq ($(findstring win,$(shell uname -a)),)
platform = win
2012-10-29 14:55:14 +00:00
endif
2016-01-23 17:17:29 +00:00
endif
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
ifeq ($(shell uname -p),powerpc)
arch = ppc
else
arch = intel
endif
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
LIBM := -lm
ifeq ($(platform), unix)
TARGET = $(TARGET_NAME)_libretro.so
fpic = -fPIC
CFLAGS += $(fpic)
PLATCFLAGS += -Dstricmp=strcasecmp
LDFLAGS += $(fpic) -shared -Wl,--version-script=link.T
else ifeq ($(platform), linux-portable)
TARGET = $(TARGET_NAME)_libretro.so
fpic = -fPIC -nostdlib
CFLAGS += $(fpic)
PLATCFLAGS += -Dstricmp=strcasecmp
LIBM :=
LDFLAGS += $(fpic) -shared -Wl,--version-script=link.T
else ifeq ($(platform), osx)
TARGET = $(TARGET_NAME)_libretro.dylib
fpic = -fPIC
ifeq ($(arch),ppc)
BIGENDIAN = 1
PLATCFLAGS += -D__ppc__ -D__POWERPC__
endif
CFLAGS += $(fpic) -Dstricmp=strcasecmp
LDFLAGS += $(fpic) -dynamiclib
OSXVER = `sw_vers -productVersion | cut -c 4`
fpic += -mmacosx-version-min=10.1
# iOS
else ifneq (,$(findstring ios,$(platform)))
TARGET = $(TARGET_NAME)_libretro_ios.dylib
fpic = -fPIC
CFLAGS += $(fpic) -Dstricmp=strcasecmp
LDFLAGS += $(fpic) -dynamiclib
PLATCFLAGS += -D__IOS__
2016-01-23 17:17:29 +00:00
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
endif
CC = cc -arch armv7 -isysroot $(IOSSDK)
LD = cc -arch armv7 -isysroot $(IOSSDK)
ifeq ($(platform),ios9)
fpic += -miphoneos-version-min=8.0
CC += -miphoneos-version-min=8.0
LD += -miphoneos-version-min=8.0
else
fpic += -miphoneos-version-min=5.0
CC += -miphoneos-version-min=5.0
LD += -miphoneos-version-min=5.0
endif
else ifeq ($(platform), ctr)
2016-08-08 01:44:03 +00:00
TARGET = $(TARGET_NAME)_libretro_$(platform).a
2016-01-23 17:17:29 +00:00
CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
PLATCFLAGS += -DARM11 -D_3DS
PLATCFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -mfpu=vfp
PLATCFLAGS += -Wall -mword-relocations
PLATCFLAGS += -fomit-frame-pointer -ffast-math
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
CPU_ARCH := arm
STATIC_LINKING = 1
2016-02-27 02:30:57 +00:00
else ifeq ($(platform), rpi2)
2016-02-27 03:12:44 +00:00
TARGET = $(TARGET_NAME)_libretro.so
2016-02-27 02:30:57 +00:00
fpic = -fPIC
CFLAGS += $(fpic)
LDFLAGS += $(fpic) -shared -Wl,--version-script=link.T
2016-02-27 03:12:44 +00:00
PLATCFLAGS += -Dstricmp=strcasecmp
2016-05-24 12:16:57 +00:00
PLATCFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
2016-02-27 02:30:57 +00:00
PLATCFLAGS += -fomit-frame-pointer -ffast-math
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions
2016-02-27 02:30:57 +00:00
CPU_ARCH := arm
2016-03-18 01:52:22 +00:00
ARM = 1
else ifeq ($(platform), rpi3)
TARGET = $(TARGET_NAME)_libretro.so
fpic = -fPIC
CFLAGS += $(fpic)
LDFLAGS += $(fpic) -shared -Wl,--version-script=link.T
PLATCFLAGS += -Dstricmp=strcasecmp
2016-05-24 12:16:57 +00:00
PLATCFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard
PLATCFLAGS += -fomit-frame-pointer -ffast-math
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions
CPU_ARCH := arm
2016-03-18 01:52:22 +00:00
ARM = 1
2016-01-23 17:17:29 +00:00
else ifeq ($(platform), android-armv7)
TARGET = $(TARGET_NAME)_libretro_android.so
CFLAGS += -fPIC
PLATCFLAGS += -march=armv7-a -mfloat-abi=softfp -Dstricmp=strcasecmp
LDFLAGS += -fPIC -shared -Wl,--version-script=link.T
CC = arm-linux-androideabi-gcc
AR = arm-linux-androideabi-ar
LD = arm-linux-androideabi-gcc
else ifeq ($(platform), qnx)
2016-08-08 01:44:03 +00:00
TARGET = $(TARGET_NAME)_libretro_$(platform).so
2016-01-23 17:17:29 +00:00
CFLAGS += -fPIC
PLATCFLAGS += -march=armv7-a -Dstricmp=strcasecmp
LDFLAGS += -fPIC -shared -Wl,--version-script=link.T
CC = qcc -Vgcc_ntoarmv7le
AR = qcc -Vgcc_ntoarmv7le
LD = QCC -Vgcc_ntoarmv7le
2016-11-06 22:50:54 +00:00
2016-01-23 17:17:29 +00:00
else ifeq ($(platform), wii)
2016-08-08 01:44:03 +00:00
TARGET = $(TARGET_NAME)_libretro_$(platform).a
2016-01-23 17:17:29 +00:00
BIGENDIAN = 1
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
PLATCFLAGS += -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -D__POWERPC__ -Dstricmp=strcasecmp
2017-01-23 18:19:23 +00:00
PLATCFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
2016-01-23 17:17:29 +00:00
STATIC_LINKING = 1
2016-11-06 22:50:54 +00:00
else ifeq ($(platform), wiiu)
TARGET = $(TARGET_NAME)_libretro_$(platform).a
BIGENDIAN = 1
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
2017-01-23 18:19:23 +00:00
PLATCFLAGS += -DGEKKO -DWIIU -mwup -mcpu=750 -meabi -mhard-float -D__ppc__ -D__POWERPC__ -Dstricmp=strcasecmp
PLATCFLAGS += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
2016-11-06 22:50:54 +00:00
STATIC_LINKING = 1
2016-01-23 17:17:29 +00:00
else ifeq ($(platform), ps3)
2016-08-08 01:44:03 +00:00
TARGET = $(TARGET_NAME)_libretro_$(platform).a
2016-01-23 17:17:29 +00:00
BIGENDIAN = 1
CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
PLATCFLAGS += -D__CELLOS_LV2__ -D__ppc__ -D__POWERPC__ -Dstricmp=strcasecmp
STATIC_LINKING = 1
else ifeq ($(platform), sncps3)
TARGET = $(TARGET_NAME)_libretro_ps3.a
BIGENDIAN = 1
CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
PLATCFLAGS += -D__CELLOS_LV2__ -D__ppc__ -D__POWERPC__ -Dstricmp=strcasecmp
STATIC_LINKING = 1
2016-05-29 13:38:22 +00:00
else ifeq ($(platform), psl1ght)
2016-08-08 01:44:03 +00:00
TARGET = $(TARGET_NAME)_libretro_$(platform).a
2016-05-29 13:38:22 +00:00
BIGENDIAN = 1
CC = $(PS3DEV)/ppu/bin/ppu-gcc$
AR = $(PS3DEV)/ppu/bin/ppu-ar$
PLATCFLAGS += -D__CELLOS_LV2__ -D__ppc__ -D__POWERPC__ -Dstricmp=strcasecmp
STATIC_LINKING = 1
2016-01-23 17:17:29 +00:00
else ifeq ($(platform), psp1)
2016-08-08 01:44:03 +00:00
TARGET = $(TARGET_NAME)_libretro_$(platform).a
2016-01-23 17:17:29 +00:00
CC = psp-gcc$(EXE_EXT)
AR = psp-ar$(EXE_EXT)
PLATCFLAGS += -DPSP -Dstricmp=strcasecmp
CFLAGS += -G0
STATIC_LINKING = 1
else ifeq ($(platform), vita)
2016-08-08 01:44:03 +00:00
TARGET = $(TARGET_NAME)_libretro_$(platform).a
2016-01-23 17:17:29 +00:00
CC = arm-vita-eabi-gcc$(EXE_EXT)
AR = arm-vita-eabi-ar$(EXE_EXT)
PLATCFLAGS += -DVITA -Dstricmp=strcasecmp
2016-08-27 00:59:57 +00:00
CFLAGS += -mthumb -mfloat-abi=hard -fsingle-precision-constant
CFLAGS += -Wall -mword-relocations
CFLAGS += -fomit-frame-pointer -ffast-math
2016-09-26 23:36:23 +00:00
CFLAGS += -fno-unwind-tables -fno-asynchronous-unwind-tables
CFLAGS += -fno-optimize-sibling-calls
CFLAGS += -ftree-vectorize -funroll-loops -fno-short-enums
2016-08-27 00:59:57 +00:00
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions
HAVE_RZLIB := 1
ARM = 1
STATIC_LINKING := 1
DEBUG = 0
2016-09-26 23:36:23 +00:00
2016-01-23 17:17:29 +00:00
else ifneq (,$(findstring armv,$(platform)))
TARGET = $(TARGET_NAME)_libretro.so
CFLAGS += -fPIC
PLATCFLAGS += -Dstricmp=strcasecmp
LDFLAGS += -fPIC -shared -Wl,--version-script=link.T
2016-03-04 05:34:55 +00:00
# GCW0
else ifeq ($(platform), gcw0)
TARGET := $(TARGET_NAME)_libretro.so
CC = /opt/gcw0-toolchain/usr/bin/mipsel-linux-gcc-4.9.1
CXX = /opt/gcw0-toolchain/usr/bin/mipsel-linux-g++
AR = /opt/gcw0-toolchain/usr/bin/mipsel-linux-ar
LDFLAGS += -shared -Wl,--version-script=link.T -Wl,-no-undefined
PLATCFLAGS += -Dstricmp=strcasecmp
LIBS := -lc -lgcc
fpic := -fPIC -nostdlib
LIBM :=
CFLAGS += -lm -march=mips32 -mtune=mips32r2 -mhard-float
else ifeq ($(platform), emscripten)
TARGET := $(TARGET_NAME)_libretro_$(platform).bc
HAVE_RZLIB := 1
STATIC_LINKING := 1
PLATCFLAGS += -Dstricmp=strcasecmp
2016-07-29 01:46:03 +00:00
# Windows
2016-01-23 17:17:29 +00:00
else
2016-07-29 01:46:03 +00:00
TARGET := $(TARGET_NAME)_libretro.dll
CC = gcc
2016-01-23 17:17:29 +00:00
LDFLAGS += -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=link.T
2016-07-29 01:46:03 +00:00
CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__ -Wno-missing-field-initializers
2016-01-23 17:17:29 +00:00
endif
ifeq ($(BIGENDIAN), 1)
PLATCFLAGS += -DMSB_FIRST
endif
# use -fsigned-char on ARM to solve potential problems with code written/tested on x86
# eg on mame2003 audio on rtype leo is wrong without it.
ifeq ($(ARM), 1)
PLATCFLAGS += -fsigned-char
endif
2016-01-23 17:17:29 +00:00
PLATCFLAGS += $(fpic)
CFLAGS += -D__LIBRETRO__ -DPI=3.1415927
LDFLAGS += $(LIBM)
2012-10-29 14:55:14 +00:00
# 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
2012-10-29 14:55:14 +00:00
# build the targets in different object dirs, since mess changes
# some structures and thus they can't be linked against each other.
DEFS = -DINLINE="static __inline__" -Dasm=__asm__
2012-10-29 14:55:14 +00:00
RETRO_PROFILE = 0
CFLAGS += -DRETRO_PROFILE=$(RETRO_PROFILE)
2013-06-09 21:10:58 +00:00
ifneq ($(platform), sncps3)
CFLAGS += -Wall -Wno-sign-compare -Wunused \
-Wpointer-arith -Wbad-function-cast -Wcast-align -Waggregate-return \
2016-01-23 17:17:29 +00:00
-Wshadow -Wstrict-prototypes \
2013-06-09 21:10:58 +00:00
-Wformat-security -Wwrite-strings \
-Wdisabled-optimization
endif
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -Wall -Wno-unused -g
# O3 optimisation causes issues on ARM
2016-11-08 07:12:29 +00:00
else ifeq ($(platform), vita)
CFLAGS += -DNDEBUG -O3 -fomit-frame-pointer -fstrict-aliasing
else ifeq ($(ARM), 1)
CFLAGS += -DNDEBUG -O2 -fomit-frame-pointer -fstrict-aliasing
2012-10-29 14:55:14 +00:00
else
CFLAGS += -DNDEBUG -O3 -fomit-frame-pointer -fstrict-aliasing
2012-10-29 14:55:14 +00:00
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
# include the various .mak files
2016-01-22 02:57:58 +00:00
include Makefile.common
2012-10-29 14:55:14 +00:00
2016-01-23 17:22:27 +00:00
CFLAGS += $(INCFLAGS)
2015-11-03 16:15:53 +00:00
2012-10-29 14:55:14 +00:00
# combine the various definitions to one
CDEFS = $(DEFS) $(COREDEFS) $(CPUDEFS) $(SOUNDDEFS) $(ASMDEFS) $(DBGDEFS)
2015-11-03 16:15:53 +00:00
2016-01-23 17:17:29 +00:00
OBJECTS := $(SOURCES_C:.c=.o)
2016-01-23 17:22:27 +00:00
all: $(TARGET)
2016-01-23 17:17:29 +00:00
$(TARGET): $(OBJECTS)
2015-11-03 16:15:53 +00:00
ifeq ($(STATIC_LINKING),1)
@echo Archiving $@...
$(AR) rcs $@ $(OBJECTS)
else
2012-10-29 14:55:14 +00:00
@echo Linking $@...
ifeq ($(platform),win)
2016-07-29 01:46:03 +00:00
# Use a temporary file to hold the list of objects, as it can exceed windows shell command limits
$(file >$@.in,$(OBJECTS))
$(CC) $(CDEFS) $(CFLAGSOSDEPEND) $(PLATCFLAGS) $(LDFLAGS) -o $@ @$@.in $(LIBS)
@rm $@.in
else
$(CC) $(CDEFS) $(CFLAGSOSDEPEND) $(PLATCFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS)
endif
endif
2012-10-29 14:55:14 +00:00
2016-01-23 17:17:29 +00:00
%.o: %.c
$(CC) $(CDEFS) $(CFLAGS) $(PLATCFLAGS) -c -o $@ $<
2012-10-29 14:55:14 +00:00
$(OBJ)/%.a:
@echo Archiving $@...
$(RM) $@
$(AR) cr $@ $^
clean:
ifeq ($(platform),win)
2016-07-29 01:46:03 +00:00
# Use a temporary file to hold the list of objects, as it can exceed windows shell command limits
$(file >$@.in,$(OBJECTS))
rm -f @$@.in $(TARGET)
@rm $@.in
else
rm -f $(OBJECTS) $(TARGET)
endif