# $Id: Makefile.in,v 1.21 1997/10/03 10:35:43 zeller Exp $
# DDD top-level Makefile.

# Copyright (C) 1996, 1997 Technische Universitaet Braunschweig, Germany.
# Written by Andreas Zeller <zeller@ips.cs.tu-bs.de>.
# 
# This file is part of the DDD Library.
# 
# The DDD 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 DDD 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 DDD Library -- see the file COPYING.LIB.
# If not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# 
# DDD is the data display debugger.
# For details, see the DDD World-Wide-Web page, 
# `http://www.cs.tu-bs.de/softech/ddd/',
# or send a mail to the DDD developers <ddd@ips.cs.tu-bs.de>.

### CUSTOMIZATION SECTION --- Please check the settings below.
# Typical values are enclosed in ().

## The shell to use.  (/bin/sh)
SHELL = /bin/sh

## The source directory.  (.)
srcdir = @srcdir@
VPATH = @srcdir@

## Subdirectories.  (libiberty librx termcap ddd)
SUBDIRS = @subdirs@

## Architecture.
# The host we were compiled on.  (CPU-COMPANY-SYSTEM)
host_canonical = @host@

# The target we were compiled for.  (CPU-COMPANY-SYSTEM)
target_canonical = @target@

### END OF CUSTOMIZATION SECTION ---
### You shouldn't need to change anything below this line.

## Some programs
# The make program, if not predefined.  ()
@SET_MAKE@

# The autoconf program.  (autoconf)
AUTOCONF = autoconf


## Default target: build all

default: all
	@:
.PHONY: default

## Recursive targets

FLAGS_TO_PASS=\
"host_canonical=$(host_canonical)"\
"target_canonical=$(target_canonical)"

# distclean, realclean -- must cleanup top-level directory

DISTCLEAN_TARGETS = distclean realclean

.PHONY: $(DISTCLEAN_TARGETS)
$(DISTCLEAN_TARGETS): FORCE
	@target=$@; \
	rootme=`pwd`; export rootme; \
	srcroot=`cd $(srcdir); pwd`; export srcroot; \
	for i in $(SUBDIRS); do \
	  rm -f ./$$i/config.cache ./$$i/config.log; \
	  if [ -f ./$$i/Makefile ]; then \
	    echo "==> Making $$target in ./$$i..."; \
	    if (cd ./$$i; $(MAKE) $(FLAGS_TO_PASS) $${target}); then true; \
	    else exit 1; fi; \
          else true; fi; \
        done
	rm -f config.status config.cache config.log Makefile MakeOut .gdbhist


# other recursive targets

OTHER_TARGETS = all clean mostlyclean TAGS

.PHONY: $(OTHER_TARGETS)
$(OTHER_TARGETS): FORCE
	@target=$@; \
	rootme=`pwd`; export rootme; \
	srcroot=`cd $(srcdir); pwd`; export srcroot; \
	for i in $(SUBDIRS); do \
	  if [ -f ./$$i/Makefile ]; then \
	    echo "==> Making $$target in ./$$i..."; \
	    if (cd ./$$i; $(MAKE) $(FLAGS_TO_PASS) $${target}); then true; \
	    else exit 1; fi; \
          else true; fi; \
        done



## DDD-only targets

DDD_TARGETS = \
	love check debug it depend strip dvi ps man html \
	install install-prog install-lib install-man install-info \
	install-c++-lib install-c++-includes \
	uninstall uninstall-prog uninstall-lib uninstall-man uninstall-info \
	uninstall-c++-lib uninstall-c++-includes picsclean

.PHONY: $(DDD_TARGETS)
$(DDD_TARGETS): FORCE
	@target=$@; \
	rootme=`pwd`; export rootme; \
	srcroot=`cd $(srcdir); pwd`; export srcroot; \
	echo "==> Making $$target in ./ddd..."; \
	cd ./ddd; $(MAKE) $${target}


## Dummy targets
.PHONY: scratch
scratch: clean all depend it
	@:

### Distribution stuff

# Build a DDD distribution.
.PHONY: dist
dist:	diststuff disttouch distclean snapshot picsdist

# Create architecture-independent files in DDD subdirectory.
.PHONY: diststuff
diststuff:
	@target=$@; \
	rootme=`pwd`; export rootme; \
	srcroot=`cd $(srcdir); pwd`; export srcroot; \
	echo "==> Making $@ in ddd..."; \
	( cd ./ddd; $(MAKE) diststuff )

# Touch `configure' files souch that they don't get re-created.
.PHONY: disttouch
disttouch:
	@for i in $(SUBDIRS); do \
	  if test -f ./$$i/Makefile && test -f ./$$i/configure; then \
	    echo "==> Making configure in $$i..."; \
	    if (cd ./$$i; $(MAKE) configure); then true; \
	    else exit 1; fi; \
	    if (cd ./$$i; touch configure); then true; \
	    else exit 1; fi; \
          else true; fi; \
        done

# Create a snapshot distribution from the current DDD development tree.
.PHONY: snapshot
snapshot:
	rm -fr proto-toplev; mkdir proto-toplev
	( \
	    ddd=`sed -n < ddd/configure.in 's/^ddd *= *//p'`; \
	    VER=`sed -n < ddd/configure.in 's/^VERSION *= *//p'`; \
	    VER=`echo $$VER | sed 's/[^0-9]*\([0-9][^ ]*\) .*/\1/'`; \
	    echo "==> Making $$ddd-$$VER.tar.gz"; \
	    rm -f $$ddd-$$VER.tar.gz; \
	    ln -s .. proto-toplev/$$ddd-$$VER; \
	    find . -name RCS -prune -o -name CVS -prune -o -name PICS -prune \
		-o -name proto-toplev -prune \
		-o -name '.[a-zA-Z0-9]*' -prune \
		-o -name '*.o' -prune \
		-o -name '*.a' -prune \
		-o -name '*~' -prune \
		-o -name '*#' -prune \
		-o \( -name "$$ddd" -type l \) -prune \
		-o -name "$$ddd-$$VER-*" -prune \
		-o -name "userinfo" -prune \
		-o -name "huffencode" -prune \
		-o -name "ctest" -prune \
		-o -name "cxxtest" -prune \
		-o -name "stringify" -prune \
		-o -name "sun" -prune \
		-o -name "linux" -prune \
		-o -type f -print -o -type l -print | \
	        sed "s,^\.,$$ddd-$$VER," | sort > proto-toplev/FILES; \
	    ( cd proto-toplev; gtar --create --dereference \
		--verbose --files-from FILES \
		--file - ) | gzip -v -9 > $$ddd-$$VER.tar.gz; \
	)
	rm -fr proto-toplev

# Create a picture distribution.
.PHONY: picsdist
picsdist:
	rm -fr proto-toplev; mkdir proto-toplev
	( \
	    ddd=`sed -n < ddd/configure.in 's/^ddd *= *//p'`; \
	    VER=`sed -n < ddd/configure.in 's/^VERSION *= *//p'`; \
	    VER=`echo $$VER | sed 's/[^0-9]*\([0-9][^ ]*\) .*/\1/'`; \
	    echo "==> Making $$ddd-$$VER-pics.tar.gz"; \
	    rm -f $$ddd-$$VER-pics.tar.gz; \
	    ln -s .. proto-toplev/$$ddd-$$VER; \
	    find ddd/PICS -name RCS -prune -o -name CVS -prune \
		-o -name proto-toplev -prune \
		-o -name '.[a-zA-Z0-9]*' -prune \
		-o -name '*.o' -prune \
		-o -name '*.a' -prune \
		-o -name '*~' -prune \
		-o -name '*#' -prune \
		-o -type f -print -o -type l -print | \
	        sed "s,^ddd,$$ddd-$$VER/ddd," | sort > proto-toplev/FILES; \
	    ( cd proto-toplev; gtar --create --dereference \
		--verbose --files-from FILES \
		--file - ) | gzip -v -9 > $$ddd-$$VER-pics.tar.gz; \
	)
	rm -fr proto-toplev

## Configuration stuff.

Makefile: Makefile.in config.status
	CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status

$(srcdir)/configure: $(srcdir)/ddd/aclocal.m4 $(srcdir)/configure.in
	-cd $(srcdir) && $(AUTOCONF) -l $(srcdir)/ddd

config.status: $(srcdir)/configure
	-$(SHELL) ./config.status --recheck || $(SHELL) $(srcdir)/configure -v

.PRECIOUS: Makefile configure config.status

## FORCE target

.PHONY: FORCE
FORCE:
	@:
