-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathexport.sh
More file actions
40 lines (36 loc) · 1.08 KB
/
export.sh
File metadata and controls
40 lines (36 loc) · 1.08 KB
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
#!/bin/sh
outdir=$1
shift
walkdeps()
{
echo $3
cat $3/SOURCES 2>/dev/null | sed -e "s:^..*:$3/&:" | xargs -r dirname
for dep in $([ -f $3/DEPS ] && gcc -E -P -x c -DASM_FILE -DTARGET_$(echo $1 | tr / _) -DTARGET=$1 -DCONFIG_H=target/$1/config.h -DTARGET_H=target/$1/target.h -Isrc -D$2 $3/DEPS | grep -v '^\#' | sed -e "s:^..*:$3/&:")
do
walkdeps $1 $2 $dep
done
}
mkdir -p $outdir
echo "[CP] Makefile"
cp Makefile $outdir/
echo "[GEN] TARGETS"
rm -f $outdir/TARGETS
make clean
(
echo src/.
for target in $*
do
echo $target >> $outdir/TARGETS
for build in debug release
do
walkdeps $target $(echo $build | tr '[a-z]' '[A-Z]') src
make -k TARGET=$target TYPE=$build >&2
done
done
find build | grep -E '.dep$' | xargs cat | tr '\\:\n' ' ' | tr -s ' ' '\n' | xargs -r dirname
) | grep '^src/' | sort | uniq | xargs -n 1 readlink -e | sort | uniq | sed -e "s:$(pwd)/\\(.*\\):\\1:" | while read dir
do
echo "[CP] $dir"
mkdir -p $outdir/$dir
cp $dir/* $outdir/$dir/ 2>/dev/null
done