File: ffi-config

package info (click to toggle)
squeak-vm 1%3A4.10.2.2614-4.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 13,284 kB
  • ctags: 15,344
  • sloc: ansic: 75,096; cs: 11,191; objc: 5,494; sh: 3,170; asm: 1,533; cpp: 449; pascal: 372; makefile: 366; awk: 103
file content (73 lines) | stat: -rwxr-xr-x 1,509 bytes parent folder | download | duplicates (8)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
# 
# ffi-config [cfgdir] [options...]
# 
#    -cpu	print the supported cpu name or `any'
#    -abi	print the supported abu name or `libffi'
#    -lib	print nothing if supported, otherwise  `-lffi'
#    -query	exit with status 0 if supported, 1 if libffi required

cfgdir=../../config

if [ $# -gt 0 ]; then
    case $1 in
	-*)	;;
	*)	cfgdir=$1; shift;;
    esac
fi

ffidir=.

if [ $# -gt 0 ]; then
    case $1 in
	-*)	;;
	*)	ffidir=$1; shift;;
    esac
fi

guess=`${cfgdir}/config.guess`
host=`${cfgdir}/config.sub ${guess}`
cpu=`echo ${host} | sed 's/-.*//'`
abi=`echo ${host} | sed 's/[^-]*-[^-]*-//;s/-.*//'`
lib=

case ${cpu} in
    powerpc|ppc)	cpu=ppc;;
    i[3456789]86)	cpu=x86;;
    *)			cpu=any;;
esac

case ${abi} in
    linux)		abi=sysv;;
    darwin*)		abi=darwin;;
    *)			abi=libffi; lib="-lffi";;
esac

if [ ! -f ${ffidir}/${cpu}-${abi}.c ] || [ ! -f ${ffidir}/${cpu}-${abi}-asm.S ]; then
    cpu=any
    abi=libffi
    lib="-lffi"
fi

if [ ! -f ${ffidir}/${cpu}-${abi}.c ] || [ ! -f ${ffidir}/${cpu}-${abi}-asm.S ]; then
    echo "Could not find ${cpu}-${abi}.c and ${cpu}-${abi}-asm.S" >&2
    exit 1
fi

if [ $# -eq 0 ]; then
    echo "${cpu}-${abi}" "${lib}"
else
    while [ $# -gt 0 ]; do
	case $1 in
	    -cpu)	echo ${cpu};;
	    -abi)	echo ${abi};;
	    -lib)	echo ${lib};;
	    -cpu-abi)	echo ${cpu}-${abi};;
	    -query)	if [ ${abi} = "libffi" ]; then exit 1; else exit 0; fi;;
	    *)		echo "$0: I don't understand \`$1'" >&1; exit 1;;
	esac
    shift
    done
fi

exit 0