all: installed

#
# Download, extract and compile from a released tarball:
#
TARBALL = build/octovis.tar.gz
TARBALL_URL = https://code.ros.org/svn/release/download/thirdparty/octomap/octovis-1.2.0.tar.gz
#TARBALL_PATCH = 
INITIAL_DIR = build/octovis
SOURCE_DIR = build/octovis-tar
include $(shell rospack find mk)/download_unpack_build.mk


#
# Use the following commented block (instead of the one above)
# to work on a SVN checkout of OctoMap. This will not work with
# ROS stack releases.
#
#SVN_DIR = build/octomap-svn
#SVN_URL = https://octomap.svn.sourceforge.net/svnroot/octomap/trunk/octomap
# latest code from trunk: empty revision
#SVN_REVISION = 
#SVN_PATCH = 
#include $(shell rospack find mk)/svn_checkout.mk
#SOURCE_DIR=$(SVN_DIR)
#

INSTALL_DIR = octovis
CMAKE = cmake 
CMAKE_ARGS = -D CMAKE_BUILD_TYPE="Release" \
	     -D CMAKE_INSTALL_PREFIX=`rospack find octovis`/$(INSTALL_DIR) \
	     -D WITH_ROS=ON \
	     -D octomap_DIR=$(shell rospack find octomap)/octomap/lib/cmake/octomap/	     
	     
# -D octomap_DIR=/home/hornunga/code/alufr-ros-pkg/octomap_mapping/octomap/octomap/lib/cmake/octomap/
# -D octomap_DIR=$(shell rospack find octomap)/octomap/lib/cmake/octomap/	     



installed: wiped $(SOURCE_DIR)/unpacked
	mkdir -p $(SOURCE_DIR)/build
	cd $(SOURCE_DIR)/build && $(CMAKE) $(CMAKE_ARGS) ..
	cd $(SOURCE_DIR)/build && make $(ROS_PARALLEL_JOBS) && make install
	touch installed

clean:
	rm -rf build
	rm -rf $(INSTALL_DIR) installed

wiped: Makefile
	make wipe
	touch wiped

wipe: clean
	rm -rf build patched
