#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# This is the debhelper compatibility version to use.
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CXXFLAGS += -O0 -g3
	CFLAGS += -O0 -g3
	export CXXFLAGS CFLAGS
endif

# shared library versions, option 1
#version=2.0.5
#major=2
# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
#version=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
#major=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`

configure: configure-stamp
configure-stamp:
	dh_testdir
	QUILT_PATCHES=debian/patches quilt push -a || test $$? = 2	
	./configure --enable-soname --prefix=/usr --with-trimesh=gimpact --enable-release
	
	touch configure-stamp


build: build-stamp
build-stamp: configure-stamp 
	dh_testdir

	$(MAKE)

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp
	
	# Add here commands to clean up after the build process.
	-$(MAKE) clean
	QUILT_PATCHES=debian/patches quilt pop -a -R || test $$? = 2
	rm -Rf `find -name '.deps' -type d`
	rm -Rf `find -name '.pc' -type d`
	rm -f drawstuff/dstest/Makefile \
			drawstuff/src/Makefile \
			drawstuff/Makefile \
			include/ode/Makefile \
			include/Makefile \
			ode/src/Makefile \
			ode/test/Makefile \
			ode/Makefile \
			Makefile \
			include/ode/config.h \
			include/ode/stamp-h1 \
			config.log \
			config.status \
			ode-config \
			debian/ode-config.1
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/tmp
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
	docbook-to-man debian/ode-config.man.sgml > \
	debian/ode-config.1

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot

	dh_installdocs
	dh_installman -plibode0-dev debian/ode-config.1
	dh_install
	dh_installchangelogs CHANGELOG.txt
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_shlibdeps
	dh_makeshlibs -V 'libode0c2 (>= 0.8)'
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
