#
# Makefile ---	Makefile for Portable Forth Environment.
#
#		Automatically generated, if you change it next time you
#		configure pfe your changes are lost. See
#			src/config/your_system/
#		for files to introduce permanent changes into.
#


#
# default/basics.mk ---	Part of makefile for pfe, some basic variables.
#

c=.c
i=.i
s=.s
o=.o
e=

nothing=
eo=-o $(nothing)
oo=-o $(nothing)
d=-D
x=/

RM=rm -f
CP=cp
MV=mv
MD=mkdir -p

TRASH=core *.core a.out *.bak *~


#
# default/options.mk --- Part of Makefile for PFE, compiler options.
#

# You *must* check file `INSTALL' if you need -D_BSD.
# Read file `TUNING' for the meaning of -DUSE_REGS.

# Where you store online help files and other stuff. Defaults to
PREFIX=/vsta
PFELIB=$(PREFIX)/lib/pfe
PFEHLP=$(PFELIB)/help

SYSTEM=UNIX

CC=gcc
OPTIM=-O -g
# OPTIM=-O -DUSE_REGS -DUNROLL_NEXT
DEBUG=-g

CL=$(CC)
CPP=$(CC) -E

OPTIONS=
# OPTIONS=-D_BSD
STRIP=-s
TERM_O=termunix$o
SYS_O=unix$o
LFLAGS=
LIBS=-ltermcap -lm


#
# default/rules.mk ---	Part of Makefile for PFE, additional rules.
#
#
#.SUFFIXES:	$c $i $s $o $e
#
#$c$s:
#		$(CC) $(CFLAGS) -S $<
#
#$c$i:
#		$(CPP) $(CFLAGS) $< > $*.i
#
#$c$e:
#		$(CC) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -o $@
#

#
# default/depend.mk ---	Part of Makefile for PFE: dependencies.
#

DEFINES =	$(d)PREFIX=$(PREFIX) $(d)PFELIB=$(PFELIB) $(d)PFEHLP=$(PFEHLP)

# if you want a final optimized version uncomment these lines:
CFLAGS =	$(OPTIONS) $(OPTIM) $(DEFINES)
# LDFLAGS =	$(STRIP) $(LFLAGS)
LDFLAGS =	$(LFLAGS)

# if you want a version for C-level debugging uncomment these lines:
#CFLAGS =	$(OPTIONS) $(DEBUG) $(DEFINES)
#LDFLAGS =	$(DEBUG) $(LFLAGS)


# object files that should be clean ANSI-C:
ANSOBJ =	core$o block$o double$o xception$o facility$o file$o \
		floating$o locals$o memory$o toolkit$o search$o string$o \
		forth-83$o lpf83$o misc$o showhelp$o debug$o dblsub$o \
		filesub$o support$o dictnry$o vocs$o lined$o term$o

# object files containing environmental dependencies:
ENVOBJ =	main$o $(TERM_O) 4ed$o signals$o sysdep$o $(SYS_O) shell$o \
		yours$o

OBJECTS =	$(ANSOBJ) $(ENVOBJ)

HEADERS =	forth.h config.h virtual.h options.h const.h types.h macros.h \
		support.h preload.h compiler.h dblsub.h term.h help.h lined.h


all:		pfe$e helpidx$e showhelp$e


pfe$e:		$(OBJECTS) version$o
		$(RM) pfe$e
		$(CL) $(LDFLAGS) $(eo)pfe$e $(OBJECTS) version$o $(LIBS)

$(OBJECTS):	$(HEADERS)
$(ENVOBJ):	$(HEADERS) nonansi.h

version$o:	$(OBJECTS)

clean:
		$(RM) pfe$e helpidx$e showhelp$e *$o $(TRASH)

new:		clean all

veryclean:	clean
		$(RM) config.h Makefile

testit:		pfe$e
		( cd ..$(x)test; .$(x)do-tests )


# Rules for the standalone help programs:

helpidx$e:	helpidx$o helpsub$o
		$(CL) $(LDFLAGS) $(eo)helpidx$e helpidx$o helpsub$o

showhelp$e:	showhlps$o helpsub$o
		$(CL) $(LDFLAGS) $(eo)showhelp$e showhlps$o helpsub$o

showhlps$o:	showhelp.c $(HEADERS)
		$(CC) $(CFLAGS) $(d)STANDALONE -c showhelp.c $(oo)showhlps$o

helpidx$o:	helpidx.c $(HEADERS)
		$(CC) $(CFLAGS) $(d)STANDALONE -c helpidx.c $(oo)helpidx$o

helpsub$o:	helpsub.c $(HEADERS)
		$(CC) $(CFLAGS) $(d)STANDALONE -c helpsub.c $(oo)helpsub$o

install:	all
		if [ ! -d $(PFELIB) ]; then $(MD) $(PFELIB); fi		;\
		if [ ! -d $(PFEHLP) ]; then $(MD) $(PFEHLP); fi		;\
		$(CP) helpidx$e showhelp$e ..$(x)help$(x)*.hlp $(PFEHLP);\
		cd $(PFEHLP)						;\
		.$(x)helpidx$e -o $(PFEHLP)$(x)index *.hlp
