#!/usr/bin/make -f
# -*- makefile -*-

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

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

#XXX old: TOOLS:=tsnullshaper ts2pes esaudio2pes tsororts eitsecfilter mpe2sec tstdt txt2pes tscbrmuxer tsudpsend tspcrrestamp vbv esvideompeg2info pes2txt tsstamp tsccc tspcrstamp pes2es tsmodder ts2sec tstcpsend tsoutputswitch sec2ts tstimedwrite tsmask pesaudio2ts esaudioinfo tstimeout m2ts2ts tsfixcc tsudpreceive dsmcc-receive eitsecmapper tspidmapper tsdoubleoutput tsnullfiller tsorts tsprinter zpipe pesdata2ts i13942ts esvideompeg2pes ts2m2ts tspcrmeasure pesinfo pesvideo2ts tsfilter tsinputswitch tsloop tstcpreceive tsvbr2cbr tscrypt

TOOLS:=oc2sec sec2ts zpipe tsfilter tsloop tsmodder tsnullfiller tsnullshaper tspcrmeasure tspidmapper esaudio2pes esaudioinfo esvideompeg2pes esvideompeg2info pes2es pesaudio2ts pesvideo2ts pesinfo tsstamp ts2pes mpe2sec tscbrmuxer mpeg2videovbv tstdt i13942ts tsvbr2cbr tsfixcc tsudpreceive tsudpsend dsmcc-receive tspcrstamp tstcpreceive tstcpsend tstimeout tstimedwrite tsinputswitch tsdoubleoutput pes2txt tsoutputswitch tsccc txt2pes ts2sec pesdata2ts tsmask tsorts tsororts tspcrrestamp tsprinter eitsecfilter eitsecmapper m2ts2ts ts2m2ts tsdiscont eitsecactualtoanother tscrypt


%:
	dh $@ --with python2

override_dh_auto_install:
	dh_auto_install
	mkdir -p debian/opencaster/usr/bin
	
	for TOOL in $(TOOLS); do \
	   echo "process $$TOOL"; \
	   cp tools/$$TOOL/$$TOOL debian/opencaster/usr/bin; \
        done
	# due to a conflict this has to be renamed
	# upstream will do the same in the next release
	mv debian/opencaster/usr/bin/m2ts2ts debian/opencaster/usr/bin/m2ts2cbrts

	cp tools/oc2sec/mod2sec.py debian/opencaster/usr/bin/mod2sec
	cp tools/oc2sec/file2mod.py debian/opencaster/usr/bin/file2mod
	cp tools/oc2sec/oc-update.sh debian/opencaster/usr/bin/oc-update

	mkdir -p debian/opencaster-doc/usr/share/doc/opencaster-doc
	cp -a tutorials debian/opencaster-doc/usr/share/doc/opencaster-doc

get-orig-source:
	./debian/get-orig-source
