# # Copyright (C) 1993,1994 by the author(s).
# 
# 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 ShapeTools
#
# $Header: Makefile[5.1] Tue Aug 23 17:34:52 1994 andy@cs.tu-berlin.de frozen $
#

# 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.2.0)
#	s_hpux     -- HP/UX (tested on HP 9000 with HP/UX 9.0)
#	s_irix	   -- IRIX (tested on Silicon Graphics with IRIX 4.0.5)
#	s_mach	   -- mach (tested on NextStation with Mach 3.0)
#	s_sunos_4  -- SunOS 4 (tested on SUN 4 with SunOS 4.1.3)
#	s_svr_4    -- Solaris 2 (tested on SUN 10 with SunOS 5.1)
#	s_svr_4    -- Sys V Rel.4 (tested on a '386 machine with ESIX)
#	s_ultrix_4 -- Ultrix (tested on DECStation 5000 with Ultrix 4.2)
# 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 = 

# 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 = $(INSTALLBASE)/bin
INSTALLBINMODE = 755
INSTALLINCPATH = $(INSTALLBASE)/include
INSTALLINCMODE = 444
INSTALLLIBPATH = $(INSTALLBASE)/lib
INSTALLSHAPELIBPATH = $(INSTALLBASE)/lib/shape
INSTALLEMACSLISPPATH = $(INSTALLBASE)/lib/emacs/lisp
INSTALLLIBMODE = 644
INSTALLMANPATH = $(INSTALLBASE)/man
INSTALLMANMODE = 444

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

LOCALLIBPATH     = $(BASE)/lib
LOCALINCLUDEPATH = $(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

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

SUBSYSTEMS = src/atfs src/sttk src/atfstk src/shape src/vc  src/rms src/interface src/patches
#SUBSYSTEMS = src/atfs src/sttk src/atfstk src/shape src/vc src/interface src/rms src/patches tutorial

# The regular source and header files.

SOURCES = CHANGES-1.4 README LICENSE INSTALL SUPPORT shape_conf.sh Questionnaire

HEADERS = 

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

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

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

SHELL=/bin/sh

INCLUDES = -I$(LOCALINCLUDEPATH)
MAKECFLAGS = -O -DATFS_OWN_LOCKING
MAKELDFLAGS = -s

CC = cc
CFLAGS  = $(INCLUDES) $(MAKECFLAGS) -D$(HOSTSYSTEM) $(SWITCHES)
LDFLAGS = $(MAKELDFLAGS)

RANLIB  = ranlib

CONFIGSCRIPT = ./shape_conf.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)

DOLIBRARIES = yes

DOEMACSLISP = yes

installtargets: installmanuals

installmanuals: $(MANUALS)
	@-echo "installing manuals in $(INSTALLMANPATH)"; \
	if [ "$(INSTALLMANPATH)" = "$(BASE)/man" ]; \
	then \
	  exit 0; \
	fi; \
	_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; \
	if [ "$(DOLIBRARIES)" = yes ]; \
	then \
	  _manuals=`ls man/man3`; \
	  for i in $$_manuals; \
	  do \
            if [ -f $(INSTALLMANPATH)/man3/$$i ] && \
               [ ! -w $(INSTALLMANPATH)/man3/$$i ]; \
            then \
              chmod u+w $(INSTALLMANPATH)/man3/$$i; \
            fi; \
            cp man/man3/$$i $(INSTALLMANPATH)/man3/$$i; \
            chmod $(INSTALLMANMODE) $(INSTALLMANPATH)/man3/$$i; \
	  done; \
	  _manuals=`ls man/man5`; \
	  for i in $$_manuals; \
	  do \
            if [ -f $(INSTALLMANPATH)/man5/$$i ] && \
               [ ! -w $(INSTALLMANPATH)/man5/$$i ]; \
            then \
              chmod u+w $(INSTALLMANPATH)/man5/$$i; \
            fi; \
            cp man/man5/$$i $(INSTALLMANPATH)/man5/$$i; \
            chmod $(INSTALLMANMODE) $(INSTALLMANPATH)/man5/$$i; \
	  done; \
	fi; \
	_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

# The cleanup action. Removes all automatically rederivable files.

doclean:
	rm -f $(TARGET) $(ALIASES) $(OBJECTS) \
	lib/libAtFS.a.old lib/libAtFS.a lib/libsttk.old.a \
	lib/libsttk.a lib/libAtFStk.old.a lib/libAtFStk.a \
	include/atfs.h include/afsys.h include/config.h \
	include/sttk.h include/atfstk.h

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

subsystems:
	@-_subsystems="$(SUBSYSTEMS)"; \
	for i in $$_subsystems; \
	do \
	  maketarget=$(MAINTARGET); \
	  installlibpath=$(INSTALLLIBPATH); \
	  installincpath=$(INSTALLINCPATH); \
	  libpath=$(LOCALLIBPATH); \
	  includepath=$(LOCALINCLUDEPATH); \
	  if [ $$i = src/atfs -o $$i = src/sttk -o $$i = src/atfstk ]; \
	  then \
	    if [ "$(MAINTARGET)" = all ]; \
	    then \
	      maketarget=localinstall; \
	      if [ "$(INSTALLLIBPATH)" = "$(LOCALLIBPATH)" ]; \
	      then \
		installlibpath=/tmp; \
	      fi; \
	      if [ "$(INSTALLINCPATH)" = "$(LOCALINCLUDEPATH)" ]; \
	      then \
		installincpath=/tmp; \
	      fi; \
	    elif [ "$(MAINTARGET)" = install ]; \
	    then \
	      if  [ "$(DOLIBRARIES)" = no ]; \
	      then \
	        maketarget="noinstall localinstall"; \
	      else \
	        maketarget="install localinstall"; \
	      fi; \
	      if [ "$(INSTALLLIBPATH)" = "$(LOCALLIBPATH)" ]; \
	      then \
		libpath=/tmp; \
		maketarget=`echo $$maketarget | sed -e s/localinstall//`; \
	      fi; \
	      if [ "$(INSTALLINCPATH)" = "$(LOCALINCLUDEPATH)" ]; \
	      then \
		includepath=/tmp; \
		maketarget=`echo $$maketarget | sed -e s/localinstall//`; \
	      fi; \
	    else \
	      if [ "$(INSTALLLIBPATH)" = "$(LOCALLIBPATH)" ]; \
	      then \
		installlibpath=/tmp; \
	      fi; \
	      if [ "$(INSTALLINCPATH)" = "$(LOCALINCLUDEPATH)" ]; \
	      then \
		installincpath=/tmp; \
	      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 \
		INSTALLSHAPELIBPATH=$(INSTALLSHAPELIBPATH) \
		INSTALLEMACSLISPPATH=$(INSTALLEMACSLISPPATH) \
		INSTALLLIBMODE=$(INSTALLLIBMODE) \
		INSTALLMANPATH=$(INSTALLMANPATH) \
		INSTALLMANMODE=$(INSTALLMANMODE) \
		LOCALLIBPATH=$$libpath \
		LOCALINCLUDEPATH=$$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_conf.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) \
		INSTALLSHAPELIBPATH=$(INSTALLSHAPELIBPATH) \
		INSTALLEMACSLISPPATH=$(INSTALLEMACSLISPPATH) \
		INSTALLLIBMODE=$(INSTALLLIBMODE) \
		INSTALLMANPATH=$(INSTALLMANPATH) \
		INSTALLMANMODE=$(INSTALLMANMODE) \
		LOCALLIBPATH=$(LOCALLIBPATH) \
		LOCALINCLUDEPATH=$(LOCALINCLUDEPATH) \
		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_conf.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) \
		INSTALLSHAPELIBPATH=$(INSTALLSHAPELIBPATH) \
		INSTALLEMACSLISPPATH=$(INSTALLEMACSLISPPATH) \
		INSTALLLIBMODE=$(INSTALLLIBMODE) \
		INSTALLMANPATH=$(INSTALLMANPATH) \
		INSTALLMANMODE=$(INSTALLMANMODE) \
		LOCALLIBPATH=$(LOCALLIBPATH) \
		LOCALINCLUDEPATH=$(LOCALINCLUDEPATH) \
		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) \
		INSTALLSHAPELIBPATH=$(INSTALLSHAPELIBPATH) \
		INSTALLEMACSLISPPATH=$(INSTALLEMACSLISPPATH) \
		INSTALLLIBMODE=$(INSTALLLIBMODE) \
		INSTALLMANPATH=$(INSTALLMANPATH) \
		INSTALLMANMODE=$(INSTALLMANMODE) \
		LOCALLIBPATH=$(LOCALLIBPATH) \
		LOCALINCLUDEPATH=$(LOCALINCLUDEPATH) \
		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
