Fixed bug in test/buildtest.sh when opensync is not pre-built
[barry/pauldeden.git] / test / buildtest.sh
blob080ade03d4ae6ccced3f8c99d0f66db4d60bccb7
1 #!/bin/sh
4 # Edit these settings to reflect your system
6 MAKEOPTS=-j3
7 export CC="ccache gcc"
8 export CXX="ccache g++"
10 # Make sure any errors stop the test
11 set -e
13 Usage() {
14 echo "Main Barry build test script."
15 echo
16 echo "Usage:"
17 echo " ./buildtest.sh /path/to/libopensync-0.22.tar.bz2"
18 echo
19 echo "Or, write a ~/.barrytest file that contains the directory"
20 echo "you used as a --prefix when building your own libopensync."
21 echo "Note that this directory must be writable by the user that"
22 echo "runs the test, as the plugin will be installed during the"
23 echo "build test."
24 echo
27 if [ "$1" = "-h" ] ; then
28 Usage
29 exit 1
33 # Jump to directory that script is located, if necessary
36 if [ "$(dirname $0)" != "." ] ; then
37 cd "$(pwd)/$(dirname $0)"
38 echo "You ran the script outside the directory it is in."
39 echo "Changing directory to: $(pwd)"
40 echo "If this is not desired, abort now..."
41 sleep 1s
44 if [ -d "build" ] ; then
45 echo "'build' directory already exists, exiting..."
46 exit 1
49 BASEPATH=$(pwd)
50 OSYNCSOURCE="$1"
52 mkdir -p build
55 # First, build opensync in a local directory
58 if [ -z "$OSYNCSOURCE" -a -f ~/.barrytest ] ; then
59 read OSYNCROOTDIR < ~/.barrytest
60 elif [ -n "$OSYNCSOURCE" ] ; then
61 echo "Extracting opensync sources and building..."
62 (cd build && tar xjf "$OSYNCSOURCE" && \
63 cd libopensync-0.22 && \
64 ./configure -prefix="$BASEPATH/build/osyncrootdir" && \
65 make $MAKEOPTS install)
66 OSYNCROOTDIR="$BASEPATH/build/osyncrootdir"
67 else
68 Usage
69 exit 1
71 echo "Using opensync rootdir: $OSYNCROOTDIR"
76 # Move .. barry into its own buildable directory
79 mkdir -p build/barry
80 (tar -C .. --exclude=CVS --exclude=.git --exclude=test/build -cf - . | \
81 tar -C build/barry -xf -)
82 diff -ruN --exclude=CVS --exclude=.git --exclude=test .. build/barry
87 # Prepare for Barry building
89 cd build/barry
90 export PKG_CONFIG_PATH="$BASEPATH/build/rootdir/lib/pkgconfig:$OSYNCROOTDIR/lib/pkgconfig"
94 # Create configure script
96 ./buildgen.sh
100 # Build and test as individual packages
102 echo "Individual package build test..."
104 rm -rf "$BASEPATH/build/rootdir"
106 export CXXFLAGS="-Wall -Werror -pedantic -O0 -g"
107 ./configure --prefix="$BASEPATH/build/rootdir"
108 make $MAKEOPTS
109 make distclean
110 ./configure --prefix="$BASEPATH/build/rootdir" --with-boost
111 make $MAKEOPTS
112 make install
113 make distclean
115 cd gui
116 export CXXFLAGS="-Wall -Werror -pedantic -O0 -g"
117 ./configure --prefix="$BASEPATH/build/rootdir"
118 make $MAKEOPTS install
119 make distclean
120 cd ..
122 cd opensync-plugin
123 export CXXFLAGS="-Wall -Werror -O0 -g"
124 ./configure --prefix="$BASEPATH/build/rootdir"
125 make $MAKEOPTS install
126 make distclean
127 cd ..
132 # Build and test as one package
135 echo "Single build test..."
137 rm -rf "$BASEPATH/build/rootdir"
139 export CXXFLAGS="-Wall -Werror -O0 -g"
140 ./configure --prefix="$BASEPATH/build/rootdir" --with-boost \
141 --enable-gui --enable-opensync-plugin
142 make $MAKEOPTS install
143 make distclean
144 ./configure --prefix="$BASEPATH/build/rootdir" \
145 --enable-gui --enable-opensync-plugin
146 make $MAKEOPTS
147 make distclean
151 # Test that cleanall cleans up all traces
153 ./buildgen.sh cleanall
154 cd "$BASEPATH"
155 diff -ruN --exclude=CVS --exclude=.git --exclude=test .. build/barry
156 cd build/barry
161 # Test 'make dist' (the dist family of targets leaves build evidence
162 # behind, so do this after the cleanall check)
164 echo "Testing 'make dist'..."
166 rm -rf "$BASEPATH/build/rootdir"
168 ./buildgen.sh
169 ./configure --enable-gui --enable-opensync-plugin
170 make dist
171 make distcheck
172 make distclean
177 # Success
179 cd "$BASEPATH"
180 rm -rf "$BASEPATH/build"
181 echo "All tests passed."