contrib/jenkins.sh: Harmonize with what we do in other projects

most importantly:
* conditional build of manuals
* enforce build of manuals if enabled
* publish manuals, if requested

Change-Id: I4ed51fd5aa9d861ea4795e33b6201c15b2281b53
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 347ea9b..30db3d7 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -1,5 +1,10 @@
 #!/bin/sh
 # jenkins build helper script for libosmo-abis.  This is how we build on jenkins.osmocom.org
+#
+# environment variables:
+# * WITH_MANUALS: build manual PDFs if set to "1"
+# * PUBLISH: upload manuals after building if set to "1" (ignored without WITH_MANUALS = "1")
+#
 
 if ! [ -x "$(command -v osmo-build-dep.sh)" ]; then
 	echo "Error: We need to have scripts/osmo-deps.sh from http://git.osmocom.org/osmo-ci/ in PATH !"
@@ -21,12 +26,20 @@
 
 export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
 export LD_LIBRARY_PATH="$inst/lib"
+export PATH="$inst/bin:$PATH"
 
 osmo-build-dep.sh libosmocore "" --disable-doxygen
 osmo-build-dep.sh libosmo-abis
 osmo-build-dep.sh libosmo-netif
 osmo-build-dep.sh simtrace2
 
+# Additional configure options and depends
+CONFIG=""
+if [ "$WITH_MANUALS" = "1" ]; then
+	osmo-build-dep.sh osmo-gsm-manuals
+	CONFIG="--enable-manuals"
+fi
+
 set +x
 echo
 echo
@@ -35,11 +48,18 @@
 echo
 set -x
 
+cd "$base"
 autoreconf --install --force
-./configure --enable-sanitize #--enable-werror
+./configure --enable-sanitize --enable-werror $CONFIG
 $MAKE $PARALLEL_MAKE
-$MAKE distcheck \
+LD_LIBRARY_PATH="$inst/lib" \
+  DISTCHCK_CONFIGURE_FLAGS="--enable-werror $CONFIG" \
+  $MAKE distcheck \
   || cat-testlogs.sh
-$MAKE maintainer-clean
 
+if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then
+	make -C "$base/doc/manuals" publish
+fi
+
+$MAKE maintainer-clean
 osmo-clean-workspace.sh