File: check-x86-asm.sh

package info (click to toggle)
skyeye 1.2.5-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,236 kB
  • ctags: 19,345
  • sloc: ansic: 90,379; sh: 5,188; python: 707; cpp: 417; makefile: 322; exp: 38
file content (59 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
#
# Written by Anthony Lee 2007.03
#

printf "Checking whether the compiler supports x86 asm ... "

case $CC in
	*gcc*)
		;;
	*)
		# other compiler, should be checked manually.
		printf "IGNORE\n"
		exit 0
		;;
esac

SRC="
int main(int argc, char **argv)
{
	int i = 1;
	__asm__ (\" \
		pushl %%eax\n \
		movl %0, %%eax\n \
		subl \$1, %%eax\n \
		movl %%eax, %0\n \
		popl %%eax\" \
		: \
		: \"g\" (i)
	);
	return i;
}"

PROG="check-x86-asm"
OBJECT="${BINARY_DIR}${PROG}.o"
TARGET="${BINARY_DIR}${PROG}${SUFFIX}"
ERR_MESSAGE="*** It seems that the compiler don't support inline x86 AT&T ASM codes.
*** Run \"make NO_DBCT=1\" instead to ignore it."

if ! ( echo "$SRC" | $CC $EXTRA_CFLAGS -o "$OBJECT" -c -x c - > /dev/null 2>&1 ); then
	printf "FAILED\n\n"
	printf "$ERR_MESSAGE\n\n"
	exit 1
fi

if ! ( $CC -o "$TARGET" "$OBJECT" $EXTRA_LIBS > /dev/null 2>&1 ); then
	printf "FAILED\n\n"
	printf "$ERR_MESSAGE\n\n"
	rm -f "$OBJECT"
	exit 1
fi

rm -f "$OBJECT"
rm -f "$TARGET"

printf "OK\n"

exit 0