forked from WellDone/gpsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·112 lines (88 loc) · 1.88 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
#!/bin/bash
set -e
#Get the directory this script is in
#From http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
SRCDIR="$BASEDIR/src"
SRCNAME="src"
BUILDNAME="build"
GPSIMBUILDDIR="$BASEDIR/build"
OUTDIR="$BASEDIR/out"
#SVN_URL="svn://svn.code.sf.net/p/gpsim/code/trunk"
OLDDIR=`pwd`
#Programs that we need
LIBTOOL="libtoolize"
function usage {
echo "Usage: build.sh [link|configure|make|clean|package]"
exit 1
}
function link_gpsim {
mkdir -p $GPSIMBUILDDIR
cd "$SRCDIR"
echo "Linking src directory to build directory."
#More cross platform way to do the symbolic linking
#(other way does not work on os x b/c bsd find does not support -printf
find . -type d -exec mkdir -p ../$BUILDNAME/{} \;
find . -type f -exec ln -sf "$SRCDIR/{}" ../$BUILDNAME/{} \;
#find $SRCDIR -mindepth 1 -depth -type d -printf \"%P\n\" | while read dir; do mkdir -p "$dir"; done
#find $SRCDIR -type f -printf \"%P\n\" | while read file; do ln -sf "$SRCDIR/$file" "$file"; done
cd ..
}
function configure_gpsim {
#rm -rf $GPSIMBUILDDIR
./build.sh link
rm -rf $GPSIMBUILDDIR/m4
cp -prf $SRCDIR/m4 $GPSIMBUILDDIR/
cd "$GPSIMBUILDDIR"
autoreconf --install --force
./configure --prefix="$OUTDIR" --disable-gui
cd ..
}
function make_gpsim {
cd "$GPSIMBUILDDIR"
make "$@"
make install
cd ..
}
function clean_gpsim {
rm -rf "$GPSIMBUILDDIR"
rm -rf "$OUTDIR"
}
function package_gpsim {
cd $OUTDIR && tar czf $BASEDIR/gpsim.tar.gz ./*
}
#Process Options
if (($#==0)); then
usage
fi
cd "$BASEDIR"
if [ ! -d $GPSIMBUILDDIR ]; then
mkdir "$GPSIMBUILDDIR"
fi
if [ ! -d $OUTDIR ]; then
mkdir "$OUTDIR"
fi
task="$1"
shift
case $task in
link)
link_gpsim
;;
configure)
configure_gpsim
;;
make)
make_gpsim
;;
clean)
clean_gpsim
;;
package)
package_gpsim
;;
*)
usage
;;
esac
cd "$OLDDIR"
exit 0