summaryrefslogtreecommitdiff
path: root/tool/mjit_archflag.sh
blob: 082fb4bcd0314511109878ab23c98d826661552a (plain)
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
# -*- sh -*-

quote() {
    printf "#${indent}define $1"
    shift
    ${1+printf} ${1+' "%s"'$sep} ${1+"$@"}
    echo
}

archs=""
arch_flag=""

parse_arch_flags() {
    for arch in $1; do
	archs="${archs:+$archs }${arch%=*}"
    done

    while shift && [ "$#" -gt 0 ]; do
	case "$1" in
	    -arch)
		shift
		archs="${archs:+$archs }$1"
		;;
	    *)
		arch_flag="${arch_flag:+${arch_flag} }$1"
		;;
	esac
    done
}

define_arch_flags() {
    ${archs:+echo} ${archs:+'#if 0'}
    for arch in $archs; do
	echo "#elif defined __${arch}__"
	quote "MJIT_ARCHFLAG   " -arch "${arch}"
    done
    ${archs:+echo} ${archs:+'#else'}
    quote "MJIT_ARCHFLAG    /* ${arch_flag:-no flag} */" ${arch_flag}
    ${archs:+echo} ${archs:+'#endif'}
}