debian swirl logo

Back to the packages list gpsshogi

#!/usr/bin/make -f

SOURCE = $(shell dpkg-parsechangelog | grep "^Source" | sed "s/Source: //")
VERSION = $(shell dpkg-parsechangelog | grep "^Version" | sed "s/Version: //")
ORIG_VERSION = $(shell echo $(VERSION) | sed "s/-.*//")
PRISTINE_VERSION = $(shell echo $(ORIG_VERSION) | sed "s/\+dfsg//")
UPSTREAM_VERSION = $(shell echo $(PRISTINE_VERSION) | sed "s/^0\.0\.//")
SRCDIR_NAME = $(SOURCE)-$(ORIG_VERSION).orig

DPKG_EXPORT_BUILDFLAGS = 1

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk
include /usr/share/dpkg/buildflags.mk
CFLAGS+= $(CPPFLAGS)
CXXFLAGS+= $(CPPFLAGS)

DEB_MAKE_CLEAN_TARGET   = clean
DEB_MAKE_BUILD_TARGET   = all
DEB_MAKE_INSTALL_TARGET = 
DEB_MAKE_CHECK_TARGET   = 

DEB_MAKE_PARALLEL ?= $(and $(DEB_BUILD_PARALLEL),$(DEB_PARALLEL_JOBS),-j$(DEB_PARALLEL_JOBS))

so_ver= 1

DEB_DBG_PACKAGE_gpsshogi = gpsshogi-dbg
DEB_INSTALL_DIRS_gpsshogi += usr/games
DEB_INSTALL_MANPAGES_gpsshogi += debian/gpsusi.1
DEB_INSTALL_MANPAGES_gpsshogi += debian/gpsshogi.1
DEB_INSTALL_MANPAGES_gpsshogi += debian/gpsshell.1
DEB_INSTALL_MANPAGES_gpsshogi += debian/gpsshogi-viewer.1
DEB_INSTALL_DOCS_gpsshogi += debian/epl-v10.txt
DEB_INSTALL_DIRS_gpsshogi_data += usr/share/gpsshogi-data/data

pre-build::
		cp $(CURDIR)/debian/qt-common-local.pro.$(DEB_HOST_ARCH_CPU) $(CURDIR)/qt-common-local.pro

build/gpsshogi::
	# gpsusi, gpsshogi
		$(MAKE) -C bin OSL_HOME=/usr/share/libosl-dev OSL_HOME_FLAGS=-DOSL_HOME=\\\"/usr/share/gpsshogi-data\\\" FILE_TCMALLOC='' FILE_OSL_ALL='' LDFLAGS='-Wl,--as-needed `dpkg-buildflags --get LDFLAGS`' LDLIBS='-losl -lboost_date_time -lboost_filesystem -lboost_serialization -lboost_iostreams -lboost_system -ltcmalloc_minimal' RELEASE=t gpsshogi gpsusi
		help2man --section 6 -n "GPSShogi for XShogi and the CSA protocol" --no-info \
		  $(CURDIR)/bin/gpsshogi > $(CURDIR)/debian/gpsshogi.1
		help2man --section 6 -n "GPSShogi for the USI protocol" --no-info \
		  $(CURDIR)/bin/gpsusi > $(CURDIR)/debian/gpsusi.1
	# gpsshell
		$(MAKE) -C sample/gpsshell OSL_HOME=/usr/share/libosl-dev OSL_HOME_FLAGS=-DOSL_HOME=\\\"/usr/share/gpsshogi-data\\\" FILE_TCMALLOC='' FILE_OSL_ALL='' LDFLAGS='-Wl,--as-needed `dpkg-buildflags --get LDFLAGS`' LDLIBS='-losl -lboost_date_time -lboost_filesystem -lboost_serialization -lboost_iostreams -lboost_system -ltcmalloc_minimal' RELEASE=t gpsshell
		help2man --section 6 -n "GPSShogi shell like client" --version-string "gpsshell" --no-info \
		  $(CURDIR)/sample/gpsshell/gpsshell > $(CURDIR)/debian/gpsshell.1
	# viewer
		for dir in lib/gui sample/viewer ; do \
		  (cd $(CURDIR)/$$dir && \
	   qmake OSL_HOME_QT= "" TCMALLOC="" OSL_HOME=/usr/share/libosl-dev && \
		   $(MAKE) OSL_HOME_QT="" TCMALLOC="" OSL_HOME=/usr/share/libosl-dev) ; \
		done

binary-install/gpsshogi::
	dh_install -p$(cdbs_curpkg) --sourcedir= bin gpsshogi gpsusi usr/games
	dh_install -p$(cdbs_curpkg) --sourcedir= sample/gpsshell gpsshell usr/games
		mv $(CURDIR)/sample/viewer/viewer $(CURDIR)/sample/viewer/gpsshogi-viewer 
	dh_install -p$(cdbs_curpkg) --sourcedir= sample/viewer gpsshogi-viewer usr/games
		for file in gpsusi gpsshogi gpsshell gpsshogi-viewer ; do \
		  chrpath --delete $(CURDIR)/debian/$(cdbs_curpkg)/usr/games/$$file ; \
		done

binary-install/gpsshogi-data::
	dh_install -p$(cdbs_curpkg) --sourcedir= data joseki.dat usr/share/$(cdbs_curpkg)/data
	dh_install -p$(cdbs_curpkg) --sourcedir= data -X.pl -X.svn rating usr/share/$(cdbs_curpkg)/data
		for file in \
		  sibling-attack.pair eval.bin eval-info.txt \
		  move-order.bin move-order-info.txt move-tactical.txt \
		  progress.txt progress-info.txt ; \
		do \
	  dh_install -p$(cdbs_curpkg) --sourcedir= data $$file usr/share/$(cdbs_curpkg)/data ; \
		done

clean::
		for dir in lib/gui sample/viewer ; do \
		  [ ! -f $$dir/Makefile ] || $(MAKE) -C $$dir OSL_HOME=/usr/share/libosl-dev distclean ; \
		done
		for dir in lib bin sample/gpsshell ; do \
		  $(MAKE) -C $$dir OSL_HOME=/usr/share/libosl-dev clean ; \
		done
		-rm -f $(CURDIR)/sample/viewer/gpsshogi-viewer
		-rm -f $(CURDIR)/qt-common-local.pro
		for file in gpsusi gpsshogi gpsshell ; do \
		  rm -rf $(CURDIR)/debian/$$file.1 ; \
		done

get-orig-source:
		if [ ! -f gpsshogi.tar.gz ] ; then \
	  wget -O gpsshogi.tar.gz "http://gps.tanaka.ecc.u-tokyo.ac.jp/cgi-bin/viewvc.cgi/trunk/gpsshogi.tar.gz?root= gpsshogi&view=tar" ; \
        fi
		mkdir debian/$(SRCDIR_NAME)
		cd debian/$(SRCDIR_NAME) && tar xzvf ../../gpsshogi.tar.gz
		if test "`ls debian/$(SRCDIR_NAME) | wc -l`" -eq "1" ; then \
	        subdir= `echo debian/$(SRCDIR_NAME)/*` && \
			find $$subdir -mindepth 1 -maxdepth 1 -exec mv -t debian/$(SRCDIR_NAME) -- {} + && \
		        rmdir $$subdir ; \
		fi
		tar czf ../$(SOURCE)_$(ORIG_VERSION).orig.tar.gz -C debian $(SRCDIR_NAME)
		rm -rf debian/$(SRCDIR_NAME)

Builds:

gpsshogi-data
data files for gpsshogi
gpsshogi-dbg
shogi playing program based on openshogilib
gpsshogi
shogi playing program based on openshogilib