aboutsummaryrefslogtreecommitdiff
path: root/recipes-demo/de10-nano-fftsw-apps/files/target_build_app.sh
blob: eba649d2514ea09a1241201af84c2ca56bd0897b (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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh

type -t gcc > /dev/null 2>&1 || {
	echo ""
	echo "ERROR: cross compiler tools are not visible in the environment."
	echo ""
	exit 1
}

THE_SYSROOT="$(gcc -print-sysroot)"

[ -f "${THE_SYSROOT:?}/usr/include/NE10.h" ] || {
        echo ""
        echo "ERROR: cannot locate include file 'NE10.h'."
        echo "ERROR: '${THE_SYSROOT:?}/usr/include/NE10.h'"
        echo ""
        exit 1
}

[ -f "${THE_SYSROOT:?}/usr/lib/libNE10.so" ] || {
        echo ""
        echo "ERROR: cannot locate library archive 'libNE10.so'."
        echo "ERROR: '${THE_SYSROOT:?}/usr/lib/libNE10.so'"
        echo ""
        exit 1
}

[ "$#" -eq "1" ] || {
	echo ""
	echo "USAGE: ${0} <application name>"
	echo ""
	exit 1
}

[ -e "${1}" ] && {
	echo ""
	echo "${1} already exists"
	echo "please remove it and try again"
	echo "rm ${1}"
	echo ""
	exit 1
}

[ -e "${1}.c" ] || {
	echo ""
	echo "${1}.c does not exists"
	echo "cannot compile it"
	echo ""
	exit 1
}

gcc \
	-march=armv7-a \
	-mfloat-abi=hard \
	-mfpu=neon \
	-mthumb-interwork \
	-mthumb \
	-O2 \
	-g \
	-feliminate-unused-debug-types  \
	-std=gnu99 \
	-W \
	-Wall \
	-Werror \
	-Wc++-compat \
	-Wwrite-strings \
	-Wstrict-prototypes \
	-pedantic \
	-o "${1}.o" \
	-c \
	"${1}.c"

[ "${1}.c" -nt "${1}.o" ] && {
	echo ""
	echo "${1}.c is newer than ${1}.o"
	echo "cannot link it"
	echo ""
	exit 1
}

g++ \
	-march=armv7-a \
	-mfloat-abi=hard \
	-mfpu=neon \
	-mthumb-interwork \
	-mthumb \
	-O2 \
	-g \
	"${1}.o" \
	-o "${1}" \
	-L. \
	-loverhead \
	-lNE10 \
	-lm