2017-04-20 19:03:52 +00:00
|
|
|
STATIC_LINKING := 0
|
|
|
|
AR := ar
|
|
|
|
|
|
|
|
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
|
|
|
|
endif
|
|
|
|
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
|
|
|
|
arch = intel
|
|
|
|
ifeq ($(shell uname -p),powerpc)
|
|
|
|
arch = ppc
|
|
|
|
endif
|
|
|
|
else ifneq ($(findstring MINGW,$(shell uname -a)),)
|
|
|
|
system_platform = win
|
|
|
|
endif
|
|
|
|
|
2017-04-25 01:50:35 +00:00
|
|
|
ifeq ($(platform), win)
|
2017-09-29 15:47:35 +00:00
|
|
|
INCFLAGS += -I Windows
|
2017-04-25 01:50:35 +00:00
|
|
|
endif
|
2017-04-20 19:03:52 +00:00
|
|
|
|
2017-10-12 19:40:48 +00:00
|
|
|
CORE_DIR += ..
|
2017-05-04 01:22:28 +00:00
|
|
|
|
2017-04-20 19:03:52 +00:00
|
|
|
TARGET_NAME = sameboy
|
2017-04-25 01:50:35 +00:00
|
|
|
LIBM = -lm
|
2017-04-20 19:03:52 +00:00
|
|
|
|
|
|
|
ifeq ($(ARCHFLAGS),)
|
|
|
|
ifeq ($(archs),ppc)
|
|
|
|
ARCHFLAGS = -arch ppc -arch ppc64
|
|
|
|
else
|
|
|
|
ARCHFLAGS = -arch i386 -arch x86_64
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(platform), osx)
|
|
|
|
ifndef ($(NOUNIVERSAL))
|
|
|
|
CXXFLAGS += $(ARCHFLAGS)
|
|
|
|
LFLAGS += $(ARCHFLAGS)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(STATIC_LINKING), 1)
|
|
|
|
EXT := a
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(platform), unix)
|
2017-10-12 16:42:30 +00:00
|
|
|
EXT ?= so
|
2017-04-20 19:03:52 +00:00
|
|
|
TARGET := $(TARGET_NAME)_libretro.$(EXT)
|
|
|
|
fpic := -fPIC
|
2017-05-04 01:22:28 +00:00
|
|
|
SHARED := -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
|
2017-04-20 19:03:52 +00:00
|
|
|
else ifeq ($(platform), linux-portable)
|
|
|
|
TARGET := $(TARGET_NAME)_libretro.$(EXT)
|
|
|
|
fpic := -fPIC -nostdlib
|
2017-05-04 01:22:28 +00:00
|
|
|
SHARED := -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T
|
2017-04-20 19:03:52 +00:00
|
|
|
LIBM :=
|
|
|
|
else ifneq (,$(findstring osx,$(platform)))
|
|
|
|
TARGET := $(TARGET_NAME)_libretro.dylib
|
|
|
|
fpic := -fPIC
|
|
|
|
SHARED := -dynamiclib
|
|
|
|
else ifneq (,$(findstring ios,$(platform)))
|
|
|
|
TARGET := $(TARGET_NAME)_libretro_ios.dylib
|
|
|
|
fpic := -fPIC
|
|
|
|
SHARED := -dynamiclib
|
|
|
|
|
|
|
|
ifeq ($(IOSSDK),)
|
|
|
|
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
|
|
|
|
endif
|
|
|
|
|
|
|
|
DEFINES := -DIOS
|
2017-09-29 15:47:35 +00:00
|
|
|
ifeq ($(platform),ios-arm64)
|
|
|
|
CC = cc -arch armv64 -isysroot $(IOSSDK)
|
|
|
|
else
|
2017-04-20 19:03:52 +00:00
|
|
|
CC = cc -arch armv7 -isysroot $(IOSSDK)
|
2017-09-29 15:47:35 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
|
2017-04-20 19:03:52 +00:00
|
|
|
CC += -miphoneos-version-min=8.0
|
|
|
|
CXXFLAGS += -miphoneos-version-min=8.0
|
|
|
|
else
|
|
|
|
CC += -miphoneos-version-min=5.0
|
|
|
|
CXXFLAGS += -miphoneos-version-min=5.0
|
|
|
|
endif
|
|
|
|
else ifneq (,$(findstring qnx,$(platform)))
|
|
|
|
TARGET := $(TARGET_NAME)_libretro_qnx.so
|
|
|
|
fpic := -fPIC
|
2017-05-04 01:22:28 +00:00
|
|
|
SHARED := -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
|
2017-04-20 19:03:52 +00:00
|
|
|
else ifeq ($(platform), emscripten)
|
|
|
|
TARGET := $(TARGET_NAME)_libretro_emscripten.bc
|
|
|
|
fpic := -fPIC
|
2017-05-04 01:22:28 +00:00
|
|
|
SHARED := -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
|
2017-04-20 19:03:52 +00:00
|
|
|
else ifeq ($(platform), vita)
|
|
|
|
TARGET := $(TARGET_NAME)_vita.a
|
|
|
|
CC = arm-vita-eabi-gcc
|
|
|
|
AR = arm-vita-eabi-ar
|
2017-06-14 07:03:56 +00:00
|
|
|
CFLAGS += -Wl,-q -Wall -O3 -fno-short-enums -fno-optimize-sibling-calls
|
2017-04-20 19:03:52 +00:00
|
|
|
STATIC_LINKING = 1
|
|
|
|
else
|
|
|
|
CC = gcc
|
|
|
|
TARGET := $(TARGET_NAME)_libretro.dll
|
2017-05-04 01:22:28 +00:00
|
|
|
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,--no-undefined
|
2017-04-20 19:03:52 +00:00
|
|
|
endif
|
|
|
|
|
2017-10-12 19:40:48 +00:00
|
|
|
TARGET := $(CORE_DIR)/build/bin/$(TARGET)
|
2017-10-12 19:26:56 +00:00
|
|
|
|
2017-10-12 16:42:30 +00:00
|
|
|
# To force use of the Unix version instead of the Windows version
|
|
|
|
MKDIR := $(shell which mkdir)
|
|
|
|
|
2017-04-20 19:03:52 +00:00
|
|
|
LDFLAGS += $(LIBM)
|
|
|
|
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CXXFLAGS += -O0 -g
|
|
|
|
else
|
2017-07-04 08:41:34 +00:00
|
|
|
CXXFLAGS += -O2 -DNDEBUG
|
2017-04-20 19:03:52 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
include Makefile.common
|
|
|
|
|
2017-10-12 19:40:48 +00:00
|
|
|
OBJECTS := $(patsubst %.c,$(CORE_DIR)/build/obj/%_libretro.c.o,$(SOURCES_C))
|
2017-04-20 19:03:52 +00:00
|
|
|
|
2017-07-04 08:41:34 +00:00
|
|
|
CFLAGS += -Wall -D__LIBRETRO__ $(fpic) $(INCFLAGS) -std=gnu11 -D_GNU_SOURCE -D_USE_MATH_DEFINES
|
2017-04-20 19:03:52 +00:00
|
|
|
CXXFLAGS += -Wall -D__LIBRETRO__ $(fpic)
|
|
|
|
|
|
|
|
all: $(TARGET)
|
|
|
|
|
2017-10-12 18:52:51 +00:00
|
|
|
$(CORE_DIR)/libretro/%_boot.c: $(CORE_DIR)/build/bin/BootROMs/%_boot.bin
|
|
|
|
echo "/* AUTO-GENERATED */" > $@
|
2017-10-12 19:06:01 +00:00
|
|
|
echo "const unsigned char $(notdir $(@:%.c=%))[] = {" >> $@
|
2017-10-12 18:52:51 +00:00
|
|
|
cat $< | xxd -i >> $@
|
|
|
|
echo "};" >> $@
|
|
|
|
echo "const unsigned $(notdir $(@:%.c=%))_length = sizeof($(notdir $(@:%.c=%)));" >> $@
|
|
|
|
|
|
|
|
$(CORE_DIR)/build/bin/BootROMs/%_boot.bin:
|
2017-10-12 21:14:32 +00:00
|
|
|
$(MAKE) -C $(CORE_DIR) $(patsubst $(CORE_DIR)/%,%,$@)
|
2017-10-12 18:52:51 +00:00
|
|
|
|
2017-04-20 19:03:52 +00:00
|
|
|
$(TARGET): $(OBJECTS)
|
2017-10-12 19:26:56 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2017-04-20 19:03:52 +00:00
|
|
|
ifeq ($(STATIC_LINKING), 1)
|
|
|
|
$(AR) rcs $@ $(OBJECTS)
|
|
|
|
else
|
2017-05-04 01:22:28 +00:00
|
|
|
$(CC) $(fpic) $(SHARED) $(INCFLAGS) -o $@ $(OBJECTS) $(LDFLAGS)
|
2017-04-20 19:03:52 +00:00
|
|
|
endif
|
|
|
|
|
2017-10-12 19:40:48 +00:00
|
|
|
$(CORE_DIR)/build/obj/%_libretro.c.o: %.c
|
2017-10-12 16:42:30 +00:00
|
|
|
-@$(MKDIR) -p $(dir $@)
|
2017-04-20 19:03:52 +00:00
|
|
|
$(CC) -c -o $@ $< $(CFLAGS) $(fpic) -DGB_INTERNAL
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) $(fpic) -c -o $@ $<
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(OBJECTS) $(TARGET)
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
|