# Makefile for ps2pk, with path searching using kpathsea
version = 1.4m

# The following make definitions (down to `end of installation
# directories') are repeated in several Makefiles, because different
# installations like to change them at different levels. If you edit the
# top-level Makefile, the changes should propagate, however.
# 
# The following define installation directories. The default paths are
# defined in kpathsea/paths.h, which is built from kpathsea/paths.h.in.
# See kpathsea/INSTALL for a description of how the various path-related
# files are used and created.

# Generic installation directories.
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
scriptdir = $(bindir)
libdir = $(exec_prefix)/lib
datadir = $(prefix)/lib
infodir = $(prefix)/info
includedir = $(prefix)/include
manext = 1
mandir = $(prefix)/man/man$(manext)

# Compilation options.
DEFS = $(XDEFS)

# CFLAGS is used for both compilation and linking.
CFLAGS = -g $(XCFLAGS)

# Do not override CPPFLAGS; change CFLAGS or DEFS instead.
CPPFLAGS = $(XCPPFLAGS) -I. -I$(srcdir) -I$(kpathsea_parent) \
           $(x_include_flags) $(DEFS) 
.c.o:
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $<

# Linking.
LDFLAGS = $(CFLAGS) $(XLDFLAGS)
LOADLIBES = $(kpathsea) $(x_libs) $(LIBS) -lm $(x_extra_libs)

# This is so kpathsea will get remade automatically if you change
# something in it and recompile from the package directory.
kpathsea_parent = ..
kpathsea_dir = $(kpathsea_parent)/kpathsea
kpathsea_srcdir_parent = $(srcdir)/..
kpathsea_srcdir = $(kpathsea_srcdir_parent)/kpathsea
kpathsea = $(kpathsea_dir)/kpathsea.a

# A similar provision for the T1 library
type1_parent = .
type1_dir = $(type1_parent)/type1
type1_srcdir_parent = $(srcdir)/.
type1_srcdir = $(type1_srcdir_parent)/type1
type1 = $(type1_dir)/libtype1.a

CC = @CC@

# LEX = @LEX@
# LEXLIB = @LEXLIB@
# YACC = @YACC@

# Command to link an executable.
CCLD = $(CC)
RANLIB = @RANLIB@
# LN = @LN_S@

wlibs = @wlibs@
LIBS = @LIBS@ $(extralibs)

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

SHELL = /bin/sh
srcdir = @srcdir@
VPATH = @srcdir@


# 
# Things below here not changed by configure.

# What to do by default.
default: all
.PHONY: default

# Where we need to make things.
# 
type1dir = type1
progdirs = $(type1dir) ps2pk
alldirs = $(progdirs)

# What to pass to subdirectories when making various things.
# $(MAKEARGS) is for the user.
makeargs=$(MFLAGS) SHELL='$(SHELL)' CC='$(CC)' CFLAGS='$(CFLAGS)'	\
  RANLIB='$(RANLIB)' LN='$(LN)' DEFS='$(DEFS)'                          \
  CCLD='$(CCLD)' LDFLAGS='$(LDFLAGS)' LIBS='$(LIBS)' 			\
  $(MAKEARGS) 
installargs=$(makeargs) 						\
  INSTALL_DATA='$(INSTALL_DATA)'					\
  INSTALL_PROGRAM='$(INSTALL_PROGRAM)'					\
  bindir=$(bindir)							


# 

all: ps2pk manpages
.PHONY: all

ps2pk: do-libs
	cd ps2pk; $(MAKE) $(makeargs) all
.PHONY: ps2pk

do-type1: 
	cd type1; $(MAKE) $(makeargs) all
.PHONY: do-type1

do-libs: $(kpathsea_srcdir)/config.status do-kpathsea do-type1
.PHONY: do-libs

do-kpathsea: $(kpathsea_srcdir)/*.c $(kpathsea_srcdir)/*.h
	cd $(kpathsea_dir); $(MAKE) $(makeargs)
.PHONY: do-kpathsea

$(kpathsea_srcdir)/config.status:
	(cd $(kpathsea_dir); configure)


manpages:
	cd man; $(MAKE) bindir=$(bindir) all
.PHONY: manpages


# 
# Installation targets.

install: install-exec install-data
.PHONY: install
install-data: install-manpages
	for name in $(progdirs); do					\
          (cd $${name}; $(MAKE) $(installargs) install-data || exit 1);		\
        done
.PHONY: install-data

install-exec: 
	$(SHELL) $(srcdir)/../mkdirchain $(bindir)
	for name in $(progdirs); do					\
          (cd $${name}; $(MAKE) $(installargs) install-exec || exit 1);		\
        done
.PHONY: install-exec

install-manpages: manpages
	cd man; $(MAKE) $(installargs)					\
           mandir=$(mandir) manext=$(manext) install
.PHONY: install-manpages




config.status: $(srcdir)/configure
	$(SHELL) $(srcdir)/configure --no-create --verbose

Makefile: $(srcdir)/Makefile.in config.status
	$(SHELL) config.status

mostlyclean clean distclean extraclean realclean::
	for name in $(alldirs); do (cd $${name}; $(MAKE) $@ || exit 1); done

realclean distclean::
	rm -f Makefile config.status config.log config.cache

extraclean::
	rm -f *~ *\#* patch* *.orig *.rej core a.out *.i *.s
	rm -f *log *gf *pk *.tfm *.pl *.dvi

configclean:
	rm -f configure lib/c-auto.h.in lib/c-auto.h

# 
# Local variables:
# page-delimiter: "^# \f"
# End:
