diff --git a/configure b/configure index a79d7df..6e912a2 100755 --- a/configure +++ b/configure @@ -296,6 +296,33 @@ fi # Platform-specific options + +#Endianess +cat >conftest.$$.c << EOF +#include +#include + +int main(int argc, char **argv) +{ + int test = 1; + + return(*(unsigned char*) (&test)); +} +EOF +$cc -o conftest.$$ conftest.$$.c +./conftest.$$ +if [ "$?" = "0" ]; then + echo "Architecture is big-endian" + echo + cflags="$cflags -DB_ENDIAN" +else + echo "Architecture is little-endian" + echo + cflags="$cflags -DL_ENDIAN" +fi +rm conftest.$$ conftest.$$.c + +#Alignment cat >conftest.$$.c << EOF #include #include @@ -317,7 +344,7 @@ need_alignment=yes if [ "$need_alignment" = "yes" ]; then echo "Architecture needs alignment" echo - cflags="$cflags -DNEED_ALIGNMENT" + cflags="$cflags -DNEED_ALIGN" fi rm conftest.$$ conftest.$$.c diff --git a/rdesktop.h b/rdesktop.h index c851bd9..21e959f 100644 --- a/rdesktop.h +++ b/rdesktop.h @@ -59,6 +59,18 @@ #define MAX(x,y) (((x) > (y)) ? (x) : (y)) #endif +/* If configure does not define the endianess, try + to find it out */ +#if !defined(L_ENDIAN) && !defined(B_ENDIAN) +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define L_ENDIAN +#elif __BYTE_ORDER == __BIG_ENDIAN +#define B_ENDIAN +#else +#error Unknown endianness. Edit rdesktop.h. +#endif +#endif /* B_ENDIAN, L_ENDIAN from configure */ + #include "parse.h" #include "constants.h" #include "types.h"