## @id $Id$

##       1         2         3         4         5         6         7         8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890

cordova_sources = hooks platforms plugins www
EXTRA_DIST = config.xml.in ${cordova_sources}
ANDROID = safechat.apk
#ANDROID_SRC = platforms/android/build/outputs/apk/android-release-unsigned.apk
ANDROID_SRC = platforms/android/build/outputs/apk/android-debug.apk
if HAVE_CORDOVA
wwwdir = ${pkgdatadir}/html
www_DATA = ${ANDROID}
endif

${ANDROID_SRC}:
	for file in ${cordova_sources}; do \
	  test -e "$${file}" || \
	    ( cp -r "@srcdir@/$${file}" "$${file}" && \
	      chmod -R u+w "$${file}" ); \
	done
	if [ "$$(whoami 2> /dev/null)" != "root" ]; then \
	  ${CORDOVA} plugin add https://github.com/katzer/cordova-plugin-background-mode.git; \
	  ${CORDOVA} build --debug || ${CORDOVA} build --debug; \
	fi

${ANDROID}: ${ANDROID_SRC}
	if [ "$$(whoami 2> /dev/null)" != "root" ]; then \
	  cp $< $@; \
	fi

clean-local:
	-platforms/android/cordova/clean

distclean-local:
	-rm -r platforms/android/.gradle
	for file in ${cordova_sources}; do \
	  if test "@srcdir@/$${file}" != "$${file}" \
	          -a -e "$${file}" \
	          -a "@srcdir@" != "." \
	          -a "@srcdir@" != "./"; then \
	    chmod -R u+w "$${file}" && rm -r "$${file}"; \
	  fi; \
	done

CLEANFILES = ${ANDROID} ${ANDROID_SRC}
MAINTAINERCLEANFILES = makefile.in
