# # Copyright (C) 1989,1990,1991,1992 by
#	Wilfried Koch, Andreas Lampen, Axel Mahler, Juergen Nickelsen,
#	Wolfgang Obst and Ulrich Pralle 
# 
# This file is part of shapeTools.
#
# This software is published in the hope that it will be useful, but
# WITHOUT ANY WARRANTY for any part of this software to work correctly
# or as described in the manuals. See the ShapeTools Public License
# for details.
#
# Permission is granted to use, copy, modify, or distribute any part of
# this software but only under the conditions described in the ShapeTools 
# Public License. A copy of this license is supposed to have been given
# to you along with shapeTools in a file named LICENSE. Among other
# things, this copyright notice and the Public License must be
# preserved on all copies.

#
# Makefile for the shape toolkit
#
# $Header: Makefile[1.23] Fri Mar 13 19:29:03 1992 shape@cs.tu-berlin.de accessed $
#

# The base directory of the shape source tree.

BASE = /home/stone/shape/development

# The operating system. Supported platforms are:
#	s-aix      -- AIX (tested on IBM RS6000 with AIX 3.1)
#	s-bsd_4_3  -- BSD 4.3 (tested on DEC microVax II with BSD 4.3)
#	s-hpux     -- HP/UX (tested on HP 9000 with HP/UX 7.0)
#	s-irix	   -- IRIX (tested on Silicon Graphics with IRIX 3.3.1)
#	s-mach	   -- mach (tested on NextStation)
#	s-sunos_4  -- SunOS (tested on SUN 4 with SunOs 4.1.1)
#	s-svr_3    -- System V Release 3 (tested on Interactive UNIX 2.2)
#	s-ultrix_4 -- Ultrix (tested on DECStation 3100 with Ultrix 4.0)
# For installing the toolkit on other operating systems see the
# README file in this directory.

HOSTSYSTEM = s-sunos_4

# The processor type (may be empty).

HOSTTYPE = sun4

# Preprocessor switches.
# Set "-DSYSLOG" if you want to have internal diagnostic messages
# handled by the syslog package.

SWITCHES = -Iconf/$(HOSTSYSTEM)

# Needed system libraries.
# As the shape toolkit uses "re_comp" (regular expressions), 
# System V machines require an additional library to be linked.
# This is usally "SYSLIBS = -lPW".

SYSLIBS = 

# Path of a subsystem relative to the root of the system hierarchy
# (e.g. vc/save)

NODEPATH = 

# A short name for the (sub)system (used for building the release ID)

NODENAME = shapeTools

# The installation base directory.
# Make sure, that the subdirectories "bin", "include", and "lib"
# exist in installation directory.

INSTALLBASE = /usr/local

# Locations and modes for the installation of executables, header
# files, libraries and manuals.

INSTALLBINPATH = /usr/local/bin
INSTALLBINMODE = 755
INSTALLINCPATH = $(INSTALLBASE)/include
INSTALLINCMODE = 444
INSTALLLIBPATH = $(INSTALLBASE)/lib
INSTALLLIBMODE = 644
INSTALLMANPATH = /usr/local/man
INSTALLMANMODE = 444

# Directories, where local libraries and header files are to be
# installed for project wide use.

LIBPATH     = $(BASE)/lib
INCLUDEPATH = $(BASE)/include

# --------------------------------------------------------------------
#		the system's components
# --------------------------------------------------------------------

#
# The system (program, library, etc.) to be built. If you want to
# manage multiple programs, you should introduce multiple targets
# (like TARGET1 TARGET2 or any better names). In this case you 
# have to adjust the system building actions accordingly.

TARGET = 

# The release number generator. The version number of this file will
# be used as release identifier for the whole system.

VERSIONFILE = Release   # source
VERSIONOBJECT =		# derived (if source contains program code)

# The names of the subdirectories containing subsystems which are also
# to be built.

SUBSYSTEMS = src/atfs src/atfstk src/shape src/vc src/interface src/rms tutorial

# Aliases for (filesystem links to) $(TARGET).

ALIASES = 

# The regular source and header files.

SOURCES = PORTING README LICENSE INSTALL +PATCHLEVEL shape_config.sh

HEADERS = 

# Auxiliary source and header files that are not genuine part of the
# system (eg. a test environment). These will also be processed on
# system building, but will *not* be included in releases.

AUXSOURCES = 

AUXHEADERS = 

# The manuals

MANUALS = $(MAN1) $(MAN3) $(MAN4) $(MAN5) $(MAN6) $(MAN7) $(MAN8)
MAN1 = 
MAN3 = 
MAN4 = 
MAN5 = 
MAN6 = 
MAN7 = 
MAN8 = 

# All source components of the system (should not be changed)

COMPONENTS = $(SOURCES) $(HEADERS) $(MANUALS) Shapefile Makefile Dependencies

# The derived files. All files, that are autamatically produced during
# a build process should be listed here.

OBJECTS = $(VERSIONOBJECT)

# --------------------------------------------------------------------
#		tools, flags, libraries etc.
# --------------------------------------------------------------------

MAKE = make
SHELL = /bin/sh
CC = cc
CFLAGS  = -I$(INCLUDEPATH) $(SWITCHES) -O
LDFLAGS = -s
RANLIB  = ranlib

CONFIGSCRIPT = ./shape_config.sh

# System libraries, local libraries and lint libraries.

LOCALLIBS = 
LINTLIBS  =

# --------------------------------------------------------------------
#			the targets
# --------------------------------------------------------------------

# The default action (do not change)

all: +all $(ALLTARGETS)

config: configure

configure:
	@$(CONFIGSCRIPT) `pwd`

# The final system building action.

targets: $(TARGET)

installtargets: installmanuals

$(INSTALLBINPATH)/$(TARGET): $(TARGET)

# installmanuals differs from template

installmanuals: $(MANUALS)
	@-echo "installing manuals in $(INSTALLMANPATH)"; \
	_manuals=`ls man/man1`; \
	for i in $$_manuals; \
	do \
          if [ -f $(INSTALLMANPATH)/man1/$$i ] && \
             [ ! -w $(INSTALLMANPATH)/man1/$$i ]; \
          then \
            chmod u+w $(INSTALLMANPATH)/man1/$$i; \
          fi; \
          cp man/man1/$$i $(INSTALLMANPATH)/man1/$$i; \
          chmod $(INSTALLMANMODE) $(INSTALLMANPATH)/man1/$$i; \
	done; \
	_manuals=`ls man/man7`; \
	for i in $$_manuals; \
	do \
          if [ -f $(INSTALLMANPATH)/man7/$$i ] && \
             [ ! -w $(INSTALLMANPATH)/man7/$$i ]; \
          then \
            chmod u+w $(INSTALLMANPATH)/man7/$$i; \
          fi; \
	  cp man/man7/$$i $(INSTALLMANPATH)/man7/$$i; \
	  chmod $(INSTALLMANMODE) $(INSTALLMANPATH)/man7/$$i; \
	done; \
	_manuals=`ls man/man8`; \
	for i in $$_manuals; \
	do \
          if [ -f $(INSTALLMANPATH)/man8/$$i ] && \
             [ ! -w $(INSTALLMANPATH)/man8/$$i ]; \
          then \
            chmod u+w $(INSTALLMANPATH)/man8/$$i; \
          fi; \
	  cp man/man8/$$i $(INSTALLMANPATH)/man8/$$i; \
	  chmod $(INSTALLMANMODE) $(INSTALLMANPATH)/man8/$$i; \
	done

# The cleanup action. Removes all automatically rederivable files.

doclean:
	rm -f $(TARGET) $(ALIASES) $(OBJECTS) \
	lib/libatfs.a.old lib/libatfs.a lib/libatfstk.a lib/libatfstk.a.old \
	include/atfs.h include/afsys.h include/config.h \
	include/atfsapp.h include/ParseArgs.h

# Recursive builds. Performed *before* building $(TARGET)

subsystems:
	@-_subsystems="$(SUBSYSTEMS)"; \
	for i in $$_subsystems; \
	do \
	  maketarget=$(MAINTARGET); \
	  if [ "$(MAINTARGET)" = all ]; \
	  then \
	    if [ $$i = src/atfs ] || [ $$i = src/atfstk ]; \
	    then \
	      maketarget=localinstall; \
	    fi; \
	  else \
	    if [ "$(MAINTARGET)" = install ]; \
	    then \
	      if [ $$i = src/atfs ] || [ $$i = src/rms ]; \
	      then \
	        maketarget="localinstall install"; \
	      fi; \
	      if [ $$i = src/atfstk ]; \
	      then \
	        maketarget="localinstall"; \
	      fi; \
	    fi; \
	  fi; \
	  echo cd $$i; \
	  (cd $$i; $(MAKE) \
		BASE=$(BASE) \
		HOSTSYSTEM=$(HOSTSYSTEM) \
		HOSTTYPE=$(HOSTTYPE) \
		SWITCHES="$(SWITCHES)" \
		INSTALLBASE=$(INSTALLBASE) \
		INSTALLBINPATH=$(INSTALLBINPATH) \
		INSTALLBINMODE=$(INSTALLBINMODE) \
		INSTALLINCPATH=$(INSTALLINCPATH) \
		INSTALLINCMODE=$(INSTALLINCMODE) \
		INSTALLLIBPATH=$(INSTALLLIBPATH) \
		INSTALLLIBMODE=$(INSTALLLIBMODE) \
		INSTALLMANPATH=$(INSTALLMANPATH) \
		INSTALLMANMODE=$(INSTALLMANMODE) \
		LIBPATH=$(LIBPATH) \
		INCLUDEPATH=$(INCLUDEPATH) \
		MAKE="$(MAKE)" \
		CC="$(CC)" \
		CFLAGS="$(CFLAGS)" \
		LDFLAGS="$(LDFLAGS)" \
		RANLIB="$(RANLIB)" \
		SYSLIBS="$(SYSLIBS)" \
		BINDDEFAULT=$(BINDDEFAULT) \
		BINDINSTALL=$(BINDINSTALL) \
		COMPILER=$(COMPILER) \
		QUALITY=$(QUALITY) \
		TOTALRELEASEBASE=$(TOTALRELEASEBASE) \
		PARTIALRELEASEBASE=$(PARTIALRELEASEBASE) \
		ALLTARGETS= \
		MAINTARGET= \
		SHAPELIBPATH=$(SHAPELIBPATH) $$maketarget ); \
	done

# --------------------------------------------------------------------
#			internals (do not modify)
# --------------------------------------------------------------------

install: +install $(ALLTARGETS)

clean: +clean $(ALLTARGETS)

+all:
	@-if [ ! -f .configured ]; \
	then \
	  echo; echo "Initial build of shapeTools on this machine."; \
	  ./shape_config.sh `pwd`; \
	  echo; echo "Got it ! Now call 'make' again to start system build."; \
          exit 0; \
	fi; \
	if [ -n "$(ALLTARGETS)" ]; \
	then : ; \
	else \
	  $(MAKE) ALLTARGETS="subsystems targets" MAINTARGET=all \
		BASE=$(BASE) \
		HOSTSYSTEM=$(HOSTSYSTEM) \
		HOSTTYPE=$(HOSTTYPE) \
		SWITCHES="$(SWITCHES)" \
		INSTALLBASE=$(INSTALLBASE) \
		INSTALLBINPATH=$(INSTALLBINPATH) \
		INSTALLBINMODE=$(INSTALLBINMODE) \
		INSTALLINCPATH=$(INSTALLINCPATH) \
		INSTALLINCMODE=$(INSTALLINCMODE) \
		INSTALLLIBPATH=$(INSTALLLIBPATH) \
		INSTALLLIBMODE=$(INSTALLLIBMODE) \
		INSTALLMANPATH=$(INSTALLMANPATH) \
		INSTALLMANMODE=$(INSTALLMANMODE) \
		LIBPATH=$(LIBPATH) \
		INCLUDEPATH=$(INCLUDEPATH) \
		MAKE="$(MAKE)" \
		CC="$(CC)" \
		CFLAGS="$(CFLAGS)" \
		LDFLAGS="$(LDFLAGS)" \
		RANLIB="$(RANLIB)" \
		SYSLIBS="$(SYSLIBS)" \
		BINDDEFAULT=$(BINDDEFAULT) \
		BINDINSTALL=$(BINDINSTALL) \
		COMPILER=$(COMPILER) \
		QUALITY=$(QUALITY) \
		TOTALRELEASEBASE=$(TOTALRELEASEBASE) \
		PARTIALRELEASEBASE=$(PARTIALRELEASEBASE) \
		SHAPELIBPATH=$(SHAPELIBPATH) all; \
	fi

+install:
	@-if [ ! -f .configured ]; \
	then \
	  echo; echo "Initial build of shapeTools on this machine."; \
	  ./shape_config.sh `pwd`; \
	  echo; echo "Got it ! Now call 'make install' again to start system build and installation."; \
          exit 0; \
	fi; \
	if [ -n "$(ALLTARGETS)" ]; \
	then : ; \
	else \
	  $(MAKE) ALLTARGETS="subsystems installtargets" \
		MAINTARGET=install \
		BASE=$(BASE) \
		HOSTSYSTEM=$(HOSTSYSTEM) \
		HOSTTYPE=$(HOSTTYPE) \
		SWITCHES="$(SWITCHES)" \
		INSTALLBASE=$(INSTALLBASE) \
		INSTALLBINPATH=$(INSTALLBINPATH) \
		INSTALLBINMODE=$(INSTALLBINMODE) \
		INSTALLINCPATH=$(INSTALLINCPATH) \
		INSTALLINCMODE=$(INSTALLINCMODE) \
		INSTALLLIBPATH=$(INSTALLLIBPATH) \
		INSTALLLIBMODE=$(INSTALLLIBMODE) \
		INSTALLMANPATH=$(INSTALLMANPATH) \
		INSTALLMANMODE=$(INSTALLMANMODE) \
		LIBPATH=$(LIBPATH) \
		INCLUDEPATH=$(INCLUDEPATH) \
		MAKE="$(MAKE)" \
		CC="$(CC)" \
		CFLAGS="$(CFLAGS)" \
		LDFLAGS="$(LDFLAGS)" \
		RANLIB="$(RANLIB)" \
		SYSLIBS="$(SYSLIBS)" \
		BINDDEFAULT=$(BINDDEFAULT) \
		BINDINSTALL=$(BINDINSTALL) \
		COMPILER=$(COMPILER) \
		QUALITY=$(QUALITY) \
		TOTALRELEASEBASE=$(TOTALRELEASEBASE) \
		PARTIALRELEASEBASE=$(PARTIALRELEASEBASE) \
		SHAPELIBPATH=$(SHAPELIBPATH) install; \
	fi

+clean:
	@-if [ -n "$(ALLTARGETS)" ]; \
	then : ; \
	else \
	  $(MAKE) ALLTARGETS="subsystems doclean" MAINTARGET=clean \
		BASE=$(BASE) \
		HOSTSYSTEM=$(HOSTSYSTEM) \
		HOSTTYPE=$(HOSTTYPE) \
		SWITCHES="$(SWITCHES)" \
		INSTALLBASE=$(INSTALLBASE) \
		INSTALLBINPATH=$(INSTALLBINPATH) \
		INSTALLBINMODE=$(INSTALLBINMODE) \
		INSTALLINCPATH=$(INSTALLINCPATH) \
		INSTALLINCMODE=$(INSTALLINCMODE) \
		INSTALLLIBPATH=$(INSTALLLIBPATH) \
		INSTALLLIBMODE=$(INSTALLLIBMODE) \
		INSTALLMANPATH=$(INSTALLMANPATH) \
		INSTALLMANMODE=$(INSTALLMANMODE) \
		LIBPATH=$(LIBPATH) \
		INCLUDEPATH=$(INCLUDEPATH) \
		MAKE="$(MAKE)" \
		CC="$(CC)" \
		CFLAGS="$(CFLAGS)" \
		LDFLAGS="$(LDFLAGS)" \
		RANLIB="$(RANLIB)" \
		SYSLIBS="$(SYSLIBS)" \
		BINDDEFAULT=$(BINDDEFAULT) \
		BINDINSTALL=$(BINDINSTALL) \
		COMPILER=$(COMPILER) \
		QUALITY=$(QUALITY) \
		TOTALRELEASEBASE=$(TOTALRELEASEBASE) \
		PARTIALRELEASEBASE=$(PARTIALRELEASEBASE) \
		SHAPELIBPATH=$(SHAPELIBPATH) clean; \
	fi
