# Makefile for g++ library version 1.25.0

# Copyright (C) 1988 Free Software Foundation
#   written by Doug Lea (dl@rocky.oswego.edu)

# This file is part of GNU CC.

# GNU CC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY.  No author or distributor
# accepts responsibility to anyone for the consequences of using it
# or for whether it serves any particular purpose or works at all,
# unless he says so in writing.  Refer to the GNU CC General Public
# License for full details.

# Everyone is granted permission to copy, modify and redistribute
# GNU CC, but only under the conditions described in the
# GNU CC General Public License.   A copy of this license is
# supposed to have been given to you along with GNU CC so you
# can know your rights and responsibilities.  It should be in a
# file named COPYING.  Among other things, the copyright notice
# and this notice must be preserved on all copies.


# you must have write permission to the following directory that
# will hold libg++.a and g++-include. 
LIBDIR = /usr/local/lib

#location to place  the genclass class generator
BINDIR = /usr/local

# location of include and prototype file directories 
IDIR = g++-include
PDIR = g++-proto
I = $(LIBDIR)/$(IDIR)
PROTO = $(LIBDIR)/($PDIR)

GXX = g++

# g++ compliation flags:
# the fchar-charconst flag is mandatory for some stream ops to work sensibly

GFLAGS= -g -O -fchar-charconst 


# use gcc for archived C files
CC = gcc
CFLAGS = -g -O -I$I

# compilation notes:
# No g++ warnings or error messages are expected to appear.
#

# g++ library sources 
SRCS = builtin.cc assert.cc File.cc stream.cc PlotFile.cc SFile.cc \
 Obstack.cc regex.c String.cc Integer.cc Rational.cc Complex.cc \
 BitSet.cc BitVec.cc BitString.cc Random.cc Binomial.cc Geometric.cc \
 HyperGeometric.cc NegativeExpntl.cc Normal.cc Poisson.cc \
 RandomInterval.cc RandomRange.cc Weibull.cc Erlang.cc \
 RNG.cc ACG.cc MLCG.cc LogNormal.cc assert.cc SampleStatistic.cc \
 SampleHistogram.cc

OBJS = builtin.o File.o  stream.o  PlotFile.o  SFile.o \
 Obstack.o  regex.o String.o  Integer.o Rational.o Complex.o \
 BitSet.o BitVec.o BitString.o Random.o  Binomial.o  Geometric.o \
 HyperGeometric.o NegativeExpntl.o Normal.o Poisson.o \
 RandomInterval.o  RandomRange.o Weibull.o Erlang.o \
 RNG.o ACG.o MLCG.o LogNormal.o assert.o SampleStatistic.o \
 SampleHistogram.o


# standard C compatibility header files
STDH = $I/std.h $I/stddef.h $I/stdio.h $I/math.h $I/stdarg.h \
 $I/regex.h $I/builtin.h $I/values.h $I/assert.h $I/generic.h

# g++ library class declaration files

GXXH = $I/File.h $I/stream.h $I/SFile.h $I/PlotFile.h $I/Obstack.h \
 $I/String.h $I/Integer.h $I/Rational.h $I/Complex.h $I/BitSet.h $I/BitVec.h \
 $I/BitString.h $I/Random.h $I/Binomial.h $I/Erlang.h $I/Geometric.h \
 $I/HyperGeometric.h $I/NegativeExpntl.h $I/Poisson.h $I/RandomInterval.h \
 $I/RandomRange.h $I/Weibull.h $I/Normal.h $I/LogNormal.h $I/RNG.h \
 $I/ACG.h $I/MLCG.h $I/SampleStatistic.h $I/SampleHistogram.h

# test0 files
TSRCS = test.hello.cc test.bye.cc test.bye2.cc test.shell.cc 
TOUTS = test0 test.bye test.bye2 test.shell 

# all g++ files should have extension .cc
.SUFFIXES: .cc
.cc.o:
	$(GXX) $(GFLAGS) -c  $<

# test0 should be run first to check g++, ld++, crt0/1 and std includes

test0: test.hello.o test.bye test.bye2 test.shell dummylibg++.a
	install -c dummylibg++.a $(LIBDIR)/libg++.a
	ranlib $(LIBDIR)/libg++.a
	$(GXX) test.hello.o -o test0
	@echo "please run test0 and follow instructions"

test.hello.o: test0.h test.hello.cc
	$(GXX) -c $(GFLAGS) test.hello.cc -o test.hello.o

test.bye: test0.h test.bye.cc
	$(GXX) -c $(GFLAGS) test.bye.cc -o test.bye

test.bye2: test0.h test.bye2.cc
	$(GXX) -c $(GFLAGS) test.bye2.cc -o test.bye2

test.shell: test0.h test.shell.cc
	$(GXX) -c $(GFLAGS) test.shell.cc -o test.shell

dummylibg++.a: dummylibg++.cc  $(STDH)
	$(GXX) -c $(GFLAGS) dummylibg++.cc
	ar r dummylibg++.a dummylibg++.o

installincl:
	cp -r $(IDIR) $(LIBDIR)
	cp -r $(PDIR) $(LIBDIR)
	install -c -m 755 genclass $(BINDIR)


libg++.a: $(STDH) $(GXXH) $(OBJS) inlines.o
	ar r libg++.a $(OBJS) inlines.o
	install -c libg++.a $(LIBDIR)
	ranlib $(LIBDIR)/libg++.a

inlines.o: inlines.cc $(STDH) $(GXXH)
	$(GXX) $(GFLAGS) -fkeep-inline-functions -c inlines.cc


tests: libg++.a $(STDH) $(GXXH)
	(cd tests;	make)

clean:
	rm -f *.o core libg++.a dummylibg++.a


# dependencies

File.o:     $I/File.h $I/std.h $I/stddef.h $I/stdio.h $I/builtin.h
stream.o:   $I/stream.h $I/File.h $I/stdio.h $I/builtin.h
PlotFile.o: $I/PlotFile.h $I/File.h $I/stdio.h $I/builtin.h
SFile.o:    $I/SFile.h $I/File.h $I/std.h $I/stddef.h $I/stdio.h $I/builtin.h
Obstack.o:  $I/Obstack.h $I/builtin.h
String.o:   $I/String.h $I/stream.h $I/regex.h $I/std.h $I/builtin.h
Integer.o:  $I/Integer.h $I/stream.h $I/File.h $I/builtin.h
Rational.o: $I/Rational.h $I/Integer.h $I/stream.h $I/File.h $I/builtin.h
Complex.o:  $I/Complex.h $I/stream.h $I/File.h $I/builtin.h
BitSet.o:   $I/BitSet.h $I/stream.h $I/builtin.h
BitVec.o:   $I/BitVec.h $I/stream.h $I/builtin.h
BitString.o: $I/BitString.h $I/stream.h $I/builtin.h
regex.o:    $I/regex.h
builtin.o:  $I/builtin.h $I/math.h
RNG.o:      $I/RNG.h
MLCG.o:     $I/RNG.h $I/MLCG.h
ACG.o:      $I/RNG.h $I/ACG.h
Random.o:   $I/assert.h $I/Random.h $I/RNG.h
Binomial.o: $I/Random.h $I/Binomial.h
Erlang.o:   $I/Random.h $I/Erlang.h 
Geometric.o: $I/Random.h $I/Geometric.h 
HyperGeometric.o: $I/Random.h $I/HyperGeometric.h 
NegativeExpntl.o: $I/Random.h $I/NegativeExpntl.h 
Normal.o:   $I/Random.h $I/Normal.h
LogNormal.o:   $I/Random.h $I/LogNormal.h
Poisson.o:  $I/Random.h $I/Poisson.h 
RandomInterval.o: $I/Random.h $I/RandomInterval.h
RandomRange.o: $I/Random.h $I/RandomRange.h
Weibull.o:  $I/Random.h $I/Weibull.h 
SampleStatistic.o: $I/SampleStatistic.h
SampleHistogram.o: $I/SampleStatistic.h $I/SampleHistogram.h
