#!/usr/bin/make -f

# Ubuntu/Debian build rules file for OOlite

# Copyright (c) 2007-2009 Chris Crowther <hikari@hikari.org.uk>
# Copyright (c) 2009      Darren Salt <linux@youmustbejoking.demon.co.uk>
# Copyright (c) 2009      Michael Werle <micha@michaelwerle.com>
# Copyright (c) 2010-2012 Nicolas Boulenguez <nicolas.boulenguez@free.fr>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
	dh $@

GSMAKE = gs_make
GSMAKE += use_deps=no
GSMAKE += ESPEAK=no
GSMAKE += OO_JAVASCRIPT_TRACE=no
GSMAKE += profile=no
GSMAKE += debug=no
GSMAKE += NO_SHADERS=no
GSMAKE += DEPLOYMENT_RELEASE_CONFIGURATION=yes
# DEPLOYMENT_RELEASE_CONFIGURATION=yes implies:
#   BUILD_WITH_DEBUG_FUNCTIONALITY=no
#   OO_CHECK_GL_HEAVY=no
#   OO_EXCLUDE_DEBUG_SUPPORT=yes
#   OO_OXP_VERIFIER_ENABLED=no
#   OO_LOCALIZATION_TOOLS=no
#   DEBUG_GRAPHVIZ=no
GSMAKE += SNAPSHOT_BUILD=no

# Use Debian system-wide mozilla library
GSMAKE += LIBJS_INC_DIR=/usr/include/mozjs
GSMAKE += LIBJS_LIB_DIR=/usr/lib
GSMAKE += LIBJS=mozjs

# Use Debian default build options.
include /usr/share/dpkg/buildflags.mk
# Link only against needed symbols.
LDFLAGS += -Wl,--as-needed
GSMAKE += CFLAGS="$(CFLAGS)"
GSMAKE += LDFLAGS="$(LDFLAGS)"

# Use all processors unless noopt is set in DEB_BUILD_OPTIONS.
# http://www.debian.org/doc/debian-policy/ch-source.html#s-debianrules-options
NUMJOBS := $(filter parallel=%,$(DEB_BUILD_OPTIONS))
ifneq (,$(NUMJOBS))
  MAKEFLAGS += --jobs=$(subst parallel=,,$(NUMJOBS))
else
  MAKEFLAGS += --jobs=$(shell getconf _NPROCESSORS_ONLN)
endif

override_dh_auto_build:
	$(GSMAKE)

override_dh_auto_clean:
	$(GSMAKE) distclean clean
	rm -rf oolite.app

override_dh_installchangelogs:
	dh_installchangelogs --all Doc/CHANGELOG.TXT
