#
# mpage:	A program to reduce pages of print so that several pages
# 	  	of output appear on one sheet of paper.
#
# Copyright (c) 1994-2004 Marcel J.E. Mol, The Netherlands
# Copyright (c) 1988 Mark P. Hahn, Herndon, Virginia
#     
#     This program is free software; you can redistribute it and/or
#     modify it under the terms of the GNU General Public License
#     as published by the Free Software Foundation; either version 2
#     of the License, or (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with this program; if not, write to the Free Software
#     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
#     Marcel Mol                     MESA Consulting
#     Hogeveenseweg 12               P.o. box 112
#     2631 PH Nootdorp               2630 AC  Nootdorp
#     The Netherlands                The Netherlands
#     phone: 015-3101310             phone: +31-6-54724868
#     marcel@mesa.nl                 info@mesa.nl
#                                    http://www.mesa.nl/pub/mpage
#                                    ftp://ftp.mesa.nl/pub/mpage
#  

# Amiga SAS/C adjustments by Andreas R. Kleinert <info@ar-kleinert.de> 1999

# Set this to an ANSI compatible C compiler (preferably gcc)
# See also system specific settings below
#CC=cc
CC=gcc

############################################################################
#
#  MPAGE Configuration
#
############################################################################

#
# Define your favorite page size:
#          Letter for US letter
#          Legal for legal
#          A4 for European A4
#  See glob.c for all possibilities
#
# PAGESIZE=Letter
PAGESIZE=A4

#
# Define your spooler type
#          ATT_SPOOLER for 'lp ...' type printing
#          BSD_SPOOLER for 'lpr ..' tpye printing
#
SPOOL_TYPE=BSD_SPOOLER

# PREFIX=e:/usr		# OS/2 type
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
LIBDIR=$(PREFIX)/lib
MANDIR=$(PREFIX)/man/man1

#
# A default encoding is given in encoding.h. Setting ENCODING=1 will
# activate this encoding by default. 0 switches default off.
# The -C option (without subargument) can be used to switch.
#
ENCODING=1

#
# Set the default sheet margin in 1/72 inches. 
#
SHEETMARGIN=20 


DEFS = -DPAGE_DEF=\"${PAGESIZE}\" -DLIBDIR=\"${LIBDIR}/mpage\" -DDEFAULT_ENCODING=${ENCODING} -DDEFAULTSMARGIN=${SHEETMARGIN} -DSPOOLER=${SPOOL_TYPE}


############################################################################
#
#  OPERATING SYSTEM SETUP
#
############################################################################

# Unix extensions
E = 
O = .o

# OS/2:
# CFLAGS = -O2 $(DEFS) -Wall
# LIBS   = -Zcrtdll -s
# DEF_FILE = mpage.defM
# E = .exe
# O = .o

# MSDOS extensions
# E = .exe
# O = .obj

# AMIGA 68k
CC=sc
CFLAGS =

############################################################################
#
#  UNIXEN SPECIFICS
#
############################################################################

# Choose one of the following CFLAGS/CC definitions:
# If you are using gcc, you probably don't need to change anything here.

# Linux:
#CFLAGS = -O2 -s $(DEFS) -Wall

# AIX (xlC on aix 4):
#CFLAGS = -O2 -s $(DEFS)

# SunOS 4.1.3_U1 1 sun4m (gcc 2.7.2)
#CFLAGS = -O2 -s $(DEFS) -D__USE_FIXED_PROTOTYPES__ -Wall

# SunOS 4.1.3_U1 1 sun4m (standard C-compiler (NOTE: sample.c will not
#     compile, since the standard cc is not ANSI-standard)
#CFLAGS = -O2 -s $(DEFS)

# HP-UX A.09.01 A 9000/735 (standard cc)
#CFLAGS = -Aa +O3 -s $(DEFS) -D_INCLUDE_POSIX_SOURCE -Wall

# BeOS
#CFLAGS= -O2 $(DEFS)

############################################################################
#
# END OF CONFIGURATION OPTIONS
#

# pattern rules. Should we define these?
%$(O): %.c
	$(CC) $(CFLAGS) -c -o $@ $<


HEAD =  mpage.h
DENC =  encoding.h
SRCS =  mpage.c glob.c text.c post.c file.c page.c args.c
MOBJ =  mpage$(O) glob$(O) text$(O) post$(O) file$(O) page$(O) args$(O)
SMPL =  sample.c page.c glob.c args.c
SOBJ =  sample$(O) page$(O) glob$(O) args$(O)

default:	mpage$(E) msample$(E)
	@echo Done!

mpage$(E):	$(MOBJ)
	SLINK LIB:c.o $(MOBJ) TO mpage LIB LIB:sc.lib LIB:amiga.lib SC SD ND

msample$(E):	$(SOBJ)
	SLINK LIB:c.o $(SOBJ) TO msample LIB LIB:sc.lib LIB:amiga.lib SC SD ND

clean:
	rm -rf $(MOBJ) mpage$(E) mpage.ps $(SOBJ) msample$(E) make.log core

mpage$(O):	$(HEAD) $(DENC) mpage.c
glob$(O):	$(HEAD) glob.c
text$(O):	$(HEAD) text.c
post$(O):	$(HEAD) post.c
file$(O):	$(HEAD) file.c
page$(O):	$(HEAD) page.c
args$(O):	$(HEAD) args.c
sample$(O):	$(HEAD) sample.c

mpage.ps:	mpage.1
	psroff -t -man mpage.1 > mpage.ps


#
# add your proper install stuff
#
install:
	if [ ! -d $(LIBDIR)/mpage ] ; then mkdir -p $(LIBDIR)/mpage ; fi
	if [ ! -d $(BINDIR) ] ; then mkdir -p $(BINDIR) ; fi
	if [ ! -d $(MANDIR) ] ; then mkdir -p $(MANDIR) ; fi
	cp mpage$(E) $(BINDIR)
	cp mpage.1 $(MANDIR)
	-cp Encodings/* $(LIBDIR)/mpage
	-chmod 644 $(LIBDIR)/mpage/*
