Building Mono Without Bash: Syntax Error in doltlibtool - bash

I'm building mono on an android device and getting an error when the build runs ./doltlibtool
make[4]: Entering directory `/bld/mono/mono-4.0.0/eglib/src'
CC libeglib_la-garray.lo
../doltlibtool: line 4: syntax error: unexpected "("
Here is line 4 of doltlibtool:
1 #!/bin/bash
2 top_builddir_slash="${0%%doltlibtool}"
3 : ${top_builddir_slash:=./}
4 args=()
5 modeok=false
6 tagok=false
From what I can tell, the problem is due to the fact that I'm not using bash. Is there any way to fix this without building and using bash?
CORRECTION
I am using bash...but the busybox version of bash, which isn't really bash and so does not support arrays.

From the mono-devel mailing list, to which I posted the question:
Is it possible to build mono without bash?
It is unlikely.
Your best bet is to cross compile.
Shells that do not handle arrays (like the default Android shell or the default shell in KBOX...which is a busybox version of bash) cannot be used when compiling mono 4.0.0. Specifically the line
args=()
will throw an error.
I ended up downloading the bash source and building it before trying to build mono

Related

The Linux script does not run on MacOS

I have a script for work which runs fine on Ubuntu Virtual machine. I have recently switched to MacOS and while trying to run the same script I get the following error:
danyateran#MacBook-Air-Danya:~/restorator$ ./restorator.sh -V
/Users/danyateran/restorator/bin/functions.sh: line 1568: syntax error near unexpected token `>'
/Users/danyateran/restorator/bin/functions.sh: line 1568: ` ssh_conn "${SOURCE_SERVERNAME}" 'exec 2>&1; whmapi1 fetch_ssl_certificates_for_fqdns domains='${ssl_host}'; exit' &>> "${TMP_TRANSFER_DIR}/ssl_info_${ssl_host}.txt"'
While the syntax seems fine and as far as I know the MacOS has the same line endings as Linux, I have no idea what could be wrong. What is the cause of this MacOS-related problem and how can it be resolved?
The syntax &>>, which appends both standard output and standard error to the same file, was introduced in bash version 4.0. MacOS ships with bash version 3.2.
You can change it to the more portable syntax:
>> "${TMP_TRANSFER_DIR}/ssl_info_${ssl_host}.txt" 2>&1
That's same thing, but will be understood by bash v3.2 (and newer, and sh).
However, there might be other things in the script which are not compatible, such as associative arrays, the mapfile built-in, various shell options, etc.
You can install a newer version of bash. The current version is 5.1.

if statement in ONESHELL Makefile not working

I get /bin/sh: -c: line 1: syntax error: unexpected end of file for the if statement in the makefile below — what's wrong? (My prompt is /tmp >.)
/tmp > make test
set -e
if [[ -f /tmp/device ]] ; then
/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** [test] Error 2
/tmp > cat Makefile
.ONESHELL:
test:
set -e
if [[ -f /tmp/device ]] ; then
echo 'Do something'
fi
I am using GNU Make 3.81.
Using GNU Make 3.81, the .ONESHELL feature is demonstrably not supported — you showed that, and I showed that. I tested on Mac OS X 10.11.5, with the supplied /usr/bin/make as GNU Make 3.81. I demonstrated to my satisfaction by adding strategically placed echo PID=$$$$ lines before set -e, after it, and so on, and observed different PID values. GNU Make version 3.81 is from 2006 (there was also version 3.82 from 2010, before version 4.x was released, starting with 4.0 in 2013).
The current version of GNU Make is 4.2.1 (June 2016). That version does support the feature; your script works as expected when using a sufficiently recent version of GNU Make. It is a feature that has been around for a while — you probably don't have to upgrade to the latest to get the support, but why would you go with a down-version if you're going to upgrade anyway.
If you wish to use the .ONSHELL: feature, you'll have to ensure you are using a new enough version of GNU Make (newer than version 3.81). If that's not feasible, don't use the feature.
Reading the NEWS file from 4.2.1, it is clear that ONESHELL was added to GNU Make version 3.82:
Version 3.82 (28 Jul 2010)
…
* New special target: .ONESHELL instructs make to invoke a single instance
of the shell and provide it with the entire recipe, regardless of how many
lines it contains. As a special feature to allow more straightforward
conversion of makefiles to use .ONESHELL, any recipe line control
characters ('#', '+', or '-') will be removed from the second and
subsequent recipe lines. This happens _only_ if the SHELL value is deemed
to be a standard POSIX-style shell. If not, then no interior line control
characters are removed (as they may be part of the scripting language used
with the alternate SHELL).

Makefile errors in Solaris when using conditional assignment

I have encountered errors on running the conditional assignment operator in a Makefile in Solaris 11.1. However I encounter no errors on running the same Makefile in Ubuntu.
version ?= 6.1
all:
echo $(version)
Note: Before the echo, there is a tab before the echo in the original code. Using four spaces here just for convenience of editing.
Error encountered in Solaris 11.1:
make: Fatal error in reader: Makefile, line 1: Badly formed macro assignment
However, there are no such errors on Ubuntu.
Better you use gmake because many Makefiles use Gnu-specific features. Solaris make might be using slightly different syntax. You can read the Solaris makefile manual; you will find that there is no ?= operator in it. Hence you are getting that error.
?= is a feature added by GNU make, which is the default version of make on Ubuntu, but on Solaris is installed as gmake or /usr/gnu/bin/make. ?= is not supported by the native make command on Solaris, which is installed as /usr/ccs/bin/make on older releases, /usr/bin/make on Solaris 11 and later.
If you need to use the GNU extensions in your makefiles, make sure you run the GNU make, not the Solaris make.

shc on Mac showing 'Killed: 9' error

I'm using shc on Mac OS, to generate stripped binary of bash scripts, for distribution. The issue is, when i execute the stripped binary (with .x ext) it shows the error killed: 9.
Even when i make and make test (as shown here), it strips the dummy match script and generates match.x, which when executed, gives the same killed: 9 error.
Any help would be appreciated.
Got it working. Just had to do
shc -T -f test.sh
I was trying it without the -T

Compiling SCOL using gcc

I am compiling an ancient program called SCOL (written in 1997) which comes pre-packged with OpinionFinder using gcc 3.4.5. I am using CentOS 5.5. After giving the make command, I get the following error:
/home/shahw/opinionfinder/software/scol1k/tools/tagfixes -c e8.fx
Wrote e8.fxc
/home/shahw/opinionfinder/software/scol1k/tools/tagfixes -c bnc.fx
Wrote bnc.fxc
env BIN=/home/shahw/scol//bin MAN=/home/shahw/scol//man LIB=/home/shahw/scol//lib ./mk.csh.rc
env: ./mk.csh.rc: No such file or directory
make[1]: *** [csh.rc] Error 127
make[1]: Leaving directory `/home/shahw/opinionfinder/software/scol1k/data'
make: *** [modules] Error 2
I have confirmation from a source that the program compiles fine with this version of gcc, however I am not able to track down other platform specific information. Could this be an os specific problem? Do I need to set some environment variable for this to work? Any hint would be greatly appreciated. Thanks.
It looks like you're using the wrong shell. You're probably using bash whereas the old makefile seems to be assuming csh or similar. Try changing your shell to csh and see if that helps.
It is not able to find the file mk.csh.rc. Try finding this file first, using find command, and then you can include the directory in which this file resides by changing the environment variable path using export command

Resources