-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.sh
123 lines (99 loc) · 2.96 KB
/
build.sh
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#! /bin/sh
# build script
# N.B we assume file names are not replicated throughout tree, except for build flavor overloading
set -a
ROOTDIR=`pwd -L`
case `uname 2>/dev/null` in
Windows*)
PATHSEP=";"
;;
Linux|CYGWIN*)
PATHSEP=":"
;;
esac
GOAL=
if [ X${1:-} = X-ac ]; then
GOAL=allclean
shift 1
fi
if [ X${1:-} = X-c ]; then
GOAL=clean
shift 1
fi
if [ X${1:-} = X-dc ]; then
GOAL=depclean
shift 1
fi
if [ X${1:-} = X-l ]; then
GOAL=list
shift 1
fi
unset TARGET TARGETTYPE ASMS LCFS SOURCES LIBS ALLCLEANS INCLUDES DEFINES
case `uname 2>/dev/null` in
Windows*|CYGWIN*)
build="windows"
;;
Linux)
build="linux"
;;
esac
# our build flavors are below
grep -v "^#" <<EOF | while read TARGET BUILD CPU
stickos windows.STICK_GUEST 512HBL.PIC32.__32MX440F512H__.HIDBL
stickos windows.STICK_GUEST 512H.PIC32.__32MX440F512H__
stickos windows.STICK_GUEST 512LBL.PIC32.__32MX460F512L__.HIDBL
stickos windows.STICK_GUEST 512L.PIC32.__32MX460F512L__
stickos windows.STICK_GUEST 795HBL.PIC32.__32MX795F512H__.HIDBL
stickos windows.STICK_GUEST 795H.PIC32.__32MX795F512H__
stickos windows.STICK_GUEST 795LBL.PIC32.__32MX795F512L__.HIDBL
stickos windows.STICK_GUEST 795L.PIC32.__32MX795F512L__
stickos windows.STICK_GUEST UNO32.CHIPKIT.PIC32.__32MX320F128H__
stickos windows.STICK_GUEST MAX32.CHIPKIT.PIC32.__32MX795F512L__
EOF
do
for MODE in DEBUG RELEASE; do
# exclude flavors not requested by the user
for i in $*; do
if echo "$TARGET $BUILD $CPU $MODE" | grep -i $i >/dev/null; then
:
else
continue 2
fi
done
# exclude impossible flavor combinations
if [ ${BUILD%%.*} = linux -a $build = windows ]; then
continue
fi
if [ ${BUILD%%.*} = windows -a $build = linux ]; then
continue
fi
if [ ${BUILD%%.*} = cw6 -a $build = linux ]; then
continue
fi
if [ ${BUILD%%.*} = cw7 -a $build = linux ]; then
continue
fi
PATHS=`echo $TARGET $BUILD $CPU $MODE | sed 's![.]! !g'`
echo "*** $PATHS ***"
# compute all possible source/include directories
DIRS=`find . -name \*.[Cchs] -o -name \*.lcf | sed 's!/[^/]*$!!' | sort -u | sed 's!$!/;!'`
# select preferred sources/include directories
SOURCEDIRS=`for i in $PATHS; do echo "$DIRS" | grep -i "/$i/"; done`
# append remaining source/include directories
PATHS=`echo $PATHS | sed 's! !/|/!g'`
SOURCEDIRS=`echo "$SOURCEDIRS"; echo "$DIRS" | grep -viE "/$PATHS/"`
# make source/include directories absolute
SOURCEDIRS=`echo $SOURCEDIRS | sed "s![.]/!$ROOTDIR/!g"`
# specify object directory name
OBJDIR=obj.${BUILD%%.*}.${CPU%%.*}.${MODE%%.*}
# finally, make the target flavor
# N.B. we pass ROOTDIR, PATHSEP, TARGET, BUILD, CPU, MODE, SOURCEDIRS, OBJDIR thru environment
if make --no-print-directory -C $TARGET -f Makefile.$TARGET $GOAL; then
:
else
exit 1
fi
echo
done
done
echo "build done!"