#		fm   --   file modifier
#             Copyright (c) Tony Field 1990
#

#	fm works on the following systems:
#	Xenix 2.3.2 and AT&T Unix 3.2.2.
#	SunOS 4.0.3, SPARCstation-1 (others are probably trivial)
#	IBM XT, MS-DOS 3.1, Microsoft C 5.0
#	DECstation-2100/3100, Ultrix
#	Sony News workstation, NEWS-OS (BSD 4.2)
#       Linux 2.0.32.
#
#	other systems have not been tried....
#
#	select the compiler/linker options for your system
#	If you are using a unix-type of system, make fm with:
#
#		make unix
#
#---------------------------------------------
# HPUX (AT&T Unix 3.2.2 - terminfo & curses)
#CC= gcc
#CC= cc
#LDFLAGS= -lHcurses
#CFLAGS= -O -Aa -D_HPUX_SOURCE
#CCFLAGS= $(CFLAGS)
#BINDIR = /usr/remote/bin
#MANDIR = /usr/local/man/man1
#BINDIR = /opt/fm/bin
#MANDIR = /opt/fm/man/man1 

#---------------------------------------------
# Linux 2.0.32 - ncurses  
CC = gcc
LDFLAGS  = -lncurses
CCFLAGS  = -O2 -Wall   
BINDIR = /usr/local/bin
MANDIR = /usr/local/man 

#---------------------------------------------
# Xenix setup:  depending on how the development package was installed,
#               you may choose to include or remove -DM_TERMINFO
# 		and -DM_TERMCAP from the following....

#---------------------------------------------
# Xenix 2.3.2 - terminfo curses
# LDFLAGS = -ltinfo
# CCFLAGS = -O -DSYSV_CURSES -DM_TERMINFO

#---------------------------------------------
# SunOs or Xenix 2.3.2 - termcap curses
O = .o
E = 
#LDFLAGS = -lcurses -ltermcap
#CCFLAGS = -O
#CCFLAGS = -g

#---------------------------------------------
# MS-DOS with Microsoft C 5.0 and pc-curses, available from uunet
# Note 1: you will have to change the link step below as well as
#         the flags in this section.
# Note 2: Huge model is definitely overkill, but I have no patience
#         with 8086 memory models...
#CCFLAGS	= /AH /FPi /J /W3 /I. /Ox /Gs
##CCFLAGS	= /AH /FPi /J /W3 /I. /Zi
#LD = link
## Make sure the memory model of pc-curses agrees with the one chosen above!
#LDFLAGS = lcurses.lib/stack:50000
##LDFLAGS = /CO /stack:50000

#---------------------------------------------
# Other unix systems:  the following may/not work for other unix systems
#		       using termcap curses:
# LDFLAGS = -lcurses
# CCFLAGS = -O

SOURCES = Readme Makefile fm.1 fm.c patchlevel.h vms.hc

OBJECTS=fm$(O)

all:	fm$(E)

fm$(O):	fm.c

fm$(E):	fm$(O)
# for Unix:
	$(CC) $(CCFLAGS) fm$(O) -o fm$(E) $(LDFLAGS)
# for DOS
#	link fm$(O),fm$(E),fm/map,$(LDFLAGS)

unix:
	$(CC) $(CCFLAGS) fm.c $(LDFLAGS) -o fm

lint:
	lint $(LINTFLAGS) fm.c $(LIBS) >fm.lint

shar:
	makekit -oMANIFEST -nfm -s64k $(SOURCES)

tar:
	tar -cvAf fm.tar $(SOURCES)

install: all
	if [ -d $(BINDIR) ]; then set +x; \
	else (set -x; mkdirhier $(BINDIR)); fi
	if [ -d $(MANDIR) ]; then set +x; \
	else (set -x; mkdirhier $(MANDIR)); fi
	cp fm $(BINDIR)
	strip $(BINDIR)/fm
	cp fm.1 $(MANDIR)
	chmod a+r $(MANDIR)/fm.1

clean:
	rm -f fm *.o core a.out
