# Makefile for GNU C++ class library (libg++)
#   Copyright (C) 1989, 1992, 1993 Free Software Foundation, Inc.
#   written by Doug Lea (dl@rocky.oswego.edu)

#This file is part of GNU libg++.

#GNU libg++ is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 1, or (at your option)
#any later version.

#GNU libg++ 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 General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with GNU libg++; see the file COPYING.  If not, write to
#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

srcdir = .

# We specify exactly what we want to pass down; don't let GNU make
# 3.63 overload the command line.
MAKEOVERRIDES=

###**######################################################################
#
# Directories, paths, compilation flags and program names.
#
# If a macro needs to have a different value, then change it in the
# site/architecture specific makefile in the directory config !
#
# This file contains the documentation for the macros and possible values.
# Don't remove them even, if they are only comments !

VERSION = 2.5.2
LIBG++_DIST_VERSION = $(VERSION)

# ------- System-dependent defines

# g++ so specific flags
OSFLAG=

# ld or ld++ os specific libraries
#OSLIBS =

# Comment out the next line to disable incremental linking test
# (this test NOT included in 1.39.0, so don't re-enable) ??? H.S.
#TEST0=test0
#TEST0=

# targets for test-install
TEST_INSTALL 		= test-90S-then-clean # test-90D-then-clean
VERIFY_GXX_INSTALLATION = foo_main # dfoo_main


# You can override gperf to not build it at all
GPERF = gperf
NON_IO_SUBDIRS	=  genclass src $(GPERF) utils tests etc test-install
SUBDIRS	=  $(NON_IO_SUBDIRS)
ALL_SUBDIRS = $(NON_IO_SUBDIRS) old-stream no-stream

ALL	=  verify-gxx-installation genclass src $(GPERF) $(UTILS)
CHECK	=  tests etc etc-tests
UTILS   =  # utils

# C++ compiler to use when testing that installation has succeeded.
INSTALLED_CXX=$(bindir)/gcc

TARGETLIB = libg++.a

# Used to insert objects from libiberty into libg++.a.
LIBIBERTY = libiberty
LIBIBERTY_OBJECTS_TO_GET = `cat needed-list` strerror.o strsignal.o

#### package, host, target, and site dependent Makefile fragments come in here.
##

tooldir = $(exec_prefix)/$(target)
INSTALLDIR = $(libdir)

###**######################################################################
#
# compilation actions

.PHONY: rest-in-parallel in-src in-io
rest-in-parallel: .stmp-genclass .stmp-tests .stmp-etc .stmp-gperf .stmp-utils

# We assume libiberty is made before .
$(TARGETLIB): in-io in-src stamp-$(TARGETLIB)

stamp-$(TARGETLIB): src/libgxx.list $(IO_DIR)/iostream.list ../$(LIBIBERTY)/libiberty.a
	-rm -f $(TARGETLIB)
	rootme=`pwd`/ ; export rootme ; cd src ; \
	  $(AR) $(AR_FLAGS) ../$(TARGETLIB) `cat libgxx.list`
	cd $(IO_DIR); \
	  $(AR) $(AR_FLAGS) ../libg++/$(TARGETLIB) `cat iostream.list`
	cd ../$(LIBIBERTY); \
	  $(AR) $(AR_FLAGS) ../libg++/$(TARGETLIB) $(LIBIBERTY_OBJECTS_TO_GET)
	$(RANLIB) $(TARGETLIB)
	@touch stamp-$(TARGETLIB)

src/libgxx.list: in-src
in-src:
	@rootme=`pwd`/ ; export rootme ; cd src ; \
		$(MAKE) $(FLAGS_TO_PASS) libgxx.list

$(IO_DIR)/iostream.list: in-io
in-io:
	@rootme=`pwd`/ ; export rootme ; cd $(IO_DIR) ; \
		$(MAKE) $(FLAGS_TO_PASS) iostream.list

in-libiberty:
	@rootme=`pwd`/ ; export rootme ; cd ../$(LIBIBERTY) ; \
		$(MAKE) $(FLAGS_TO_PASS)

.PHONY: installcheck
installcheck: check

.stmp-genclass: $(TARGETLIB)
	@rootme=`pwd`/ ; export rootme ; cd genclass ; \
	  $(MAKE) $(FLAGS_TO_PASS) "gxx_includedir=$(gxx_includedir)"
	touch $@

.stmp-tests: $(TARGETLIB)
	@rootme=`pwd`/ ; export rootme ; cd tests ; \
	  $(MAKE) $(FLAGS_TO_PASS)
	touch $@

.stmp-etc: $(TARGETLIB)
	@rootme=`pwd`/ ; export rootme ; cd etc ; \
	  $(MAKE) $(FLAGS_TO_PASS)
	touch $@

.stmp-gperf: $(TARGETLIB)
	@if [ "x$(GPERF)" != "x" ]; then \
	   rootme=`pwd`/ ; export rootme ; cd $(GPERF) ; \
	      $(MAKE) $(FLAGS_TO_PASS); \
	 else true; fi
	touch $@

.stmp-utils: $(TARGETLIB)
	@if [ "x$(UTILS)" != "x" ]; then \
	   rootme=`pwd`/ ; export rootme ; cd $(UTILS) ; \
	     $(MAKE) $(FLAGS_TO_PASS); \
	 else true; fi
	touch $@

#
#
# Installation
#

.PHONY: install
install:
	$(INSTALL_DATA) $(TARGETLIB) $(INSTALLDIR)/$(TARGETLIB)
	$(RANLIB) $(INSTALLDIR)/$(TARGETLIB)
	chmod a-x $(INSTALLDIR)/$(TARGETLIB)
	cd $(srcdir)/src; \
	for FILE in *.h gen/*.ccP gen/*.hP; do \
		rm -f $(gxx_includedir)/$$FILE ; \
		$(INSTALL_DATA) $$FILE $(gxx_includedir)/$$FILE || exit 1; \
		chmod a-x,a+r $(gxx_includedir)/$$FILE ; \
	done
	if [ "x$(GPERF)" != "x" ]; then \
	  cd gperf ; $(MAKE) $(FLAGS_TO_PASS) install; \
	else true; fi
	@for D in genclass $(UTILS) ; do \
		if [ -d $$D ] ; then \
			(cd $$D; $(MAKE) $(FLAGS_TO_PASS) "gxx_includedir=$(gxx_includedir)" install) ; \
		else true ; \
		fi ; \
	done

installcheck:
	if [ "x$(TEST_INSTALL)" != "x" ]; then \
	  cd test-install; $(MAKE) $(TEST_INSTALL) \
	      CXX=$(INSTALLED_CXX) "CXXFLAGS=$(CXXFLAGS)" \
	      COMPILE_FLAGS="" LIBS=-lg++; \
	else true; fi

DIST_NAME = libg++-$(LIBG++_DIST_VERSION)

$(DIST_NAME).tar.gz: dist

# Making a dist:
# cvs rtag libgxx-x-yy libg++
# cvs co -r libgxx-x-yy libg++
# Sanitize
# cd {HERE}/..
# make -f Makefile.in libg++.tar.gz

diststuff: info

force:
.PHONY: $(SUBDIRS) dist
