summaryrefslogtreecommitdiff
path: root/nuttx/configs/ea3131/tools/mklpc.sh
blob: 0198a29fc96a4884cec834151947c6badb3b522a (plain) (blame)
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
#!/bin/sh

# This script lies in sub-directory configs/ea3131/tools but make be executed
# from either that directory or TOPDIR

MYNAME=`basename $0`
if [ -x "$PWD/$MYNAME" ]; then
	TOPDIR="$PWD/../../.."
else
	if [ -x "$PWD/configs/ea3131/tools/$MYNAME" ]; then
		TOPDIR="$PWD"
	else
		echo "This script must be executed from a known director"
		exit 1
	fi
fi
echo "TOOLDIR: $TOOLDIR"

# The lpchdr could be named lpchdr.exe if we are running under Cygwin or
# just lpchdr under Linux

TOOLDIR=$TOPDIR/configs/ea3131/tools

if [ ! -d "$TOOLDIR" ]; then
	echo "Tool directory $TOOLDIR does not exist"
	exit 1
fi

if [ -x "$TOOLDIR/lpchdr.exe" ]; then
	LPCHDR="$TOOLDIR/lpchdr.exe"
else
	if  [ -x "$TOOLDIR/lpchdr" ]; then
		LPCHDR="$TOOLDIR/lpchdr"
	else
		echo "lpchdr executable does not exist in $TOODIR"
		echo " - cd $TOOLDIR"
		echo " - make"
	fi
fi
echo "LPCHDR: $LPCHDR"

# Now get the path to the NuttX executable

NUTTXPATH="$TOPDIR/nuttx.bin"

if [ ! -f "$NUTTXPATH" ]; then
	echo "NuttX binary does not exist at $NUTTXPATH"
	echo " - cd $TOPDIR"
	echo " - make"
	exit 1
fi
echo "NUTTXPATH: $NUTTXPATH"

# Create the binary

echo "COMMAND: $LPCHDR -o $TOPDIR/nuttx.lpc $NUTTXPATH"
"$LPCHDR" -o "$TOPDIR/nuttx.lpc" "$NUTTXPATH" || \
	{ echo "$LPCHDR failed" ; exit 1 ; }
echo "Successfully created binary"