# Top-level Makefile.in for PMW2. The building work is done by a separate
# Makefile in the src directory, which gets passed settings from here.

mkinstalldirs = $(SHELL) mkinstalldirs

# These variables get set up by the configure script.

CC=@CC@
CFLAGS=@CFLAGS@
LFLAGS=@LFLAGS@
SUPPORT_XML=@SUPPORT_XML@

INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@

BINDIR=$(DESTDIR)@prefix@/bin
DATADIR=$(DESTDIR)@prefix@/share/pmw
MANDIR=$(DESTDIR)@prefix@/man

# BINDIR is the directory in which the pmw command is installed.
# DATADIR is the directory in which the fontmetrics, the PostScript fonts,
#   and the PostScript header file are installed, in a subdirectory called pmw.
# MANDIR is the directory in which the man pages are installed.

# The compile commands can be very long. To make the output look better,
# they are not normally echoed in full. To get full echoing, the caller
# must set FULLECHO='' on the command line and call make with -e. We default
# FULLECHO to '@' to suppress the full echo. Then define an abbreviation.

FULLECHO = @
FE       = $(FULLECHO)

build:; @cd src; \
        $(MAKE) all \
        BINDIR=$(BINDIR) \
        DATADIR=$(DATADIR) \
        MANDIR=$(MANDIR) \
        CC="$(CC)" \
        CFLAGS="$(CFLAGS)" \
        LFLAGS="$(LFLAGS)" \
        SUPPORT_XML="$(SUPPORT_XML)" \
        FE="$(FE)" \
        $(MFLAGS)

clean:; cd src; $(MAKE) clean

distclean:;     rm -f Makefile config.cache config.log config.status; \
                cd src; $(MAKE) distclean

test:           build
		cd testdist; ./RunTests

vtest:          build
		cd testdist; ./RunTests valgrind

# "Standard" name for testing is "check"

check: test ;
vcheck: vtest ;

install:        build
		$(mkinstalldirs) $(BINDIR)
		$(mkinstalldirs) $(DATADIR)
		$(mkinstalldirs) $(DATADIR)/fontmetrics
		$(mkinstalldirs) $(DATADIR)/macros
		$(mkinstalldirs) $(DATADIR)/psfonts
		$(mkinstalldirs) $(MANDIR)
		$(mkinstalldirs) $(MANDIR)/man1
		$(INSTALL) src/pmw $(BINDIR)/pmw
		$(INSTALL_DATA) PSheader $(DATADIR)
		$(INSTALL_DATA) MIDIvoices $(DATADIR)
		$(INSTALL_DATA) MIDIperc $(DATADIR)
		$(INSTALL_DATA) macros/* $(DATADIR)/macros
		$(INSTALL_DATA) psfonts/PMW-Music.pfa $(DATADIR)/psfonts
		$(INSTALL_DATA) psfonts/PMW-Music.otf $(DATADIR)/psfonts
		$(INSTALL_DATA) psfonts/PMW-Alpha $(DATADIR)/psfonts
		$(INSTALL_DATA) fontmetrics/* $(DATADIR)/fontmetrics
		$(INSTALL_DATA) doc/pmw.1 $(MANDIR)/man1
		./post-install "$(BINDIR)" "$(DATADIR)" "$(MANDIR)"

uninstall:;     rm -rf \
		$(BINDIR)/pmw \
		$(DATADIR) \
		$(MANDIR)/man1/pmw.1

# End
