# Makefile for pep   1995-08-11 [gh]
#-----------------------------------------------------------------------------
# Abstract:
#    Generic makefile for pep.
#
# Design:
#    This Makefile will work under Unix, with Borland's make and MS nmake.
#
#    It assumes that some DOS utilities (i.e. make, pkzip, shar) are clever
#    enough to understand Unix subdirectory separator (/).
#
#    If you don't have sed, then use an editor to define the symbol "LIBY",
#    in the file plain.src/plain.c to be your own library directory for the
#    filter files.
#
#    To make pep on a particular platform, set/remove comments in the
#    "customization section" below.  Also, edit the directories etc. so that
#    things install in the right places.
#
#     For DOS, plain.c and Doc/pep.txt can't be remade..
#
# Targets:
#    - it      : build program
#    - date    : set datastamp for all files in distribution
#    - zipus   : the international distribution archive
#    - zipno   : adds extra files for Norwegian archive
#    - zipxx   : adds my personal files
#    - zipall  : zipus + zipno + zipxx
#    - manhc   : print manual
#    - install : install the stuff
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
#                        START OF CUSTOMIZATION SECTION
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# MS-DOS, Microsoft C
#CC	= cl
#CFLAGS	= /DMSDOS
#LFLAGS	= -o pep
#SFLAGS	= -a
#SRC	= c
#XXX	= x
#OBJ	= obj
#OBJS	= main.obj ansi.obj plain.obj bdmg.obj
#RM	= rm
#EXES	= pep.exe
#RMISC	=
#ZIP	= pkzip
#UNZIP	= pkunzip

# MS-DOS, Borland C
#CC	= bcc
#CFLAGS	= -w-pia -w-def
#LFLAGS	= -epep
#SRC	= c
#XXX	= x
#OBJ	= obj
#OBJS	= main.obj ansi.obj plain.obj bdmg.obj
#ZFLAGS	= -a -o -P
#RM	= rm
#EXES	= pep.exe
#RMISC	=
#ZIP	= pkzip
#UNZIP	= pkunzip

# Unix (Solaris, Linux)
CC	= gcc
LFLAGS	= -o pep
SRC	= src
XXX	= c
OBJ	= o
OBJS	= main.o   ansi.o   plain.o
RM	= \rm -f
EXES	= pep
RMISC	= plain.c Doc/pep.txt
ZIP	= zip
UNZIP	= unzip

# directories, etc.
BINDIR	= $(HOME)/bin/$(HOSTTYPE)
LIBDIR	= $(HOME)/lib/pep
MANEXT	= 1
MANDIR	= $(HOME)/man/man$(MANEXT)
TODAY	= 19950811
CLOCK	= 0200
VER	= 28

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#                         END OF  CUSTOMIZATION SECTION
#-----------------------------------------------------------------------------

# Files
DIZ0	= file_id.diz
MAKE	= Makefile
DOC1	= aareadme.txt Doc/header.txt Doc/pep.man
DOC2	= Doc/pep.txt
DOC3	= Doc/hjelp.txt
SRCS	= ansi.c bdmg.c main.c plain.$(SRC) pep.h bdmg.h
FLT1	= Filters/mac2iso Filters/iso2mac Filters/ibm2iso Filters/iso2ibm
FLT2	= Filters/mac2ibm Filters/ibm2mac Filters/ibm2ro8 Filters/ro82ibm
FLT3	= Filters/ebc2ns7 Filters/iso2as7 Filters/iso2ns7 Filters/nxt2ns7
STUF	= Doc/poster.txt
# crlf.tst notes.let pep.dok

.c.obj:
	$(CC) -c $(CFLAGS) $<

it:		generic

dist:		zipus zipno

archive:	zipus zipno zipxx

# Unix only
date: Doc/pep.txt
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) aareadme.txt
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) file_id.diz
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Makefile
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) ansi.c
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) bdmg.c
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) main.c
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) plain.$(SRC)
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) bdmg.h
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) pep.h
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) pep.exe
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Doc/poster.txt
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Doc/pep.man
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Doc/pep.txt
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Doc/pep.$(MANEXT)
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Doc/header.txt
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Doc/hjelp.txt
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Doc/copying.txt
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Filters/mac2ibm
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Filters/ibm2mac
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Filters/mac2iso
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Filters/ebc2ns7
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Filters/ibm2ro8
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Filters/ro82ibm
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Filters/ibm2iso
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Filters/iso2ibm
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Filters/iso2mac
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Filters/iso2as7
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Filters/iso2ns7
	/usr/bin/touch -m -t $(TODAY)$(CLOCK) Filters/nxt2ns7

zipus:		$(MAKE) $(DIZ0) $(DOC1) $(DOC2) $(SRCS) $(FLT1) $(FLT2) $(FLT3) pep.exe
	-$(RM) pep$(VER).zip
	$(ZIP) $(ZFLAGS) pep$(VER) $(MAKE) $(DIZ0) $(DOC1) $(DOC2)
	$(ZIP) $(ZFLAGS) pep$(VER) $(SRCS) pep.exe
	$(ZIP) $(ZFLAGS) pep$(VER) $(FLT1)
	$(ZIP) $(ZFLAGS) pep$(VER) $(FLT2)
	$(ZIP) $(ZFLAGS) pep$(VER) $(FLT3)
	$(UNZIP) -v pep$(VER).zip
	@echo Archive should contain 25 files

zipno:		$(DOC3)
	$(ZIP) $(ZFLAGS) pep$(VER) $(DOC3)
	$(UNZIP) -v pep$(VER).zip
	@echo Archive should contain 26 files

zipxx:		$(STUF)
	$(ZIP) $(ZFLAGS) pep$(VER) $(STUF)
	$(UNZIP)  -v pep$(VER).zip
	@echo Archive should contain 28 files

# Unix only
pep.txt:	Doc/pep.txt
Doc/pep.txt:	Doc/pep.$(MANEXT)
	nroff -man -Tlp Doc/pep.$(MANEXT) | pep > Doc/pep.txt

# Unix only
manhc:		Doc/pep.$(MANEXT)
	psroff -man Doc/pep.$(MANEXT)

# Unix only
install:	Doc/pep.$(MANEXT) $(FLT1) $(FLT2) $(FLT3)
	-cp pep $(BINDIR)
	-cp Doc/pep.$(MANEXT) $(MANDIR)
	-mkdir $(LIBDIR)
	-cp $(FLT1) $(FLT2) $(FLT3) $(LIBDIR)


#---( compilations )----------------------------------------------------------

generic:	$(OBJS)
	$(CC) $(LFLAGS) $(OBJS)

cpm86:		$(OBJS)
	cc -D__CPM86__ -i15/ main.c ansi.c plain.c bdmg.c

vms:		main.c ansi.c plain.c bdmg.c
	cc/nowarnings main.c
	cc/nowarnings ansi.c
	cc/nowarnings plain.c
	cc/nowarnings/define=STRICMP bdmg.c
	link/executable=pep.exe main.obj,plain.obj,ansi.obj,bdmg.obj

#---( objects )---------------------------------------------------------------

main.$(OBJ):	main.c	pep.h bdmg.h
ansi.$(OBJ):	ansi.c	pep.h
plain.$(OBJ):	plain.c pep.h
bdmg.$(OBJ):	bdmg.c	pep.h bdmg.h


#---( misc )------------------------------------------------------------------

Doc/pep.$(MANEXT): Doc/pep.man
	    sed -e 's;MANEXT;$(MANEXT);' \
		-e 's;LIBDIR;$(LIBDIR);' \
		< Doc/pep.man \
		> Doc/pep.$(MANEXT)

plain.$(XXX):	plain.src
	    sed -e 's;LIBDIR;$(LIBDIR);' \
		< plain.src \
		> plain.c

#---( housekeeping )----------------------------------------------------------

tidy:
	$(RM) *.$(OBJ) Doc/pep.$(MANEXT) $(RMISC)

clean:
	$(RM) *.$(OBJ) $(EXES) pep*.zip Doc/pep.$(MANEXT) $(RMISC)

# EOF
