#14 Compile errors on non-Windows/Linux machines

closed-fixed
nobody
None
5
2010-08-21
2005-02-11
No

brickOS 0.9.0 doesn't compile on other platforms than
Cygwin and Linux due to some portability problems:

The following command in 'Makefile' does not work with
the built-in test command of some shells (neither does
'if test ...; then') :

all::
@if [ configure -nt .configured.flg ]; then
rm -f .configured.flg; \ fi

It can be replaced by a construction using the Makefile
syntax, which works with all shells and informs the
user of the problem.

.configured.flg: configure
@echo "ERROR- brickOS builds are not yet
configured..." >&2
@echo " Please run ./configure then try to
build again." >&2
@echo "" >&2
@exit 2

all:: .configured.flg

The 'configure' script says it needs /bin/sh, but it
uses the bash-only command substitution $(...):

TOOLPREFIX=$DIRNAME/$(echo $BASENAME | sed "s/gcc.*//")

Backticks should work in every shell:

TOOLPREFIX=$DIRNAME/`echo $BASENAME | sed "s/gcc.*//"`

If the same script detects a Unix/Linux environment, it
uses 'cc' instead of 'gcc', but some compiler options
seem to be gcc-specific (-O2, -Wall). At least the
Solaris cc rejects them. It might be a work-around to
use 'gcc' also on Unix:

CC=gcc

Some #ifdef conditionals in 'util/firmdl/rcx_comm.c'
only distinguish between for example 'Win32' and
'others', but 'not Win32' does not mean 'Linux'. This
causes three errors:

1. ioctl.h is included on all Unix systems although it
can only be used on Linux. Strictly speeking this is no
error as long as the file exists.

2. Some variables are used but not declared on systems
like Solaris in function nbread.

3. nbread contains an ioctl call to the USB tower on
all Unix systems although it compiles only under Linux.

The attached patch fixes the errors as described above.

Discussion

  • Portability problems fix for brickOS 0.9.0

     
    Attachments
  • mesheets
    mesheets
    2010-08-21

    • status: open --> closed-fixed