#!/usr/bin/make -f
# -*- makefile -*-
# This file was originally written by Vollstrecker

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


# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

CFLAGS = -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif

#Here are the packages that can't be compiled separate now
general_pkgs = "amule-common"\
	"amule-skin-gnome"\
	"amule-skin-kde4"\
	"amule-skin-tango"\
	"amule-skin-xfce"\
	"amule-theme-default"\
	"amule-theme-php-default"\
	"amule-theme-chicane"\
	"amule-xas"

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif

# First, get the targets from commandline
flags = ${MAKECMDGOALS}

#First we have to find out, if we are called from dpkg-buildpackage

ifeq ("binary", "$(findstring binary, $(flags))")

	WXCAS = --enable-wxcas
	CAS = --enable-cas
	WEBSERVER = --enable-webserver
	REMOTEGUI = --enable-amule-gui
	DAEMON = --enable-amule-daemon
	ALCC = --enable-alcc
	ALC = --enable-alc
	AMULECMD = --enable-amulecmd
	DEBUGGING = --enable-debug --disable-optimise --disable-profile
	LANGFLAG = --with-language=all

else ifeq ("clean", "$(findstring clean, $(flags))")

	WXCAS = --enable-wxcas
	CAS = --enable-cas
	WEBSERVER = --enable-webserver
	REMOTEGUI = --enable-amule-gui
	DAEMON = --enable-amule-daemon
	ALCC = --enable-alcc
	ALC = --enable-alc
	AMULECMD = --enable-amulecmd
	DEBUGGING = --enable-debug --disable-optimise --disable-profile
	LANGFLAG = --with-language=all

else ifeq ("build", "$(findstring build, $(flags))")

	WXCAS = --enable-wxcas
	CAS = --enable-cas
	WEBSERVER = --enable-webserver
	REMOTEGUI = --enable-amule-gui
	DAEMON = --enable-amule-daemon
	ALCC = --enable-alcc
	ALC = --enable-alc
	AMULECMD = --enable-amulecmd
	DEBUGGING = --enable-debug --disable-optimise --disable-profile
	LANGFLAG = --with-language=all

else
	#Now we have to check what packages are build to configure only them

	#We have to filter the right targets (wo_ means without)
	wo_wxcas = $(subst wxcas, , ${flags})
	wo_alcc = $(subst alcc, , ${flags})
	wo_amule_utils_gui = $(subst amule-utils-gui, ,${flags})
	wo_all_other_amules = $(subst amulecmd, ,$(subst amule-utils-gui, ,$(subst amule-utils, ,${flags})))
	LANGUAGE := en_GB

	ifeq ("wxcas", "$(findstring wxcas, $(flags))")
		WXCAS = --enable-wxcas
	endif

	ifeq ("cas", "$(findstring cas, $(wo_wxcas))")
		CAS = --enable-cas
	endif

	ifeq ("webserver", "$(findstring webserver, $(flags))")
		WEBSERVER = --enable-webserver
	endif

	ifeq ("remotegui", "$(findstring remotegui, $(flags))")
		REMOTEGUI = --enable-amule-gui
	endif

	ifeq ("daemon", "$(findstring daemon, $(flags))")
		DAEMON = --enable-amule-daemon
	endif

	ifeq ("alcc", "$(findstring alcc, $(flags))")
		ALCC = --enable-alcc
	endif

	ifeq ("alc", "$(findstring alc, $(wo_alcc))")
		ALC = --enable-alc
	endif

	ifeq ("amulecmd", "$(findstring amulecmd, $(flags))")
		AMULECMD = --enable-amulecmd
	endif

	ifneq ("amule", "$(findstring amule, $(wo_all_other_amules))")
		AMULE = --disable-monolithic
	endif

	ifneq ("ed2k", "$(findstring ed2k, $(flags))")
		ED2K = --disable-ed2k
	endif

	#Now find out if a Metapackage should be build
	ifeq ("amule-utils-gui", "$(findstring amule-utils-gui, $(flags))")
		ALC = --enable-alc
		REMOTEGUI = --enable-amule-gui
		WXCAS = --enable-wxcas
	endif

	ifeq ("amule-utils", "$(findstring amule-utils, $(wo_amule_utils_gui))")
		ALCC = --enable-alcc
		AMULECMD = --enable-amulecmd
		CAS = --enable-cas
	endif

	#Find this whole i18n stuff
	ifneq ("i18n-en-only", "$(findstring i18n-en-only, $(flags))")

		ifeq ("i18n-ar", "$(findstring i18n-ar, $(flags))")
			LANGUAGE := $(LANGUAGE),ar
		endif

		ifeq ("i18n-bg", "$(findstring i18n-bg, $(flags))")
			LANGUAGE := $(LANGUAGE),bg
		endif

		ifeq ("i18n-ca", "$(findstring i18n-ca, $(flags))")
			LANGUAGE := $(LANGUAGE),ca
		endif

		ifeq ("i18n-da", "$(findstring i18n-da, $(flags))")
			LANGUAGE := $(LANGUAGE),da
		endif

		ifeq ("i18n-de", "$(findstring i18n-de, $(flags))")
			LANGUAGE := $(LANGUAGE),de
		endif

		ifeq ("i18n-es", "$(findstring i18n-es, $(flags))")
			LANGUAGE := $(LANGUAGE),es
		endif

		ifeq ("i18n-et-ee", "$(findstring i18n-et-ee, $(flags))")
			LANGUAGE := $(LANGUAGE),et_EE
		endif

		ifeq ("i18n-eu", "$(findstring i18n-eu, $(flags))")
			LANGUAGE := $(LANGUAGE),eu
		endif

		ifeq ("i18n-fi", "$(findstring i18n-fi, $(flags))")
			LANGUAGE := $(LANGUAGE),fi
		endif

		ifeq ("i18n-fr", "$(findstring i18n-fr, $(flags))")
			LANGUAGE := $(LANGUAGE),fr
		endif

		ifeq ("i18n-gl", "$(findstring i18n-gl, $(flags))")
			LANGUAGE := $(LANGUAGE),gl
		endif

		ifeq ("i18n-hr", "$(findstring i18n-hr, $(flags))")
			LANGUAGE := $(LANGUAGE),hr
		endif

		ifeq ("i18n-hu", "$(findstring i18n-hu, $(flags))")
			LANGUAGE := $(LANGUAGE),hu
		endif

		ifeq ("i18n-it", "$(findstring i18n-it, $(flags))")
			LANGUAGE := $(LANGUAGE),it
		endif

		ifeq ("i18n-it-ch", "$(findstring i18n-it-ch, $(flags))")
			LANGUAGE := $(LANGUAGE),it_CH
		endif

		ifeq ("i18n-ko-kr", "$(findstring i18n-ko-kr, $(flags))")
			LANGUAGE := $(LANGUAGE),ko_KR
		endif

		ifeq ("i18n-lt", "$(findstring i18n-lt, $(flags))")
			LANGUAGE := $(LANGUAGE),lt
		endif

		ifeq ("i18n-nl", "$(findstring i18n-nl, $(flags))")
			LANGUAGE := $(LANGUAGE),hl
		endif

		ifeq ("i18n-nn", "$(findstring i18n-nn, $(flags))")
			LANGUAGE := $(LANGUAGE),nn
		endif

		ifeq ("i18n-pl", "$(findstring i18n-pl, $(flags))")
			LANGUAGE := $(LANGUAGE),pl
		endif

		ifeq ("i18n-pt-br", "$(findstring i18n-pt-br, $(flags))")
			LANGUAGE := $(LANGUAGE),pt_BR
		endif

		ifeq ("i18n-pt-pt", "$(findstring i18n-pt-pt, $(flags))")
			LANGUAGE := $(LANGUAGE),pt_PT
		endif

		ifeq ("i18n-ru", "$(findstring i18n-ru, $(flags))")
			LANGUAGE := $(LANGUAGE),ru
		endif

		ifeq ("i18n-sl", "$(findstring i18n-sl, $(flags))")
			LANGUAGE := $(LANGUAGE),sl
		endif

		ifeq ("i18n-sv", "$(findstring i18n-sv, $(flags))")
			LANGUAGE := $(LANGUAGE),sv
		endif

		ifeq ("i18n-tr", "$(findstring i18n-tr, $(flags))")
			LANGUAGE := $(LANGUAGE),tr
		endif

		ifeq ("i18n-zh-cn", "$(findstring i18n-zh-cn, $(flags))")
			LANGUAGE := $(LANGUAGE),zh_CN
		endif

		ifeq ("i18n-zh-tw", "$(findstring i18n-zh-tw, $(flags))")
			LANGUAGE := $(LANGUAGE),zh_TW
		endif

		ifeq ($(LANGUAGE),en_GB)
			LANGUAGE = all
		endif

	endif

	LANGFLAG = --with-language=$(LANGUAGE)

	#And at Last, find out if we compile a debug-package or not.
	ifeq ("dbg", "$(findstring dbg, $(flags))")
		DEBUGGING = --enable-debug --disable-optimise --disable-profile
	else
		DEBUGGING = --disable-debug --enable-optimize --enable-profile 
	endif
endif

#Before we start, I want to introduce two sequences for building the packages
#I define two, so I can put the commands for the *-dbg packages between them
define stage1
	dh_testdir -p${pkg}
	dh_testroot -p${pkg}
	dh_installdirs -p${pkg}
	dh_installchangelogs docs/Changelog -p${pkg}
	dh_installdocs -p${pkg}
	dh_install -Xlicense.txt -p${pkg}
	dh_installmenu -p${pkg}
	dh_installdebconf -p${pkg}
	dh_installman -p${pkg}
	dh_link -p${pkg}
	install -D --mode=644 debian/${pkg}.override debian/${pkg}/usr/share/lintian/overrides/${pkg}
	touch $@
endef

define stage2
	dh_compress -X.pl -p${pkg}
	dh_perl -p${pkg}
	dh_makeshlibs -p${pkg}
	dh_installdeb -p${pkg}
	dh_shlibdeps -p${pkg}
	dh_gencontrol -p${pkg}
	dh_md5sums -p${pkg}
	dh_fixperms -p${pkg}
	dh_builddeb -p${pkg}
	touch $@
endef

#Now we configure this whole thing
config.status: configure
	dh_testdir
	CFLAGS="$(CFLAGS)" ./configure\
		--host=$(DEB_HOST_GNU_TYPE)\
		--build=$(DEB_BUILD_GNU_TYPE)\
		--prefix=/usr\
		--mandir=\$${prefix}/share/man\
		--infodir=\$${prefix}/share/info\
		--enable-systray\
		--with-ccache\
		--enable-utf8-systray\
		--enable-geoip\
		--disable-embedded-crypto\
		${AMULECMD}\
		${DEBUGGING}\
		${WEBSERVER}\
		${CAS}\
		${WXCAS}\
		${ALC}\
		${ALCC}\
		${REMOTEGUI}\
		${DAEMON}\
		${AMULE}\
		${ED2K}\
		$(LANGFLAG)


#And here is the well known clean target
clean:
	dh_testdir
	dh_testroot
	rm -f alc
	rm -f alc-dbg
	rm -f alcc
	rm -f alcc-dbg
	rm -f amule
	rm -f amule-alc-dbg
	rm -f amule-alc-stage1
	rm -f amule-alc-stage2
	rm -f amule-alcc-dbg
	rm -f amule-alcc-stage1
	rm -f amule-alcc-stage2
	rm -f amule-cas-dbg
	rm -f amule-cas-stage1
	rm -f amule-cas-stage2
	rm -f amule-cmd-dbg
	rm -f amule-cmd-stage1
	rm -f amule-cmd-stage2
	rm -f amule-common
	rm -f amule-daemon-dbg
	rm -f amule-daemon-stage1
	rm -f amule-daemon-stage2
	rm -f amule-dbg
	rm -f amule-ed2k-dbg
	rm -f amule-ed2k-stage1
	rm -f amule-ed2k-stage2
	rm -f amule-remote-gui-dbg
	rm -f amule-remote-gui-stage1
	rm -f amule-remote-gui-stage2
	rm -f amule-stage1
	rm -f amule-stage2
	rm -f amule-utils
	rm -f amule-utils-gui
	rm -f amule-wxcas-dbg
	rm -f amule-wxcas-stage1
	rm -f amule-wxcas-stage2
	rm -f amulecmd
	rm -f amulecmd-dbg
	rm -f amuleweb-stage1
	rm -f amuleweb-stage2
	rm -f amuleweb-dbg
	rm -f build-stamp 
	rm -f cas
	rm -f cas-dbg
	rm -f compile
	rm -f daemon
	rm -f daemon-dbg
	rm -f ed2k
	rm -f ed2k-dbg
	rm -f i18n-ar
	rm -f i18n-bg
	rm -f i18n-ca
	rm -f i18n-da
	rm -f i18n-de
	rm -f i18n-en-gb
	rm -f i18n-es
	rm -f i18n-et-ee
	rm -f i18n-eu
	rm -f i18n-fi
	rm -f i18n-fr
	rm -f i18n-gl
	rm -f i18n-hr
	rm -f i18n-hu
	rm -f i18n-it
	rm -f i18n-it-ch
	rm -f i18n-ko-kr
	rm -f i18n-lt
	rm -f i18n-nl
	rm -f i18n-nn
	rm -f i18n-pl
	rm -f i18n-pt-br
	rm -f i18n-pt-pt
	rm -f i18n-ru
	rm -f i18n-sl
	rm -f i18n-sv
	rm -f i18n-tr
	rm -f i18n-zh-cn
	rm -f i18n-zh-tw
	rm -f remotegui
	rm -f remotegui-dbg
	rm -f webserver
	rm -f webserver-dbg
	rm -f wxcas
	rm -f wxcas-dbg

	[ ! -f Makefile ] || $(MAKE) distclean

ifneq "$(wildcard /usr/share/misc/config.sub)" ""
	cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
	cp -f /usr/share/misc/config.guess config.guess
endif
	
	rm -f debian/files
	dh_clean -k

#Some generic targets to check the build process
build: build-stamp

build-stamp:  config.status
	dh_testdir

	# Add here commands to compile the package.
	$(MAKE)

	touch build-stamp

#Now we install the packages all together to the tmp-dir inside of debian/
install: build
	dh_testdir
	dh_testroot
	dh_clean -a -k 
	dh_installdirs

	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp

#Now first build the packages that are compiled and installed on every build
amule-common: install

	for pkg in $(general_pkgs); do \
		dh_testdir -p$$pkg; \
		dh_testroot -p$$pkg; \
		dh_installdirs -p$$pkg; \
		dh_installchangelogs docs/Changelog -p$$pkg; \
		dh_installdocs -p$$pkg; \
		dh_install -Xlicense.txt -p$$pkg; \
		dh_installmenu -p$$pkg; \
		dh_installdebconf -p$$pkg; \
		dh_installman -p$$pkg; \
		dh_link -p$$pkg; \
		install -D --mode=644 debian/$$pkg.override debian/$$pkg/usr/share/lintian/overrides/$$pkg; \
		dh_compress -X.pl -p$$pkg; \
		dh_perl -p$$pkg; \
		dh_makeshlibs -p$$pkg; \
		dh_installdeb -p$$pkg; \
		dh_shlibdeps -p$$pkg; \
		dh_gencontrol -p$$pkg; \
		dh_md5sums -p$$pkg; \
		dh_fixperms -p$$pkg; \
		dh_builddeb -p$$pkg; \
	done
	touch amule-common

amule-stage1: pkg=amule
amule-stage1: amule-common
	${stage1}

amule-stage2: pkg=amule
amule-stage2: amule-stage1
	${stage2}

amule-ed2k-stage1: pkg=amule-ed2k
amule-ed2k-stage1: amule-common
	${stage1}

amule-ed2k-stage2: pkg=amule-ed2k
amule-ed2k-stage2: amule-ed2k-stage1
	${stage2}

amule-cas-stage1: pkg=amule-cas
amule-cas-stage1: amule-common
	${stage1}

amule-cas-stage2: pkg=amule-cas
amule-cas-stage2: amule-cas-stage1
	${stage2}

amule-wxcas-stage1: pkg=amule-wxcas
amule-wxcas-stage1: amule-common
	${stage1}

amule-wxcas-stage2: pkg=amule-wxcas
amule-wxcas-stage2: amule-wxcas-stage1
	${stage2}

amuleweb-stage1: pkg=amuleweb
amuleweb-stage1: amule-common
	${stage1}

amuleweb-stage2: pkg=amuleweb
amuleweb-stage2: amuleweb-stage1
	${stage2}

amule-remote-gui-stage1: pkg=amule-remote-gui
amule-remote-gui-stage1: amule-common
	${stage1}

amule-remote-gui-stage2: pkg=amule-remote-gui
amule-remote-gui-stage2: amule-remote-gui-stage1
	${stage2}

amule-daemon-stage1: pkg=amule-daemon
amule-daemon-stage1: amule-common
	${stage1}

amule-daemon-stage2: pkg=amule-daemon
amule-daemon-stage2: amule-daemon-stage1
	${stage2}

amule-alc-stage1: pkg=amule-alc
amule-alc-stage1: amule-common
	${stage1}

amule-alc-stage2: pkg=amule-alc
amule-alc-stage2: amule-alc-stage1
	${stage2}

amule-alcc-stage1: pkg=amule-alcc
amule-alcc-stage1: amule-common
	${stage1}

amule-alcc-stage2: pkg=amule-alcc
amule-alcc-stage2: amule-alcc-stage1
	${stage2}

amule-cmd-stage1: pkg=amule-cmd
amule-cmd-stage1: amule-common
	${stage1}

amule-cmd-stage2: pkg=amule-cmd
amule-cmd-stage2: amule-alcc-stage1
	${stage2}


amule-ed2k-dbg: pkg=amule-ed2k-dbg
amule-ed2k-dbg: amule-ed2k-stage1
	${stage1}
	dh_strip -pamule-ed2k --dbg-package=amule-ed2k-dbg
	${stage2}

amule-cas-dbg: pkg=amule-cas-dbg
amule-cas-dbg: amule-cas-stage1
	${stage1}
	dh_strip -pamule-cas --dbg-package=amule-cas-dbg
	${stage2}

amule-wxcas-dbg: pkg=amule-wxcas-dbg
amule-wxcas-dbg: amule-wxcas-stage1
	${stage1}
	dh_strip -pamule-wxcas --dbg-package=amule-wxcas-dbg
	${stage2}

amuleweb-dbg: pkg=amuleweb-dbg
amuleweb-dbg: amuleweb-stage1
	${stage1}
	dh_strip -pamuleweb --dbg-package=amuleweb-dbg
	${stage2}

amule-remote-gui-dbg: pkg=amule-remote-gui-dbg
amule-remote-gui-dbg: amule-remote-gui-stage1
	${stage1}
	dh_strip -pamule-remote-gui --dbg-package=amule-remote-gui-dbg
	${stage2}

amule-daemon-dbg: pkg=amule-daemon-dbg
amule-daemon-dbg: amule-daemon-stage1
	${stage1}
	dh_strip -pamule-daemon --dbg-package=amule-daemon-dbg
	${stage2}

amule-alc-dbg: pkg=amule-alc-dbg
amule-alc-dbg: amule-alc-stage1
	${stage1}
	dh_strip -pamule-alc --dbg-package=amule-alc-dbg
	${stage2}

amule-alcc-dbg: pkg=amule-alcc-dbg
amule-alcc-dbg: amule-alcc-stage1
	${stage1}
	dh_strip -pamule-alcc --dbg-package=amule-alcc-dbg
	${stage2}

amule-cmd-dbg: pkg=amule-cmd-dbg
amule-cmd-dbg: amule-cmd-stage1
	${stage1}
	dh_strip -pamule-cmd --dbg-package=amule-cmd-dbg
	${stage2}

#Now just the targets to map the Commandline Name to the package names
amule: amule-stage2
	touch amule

ed2k: amule-ed2k-stage2
	touch ed2k

cas: amule-cas-stage2
	touch cas

wxcas: amule-wxcas-stage2
	touch wxcas

webserver: amuleweb-stage2
	touch webserver

remotegui: amule-remote-gui-stage2
	touch remotegui

daemon: amule-daemon-stage2
	touch daemon

alc: amule-alc-stage2
	touch alc

alcc: amule-alcc-stage2
	touch alcc

amulecmd: amule-cmd-stage2
	touch amulecmd

ed2k-dbg: amule-ed2k-dbg
	touch ed2k-dbg

cas-dbg: amule-cas-dbg
	touch cas-dbg

wxcas-dbg: amule-wxcas-dbg
	touch wxcas-dbg

webserver-dbg: amuleweb-dbg
	touch webserver-dbg

remotegui-dbg: amule-remote-gui-dbg
	touch remotegui-dbg

daemon-dbg: amule-daemon-dbg
	touch daemon-dbg

alc-dbg: amule-alc-dbg
	touch alc-dbg

alcc-dbg: amule-alcc-dbg
	touch alcc-dbg

amulecmd-dbg: amule-cmd-dbg
	touch amulecmd-dbg

amule-dbg: pkg=amule-dbg
amule-dbg: amule-stage1
	${stage1}
	dh_strip -pamule --dbg-package=amule-dbg
	${stage2}

#Her come the Targets for the langauge packages
i18n-ar: pkg=amule-i18n-ar
i18n-ar: amule-common
	${stage1}
	${stage2}

i18n-bg: pkg=amule-i18n-bg
i18n-bg: amule-common
	${stage1}
	${stage2}

i18n-ca: pkg=amule-i18n-ca
i18n-ca: amule-common
	${stage1}
	${stage2}

i18n-da: pkg=amule-i18n-da
i18n-da: amule-common
	${stage1}
	${stage2}

i18n-de: pkg=amule-i18n-de
i18n-de: amule-common
	${stage1}
	${stage2}

i18n-en-gb: pkg=amule-i18n-en-gb
i18n-en-gb: amule-common
	${stage1}
	${stage2}

i18n-es: pkg=amule-i18n-es
i18n-es: amule-common
	${stage1}
	${stage2}

i18n-et-ee: pkg=amule-i18n-et-ee
i18n-et-ee: amule-common
	${stage1}
	${stage2}

i18n-eu: pkg=amule-i18n-eu
i18n-eu: amule-common
	${stage1}
	${stage2}

i18n-fi: pkg=amule-i18n-fi
i18n-fi: amule-common
	${stage1}
	${stage2}

i18n-fr: pkg=amule-i18n-fr
i18n-fr: amule-common
	${stage1}
	${stage2}

i18n-gl: pkg=amule-i18n-gl
i18n-gl: amule-common
	${stage1}
	${stage2}

i18n-hr: pkg=amule-i18n-hr
i18n-hr: amule-common
	${stage1}
	${stage2}

i18n-hu: pkg=amule-i18n-hu
i18n-hu: amule-common
	${stage1}
	${stage2}

i18n-it-ch: pkg=amule-i18n-it-ch
i18n-it-ch: amule-common
	${stage1}
	${stage2}

i18n-it: pkg=amule-i18n-it
i18n-it: amule-common
	${stage1}
	${stage2}

i18n-ko-kr: pkg=amule-i18n-ko-kr
i18n-ko-kr: amule-common
	${stage1}
	${stage2}

i18n-lt: pkg=amule-i18n-lt
i18n-lt: amule-common
	${stage1}
	${stage2}

i18n-nn: pkg=amule-i18n-nn
i18n-nn: amule-common
	${stage1}
	${stage2}

i18n-nl: pkg=amule-i18n-nl
i18n-nl: amule-common
	${stage1}
	${stage2}

i18n-pl: pkg=amule-i18n-pl
i18n-pl: amule-common
	${stage1}
	${stage2}

i18n-pt-br: pkg=amule-i18n-pt-br
i18n-pt-br: amule-common
	${stage1}
	${stage2}

i18n-pt-pt: pkg=amule-i18n-pt-pt
i18n-pt-pt: amule-common
	${stage1}
	${stage2}

i18n-ru: pkg=amule-i18n-ru
i18n-ru: amule-common
	${stage1}
	${stage2}

i18n-sl: pkg=amule-i18n-sl
i18n-sl: amule-common
	${stage1}
	${stage2}

i18n-sv: pkg=amule-i18n-sv
i18n-sv: amule-common
	${stage1}
	${stage2}

i18n-tr: pkg=amule-i18n-tr
i18n-tr: amule-common
	${stage1}
	${stage2}

i18n-zh-cn: pkg=amule-i18n-zh-cn
i18n-zh-cn: amule-common
	${stage1}
	${stage2}

i18n-zh-tw: pkg=amule-i18n-zh-tw
i18n-zh-tw: amule-common
	${stage1}
	${stage2}

#They are just metapackages
amule-utils: pkg=amule-utils
amule-utils: alcc amulecmd cas
	${stage1}
	${stage2}

amule-utils-gui: pkg=amule-utils-gui
amule-utils-gui: alc remotegui wxcas
	${stage1}
	${stage2}

#These Two are empty (Space after Semicolon)
debug-packages: amule-dbg ed2k-dbg cas-dbg wxcas-dbg webserver-dbg remotegui-dbg daemon-dbg alc-dbg alcc-dbg amulecmd-dbg ; 
normal-packages: amule-utils amule-utils-gui amule ed2k webserver daemon ; 

language-packages: i18n-ar i18n-bg i18n-ca i18n-da i18n-de i18n-en-gb i18n-es i18n-et-ee i18n-eu i18n-fi i18n-fr i18n-gl i18n-hr i18n-hu i18n-it-ch i18n-it i18n-ko-kr i18n-lt i18n-nn i18n-nl i18n-pl i18n-pt-br i18n-pt-pt i18n-ru i18n-sl i18n-sv i18n-tr i18n-zh-cn i18n-zh-tw ; 

i18n-en-only: ; 

#Now the targets for dpkg-buildpackage
binary-indep: build install

binary-arch: debug-packages normal-packages language-packages

binary: binary-indep binary-arch

help:
	cat README.Debian-Packages

.DEFAULT_GOAL = help
.PHONY: build clean binary-indep binary-arch binary install debug-packages normal-packages amule-utils-gui amule-utils i18n-only language-packages
