
# A simple makefile to install the developer tools.
# Assumes you *already have* the runtime code installed!

# If you are running from SVN, use the setup and unsetup
# scripts instead

PREFIX=/usr

.PHONY: help install uninstall

help:
	@echo "This makefile supports the install and uninstall targets but nothing else"

install:
	@echo "Installing the developer tools"
	mkdir -p $(PREFIX)/share/autopackage
	cp -rv share/skeletons $(PREFIX)/share/autopackage/skeletons
	cp -rv share/*.template $(PREFIX)/share/autopackage
	cp -v  share/apkg-mimetype.xsl $(PREFIX)/share/autopackage
	mkdir -p $(PREFIX)/libexec/autopackage
	cp -f  libexec/fixlibtool $(PREFIX)/libexec/autopackage/
	cp -f  libexec/abi-install $(PREFIX)/libexec/autopackage/
	cp -f  libexec/bsdiff $(PREFIX)/libexec/autopackage/
	cp -f  libexec/dump-elf-metadata $(PREFIX)/libexec/autopackage/
	cp -f  libexec/autopackage-curl $(PREFIX)/libexec/autopackage/
	mkdir -p $(PREFIX)/bin
	cp -f  makepackage $(PREFIX)/bin/makepackage
	if [ -d apbuild ]; then cd apbuild && make install; fi
	if [ -d binreloc ]; then cp -rf binreloc "$(PREFIX)"; fi
	if [ -d gtk-headers ]; then cd gtk-headers && make install; fi
	if [ -d lzma ]; then cd lzma && make && make install; fi
	@echo "Done!"

uninstall:
	@echo "Uninstalling the developer tools"
	rm -rf $(PREFIX)/share/autopackage/skeletons
	rm -f  $(PREFIX)/share/autopackage/*.template
	rmdir  $(PREFIX)/share/autopackage || true
	rm -f  $(PREFIX)/libexec/autopackage/{fixlibtool,abi-install,bsdiff,dump-elf-metadata,autopackage-curl}
	rmdir  $(PREFIX)/libexec/autopackage || true
	rm -f  $(PREFIX)/bin/makepackage
	if [ -d apbuild ]; then cd apbuild && make uninstall; fi
	if [ -d binreloc ]; then rm -rf binreloc; fi
	if [ -d gtk-headers ]; then cd gtk-headers && make uninstall; fi
	if [ -d lzma ]; then cd lzma && make uninstall; fi
	@echo "Done!"

