aboutsummaryrefslogtreecommitdiff
path: root/recipes-demo/de10-nano-fftsw-apps/files/build_app.sh
blob: d64b34738ecd5ca35e995e4135cba9a2083419ad (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
96
97
98
99
100
101
102
103
104
#!/bin/sh

CC_TEST="${CC:?}"
type -t ${CC%${CC#*gcc}} > /dev/null 2>&1 || {
	echo ""
	echo "ERROR: cross compiler tools are not visible in the environment."
	echo ""
	exit 1
}

THE_SYSROOT="$(${CC:?} -print-sysroot)"

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

[ -f "${THE_SYSROOT:?}${libdir:?}/libNE10.so" ] || {
	echo ""
	echo "ERROR: cannot locate library archive 'libNE10.so'."
	echo "ERROR: '${THE_SYSROOT:?}${libdir:?}/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
}

${CC:?} \
	-march=armv7-a \
	-mfloat-abi=hard \
	-mfpu=neon \
	-mthumb-interwork \
	-mthumb \
	-O2 -D_FORTIFY_SOURCE=2 \
	-g \
	-feliminate-unused-debug-types  \
	-std=gnu99 \
	-W \
	-Wall \
	-Werror \
	-Wc++-compat \
	-Wwrite-strings \
	-Wstrict-prototypes \
	-Wformat -Wformat-security \
	-pedantic \
	-fstack-protector-strong \
	-z noexecstack \
	-z relro -z now \
	-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
}

${CXX:?} \
	-march=armv7-a \
	-mfloat-abi=hard \
	-mfpu=neon \
	-mthumb-interwork \
	-mthumb \
	-O2 -D_FORTIFY_SOURCE=2 \
	-Wformat -Wformat-security \
	-fstack-protector-strong \
	-z noexecstack \
	-z relro -z now \
	-g \
	"${1}.o" \
	-o "${1}" \
	-L. \
	-loverhead \
	-lNE10 \
	-lm