PACKAGE=xfonts-dosemu-lt
VERSION=0.0.3

SUBDIRS = debian

ALIAS = xfonts-dosemu-lt.alias
BDF = vga11x19-cp773.bdf
PCF = vga11x19-cp773.pcf
BDF2 = vga14x21-cp773.bdf
PCF2 = vga14x21-cp773.pcf
BDF3 = vga11x19-cp775.bdf
PCF3 = vga11x19-cp775.pcf

FONTDIR = /usr/share/X11/fonts/misc
ALIASDIR = /etc/X11/fonts/misc

EXTRA_DIST = \
AUTHORS \
COPYING \
Makefile \
xfonts-dosemu-lt.alias $(BDF) $(BDF2) $(BDF3) $(ALIAS)

all: font-clean
	bdftopcf $(BDF) > $(PCF)
	gzip --best $(PCF)
	bdftopcf $(BDF2) > $(PCF2)
	gzip --best $(PCF2)
	bdftopcf $(BDF3) > $(PCF3)
	gzip --best $(PCF3)
	
font-clean:
	rm -f $(PCF) $(PCF).gz
	rm -f $(PCF2) $(PCF2).gz
	rm -f $(PCF3) $(PCF3).gz
	
clean: font-clean
	rm -f build-stamp
	for i in $(SUBDIRS); do \
		make -C $$i clean; \
	done

install: all
	test -d "$(DESTDIR)/$(FONTDIR)/" || mkdir -p "$(DESTDIR)/$(FONTDIR)/"
	install -c -m 644 $(PCF).gz "$(DESTDIR)/$(FONTDIR)/"
	install -c -m 644 $(PCF2).gz "$(DESTDIR)/$(FONTDIR)/"
	install -c -m 644 $(PCF3).gz "$(DESTDIR)/$(FONTDIR)/"
	test -d "$(DESTDIR)/$(ALIASDIR)/" || mkdir -p "$(DESTDIR)/$(ALIASDIR)/"
	install -c -m 644 $(ALIAS) "$(DESTDIR)/$(ALIASDIR)/"
	(cd "$(DESTDIR)/$(FONTDIR)" && mkfontdir )
	@echo ""
	@echo "If you are running the xfont server you should restart it"
	@echo "Regardless, you should run \"xset fp rehash\" as the user"
	@echo "who is running the session."
	@echo "You can verify that this all worked by running:"
	@echo "xlsfonts | fgrep vga11x19"

uninstall:
	rm -f "$(DESTDIR)/$(FONTDIR)/$(PCF).gz"
	rm -f "$(DESTDIR)/$(FONTDIR)/$(PCF2).gz"
	rm -f "$(DESTDIR)/$(FONTDIR)/$(PCF3).gz"
	rm -f "$(DESTDIR)/$(ALIASDIR)/$(ALIAS) "
	(cd "$(DESTDIR)/$(FONTDIR)" && mkfontdir )
	@echo ""
	@echo "If you are running the xfont server you should restart it"
	@echo "Regardless, you should run \"xset fp rehash\" as the user"
	@echo "who is running the session."
	@echo "You can verify that this all worked by running:"
	@echo "xlsfonts | fgrep vga11x19"

distclean-1:
	rm -rf "$(PACKAGE)-$(VERSION)/" "$(PACKAGE)-$(VERSION).tar" \
		"$(PACKAGE)-$(VERSION).tar.gz"

distclean: distclean-1 clean

dist: distclean-1
	mkdir "$(PACKAGE)-$(VERSION)/"
	cp $(EXTRA_DIST) "$(PACKAGE)-$(VERSION)/"
	for i in $(SUBDIRS); do \
		DISTDIR="../$(PACKAGE)-$(VERSION)/$$i" make -C $$i dist; \
	done
	tar -cf "$(PACKAGE)-$(VERSION).tar" "$(PACKAGE)-$(VERSION)/"
	gzip --best "$(PACKAGE)-$(VERSION).tar"
	rm -rf "$(PACKAGE)-$(VERSION)/"

distcheck: dist
	tar -zxf "$(PACKAGE)-$(VERSION).tar.gz"
	mkdir "$(PACKAGE)-$(VERSION)/.build/"
	(cd "$(PACKAGE)-$(VERSION)/.build/" ;\
		DESTDIR="$(PWD)/../.done/" make -C ../ distclean all install)
	rm -r "$(PACKAGE)-$(VERSION)/"
	@echo "############################################################"
	@echo "# $(PACKAGE)-$(VERSION).tar.gz is ready for distribution"
	@echo "############################################################"

	 
