-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew-openwrt-toolchain
executable file
·55 lines (49 loc) · 1.19 KB
/
new-openwrt-toolchain
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
#!/bin/sh
if [ $# -lt 5 ]; then
echo "Usage:
$0 targetdir toolchaindir archprefix dest platform
"
exit 1
fi
targetdir=$1
toolchaindir=$2
archprefix=$3
dest=$4
platform=$5
[ -d "$targetdir/pkginfo" ] || { echo "error: no '$targetdir/pkginfo' directory found"; exit 1; }
[ -e "$toolchaindir/info.mk" ] || { echo "error: no '$toolchaindir/info.mk' file found"; exit 1; }
[ -x "$toolchaindir/bin/$archprefix-gcc" ] || { echo "error: '$toolchaindir/bin/$archprefix-gcc' does not exist or is not executable"; exit 1; }
rm -rf "$dest" && mkdir -p "$dest" && cd "$dest" || exit 1
makescript() {
{
cat <<EOF
#/bin/sh
export STAGING_DIR="$targetdir"
export PATH="$toolchaindir/bin:\$PATH"
EOF
cat
} > "$1"
chmod u+x "$1"
}
makescript env <<EOF
EOF
makescript compile-c <<EOF
$archprefix-gcc $CFLAGS "\$@"
EOF
makescript compile-c++ <<EOF
$archprefix-g++ $CFLAGS $CPPFLAGS "\$@"
EOF
makescript link <<EOF
$archprefix-gcc $LDFLAGS "\$@"
EOF
makescript strip <<EOF
$archprefix-strip -d "\$@"
EOF
makescript make-static-lib <<EOF
$archprefix-ar rcs "\$@"
EOF
echo "PLATFORM_STRING=$platform" > platform
cat <<EOF > platform.h
#define PLATFORM_STRING "$platform"
#define TOOLCHAIN_ARCH "$(basename "$dest")"
EOF