include Makefile.vars

all:: lib/libDwmCfg2Json.la
	${MAKE} -C src
	${MAKE} -C tests

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

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

doc/html/index.html::
	${MAKE} -C doc

ifeq ("${OSNAME}", "freebsd")
freebsd-pkg: tarprep
	./install-sh -c -m 444 packaging/libDwmCfg2Json.pc ${TARDIR}/libdata/pkgconfig/libDwmCfg2Json.pc
	mkfbsdmnfst -r packaging/fbsd_manifest staging > staging/+MANIFEST
	pkg create -o . -r staging -m staging
endif

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

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

package: ${OSNAME}-pkg

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

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