aboutsummaryrefslogtreecommitdiff
path: root/dists/amiga/Ext_Inst_so.rexx
diff options
context:
space:
mode:
authorHubert Maier2019-10-21 20:38:24 +0200
committerFilippos Karapetis2019-10-21 21:38:24 +0300
commit80a96fd90d8b6306d025300f291122d341a000d8 (patch)
tree8d94af2faec7656b2da8d42445c328d532f7393a /dists/amiga/Ext_Inst_so.rexx
parent93a864f39a1d527525196fed66a2d16c83ee5f75 (diff)
downloadscummvm-rg350-80a96fd90d8b6306d025300f291122d341a000d8.tar.gz
scummvm-rg350-80a96fd90d8b6306d025300f291122d341a000d8.tar.bz2
scummvm-rg350-80a96fd90d8b6306d025300f291122d341a000d8.zip
AMIGAOS4: Automate special target installation even more (#1901)
* AMIGAOS4: Update amigaos.mk - reorg - add stripping/copying engine plugins - add Ext_Ins_so.rexx * Ext_Inst_so.rexx Add script to extract and install all compiled-in shared libraries to a local sobjs/ dir. Reason is that not every AmigaOS4 installation, especially vanilla ones, feature all mandatory libraries (which has led to many bug reports and lots of gathering of the correct libraries for users in the past) * AMIGAOS4: RM2AG.rexx - Add automatic installation to the correct path - Add deleting the temp file - Typos and rewording - Add I/O panic switches
Diffstat (limited to 'dists/amiga/Ext_Inst_so.rexx')
-rw-r--r--dists/amiga/Ext_Inst_so.rexx107
1 files changed, 107 insertions, 0 deletions
diff --git a/dists/amiga/Ext_Inst_so.rexx b/dists/amiga/Ext_Inst_so.rexx
new file mode 100644
index 0000000000..845acc687b
--- /dev/null
+++ b/dists/amiga/Ext_Inst_so.rexx
@@ -0,0 +1,107 @@
+/*
+$VER: Ext_Inst_so.rexx 0.3 (21.10.2019) Extract and install compiled-in shared libraries from a given ELF binary.
+*/
+
+PARSE ARG executable install_path
+
+/*
+Check if arguments are available, otherwise quit.
+*/
+IF ~ARG() THEN DO
+ SAY 'No Arguments given!'
+ SAY 'Usage: Ext_Inst_so.rexx EXECUTABLE INSTALL_PATH'
+ EXIT No Arguments given!
+END
+
+/*
+If the given filename/path has spaces in it, AmigaDOS/CLI
+will add extra quotation marks to secure a sane working path.
+Get rid of them to make AREXX find the file and remove leading
+and trailing spaces.
+*/
+IF ~EXISTS(executable) THEN DO
+ SAY executable' not available!'
+ EXIT EXECUTABLE not available!
+END
+ELSE DO
+ executable=STRIP(executable)
+ executable=COMPRESS(executable,'"')
+END
+IF installpath='' THEN DO
+ SAY 'No installation destination given!'
+ EXIT No installation destination given!
+END
+ELSE DO
+ install_path=STRIP(install_path)
+ install_path=COMPRESS(install_path,'"')
+ /*
+ Check for destination path and create it, if needed.
+ */
+ IF ~EXISTS(install_path'/sobjs/') THEN
+ ADDRESS COMMAND 'makedir 'install_path'/sobjs'
+END
+
+/*
+Create shared objects dump.
+*/
+ADDRESS COMMAND 'readelf -d 'executable' >so_dump'
+
+/*
+Error check, if I/O went wrong.
+*/
+IF ~OPEN(SO_read,'so_dump','R') THEN DO
+ SAY 'File so_dump opening failed!'
+ EXIT File so_dump opening failed!
+END
+
+/*
+We know that the dumped shared library entries always start
+at line 4. Skip unneeded lines to speed up processing.
+*/
+working_line=CALL READLN(SO_read)
+working_line=CALL READLN(SO_read)
+working_line=CALL READLN(SO_read)
+
+i=1
+
+DO WHILE i>0
+ working_line=READLN(SO_read)
+ IF POS('Shared library:', working_line)>0 THEN DO
+ i=1
+ /*
+ We know that the shared library names always start at position 59.
+ */
+ lib.so=SUBSTR(working_line,59,LASTPOS(']', working_line)-59)
+ /*
+ Check whether the installed shared libraries are placed in the SDK
+ (most of them) or AmigaOS SOBJS: drawer (few of them) and copy them accordingly.
+ */
+ IF EXISTS('SDK:local/newlib/lib/'lib.so) THEN
+ ADDRESS COMMAND 'copy clone SDK:local/newlib/lib/'lib.so install_path'/sobjs/'
+ ELSE
+ IF EXISTS('SYS:SOBJS/'lib.so) THEN
+ ADDRESS COMMAND 'copy clone SYS:SOBJS/'lib.so install_path'/sobjs/'
+ ELSE DO
+ /*
+ If a shared library is not found, abort.
+ */
+ SAY lib.so' not found! Aborting!'
+ EXIT Shared Library not found! Aborting!
+ END
+ END
+ ELSE
+ i=0
+END
+
+/*
+AREXX is doing its own cleaning up of open files.
+Close the file manually anyway.
+*/
+IF ~CLOSE(SO_Read) THEN DO
+ SAY 'File so_dump closing failed!'
+ EXIT File so_dump opening failed!
+END
+
+ADDRESS COMMAND 'delete so_dump'
+
+EXIT 0