#!/usr/bin/make -f
# based on the debian/rules file, adapted for the cygwin environment

package=gtk-gnutella

build:
	$(checkdir)
	rm -f config.sh
	./build.sh --prefix=/usr
	touch build

clean:
	$(checkdir)
	-rm -f build
	-$(MAKE) clobber
	-rm -f `find . -name "*~"`
	-rm -rf cygwin/tmp core cygwin/depend

binary-indep: checkroot build
	$(checkdir)
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch: checkroot build
	$(checkdir)
	-rm -rf cygwin/tmp
	install -d cygwin/tmp
	cd cygwin/tmp && install -d `cat ../dirs`
	$(MAKE) install INSTALL_PREFIX=`pwd`/cygwin/tmp
	$(MAKE) install.man INSTALL_PREFIX=`pwd`/cygwin/tmp
	$(depend)
	chown -R root.root cygwin/tmp
	chmod -R go=rX cygwin/tmp

define depend
  (cd cygwin/tmp && \
  find . -name "*.exe" -o -name "*.dll" | xargs -r cygcheck | \
  sed -e '/\.exe/d' -e 's,\\,/,g' | sort -bu | xargs -r -n1 cygpath -u \
  | xargs -r cygcheck -f | sed 's%^%  %' | sort -u ; \
  true ) >cygwin/depend
endef

define checkdir
	test -f cygwin/rules
endef

binary: binary-indep binary-arch

checkroot:
	$(checkdir)
	test root = "`whoami`"

.PHONY: binary binary-arch binary-indep clean checkroot checkdir depend
