#!/bin/sh
tmpc=".endianness.tmp.c"
tmpx=".endianness.bin"
cat > $tmpc <<EOF
#define LITTLE_ENDIAN 0
#define BIG_ENDIAN    1
#include <stdio.h>
union u {
	short s;
	char c[sizeof(short)];
};
int main()
{
	union u u;
	u.s = 0x0102;
	if (u.c[0] == 0x02) {
		puts("Little"); return LITTLE_ENDIAN;
	} else {
		puts("Big"); return BIG_ENDIAN;
	}
}
EOF
gcc -Wall -pedantic -pipe -o $tmpx $tmpc
./$tmpx
rm -rf $tmpc $tmpx
