include Makefile.vars

# all:: tests apps

ifeq (,$(findstring iPhone,$(PLATFORM)))
all:: tests apps
else
all:: lib/libDwmAuth.la
endif

tests::
	${MAKE} -C tests

apps::
	${MAKE} -C apps

lib/libDwmAuth.la::
	${MAKE} -C src

tarprep: apps lib/libDwmAuth.la
	${MAKE} -C src $@
	${MAKE} -C include $@
	${MAKE} -C apps $@
ifeq ("${BUILD_DOCS}", "yes")
	${MAKE} -C docs $@
endif
	${MAKE} -C packaging $@

package: ${OSNAME}-pkg

freebsd-pkg: tarprep
	./install-sh -c -m 444 packaging/libDwmAuth.pc ${TARDIR}/libdata/pkgconfig/libDwmAuth.pc
	mkfbsdmnfst -r packaging/fbsd_manifest staging > staging/+MANIFEST
	pkg create -o . -r staging -m staging

darwin-pkg: tarprep
	pkgbuild --root staging --identifier com.mcplex.libDwmAuth --version ${VERSION} libDwmAuth-${VERSION}.pkg

linux-pkg: tarprep
	echo "%product libDwmAuth" > libDwmAuth.list
	echo "%copyright 2016-2017 by Daniel W. McRobb, All Rights Reserved." >> libDwmAuth.list
	echo "%vendor Daniel W. McRobb" >> libDwmAuth.list
	echo "%license /dev/null" >> libDwmAuth.list
	echo "%readme /dev/null" >>  libDwmAuth.list
	echo "%description C++ classes for encrypted authentication" >> libDwmAuth.list
	echo "%version ${VERSION}" >> libDwmAuth.list
	mkepmlist -u root -g wheel --prefix /usr/local staging/usr/local >> libDwmAuth.list
	epm -k --keep-files --output-dir . -f native libDwmAuth

install:: lib/libDwmAuth.la
	${MAKE} -C src $@
	${MAKE} -C include $@

clean: clean-tarprep
	${MAKE} -C src $@
	${MAKE} -C tests $@
	${MAKE} -C apps $@

clean-tarprep::
	${MAKE} -C src $@
	${MAKE} -C include $@
	${MAKE} -C apps $@

distclean: clean
	${MAKE} -C src $@
	rm -Rf config.status config.log configure.lineno autom4te.cache \
          Makefile.vars
