#
# Installation makefile for -art resources.
#


VERA_DESCRIPTION = \
"The Vera fonts are a set of latin-1 fonts well suited to on-screen use."

#"If you " \
"primarily deal with latin-1 (West European) text, it is recommended that " \
"you set these as your default fonts (eg. by runing '$(MAKE) vera-default')."


FREEFONTS_DESCRIPTION = \
"The FreeFonts are a set of" \
"fonts similar to Helvetica," \
"Times, and Courier. Though not as good as the Vera fonts" \
"for on-screen use, they contain glyphs for many more characters."

#"If you deal with non-latin-1 text, it is recommended that you use" \
"these as your default fonts (eg. by running '$(MAKE) freefonts-default')."


INSTALL_BLURB_1 = \
"The FreeFonts and Vera fonts have now been installed."

INSTALL_BLURB_2 = \
"The Vera fonts are well-suited to on-screen use, and it is recommended" \
"that you use these as your default fonts if you deal primarily with" \
"latin-1 (West European) text. To set these as the default fonts for a user" \
"run 'make vera-default' as that user."

INSTALL_BLURB_3 = \
"The FreeFonts are not as well-suited as the Vera fonts to on-screen use, but" \
"they contain a lot more characters. If you deal with non-latin-1 text, it is" \
"recommended that you use these as your default fonts (eg. by running" \
"'$(MAKE) freefonts-default')."

#" Normally, you don't need" \
"to do anything to use these as your default fonts, but if you have other" \
"versions of Helvetica or Courier installed, or if you have changed the defaults" \
"previously, '$(MAKE) freefonts-default' will set the FreeFonts as the default fonts" \
"for the current user."

INSTALL_BLURB_4 = \
"To reset the default fonts for a user, run '$(MAKE) default-default' as that user."



.PHONY: all help

all:: check_GNUstep_sh_sourced
	@(echo "-art resource package version 0.1  Alexander Malmberg <alexander@malmberg.org>"; \
	echo; \
	echo "This package contains:"; \
	echo; \
	echo "Vera fonts   (http://www.gnome.org/fonts/)"; \
	echo "    "$(VERA_DESCRIPTION) | fmt; \
	echo; \
	echo "FreeFonts    (http://www.nongnu.org/freefont/)"; \
	echo "    "$(FREEFONTS_DESCRIPTION) | fmt; \
	echo; \
	echo "You probably want to run:"; \
	echo; \
	echo "$(MAKE) install"; \
	echo "    Installs the Vera fonts, the FreeFonts, and mknfonts in the"; \
	echo "    local domain."; \
	echo; \
	echo "or:"; \
	echo; \
	echo "$(MAKE) vera-default"; \
	echo "    Sets the Vera fonts as the default fonts for the _current_ user."; \
	echo; \
	echo "but you can also run '$(MAKE) help' for more extensive information."; \
	)

help:: check_GNUstep_sh_sourced
	@(echo "Use:"; \
	echo; \
	echo "$(MAKE) install"; \
	echo "    Installs the Vera fonts, the FreeFonts, and mknfonts in the"; \
	echo "    local domain."; \
	echo; \
	echo "$(MAKE) vera-default"; \
	echo "    Sets the Vera fonts as the default fonts for the _current_ user."; \
	echo; \
	echo "$(MAKE) freefonts-default"; \
	echo "    Sets the FreeFonts as the default fonts for the _current_ user."; \
	echo; \
	echo "$(MAKE) default-default"; \
	echo "    Resets the default fonts for the _current_ user."; \
	echo; \
	echo "To build or install mknfonts, move to the mknfonts/ directory and use"; \
	echo "standard make commands."; \
	)

install:: check_GNUstep_sh_sourced install-vera install-freefonts
	@(if ! ($(MAKE) -C mknfonts && $(MAKE) -C mknfonts install); then \
		echo; \
		echo "The automatic install of mknfonts failed. To do it manually,"; \
		echo "run 'make install' in the mknfonts/ directory. Please report"; \
		echo "this as a bug along with the output of this command."; \
	fi \
	)
	@(echo; \
	echo $(INSTALL_BLURB_1) | fmt; \
	echo; \
	echo $(INSTALL_BLURB_2) | fmt; \
	echo; \
	echo $(INSTALL_BLURB_3) | fmt; \
	echo; \
	echo $(INSTALL_BLURB_4) | fmt \
	)


FONT_DEST = $(GNUSTEP_LOCAL_ROOT)/Library/Fonts


.PHONY: install-vera install-freefonts

install-vera:: check_GNUstep_sh_sourced
	@echo Installing the Vera fonts...
	@./install-nfont Vera\ Sans.nfont $(FONT_DEST) FoO
	@./install-nfont Vera\ Serif.nfont $(FONT_DEST) FoO
	@./install-nfont Vera\ Sans\ Mono.nfont $(FONT_DEST) FoO

install-freefonts:: check_GNUstep_sh_sourced
	@echo Installing the FreeFonts...
	@./install-nfont FreeSans.nfont $(FONT_DEST) FoO
	@./install-nfont FreeSerif.nfont $(FONT_DEST) FoO
	@./install-nfont FreeMono.nfont $(FONT_DEST) FoO
	

vera-default:: check_GNUstep_sh_sourced
	defaults write NSGlobalDomain NSFont BitstreamVeraSans-Roman
	defaults write NSGlobalDomain NSBoldFont BitstreamVeraSans-Bold
	defaults write NSGlobalDomain NSUserFixedPitchFont BitstreamVeraSansMono-Roman

freefonts-default:: check_GNUstep_sh_sourced
	defaults write NSGlobalDomain NSFont FreeSans
	defaults write NSGlobalDomain NSBoldFont FreeSansBold
	defaults write NSGlobalDomain NSUserFixedPitchFont FreeMono

default-default:: check_GNUstep_sh_sourced
	defaults delete NSGlobalDomain NSFont
	defaults delete NSGlobalDomain NSBoldFont
	defaults delete NSGlobalDomain NSUserFixedPitchFont


.PHONY: check_GNUstep_sh_sourced
ifeq ($(GNUSTEP_ROOT),)
check_GNUstep_sh_sourced::
	@echo You must source the GNUstep.sh script before running $(MAKE) here.
	@false
else
check_GNUstep_sh_sourced::
endif


VERSION = 0.1.2

.PHONY: dist
dist::
	tar c Makefile install-nfont mknfonts *.nfont > ArtResources-$(VERSION).tar


