#!/usr/bin/make -f
#
# @package      hubzero-submit-condor
# @file         rules
# @copyright    Copyright (c) 2010-2020 The Regents of the University of California.
# @license      http://opensource.org/licenses/Apache-2.0 Apache2
#
# Copyright (c) 2010-2020 The Regents of the University of California.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# HUBzero is a registered trademark of The Regents of the University of California.
#

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

$(info ########## Goals: $(MAKECMDGOALS) ##########)

CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)
CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS)
LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)

export CFLAGS
export CPPFLAGS
export CXXFLAGS
export LDFLAGS

DEB_MAJOR:=$(shell lsb_release -r -s | cut -d . -f 1)

configure:
	@echo "########## configure ##########"
	dh_testdir
	>$@

build: configure
	@echo "########## build ##########"
	dh_testdir
	$(MAKE)
	cp $(CURDIR)/condor_grid $(CURDIR)/debian/condor_grid.init
	>$@

clean:
	@echo "########## clean ##########"
	dh_testdir
	dh_testroot
	rm -fr build configure
	$(MAKE) clean
	rm -f $(CURDIR)/debian/condor_grid.init
	dh_clean

install: build
	@echo "########## install ##########"
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	$(MAKE) DESTDIR=$(CURDIR)/debian/hubzero-submit-condor install

binary-indep: install
	@echo "########## binary-indep ##########"
	dh_testdir -i
	dh_testroot -i
	dh_installchangelogs -i
	dh_installdocs -i
	dh_installexamples -i
	dh_install -i
	dh_installlogrotate -i
	dh_installinit -i
	dh_installman -i
	#dh_python2 -i
	dh_link -i
	dh_strip -i
	dh_lintian -i
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_shlibdeps -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch: install
	@echo "########## binary-arch ##########"
	dh_testdir -a
	dh_testroot -a
	dh_installchangelogs -a
	dh_installdocs -a
	dh_installexamples -a
	dh_install -a
	dh_installlogrotate -a
	dh_installinit -a --name=condor_grid
	dh_installman -a
	dh_link -a
	dh_strip -a
	dh_lintian -a
	dh_compress -a
	dh_fixperms -a
	dh_installdeb -a
	#dh_shlibdeps -a -Xlib/native
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

#binary: binary-indep 
binary: binary-arch
	@echo "########## binary ##########"

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