# Makefile for PS utilities release 1 patchlevel 16
#
# Copyright (C) Angus J. C. Duggan 1991-1995
# See file LICENSE for details.
#
# updated AJCD 14/3/94
#
# Multiple makefiles for different OSes are generated from a single master
# now.
#
# There are so many incompatible makes around that putting all of the
# non-standard targets explicitly seems to be the only way of ensuring
# portability.

# epsffit fits an epsf file to a given bounding box
# psbook rearranges pages into signatures
# psselect selects page ranges
# pstops performs general page rearrangement and merging
# psnup puts multiple logical pages on one physical page
# psresize scales and moves pages to fit on different paper sizes

PAPER=a4

# Makefile for PSUtils under OS/2, GCC C Compiler

BINDIR = \psutils
SCRIPTDIR = $(BINDIR)
INCLUDEDIR = /lib/psutils
PERL = perl

BINMODE = 0755
MANMODE = 0644
CHMOD = chmod
INSTALL = install -c -m $(BINMODE)
INSTALLMAN = install -c -m $(MANMODE)
MANEXT = 1
MANDIR = /man/man$(MANEXT)

CC = gcc
CFLAGS = -DPAPER=\"$(PAPER)\" -DOS2 -Zomf -Zmtd -s -Zlinker /PM:VIO

BIN = psbook.exe psselect.exe pstops.exe epsffit.exe psnup.exe \
	psresize.exe
SHELLSCRIPTS = getafm.cmd
PERLSCRIPTS = fixfmps.cmd fixmacps.cmd fixpsditps.cmd fixpspps.cmd \
	fixtpps.cmd fixwfwps.cmd fixwpps.cmd fixscribeps.cmd fixwwps.cmd \
	fixdlsrps.cmd extractres.cmd includeres.cmd psmerge.cmd
MANPAGES =      \
	    \
	    \
	    \
	  
INCLUDES = md68_0.ps md71_0.ps

all: $(BIN) $(PERLSCRIPTS) $(MANPAGES)

psutil.o: psutil.h patchlev.h pserror.h psutil.c

psspec.o: psutil.h patchlev.h psspec.h pserror.h psspec.c

pserror.o: psutil.h patchlev.h pserror.h pserror.c

epsffit.o: epsffit.c pserror.h patchlev.h

epsffit.exe: epsffit.o pserror.o
	$(CC) -o epsffit pserror.o epsffit.o

psnup.exe: psnup.o psutil.o psspec.o pserror.o
	$(CC) -o psnup psutil.o psspec.o pserror.o psnup.o

psnup.o: psutil.h patchlev.h psspec.h pserror.h psnup.c

psresize.exe: psresize.o psutil.o pserror.o psspec.o
	$(CC) -o psresize psutil.o psspec.o pserror.o psresize.o

psresize.o: psutil.h patchlev.h psspec.h pserror.h psresize.c

psbook.exe: psbook.o psutil.o pserror.o
	$(CC) -o psbook psutil.o pserror.o psbook.o

psbook.o: psutil.h patchlev.h pserror.h psbook.c

psselect.exe: psselect.o psutil.o pserror.o
	$(CC) -o psselect psutil.o pserror.o psselect.o

psselect.o: psutil.h patchlev.h pserror.h psselect.c

pstops.exe: pstops.o psutil.o psspec.o pserror.o
	$(CC) -o pstops psutil.o psspec.o pserror.o pstops.o

pstops.o: psutil.h patchlev.h psspec.h pserror.h pstops.c

psmerge.cmd: psmerge.pl
	$(PERL) maketext PERL=$(PERL) $? > $@
	$(CHMOD) $(BINMODE) $@

fixfmps.cmd: fixfmps.pl
	$(PERL) maketext PERL=$(PERL) $? > $@
	$(CHMOD) $(BINMODE) $@

fixmacps.cmd: fixmacps.pl
	$(PERL) maketext PERL=$(PERL) INCLUDE=$(INCLUDEDIR) $? > $@
	$(CHMOD) $(BINMODE) $@

fixpsditps.cmd: fixpsditps.pl
	$(PERL) maketext PERL=$(PERL) $? > $@
	$(CHMOD) $(BINMODE) $@

fixpspps.cmd: fixpspps.pl
	$(PERL) maketext PERL=$(PERL) $? > $@
	$(CHMOD) $(BINMODE) $@

fixscribeps.cmd: fixscribeps.pl
	$(PERL) maketext PERL=$(PERL) $? > $@
	$(CHMOD) $(BINMODE) $@

fixtpps.cmd: fixtpps.pl
	$(PERL) maketext PERL=$(PERL) $? > $@
	$(CHMOD) $(BINMODE) $@

fixwfwps.cmd: fixwfwps.pl
	$(PERL) maketext PERL=$(PERL) $? > $@
	$(CHMOD) $(BINMODE) $@

fixwpps.cmd: fixwpps.pl
	$(PERL) maketext PERL=$(PERL) $? > $@
	$(CHMOD) $(BINMODE) $@

fixwwps.cmd: fixwwps.pl
	$(PERL) maketext PERL=$(PERL) $? > $@
	$(CHMOD) $(BINMODE) $@

fixdlsrps.cmd: fixdlsrps.pl
	$(PERL) maketext PERL=$(PERL) $? > $@
	$(CHMOD) $(BINMODE) $@

extractres.cmd: extractres.pl
	$(PERL) maketext PERL=$(PERL) $? > $@
	$(CHMOD) $(BINMODE) $@

includeres.cmd: includeres.pl
	$(PERL) maketext PERL=$(PERL) INCLUDE=$(INCLUDEDIR) $? > $@
	$(CHMOD) $(BINMODE) $@


clean:
	RM *.o

veryclean realclean: clean
	RM $(BIN) $(PERLSCRIPTS) $(MANPAGES)

install: install.bin install.script install.include

install.bin: $(BIN)
	-mkdir $(BINDIR)
	@for %1 in ( $(BIN) ) do copy %1 $(BINDIR)

install.script: $(PERLSCRIPTS)
	-mkdir $(SCRIPTDIR)
	@for %1 in ( $(PERLSCRIPTS) ) do copy %1 $(SCRIPTDIR)

install.include: $(INCLUDES)
	-mkdir $(INCLUDEDIR)
	@for %1 in ( $(INCLUDES) ) do copy %1 $(INCLUDEDIR)

