# Makefile to generate the GNU Pascal run time system.
#
#   Copyright (C) 1991 Free Software Foundation, Inc.
#
#   This file is part of GNU Pascal Library.
#
# The GNU Pascal Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# The GNU Pascal Library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with the GNU Pascal Library; see the file COPYING.LIB.  If
# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
# Cambridge, MA 02139, USA.  */

#
# System type is defined in GCC configuration file config.h that
# is a link to one of the config/xm-*.h files
#
# Currently the run time system understands only
# USG systems and NOT-USG systems, which are defined to
# be BSD systems in gpcsym.h
#

# If you have problems with RANLIB, check that your standard BSD
# ranlib (which calls "ar" internally) does not get GNU ar, since
# GNU ar does not allow non-object files to be placed into the
# archive!!!!

GPCLIB=	libgpc.a

VERSION=2.7

# We don't install, the upper level make does it for us.


# Rather use the compiler specified by the upper level Makefile
#
# I (must?!) do two separate makes, so I define everything here. PG
#
COMMON_CFLAGS= -DGPC $(MY_CFLAGS)
RTSFLAGS=$(COMMON_CFLAGS) $(MY_LIBFLAGS)
RTS_GCC=$(gccdir)/gcc -B$(gccdir)/ # no warning options
CC=$(RTS_GCC)

#
# These might be overriden by the upper level makefile.
#
objdir = ..

srcdir = ..
gccsrc = ../../gcc-263
gccdir = ../../gcc-263
libdir = /usr/lib

VPATH= .:$(srcdir)/rts:$(srcdir):$(gccsrc)

RANLIB = ar s

#
# DEBUG		to be able to see run time system debug messages
#		(-Grts -d -- option to your Pascal program. On by default.)
#
#
# You can define these in command line by setting e.g.:

MY_LIBFLAGS=-DNO_DEVNULL

# on the top level gpc make command.
# But I define it here. PG
#
# The following HAVE_* are defined in rts/rts.h unless you define NO_*
# e.g. HAVE_FTRUNCATE is defined unless you define NO_FTRUNCATE
#
# NO_FTRUNCATE
# NO_DEVNULL
# NO_CASECMP
# NO_SETINEBUF
# NO_GETTIMEOFDAY
#
# In addition, you might define the following (undefined otherwise):
#
# HAVE_STRDUP
# HAVE_TIME
# WARN_READ_ONLY
# PATH_SEPARATOR	default '/'
#
# If the included system header files don't specify which kind of system you are,
# the following are currently recognized:
# 
# BSD			BSD system
# _BSD			-"-
#
# USG			SYSTEM V
# SYSV			-"-
#

INCLUDES= -I.. -I$(gccdir) -I$(gccsrc) -I$(gccsrc)/config

CCFLAGS= -DDEBUG

CFLAGS= $(RTSFLAGS) $(CCFLAGS)

PRINT=	print

#
# If you need malloc libary, get it from Emacs or somewere.
#
#MALLOC = malloc.o
MALLOC =

SRCS=	rts-vers.c rts-writ.c rts-read.c rts-file.c \
	rts-rand.c rts-heap.c rts-setu.c rts-rt0.c  \
	rts-erro.c rts-time.c rts-misc.c rts-set.c \
	rts-math.c rts-stri.c rts-rdsu.c rts-zmat.c \
	rts-bind.c

# Also as defines to split the math file
MATHOBJS= p_ARCTAN.o p_SQRT.o p_LN.o p_EXP.o p_SIN.o p_COS.o p_POW.o p_EXPON.o
ZMATHOBJS=z_ARCTAN.o z_SQRT.o z_LN.o z_EXP.o z_SIN.o z_COS.o z_POW.o z_EXPON.o \
	  p_POLAR.o p_ARG.o

OBJS=	rts-vers.o rts-writ.o rts-read.o rts-file.o \
	rts-rand.o rts-heap.o rts-setu.o rts-rt0.o  \
	rts-erro.o rts-time.o rts-misc.o rts-set.o \
	rts-stri.o rts-bind.o $(MALLOC)

HS=	rts.h rts-fdr.h rts-hdr.h rts-machine.h

all:	$(GPCLIB)

.c.o:
	$(CC) -c $(CFLAGS) $(CPPFLAGS) $(INCLUDES) $<

$(GPCLIB): rts-vers.c $(OBJS) $(MATHOBJS) $(ZMATHOBJS)
	touch $(GPCLIB)
	del $(GPCLIB)
	ar cr $(GPCLIB) $(OBJS) $(MATHOBJS) $(ZMATHOBJS)
	$(RANLIB) $(GPCLIB)

install: all
	copy libgpc.a $(libdir)\gpc.a

#rts-version.c: Makefile
#	echo 'VARLIST="PROG1"'  > gnuvers.con
#	echo 'PROG1='$(VERSION) >> gnuvers.con
#	sh $(srcdir)/gnuvers.sh gnuvers.con $(srcdir)/rts/Version.c
#	mv version.c rts-version.c
# Must exist. PG

rts-stri.o: rts-stri.c rts-rdsu.c
rts-read.o: rts-read.c rts-rdsu.c

$(MATHOBJS):  math-stam
$(ZMATHOBJS): zmath-sta

math-stam: rts-math.c rts.h
	$(CC) -c -o p_ARCTAN.o -Dp_ARCTAN $(INCLUDES) $(srcdir)/rts/rts-math.c
	$(CC) -c -o p_SQRT.o -Dp_SQRT $(INCLUDES) $(srcdir)/rts/rts-math.c
	$(CC) -c -o p_LN.o -Dp_LN $(INCLUDES) $(srcdir)/rts/rts-math.c
	$(CC) -c -o p_EXP.o -Dp_EXP $(INCLUDES) $(srcdir)/rts/rts-math.c
	$(CC) -c -o p_SIN.o -Dp_SIN $(INCLUDES) $(srcdir)/rts/rts-math.c
	$(CC) -c -o p_COS.o -Dp_COS $(INCLUDES) $(srcdir)/rts/rts-math.c
	$(CC) -c -o p_POW.o -Dp_POW $(INCLUDES) $(srcdir)/rts/rts-math.c
	$(CC) -c -o p_EXPON.o -Dp_EXPON $(INCLUDES) $(srcdir)/rts/rts-math.c
	touch math-stam

zmath-sta: rts-zmat.c rts.h
	$(CC) -c -o z_ARCTAN.o -Dz_ARCTAN $(INCLUDES) $(srcdir)/rts/rts-zmath.c
	$(CC) -c -o z_SQRT.o -Dz_SQRT $(INCLUDES) $(srcdir)/rts/rts-zmath.c
	$(CC) -c -o z_LN.o -Dz_LN $(INCLUDES) $(srcdir)/rts/rts-zmath.c
	$(CC) -c -o z_EXP.o -Dz_EXP $(INCLUDES) $(srcdir)/rts/rts-zmath.c
	$(CC) -c -o z_SIN.o -Dz_SIN $(INCLUDES) $(srcdir)/rts/rts-zmath.c
	$(CC) -c -o z_COS.o -Dz_COS $(INCLUDES) $(srcdir)/rts/rts-zmath.c
	$(CC) -c -o z_POW.o -Dz_POW $(INCLUDES) $(srcdir)/rts/rts-zmath.c
	$(CC) -c -o z_EXPON.o -Dz_EXPON $(INCLUDES) $(srcdir)/rts/rts-zmath.c
	$(CC) -c -o p_POLAR.o -Dp_POLAR $(INCLUDES) $(srcdir)/rts/rts-zmath.c
	$(CC) -c -o p_ARG.o -Dp_ARG $(INCLUDES) $(srcdir)/rts/rts-zmath.c
	touch zmath-sta

# Not done here
#install: $(libsubdir)/$(GPCLIB)
#
#$(libsubdir)/$(GPCLIB): $(GPCLIB)
#	$(INSTALL_PROGRAM) $(GPCLIB) $(libsubdir)/$(GPCLIB)
#	$(RANLIB) $(libsubdir)/$(GPCLIB)

depend: $(SRCS) $(HS)
	mkdep $(CFLAGS) $(SRCS) $(HS)

#clean:
#	rm -f $(OBJS) core $(GPCLIB) miten.meni* $(MATHOBJS) $(ZMATHOBJS)
#	rm -f math-stamp zmath-stamp rts-version.o rts-version.c gnuvers.conf

#lint:
#	lint $(CCFLAGS) $(SRCS)

#print:
#	$(PRINT) $(HS) $(SRCS)

# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.

# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
