mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
libretro, build fixes
This commit is contained in:
parent
b1ccc27109
commit
03718e6276
5 changed files with 71 additions and 19 deletions
3
Makefile
3
Makefile
|
@ -280,6 +280,9 @@ endif
|
|||
pico/carthw_cfg.c: pico/carthw.cfg
|
||||
tools/make_carthw_c $< $@
|
||||
|
||||
# preprocessed asm files most probably include the offsets file
|
||||
$(filter %.S,$(SRCS_COMMON)): pico/pico_int_offs.h
|
||||
|
||||
# random deps
|
||||
pico/carthw/svp/compiler.o : cpu/drc/emit_arm.c
|
||||
cpu/sh2/compiler.o : cpu/drc/emit_arm.c cpu/drc/emit_arm64.c cpu/drc/emit_ppc.c
|
||||
|
|
|
@ -364,6 +364,10 @@ else ifeq ($(platform), emscripten)
|
|||
STATIC_LINKING = 1
|
||||
DONT_COMPILE_IN_ZLIB = 1
|
||||
|
||||
use_cyclone = 0
|
||||
use_fame = 1
|
||||
use_drz80 = 0
|
||||
use_cz80 = 1
|
||||
# GCW0
|
||||
else ifeq ($(platform), gcw0)
|
||||
TARGET := $(TARGET_NAME)_libretro.so
|
||||
|
|
|
@ -76,7 +76,7 @@ SRCS_COMMON += $(R)pico/32x/draw_arm.S
|
|||
endif
|
||||
ifeq "$(asm_32xmemory)" "1"
|
||||
DEFINES += _ASM_32X_MEMORY_C
|
||||
SRCS_COMMON += $(R)pico/32x/memory_arm.s
|
||||
SRCS_COMMON += $(R)pico/32x/memory_arm.S
|
||||
endif
|
||||
ifeq "$(asm_mix)" "1"
|
||||
SRCS_COMMON += $(R)pico/sound/mix_arm.S
|
||||
|
|
|
@ -2,7 +2,7 @@ TARGETS = amalgamate textfilter
|
|||
OBJS = $(addsuffix .o,$(TARGETS))
|
||||
|
||||
all: $(TARGETS)
|
||||
CC="$(XCC)" CFLAGS="$(XCFLAGS)" ./mkoffsets.sh ../pico
|
||||
CC="$(XCC)" CFLAGS="$(XCFLAGS)" sh ./mkoffsets.sh ../pico
|
||||
|
||||
clean:
|
||||
$(RM) $(TARGETS) $(OBJS)
|
||||
|
|
|
@ -8,30 +8,80 @@ CC=${CC:-gcc}
|
|||
# endianess of target (automagically determined below)
|
||||
ENDIAN=
|
||||
|
||||
# don't do this if ELF format isn't used. it doesn't matter since offsets are
|
||||
# only needed for the asm parts (currently mips/arm32) and those have ELF
|
||||
check_elf ()
|
||||
# check which object format to dissect
|
||||
READELF=
|
||||
OBJDUMP=
|
||||
check_obj ()
|
||||
{
|
||||
# prepare an object file; as side effect dtermine the endianess
|
||||
CROSS=$(echo $CC | sed 's/gcc.*//')
|
||||
echo '#include <stdint.h>' >/tmp/getoffs.c
|
||||
echo "const int32_t val = 1;" >>/tmp/getoffs.c
|
||||
$CC $CFLAGS -I .. -c /tmp/getoffs.c -o /tmp/getoffs.o || exit 1
|
||||
if ! command -v readelf >/dev/null || ! file /tmp/getoffs.o | grep -q ELF; then
|
||||
echo "/* mkoffset.sh: no readelf or not ELF, offset table not created */" >$fn
|
||||
echo "WARNING: no readelf or not ELF, offset table not created"
|
||||
exit
|
||||
|
||||
# check for readelf; readelf is the only toolchain tool not using bfd,
|
||||
# hence it works with ELF files for every target
|
||||
if file /tmp/getoffs.o | grep -q ELF; then
|
||||
if command -v readelf >/dev/null; then
|
||||
READELF=readelf
|
||||
elif command -v ${CROSS}readelf >/dev/null; then
|
||||
READELF=${CROSS}readelf
|
||||
fi
|
||||
fi
|
||||
if [ -n "$READELF" ]; then
|
||||
# find the the .rodata section (in case -fdata-sections is used)
|
||||
rosect=$($READELF -S /tmp/getoffs.o | grep '\.rodata\|\.sdata' |
|
||||
sed 's/^[^.]*././;s/ .*//')
|
||||
# read .rodata section as hex string (should be only 4 bytes)
|
||||
ro=$($READELF -x $rosect /tmp/getoffs.o | grep '0x' | cut -c14-48 |
|
||||
tr -d ' \n' | cut -c1-8)
|
||||
# if no output could be read readelf isn't working
|
||||
if [ -z "$ro" ]; then
|
||||
READELF=
|
||||
fi
|
||||
fi
|
||||
# if there is no working readelf try using objdump
|
||||
if [ -z "$READELF" ]; then
|
||||
# objdump is using bfd; try using the toolchain objdump first
|
||||
# since this is likely working with the toolchain objects
|
||||
if command -v ${CROSS}objdump >/dev/null; then
|
||||
OBJDUMP=${CROSS}objdump
|
||||
elif command -v objdump >/dev/null; then
|
||||
OBJDUMP=objdump
|
||||
fi
|
||||
# find the start line of the .rodata section; read the next line
|
||||
ro=$($OBJDUMP -s /tmp/getoffs.o | awk '\
|
||||
/Contents of section.*(__const|.rodata|.sdata)/ {o=1; next} \
|
||||
{if(o) { gsub(/ .*/,""); $1=""; gsub(/ /,""); print; o=0}}')
|
||||
# no working tool for extracting the ro data; stop here
|
||||
if [ -z "$ro" ]; then
|
||||
echo "/* mkoffset.sh: no readelf or not ELF, offset table not created */" >$fn
|
||||
echo "WARNING: no readelf or not ELF, offset table not created"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
# extract decimal value from ro
|
||||
rodata=$(printf "%d" 0x$ro)
|
||||
ENDIAN=$(if [ "$rodata" -eq 1 ]; then echo be; else echo le; fi)
|
||||
}
|
||||
|
||||
# compile with target C compiler and extract value from .rodata section
|
||||
compile_rodata ()
|
||||
{
|
||||
$CC $CFLAGS -I .. -c /tmp/getoffs.c -o /tmp/getoffs.o || exit 1
|
||||
# find the name of the .rodata section (in case -fdata-sections is used)
|
||||
rosect=$(readelf -S /tmp/getoffs.o | grep '\.rodata\|\.sdata' |
|
||||
if [ -n "$READELF" ]; then
|
||||
# find the .rodata section (in case -fdata-sections is used)
|
||||
rosect=$(readelf -S /tmp/getoffs.o | grep '\.rodata\|\.sdata' |
|
||||
sed 's/^[^.]*././;s/ .*//')
|
||||
# read out .rodata section as hex string (should be only 4 bytes)
|
||||
ro=$(readelf -x $rosect /tmp/getoffs.o | grep '0x' | cut -c14-48 |
|
||||
# read .rodata section as hex string (should be only 4 bytes)
|
||||
ro=$(readelf -x $rosect /tmp/getoffs.o | grep '0x' | cut -c14-48 |
|
||||
tr -d ' \n' | cut -c1-8)
|
||||
elif [ -n "$OBJDUMP" ]; then
|
||||
# find the start line of the .rodata section; read the next line
|
||||
ro=$($OBJDUMP -s /tmp/getoffs.o | awk '\
|
||||
/Contents of section.*(__const|.rodata|.sdata)/ {o=1; next} \
|
||||
{if(o) { gsub(/ .*/,""); $1=""; gsub(/ /,""); print; o=0}}')
|
||||
fi
|
||||
if [ "$ENDIAN" = "le" ]; then
|
||||
# swap needed for le target
|
||||
hex=""
|
||||
|
@ -63,12 +113,7 @@ get_define () # prefix struct member member...
|
|||
fn="${1:-.}/pico_int_offs.h"
|
||||
if echo $CFLAGS | grep -qe -flto; then CFLAGS="$CFLAGS -fno-lto"; fi
|
||||
|
||||
check_elf
|
||||
# determine endianess
|
||||
echo '#include <stdint.h>' >/tmp/getoffs.c
|
||||
echo "const int32_t val = 1;" >>/tmp/getoffs.c
|
||||
compile_rodata
|
||||
ENDIAN=$(if [ "$rodata" -eq 1 ]; then echo be; else echo le; fi)
|
||||
check_obj
|
||||
# output header
|
||||
echo "/* autogenerated by mkoffset.sh, do not edit */" >$fn
|
||||
echo "/* target endianess: $ENDIAN, compiled with: $CC $CFLAGS */" >>$fn
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue