#+
#  Name:
#     makefile
#
#  Version:
#     Base Set makefile Mk V
#
#  Purpose:
#     Build and install the STARPERL package.
#
#  Type of Module:
#     Description file for the make utility.
#
#  Description:
#     This description file is used by the make utility to build the
#     STARPERL package from the distributed source files, to install
#     the resulting system for use, and to perform other housekeeping
#     tasks.
#
#     This makefile is designed to `wrap' an existing package makefile 
#     system to provide easier package manipulation for Starlink sites.
#
#  Invocation:
#     This makefile is not intended to be used by make when invoked
#     directly (although this is possible), but instead to be used via
#     the accompanying mk script.  This script sets up a number of
#     environment variables which are used as macros within the
#     makefile and which accommodate differences between machines and
#     operating systems (it invokes make with the -e option).  Please
#     consult the mk script prologue for full details.
#
#  Targets:
#     The following make targets are defined in this script for
#     external use:
#
#        [help]
#           This is the default target.  It outputs a message describing
#           the mk script and lists the targets provided.
#
#        check
#           Performs a simple check that all necessary source files are
#           present, and displays the version number and current state
#           of the package (built/installed/tested, etc.).
#
#        build
#           Compiles the source files and creates all files needed
#           prior to installing the package for use.
#
#        install
#           Installs the package for use by putting the necessary files
#           into sub-directories of the $INSTALL directory (the $HOME
#           directory is used if the environment variable INSTALL is
#           not defined).  Links to the installed files are left in the
#           source directory.
#
#        deinstall
#           Reverses the action of the install target, removing files
#           from sub-directories of the $INSTALL directory and
#           restoring them to the source directory (the $HOME directory
#           is used by default if the environment variable INSTALL is
#           not defined).
#
#        test
#           Builds and runs a simple test program to check for correct
#           installation of the package.
#
#        export
#           Produces an export copy of the built package suitable for
#           passing to another user.  A compressed tar file is created
#           in the $EXPORT directory containing copies of the source
#           files and built files for the package (the current
#           directory is used by default if the environment variable
#           EXPORT is not defined).  The package should normally be
#           built, installed and tested (see above) before using this
#           target.  After unpacking the exported file on a similar
#           machine, the recipient may simply install it for use.
#
#        export_run
#           Produces an export copy of the built package suitable for
#           passing to another user.  A compressed tar file is created
#           in the $EXPORT directory containing copies of the built 
#           files for the package (the current directory is used by 
#           default if the environment variable EXPORT is not defined).
#           The package should normally be built, installed and tested 
#           (see above) before using this target.  After unpacking the
#           exported file on a similar machine, the recipient may simply
#           install it for use.
#
#        export_source
#           Produces an export copy of the source for the package
#           suitable for passing to another user to build (possibly on
#           a different type of machine).  A compressed tar file is
#           created in the $EXPORT directory containing copies of just
#           the source files for the package (the current directory is
#           used by default if the environment variable EXPORT is not
#           defined).  After unpacking the exported file, the recipient
#           must build the package before installing it for use.
#
#        clean
#           Cleans up after building the package, removing all
#           intermediate files created during the building process, but
#           leaving the built files themselves.
#
#        unbuild
#           Reverses the building process, removing all intermediate
#           files along with all the built files.
#
#        strip
#           This target `strips' the executable files.  This can lead
#           to significant reduction in the sizes of binaries.
#
#  External Dependencies:
#     The STARPERL package depends on the following other Starlink
#     packages which must previously have been installed into the
#     appropriate sub-directories of the $STARLINK directory (/star is
#     used if the environment variable STARLINK is not defined).
#
#        PERL
#           Starlink wrap of standard Perl system
#        PERLMODS
#           Starlink wrap of extra Perl modules from CPAN
#        NDF
#           N-d extensible data format library
#        EMS
#           Error Message System library
#        PCS
#           Parameter and Communications Subsystems libraries
#
#  Notes:
#     This makefile uses the presence/absence of the hidden files
#     .BUILT, .INSTALLED_$(SYSTEM) and .TESTED_$(SYSTEM) to record the
#     current state of the system during housekeeping operations.
#
#     This is not a standard makefile and should not be used as a template
#     for standard Starlink packages.
#
#  Implementation Deficiencies:
#
#  Copyright:
#     Copyright (C) 1998 Rutherford Appleton Laboratory
#
#  Authors:
#     RFWS: R.F.Warren-Smith (Starlink, RAL)
#     PMA: P.M.Allan (Starlink, RAL)
#     PTW: P.T.Wallace (Starlink, RAL)
#     BLY: M.J.Bly (Starlink, RAL)
#     AJC: A.J.Chipperfield (Starlink, RAL)
#     SER: S.E.RANKIN (Starlink, RAL)
#     {enter_new_authors_here}
#
#  History:
#     4-JAN-1993 (RFWS):
#        Original version.
#     22-MAY-1997 (BLY):
#        Mk V version adapted for JPEG.
#     13-FEB-1998 (BLY):
#        Adapted for NDFPERL.
#     23-DEC-1998 (BLY):
#        Further adapted for STARPERL.
#     28-JAN-1999 (BLY):
#        Added install/deinstall of link to MessageRelay.pl so that
#        SURF can find it without needing the PERL system in the PATH.
#     18-JUN-1999 (BLY):
#        Split STARPERL from PERLMODS v1.0-2 and update with new
#           modules from Tim Jenness.
#     20-NOV-1999 (BLY):
#        Updated Starlink module to v1.11.
#        version 1.1-0.
#     07-MAY-2003 (SER):
#        Updated to NDF-1.45, GSD-1.13, Starlink-1.14 and Perl 5.8.0.
#        Now V1.4.0.
#     10-FEB-2004 (SER):
#        Added Astro::Telescope 0.50. Updated makefile so all files
#        get installed with the correct path. Perl now version 5.8.3.
#
#  Bugs:
#     {note_any_bugs_here}
#
#-------------------------------------------------------------------------------

#  Help target.
#  ===========
#
#  This is the default target, so it appears first.

#  Display information about the mk script and the make targets.

help:
	@ echo \
   '   The makefile provided is intended to be used by the make utility when';\
        echo \
   '   invoked via the associated mk script.  This script defines environment';\
        echo \
   '   variables which are used by make to accommodate differing machine and';\
        echo \
   '   operating system characteristics.  Please see the mk script prologue';\
        echo \
   '   for full details.';\
        echo;\
        echo \
   '   The following targets are provided:';\
        echo;\
        echo \
   '      help          - Display this message';\
        echo \
   '      check         - Check source file presence and show current state';\
        echo \
   '      build         - Build the package from source';\
        echo \
   '      install       - Install the built package for use';\
        echo \
   '      deinstall     - Deinstall the package';\
        echo \
   '      test          - Perform a quick test of the installation';\
        echo \
   '      export        - Make a compressed tar file for exporting the'\
   'built package';\
        echo \
   '                      complete with source and documentation';\
        echo \
   '      export_run    - Make a compressed tar file for exporting the'\
   'built package';\
        echo \
   '                      with documentation but no source';\
        echo \
   '      export_source - Make a compressed tar file for exporting the'\
   'source files';\
        echo \
   '      clean         - Tidy up after building the package';\
        echo \
   '      unbuild       - Remove all the built files';\
        echo \
   '      strip         - Strip the binary files (executables)';\
        echo;\
        echo \
   '   To build and install the $(PACK_NAME) package on a supported system:';\
        echo;\
        echo \
   '      mk build; mk install; mk test; mk clean';\
        echo

#-------------------------------------------------------------------------------

#  Defaults.
#  ========
#
#  This section defines default macros and should rarely need changing.
#  The values given here should be overridden externally to adapt to
#  the local system setup (either use the mk script or use environment
#  variables and invoke "make" with the "-e" option).

#  Name of computer hardware/OS combination.

SYSTEM = unknown

#  Name used to distinguish platform-specific source files.

SOURCE_VARIANT = $(SYSTEM)

#  Pathname of the root directory beneath which other Starlink software
#  is currently installed.

STARLINK = /star

#  Pathnames of Starlink sub-directories that may be referenced when
#  building this package.

STAR_BIN = $(STARLINK)/bin
STAR_DATES = $(STARLINK)/dates
STAR_DOCS = $(STARLINK)/docs
STAR_ETC = $(STARLINK)/etc
STAR_HELP = $(STARLINK)/help
STAR_INC = $(STARLINK)/include
STAR_LIB = $(STARLINK)/lib
STAR_SHARE = $(STARLINK)/share

#  Pathname of the root directory beneath which the built files for
#  this package should be installed for use.  This defaults to the
#  user's home directory.

INSTALL = $(HOME)

#  Pathname of the directory into which exported tar files will be
#  placed.  This defaults to the current working directory.

EXPORT = .

#  Default macros for compiling C and Fortran source code.

CC = c89
CFLAGS = -O
FC = fort77
FFLAGS = -O

#  Command for forming a link to a file.

LINK = ln

#  Command for "randomizing" an object library.  The default acts as a
#  null command.

RANLIB = :

#  Commands for adding to and extracting from an archive file (.tar).

TAR_IN = tar cvhf
TAR_OUT = tar xf
TAR_COPY = tar cf

#  Command for adding a file to an object archive (.a).

AR_IN = ar -r

#  Location of Perl system.  Default is Starlink version

PERLROOT = $(STARLINK)/Perl
PERL = $(PERLROOT)/bin/perl
PERL_SYS = `cat $(STARLINK)/Perl/perl_sys`

#-------------------------------------------------------------------------------
################################################################################
#
#  Define package source files.
#  ===========================
#
#  This section defines the set of source files for the package.

#  Name of the package as specified in documentation
#  The value is used in messages from make to the user.

PACK_NAME = STARPERL

#  Prefix for the package in lower-case as used in filenames etc.
PKG_NAME = starperl

#  Version number (as in the documentation - i.e. not the same thing
#  as the shared library version number).

PKG_VERS = 1.4.2

#  Perl version - should determine this automatically.

PERL_VERS = 5.8.2

# Source directory

PKG_SOURCE = $(STARLINK)/sources/$(PKG_NAME)

#  Names and version numbers for the CPAN  and other components that 
#  make up the STARPERL package.

PKGNAME1 = Starlink-Config
PKGNAME1_1 = Starlink
PKGNAME1_2 = Config
PKGVERS1 = 1.00
PKGNAME2 = NDF
PKGVERS2 = 1.45
PKGNAME3 = Starlink
PKGVERS3 = 1.14
PKGNAME4 = GSD
PKGVERS4 = 1.13
PKGNAME5 = Astro-SLA
PKGNAME5_1 = Astro
PKGNAME5_2 = SLA
PKGVERS5 = 0.98
PKGNAME6 = Astro-Telescope
PKGNAME6_1 = Astro
PKGNAME6_2 = Telescope
PKGVERS6 = 0.50
PKGNAME7 = Time-Piece
PKGNAME7_1 = Time
PKGNAME7_2 = Piece
PKGVERS7 = 1.08
PKGNAME8 = Astro-Coords
PKGNAME8_1 = Astro
PKGNAME8_2 = Coords
PKGVERS8 = 0.05
#  Root directory for STARPERL systems.  The default is the current
#  directory, set by the mk script if not already set.  

PKGROOT = $(HOME)

#  Dircetory and source file names for CPAN components.  PKGDIRn and
#  PKGSOURCEn are package and version dependent.

PKGDIR1 = $(PKGNAME1)-$(PKGVERS1)
PKGSOURCE1 = $(PKGNAME1)-$(PKGVERS1).tar

PKGDIR2 = $(PKGNAME2)-$(PKGVERS2)
PKGSOURCE2 = $(PKGNAME2)-$(PKGVERS2).tar

PKGDIR3 = $(PKGNAME3)-$(PKGVERS3)
PKGSOURCE3 = $(PKGNAME3)-$(PKGVERS3).tar

PKGDIR4 = $(PKGNAME4)-$(PKGVERS4)
PKGSOURCE4 = $(PKGNAME4)-$(PKGVERS4).tar

PKGDIR5 = $(PKGNAME5)-$(PKGVERS5)
PKGSOURCE5 = $(PKGNAME5)-$(PKGVERS5).tar

PKGDIR6 = $(PKGNAME6)-$(PKGVERS6)
PKGSOURCE6 = $(PKGNAME6)-$(PKGVERS6).tar

PKGDIR7 = $(PKGNAME7)-$(PKGVERS7)
PKGSOURCE7 = $(PKGNAME7)-$(PKGVERS7).tar

PKGDIR8 = $(PKGNAME8)-$(PKGVERS8)
PKGSOURCE8 = $(PKGNAME8)-$(PKGVERS8).tar

#  List of files comprising the distributed source-only system.  This
#  defines the minimum set of files required to rebuild completely the
#  package from source (including this makefile, the associated mk
#  script and any documentation files).  It is advisable to use several
#  smaller source archives in place of one large one to speed up build
#  times.

SOURCE_FILES = makefile mk $(DOCUMENTATION) \
$(PKGSOURCE1) $(PKGSOURCE2) $(PKGSOURCE3) $(PKGSOURCE4) $(PKGSOURCE5) \
$(PKGSOURCE6) $(PKGSOURCE7) $(PKGSOURCE8)

#  Lists of Latex and hypertext documents.

LATEX_DOCS = sun228.tex
HYPERTEXT_DOCS = sun228.htx

#  List of documentation files.

DOCUMENTATION = $(LATEX_DOCS) $(HYPERTEXT_DOCS:.htx=.htx_tar) \
$(PKG_NAME).news

#-------------------------------------------------------------------------------
#  Pathnames of directories into which files may be placed when the
#  package is installed.

INSTALL_BIN = $(INSTALL)/bin
INSTALL_DATES = $(INSTALL)/dates
INSTALL_DOCS = $(INSTALL)/docs

#  List of directories actually used for installation (selected from
#  those above).

INSTALL_DIRS = $(INSTALL_BIN) $(INSTALL_DATES) $(INSTALL_DOCS)

$(INSTALL_DIRS):
	mkdir -p $@

#-------------------------------------------------------------------------------
#  List of files to be built.

BUILT_FILES = $(BUILT_DIRS) \
   $(PKGBUILT1) $(PKGINSTALL1) \
   $(PKGBUILT2) $(PKGINSTALL2) \
   $(PKGBUILT3) $(PKGINSTALL3) \
   $(PKGBUILT4) $(PKGINSTALL4) \
   $(PKGBUILT5) $(PKGINSTALL5) \
   $(PKGBUILT6) $(PKGINSTALL6) \
   $(PKGBUILT7) $(PKGINSTALL7) \
   $(PKGBUILT8) $(PKGINSTALL8) \
   ${ADDEDIT}

PKGBUILT1   = .BUILT_$(PKGNAME1)
PKGINSTALL1 = .INSTALL_$(PKGNAME1)
PKGBUILT2   = .BUILT_$(PKGNAME2)
PKGINSTALL2 = .INSTALL_$(PKGNAME2)
PKGBUILT3   = .BUILT_$(PKGNAME3)
PKGINSTALL3 = .INSTALL_$(PKGNAME3)
PKGBUILT4   = .BUILT_$(PKGNAME4)
PKGINSTALL4 = .INSTALL_$(PKGNAME4)
PKGBUILT5   = .BUILT_$(PKGNAME5)
PKGINSTALL5 = .INSTALL_$(PKGNAME5)
PKGBUILT6   = .BUILT_$(PKGNAME6)
PKGINSTALL6 = .INSTALL_$(PKGNAME6)
PKGBUILT7   = .BUILT_$(PKGNAME7)
PKGINSTALL7 = .INSTALL_$(PKGNAME7)
PKGBUILT8   = .BUILT_$(PKGNAME8)
PKGINSTALL8 = .INSTALL_$(PKGNAME8)
ADDEDIT     = .ADDEDIT_$(PKG_NAME)

BUILT_DIRS = bin lib man

# Installed binary script files that need the ${INSTALL} path
BUILT_FILES2 = gsdprint MessageRelay.pl starversion stime



$(BUILT_DIRS):
	mkdir $@

#  Name of the date stamp file.  This is used to record the time of the
#  most recent build for use in subsequent operations that require it.
#  There must be no rule for generating this file; it is updated only
#  as a side effect of building the package.

DATE_STAMP = $(PKG_NAME)_datestamp

#-------------------------------------------------------------------------------
#  Primary targets.
#  ===============
#
#  These are the targets intended for normal external use (apart from
#  help, which appears at the start of the file).

#-------------------------------------------------------------------------------
#  check: Check source file presence and show current state.
#  --------------------------------------------------------

check:
	@ echo
	@ echo \
   '*** This is $(PACK_NAME) version V$(PKG_VERS) on system $(SYSTEM)'
	@ echo
	@ nosource='';\
          for f in $(SOURCE_FILES); do \
             if test ! -f $$f -a ! -d $$f; then \
                echo "NOT FOUND: " $$f;\
                nosource='1';\
                break;\
             else :; fi;\
          done;\
          if test -n "$$nosource"; then \
             echo '    Source files are NOT present';\
          else \
             echo '    All essential source files are present';\
          fi
	@ echo
#
#  Display the current state.
	@ if test -f .BUILT;\
          then echo '    The package is currently:  built for system'\
             `cat .BUILT`;\
          else echo '    The package is currently:  not built';fi
	@ if test -f .INSTALLED_$(SYSTEM);\
          then echo '                               installed in'\
             `cat .INSTALLED_$(SYSTEM)`;\
          else echo '                               not installed';fi
	@ if test -f .TESTED_$(SYSTEM);\
          then echo '                               tested';\
          else echo '                               not tested';fi
	@ echo
	@ if test -f .BUILT;\
          then if test "$(SYSTEM)" != "`cat .BUILT`";\
             then echo '***  WARNING  ***';\
                echo \
'    The package is built for a system other than the current one';\
                echo ;\
             else :;fi;\
          else :;fi

#-------------------------------------------------------------------------------
#  build: Build the system.
#  -----------------------
#
#  Compile the source and build the required files in the source
#  directory.

#  The build target first checks that the package is not installed.  If
#  not, it then causes the .BUILT target to be made which ensures that
#  the package has been built.

build:
	@ if test -f .INSTALLED_$(SYSTEM); then \
           echo;\
           echo \
   '*** The $(PACK_NAME) package is currently installed -- please use the';\
           echo '    "deinstall" target before re-building it';\
           echo;\
        elif $(MAKE) .BUILT; then \
           echo;\
           echo '*** The $(PACK_NAME) package has been built';\
           echo;\
        else \
           echo;\
           echo '*** "make" failed building the $(PACK_NAME) package';\
           echo;\
           exit 1;\
        fi

#  The .BUILT target records the time of the most recent build which
#  modified any of the built files.  It depends on all the built files
#  being up to date (which causes them to be built).

#  Build the software from the source and complete any preinstallation to
#  bring all required files into the working directories.

.BUILT: $(BUILT_FILES)
#
#  Enter information about the current machine and build environment
#  into the date stamp file.
	@ echo 'Package : $(PACK_NAME)'        >$(DATE_STAMP)
	@ echo 'Version : V$(PKG_VERS)'       >>$(DATE_STAMP)
	@ echo ''                             >>$(DATE_STAMP)
	@ echo "Built by: $(USER) on node `uname -n`" \
                                              >>$(DATE_STAMP)
	@ echo "On      : `date`"             >>$(DATE_STAMP)
	@ echo ''                             >>$(DATE_STAMP)
	@ echo \
  "Machine : `uname -m` running `uname -s` `uname -v` (release `uname -r`)" \
                                              >>$(DATE_STAMP)
	@ echo ''                             >>$(DATE_STAMP)
	@ echo 'make macros:'                 >>$(DATE_STAMP)
	@ echo ''                             >>$(DATE_STAMP)
	@ echo '   SYSTEM  : $(SYSTEM)'       >>$(DATE_STAMP)
	@ echo ''                             >>$(DATE_STAMP)
	@ echo '   EXPORT  : $(EXPORT)'       >>$(DATE_STAMP)
	@ echo '   INSTALL : $(INSTALL)'      >>$(DATE_STAMP)
	@ echo '   STARLINK: $(STARLINK)'     >>$(DATE_STAMP)
	@ echo ''                             >>$(DATE_STAMP)
	@ echo '   LINK    : $(LINK)'         >>$(DATE_STAMP)
	@ echo '   TAR_IN  : $(TAR_IN)'       >>$(DATE_STAMP)
	@ echo '   TAR_OUT : $(TAR_OUT)'      >>$(DATE_STAMP)
	@ echo ''                             >>$(DATE_STAMP)
#
#  Record completion of the build.
	@ echo '$(SYSTEM)' > .BUILT

#
#  Build the STARPERL components.

#
#  Package 1 (Starlink-Config).

.BUILT_$(PKGNAME1):
	@ echo ; echo "Processing $@" ; echo
	if [ -d $(PKGDIR1) ]; then :; else $(TAR_OUT) $(PKGSOURCE1); fi
	cd $(PKGDIR1); $(PERL) Makefile.PL PREFIX=$(PKGROOT) && \
           make && make test && touch $(PKGROOT)/.BUILT_$(PKGNAME1)

.INSTALL_$(PKGNAME1):
	@ echo ; echo "Processing $@" ; echo
	cd $(PKGDIR1); make pure_install PREFIX=$(PKGROOT) \
           INSTALLMAN3DIR='$$(INSTALLPRIVLIB)'/man/man3 && \
           sed -e 's#${PKG_SOURCE}#INSTALL_BIN#g' \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME1_1)/$(PKGNAME1_2)/.packlist \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME1_1)/$(PKGNAME1_2)/.packlist \
            && rm -f tmpfile && \
           touch $(PKGROOT)/.INSTALL_$(PKGNAME1)
#
#  Package 2 (NDFPerl).

.BUILT_$(PKGNAME2):
	@ echo ; echo "Processing $@" ; echo
	if [ -d $(PKGDIR2) ]; then :; else $(TAR_OUT) $(PKGSOURCE2); fi
	cd $(PKGDIR2); PATH=$(PATH):$(STAR_BIN) ; export PATH ; \
           PERL5LIB=$(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS); export PERL5LIB ;\
           $(PERL) Makefile.PL PREFIX=$(PKGROOT) && \
           make && make test && touch $(PKGROOT)/.BUILT_$(PKGNAME2)

.INSTALL_$(PKGNAME2):
	@ echo ; echo "Processing $@" ; echo
	cd $(PKGDIR2); make pure_install PREFIX=$(PKGROOT) \
           INSTALLMAN3DIR='$$(INSTALLPRIVLIB)'/man/man3 && \
           sed -e 's#${PKG_SOURCE}#INSTALL_BIN#g' \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME2)/.packlist \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME2)/.packlist \
            && rm -f tmpfile && \
           touch $(PKGROOT)/.INSTALL_$(PKGNAME2)
#
#  Package 3 (Starlink).

.BUILT_$(PKGNAME3):
	@ echo ; echo "Processing $@" ; echo
	if [ -d $(PKGDIR3) ]; then :; else $(TAR_OUT) $(PKGSOURCE3); fi
	cd $(PKGDIR3);  PATH=$(PATH):$(STAR_BIN) ; export PATH ;\
           PERL5LIB=$(PKGROOT)/lib/perl5/site_perl; export PERL5LIB ;\
           $(PERL) Makefile.PL PREFIX=$(PKGROOT) && \
           make && make test && touch $(PKGROOT)/.BUILT_$(PKGNAME3)

.INSTALL_$(PKGNAME3):
	@ echo ; echo "Processing $@" ; echo
	cd $(PKGDIR3); make pure_install PREFIX=$(PKGROOT) \
           INSTALLMAN3DIR='$$(INSTALLPRIVLIB)'/man/man3 && \
           sed -e 's#${PKG_SOURCE}#INSTALL_BIN#g' \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME3)/.packlist \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME3)/.packlist \
            && rm -f tmpfile && \
           sed -e 's#${INSTALL}#INSTALL_BIN#g' \
            $(PKGROOT)/bin/MessageRelay.pl \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/bin/MessageRelay.pl && \
           chmod 755 $(PKGROOT)/bin/MessageRelay.pl && \
           rm -f tmpfile && \
           sed -e 's#${INSTALL}#INSTALL_BIN#g' \
            $(PKGROOT)/bin/starversion \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/bin/starversion && \
           chmod 755 $(PKGROOT)/bin/starversion && \
           rm -f tmpfile && \
           touch $(PKGROOT)/.INSTALL_$(PKGNAME3)
#
#  Package 4 (GSD)

.BUILT_$(PKGNAME4):
	@ echo ; echo "Processing $@" ; echo
	if [ -d $(PKGDIR4) ]; then :; else $(TAR_OUT) $(PKGSOURCE4); fi
	cd $(PKGDIR4);  PATH=$(PATH):$(STAR_BIN) ; export PATH ;\
           PERL5LIB=$(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS); export PERL5LIB ;\
           $(PERL) Makefile.PL PREFIX=$(PKGROOT) && \
           make && make test && touch $(PKGROOT)/.BUILT_$(PKGNAME4)

.INSTALL_$(PKGNAME4):
	@ echo ; echo "Processing $@" ; echo
	cd $(PKGDIR4); make pure_install PREFIX=$(PKGROOT) \
           INSTALLMAN3DIR='$$(INSTALLPRIVLIB)'/man/man3 && \
           sed -e 's#${PKG_SOURCE}#INSTALL_BIN#g' \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME4)/.packlist \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME4)/.packlist \
            && rm -f tmpfile && \
           sed -e 's#${INSTALL}#INSTALL_BIN#g' \
            $(PKGROOT)/bin/gsdprint \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/bin/gsdprint && \
            chmod 755 $(PKGROOT)/bin/gsdprint \
            && rm -f tmpfile && \
           touch $(PKGROOT)/.INSTALL_$(PKGNAME4)
#
#  Package 5 (Astro-SLA)

.BUILT_$(PKGNAME5):
	@ echo ; echo "Processing $@" ; echo
	if [ -d $(PKGDIR5) ]; then :; else $(TAR_OUT) $(PKGSOURCE5); fi
	cd $(PKGDIR5);  PATH=$(PATH):$(STAR_BIN) ; export PATH ;\
           PERL5LIB=$(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS); export PERL5LIB ;\
           $(PERL) Makefile.PL PREFIX=$(PKGROOT) && \
           make && make test && touch $(PKGROOT)/.BUILT_$(PKGNAME5)

.INSTALL_$(PKGNAME5):
	@ echo ; echo "Processing $@" ; echo
	cd $(PKGDIR5); make pure_install PREFIX=$(PKGROOT) \
           INSTALLMAN3DIR='$$(INSTALLPRIVLIB)'/man/man3 && \
           sed -e 's#${PKG_SOURCE}#INSTALL_BIN#g' \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME5_1)/$(PKGNAME5_2)/.packlist \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME5_1)/$(PKGNAME5_2)/.packlist \
            && rm -f tmpfile && \
           sed -e 's#${INSTALL}#INSTALL_BIN#g' \
            $(PKGROOT)/bin/stime \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/bin/stime && \
            chmod 755 $(PKGROOT)/bin/stime \
            && rm -f tmpfile && \
           touch $(PKGROOT)/.INSTALL_$(PKGNAME5)
#
#  Package 6 (Astro-Telescope)

.BUILT_$(PKGNAME6):
	@ echo ; echo "Processing $@" ; echo
	if [ -d $(PKGDIR6) ]; then :; else $(TAR_OUT) $(PKGSOURCE6); fi
	cd $(PKGDIR6);  PATH=$(PATH):$(STAR_BIN) ; export PATH ;\
           PERL5LIB=$(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS); export PERL5LIB ;\
           $(PERL) Makefile.PL PREFIX=$(PKGROOT) && \
           make && make test && touch $(PKGROOT)/.BUILT_$(PKGNAME6)

.INSTALL_$(PKGNAME6):
	@ echo ; echo "Processing $@" ; echo
	cd $(PKGDIR6); make pure_install PREFIX=$(PKGROOT) \
           INSTALLMAN3DIR='$$(INSTALLPRIVLIB)'/man/man3 && \
           sed -e 's#${PKG_SOURCE}#INSTALL_BIN#g' \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME6_1)/$(PKGNAME6_2)/.packlist \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME6_1)/$(PKGNAME6_2)/.packlist \
            && rm -f tmpfile && \
           touch $(PKGROOT)/.INSTALL_$(PKGNAME6)

#
#  Package 7 (Time-Piece)

.BUILT_$(PKGNAME7):
	@ echo ; echo "Processing $@" ; echo
	if [ -d $(PKGDIR7) ]; then :; else $(TAR_OUT) $(PKGSOURCE7); fi
	cd $(PKGDIR7);  PATH=$(PATH):$(STAR_BIN) ; export PATH ;\
           PERL5LIB=$(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS); export PERL5LIB ;\
           $(PERL) Makefile.PL PREFIX=$(PKGROOT) && \
           make && make test && touch $(PKGROOT)/.BUILT_$(PKGNAME7)

.INSTALL_$(PKGNAME7):
	@ echo ; echo "Processing $@" ; echo
	cd $(PKGDIR7); make pure_install PREFIX=$(PKGROOT) \
           INSTALLMAN3DIR='$$(INSTALLPRIVLIB)'/man/man3 && \
           sed -e 's#${PKG_SOURCE}#INSTALL_BIN#g' \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME7_1)/$(PKGNAME7_2)/.packlist \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME7_1)/$(PKGNAME7_2)/.packlist \
            && rm -f tmpfile && \
           touch $(PKGROOT)/.INSTALL_$(PKGNAME7)
#
#  Package 8 (Astro-Coords)

.BUILT_$(PKGNAME8):
	@ echo ; echo "Processing $@" ; echo
	if [ -d $(PKGDIR8) ]; then :; else $(TAR_OUT) $(PKGSOURCE8); fi
	cd $(PKGDIR8);  PATH=$(PATH):$(STAR_BIN) ; export PATH ;\
           PERL5LIB=$(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS); export PERL5LIB ;\
           $(PERL) Makefile.PL PREFIX=$(PKGROOT) && \
           make && make test && touch $(PKGROOT)/.BUILT_$(PKGNAME8)

.INSTALL_$(PKGNAME8):
	@ echo ; echo "Processing $@" ; echo
	cd $(PKGDIR8); make pure_install PREFIX=$(PKGROOT) \
           INSTALLMAN3DIR='$$(INSTALLPRIVLIB)'/man/man3 && \
           sed -e 's#${PKG_SOURCE}#INSTALL_BIN#g' \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME8_1)/$(PKGNAME8_2)/.packlist \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PERL_SYS)/auto/$(PKGNAME8_1)/$(PKGNAME8_2)/.packlist \
            && rm -f tmpfile && \
           touch $(PKGROOT)/.INSTALL_$(PKGNAME8)

.ADDEDIT_$(PKG_NAME):
	@ echo ; echo "Processing $@" ; echo
	sed -e 's#${STARLINK}#INSTALL_BIN#g' \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PKGNAME1_1)/$(PKGNAME1_2).pm \
            > tmpfile && cp -f tmpfile \
            $(PKGROOT)/lib/perl5/site_perl/$(PERL_VERS)/$(PKGNAME1_1)/$(PKGNAME1_2).pm \
            && rm -f tmpfile && \
           touch $(PKGROOT)/.ADDEDIT_$(PKG_NAME)

#-------------------------------------------------------------------------------
#  install: Install the package for use.
#  ------------------------------------
#
#  Copy the built files to their installation directories, from where
#  they may be accessed.

#  The install target first checks if any part of the package is
#  already installed.  If not, it checks that the system is built for this
#  SYSTEM and, if it is, causes the .INSTALLED_$(SYSTEM) target to be made
#  which performs the installation.

install:
	@ if test -f .INSTALLED_$(SYSTEM); then \
           echo;\
           echo \
   '*** The $(PACK_NAME) package has already been installed -- please use the';\
           echo \
   '    "deinstall" target first if you wish to reinstall it';\
           echo;\
        elif test -f .BUILT; then \
           if test "`cat .BUILT`" = "$(SYSTEM)"; then \
              if $(MAKE) .INSTALLED_$(SYSTEM); then \
                 echo;\
                 echo \
   '*** The $(PACK_NAME) package has been installed in directory $(INSTALL)';\
                 echo;\
              else \
                 echo;\
                 echo \
   '*** "make" failed installing the $(PACK_NAME) package in directory $(INSTALL)';\
                 echo;\
                 exit 1;\
              fi;\
           else \
              echo;\
              echo \
   "*** The $(PACK_NAME) package is built for system `cat .BUILT` -"\
   'so cannot be installed on system $(SYSTEM)';\
              echo;\
              exit 1;\
           fi;\
        else \
           echo;\
           echo \
   '*** The $(PACK_NAME) package is not built, so cannot be installed';\
           echo;\
           exit 1;\
        fi

#  The .INSTALLED_$(SYSTEM) target copies each file from the source
#  directory using "cp -p" to preserve its date, and replaces each
#  original file by a link to the installed copy.

.INSTALLED_$(SYSTEM): $(INSTALL_DIRS)
#
#  Create .INSTALLED_$(SYSTEM), containing $INSTALL, to record that the 
#  package is installed (at least in part).
	@ echo $(INSTALL) > .INSTALLED_$(SYSTEM)
#
#  Install the binaries and scripts.
	cd bin; $(TAR_COPY) - . | ( cd $(INSTALL)/Perl/bin ; $(TAR_OUT) - )
#
#  Install the libraries, modules and other stuff.
	cd lib; $(TAR_COPY) - . | ( cd $(INSTALL)/Perl/lib ; $(TAR_OUT) - )
#
#  Install a link to the MessageRelay.pl script in INSTALL_BIN.
	$(LINK) `find $(INSTALL)/Perl/bin -name MessageRelay.pl` \
            $(INSTALL_BIN)/MessageRelay.pl
#
#  Install a link to the starversion binary from INSTALL_BIN.
	 $(LINK) `find $(INSTALL)/Perl/bin -name starversion` \
            $(INSTALL_BIN)/starversion
#
#  Install a link for NDFPERL back-compatability.
	$(LINK) $(PERL) $(INSTALL_BIN)/ndfperl
#
#  Edit .packlist files to add ${INSTALL} path.
	- cd $(INSTALL)/Perl/lib ;\
           for f in `find . -name .packlist` ; do \
              if test -n "$$f"; then\
                 sed -e 's#INSTALL_BIN#${INSTALL}/Perl#g' $$f > tmpfile ;\
                 cp -f tmpfile $$f ;\
                 rm -f tmpfile;\
              else :; fi;\
           done
#
#  Edit Config.pm file to add ${INSTALL} path.
	- cd $(INSTALL)/Perl/lib ;\
           for f in `find . -name Config.pm` ; do \
              if test -n "$$f"; then\
                 sed -e 's#INSTALL_BIN#${INSTALL}#g' $$f > tmpfile ;\
                 cp -f tmpfile $$f ;\
                 rm -f tmpfile;\
              else :; fi;\
           done
#
#  Edit binary files to add ${INSTALL} path.
	- cd $(INSTALL)/Perl/bin ;\
           for f in $(BUILT_FILES2) ""; do \
              if test -n "$$f"; then\
                 sed -e 's#INSTALL_BIN#${INSTALL}#g' $$f > tmpfile ;\
                 cp -f tmpfile $$f ;\
                 rm -f tmpfile;\
              else :; fi;\
           done
#
#  Install the Latex documentation, giving it world read permission,
#  leaving the source copy in place.
	for f in $(LATEX_DOCS) ""; do \
           if test -n "$$f"; then \
              cp -p $$f $(INSTALL_DOCS);\
              chmod 644 $(INSTALL_DOCS)/$$f;\
           else :; fi;\
        done
#
#  Install any hypertext documents, giving world read access to all the files
#  they contain and linking with other documents.
	if test -n "$(HYPERTEXT_DOCS)"; then \
           pwd=`pwd`;\
           (cd $(INSTALL_DOCS);\
           for f in $(HYPERTEXT_DOCS) ""; do \
              if test -n "$$f"; then\
                 $(TAR_OUT) $$pwd/$${f}_tar;\
                 chmod 755 `find $$f -type d -print`;\
                 chmod 644 `find $$f ! -type d -print`;\
                 touch $$f;\
              else :; fi;\
           done);\
           HTX_PATH='$(STAR_DOCS):$(STAR_HELP)';\
           export HTX_PATH;\
           $(STAR_BIN)/hlink $(INSTALL_DOCS) $(INSTALL_HELP);\
        fi;
#
#  Install the date stamp file and make it read-only to prevent its
#  date being changed.
	cp -p $(DATE_STAMP) $(INSTALL_DATES)
	chmod 444 $(INSTALL_DATES)/$(DATE_STAMP)
	chmod 644 $(DATE_STAMP)
	rm $(DATE_STAMP)
	$(LINK) $(INSTALL_DATES)/$(DATE_STAMP) $(DATE_STAMP)

#-------------------------------------------------------------------------------
#  deinstall: Deinstall the package.
#  --------------------------------
#
#  Reverse the action of the install target, removing the installed
#  files and returning them to the source directory.

#  The deinstall target checks that the package is installed in the INSTALL
#  directory.  If so, it causes the do_deinstall target to be made which 
#  performs the deinstallation.

deinstall:
	@ if test ! -f .INSTALLED_$(SYSTEM); then \
           echo;\
           echo '*** The $(PACK_NAME) package is not currently installed';\
           echo;\
        else \
           if test "`cat .INSTALLED_$(SYSTEM)`" = "$(INSTALL)"; then \
              if $(MAKE) do_deinstall; then \
                 echo;\
                 echo \
'*** The $(PACK_NAME) package has been deinstalled from directory $(INSTALL)';\
                 echo;\
              else \
                 echo;\
                 echo \
'*** "make" failed deinstalling the $(PACK_NAME) package from directory $(INSTALL)';\
                 echo;\
                 exit 1;\
              fi;\
           else \
              echo;\
              echo \
"*** The $(PACK_NAME) package is installed in `cat .INSTALLED_$(SYSTEM)`";\
              echo \
"*** and not in your INSTALL directory ($(INSTALL))";\
              echo '*** Not deinstalled';\
              exit 1;\
           fi;\
        fi

#  The do_deinstall target (which should never exist) checks that an
#  installed version of each file exists (in case an install failed
#  part of the way through) and returns it to the source directory,
#  using "cp -p" to preserve file dates.  Links are removed from the
#  source directory before copying.

do_deinstall:
#
#  Note the package will need to be tested again.
	@- if test -f .TESTED_$(SYSTEM); then rm -f .TESTED_$(SYSTEM); else :; fi
#
#  Deinstall the binaries and scripts
	- cd bin ;\
           for f in `find . ! -type d `; do \
              if [ -f $(PERLROOT)/bin/$$f ]; then \
                 chmod 644 $(PERLROOT)/bin/$$f ;\
                 rm -f $(PERLROOT)/bin/$$f ;\
              else :; fi;\
           done
#
#  Deinstall the libraries, module and other stuff.
	- cd lib ;\
           for f in `find . ! -type d ` ; do \
              if [ -f $(PERLROOT)/lib/$$f ]; then \
                 chmod 644 $(PERLROOT)/lib/$$f ;\
                 rm -f $(PERLROOT)/lib/$$f ;\
              else :; fi;\
           done
#
#  Remove MessageRelay.pl link.
	- rm -f $(INSTALL_BIN)/MessageRelay.pl
#
#  Remove starversion link.
	- rm -f $(INSTALL_BIN)/starversion
#
#  Remove NDFPERL back-compatibility link.
	- rm -f $(INSTALL_BIN)/ndfperl
#
#  Deinstall the Latex documentation, if installed versions exist.
	- for f in $(LATEX_DOCS) ""; do \
           if test -n "$$f" -a -f $(INSTALL_DOCS)/$$f; then \
              rm -f $(INSTALL_DOCS)/$$f;\
           else :; fi;\
        done
#
#  Deinstall any hypertext documents,  and relink the hypertext if required.
	- if test -n "$(HYPERTEXT_DOCS)"; then \
           for f in $(HYPERTEXT_DOCS) ""; do \
              if test -n "$$f" -a -d $(INSTALL_DOCS)/$$f; then \
                 rm -f -r $(INSTALL_DOCS)/$$f;\
              else :; fi;\
           done;\
           HTX_PATH='$(STAR_DOCS):$(STAR_HELP)';\
           export HTX_PATH;\
           $(STAR_BIN)/hlink $(INSTALL_DOCS) $(INSTALL_HELP);\
        fi
#
#  Deinstall the date stamp file after setting its protection so it may
#  be removed.
	- if test -f $(INSTALL_DATES)/$(DATE_STAMP); then \
           chmod 644 $(DATE_STAMP); rm $(DATE_STAMP);\
           chmod 644 $(INSTALL_DATES)/$(DATE_STAMP);\
           cp -p $(INSTALL_DATES)/$(DATE_STAMP) .;\
           rm $(INSTALL_DATES)/$(DATE_STAMP);\
        else :; fi
#
#  Note the system is no longer installed.  Re-create .BUILT, since we have
#  returned the built files to the source directory but an unbuild may have
#  been done.
	@- rm -f .INSTALLED_$(SYSTEM) 1>/dev/null 2>/dev/null
	@ echo '$(SYSTEM)' > .BUILT

#-------------------------------------------------------------------------------
#  test: Perform an installation test.
#  ----------------------------------
#
#  Check that installed files are in their correct places and that a
#  simple test program will run correctly.

#  The test target checks that the package is currently installed.  If
#  so, it causes the do_test target to be made, which performs the
#  installation test.

test:
	@ if test ! -f .INSTALLED_$(SYSTEM); then \
           echo;\
           echo '*** The $(PACK_NAME) package is not currently installed';\
           echo;\
        elif $(MAKE) do_test; then\
           echo;\
           echo \
           '*** Installation test for the $(PACK_NAME) package has been run';\
           echo;\
        else \
           echo;\
           echo \
           '*** Installation test for the $(PACK_NAME) package failed';\
           echo;\
           exit 1;\
        fi

#  The do_test target performs the installation test. A file named do_test
#  should never exist.

do_test:
#
#  Note the test has not yet succeeded.
	@- if test -f .TESTED_$(SYSTEM); then rm -f .TESTED_$(SYSTEM); else :; fi
#  Note the test has been run.
	@ touch .TESTED_$(SYSTEM)

#-------------------------------------------------------------------------------
#  export: Export the installed system.
#  -----------------------------------
#
#  Export the source plus all the built files to a new user.

#  The export target depends on the resulting compressed tar file being
#  up to date.

export: $(EXPORT)/$(PKG_NAME)_$(SYSTEM).tar.Z
	@ echo
	@ echo \
'*** Export copy of the built $(PACK_NAME) package is in the compressed'
	@ echo \
'    tar file $(EXPORT)/$(PKG_NAME)_$(SYSTEM).tar.Z'
	@ echo

#  The compressed tar file is up to date if it exists and is more
#  recent than all the source files and the date stamp file (which
#  records the time of the last build which modified any files).

$(EXPORT)/$(PKG_NAME)_$(SYSTEM).tar.Z: $(SOURCE_FILES) $(DATE_STAMP)
#
#  Issue a warning if the package has not been tested.
	@ if test ! -f .TESTED_$(SYSTEM); then \
           echo;\
           echo '*** Warning: the $(PACK_NAME) package has not been tested';\
           echo;\
        else :; fi
#
#  Remove any pre-existing tar files before creating new ones.
	if test -f $(EXPORT)/$(PKG_NAME)_$(SYSTEM).tar.Z; then \
           rm -f $(EXPORT)/$(PKG_NAME)_$(SYSTEM).tar.Z; else :; fi
	$(TAR_IN) - $(SOURCE_FILES) $(BUILT_FILES) $(DATE_STAMP) .BUILT \
           | compress -v > $(EXPORT)/$(PKG_NAME)_$(SYSTEM).tar.Z

#-------------------------------------------------------------------------------
#  export_run: Export the built system (without source).
#  -----------------------------------------------------
#
#  Export all the built files to a new user.

#  The export_run target depends on the resulting compressed tar file being
#  up to date.

export_run: $(EXPORT)/$(PKG_NAME)_$(SYSTEM)_run.tar.Z
	@ echo
	@ echo \
'*** Export copy of the "runtime" $(PACK_NAME) package is in the compressed'
	@ echo \
'    tar file $(EXPORT)/$(PKG_NAME)_$(SYSTEM)_run.tar.Z'
	@ echo

#  The compressed tar file is up to date if it exists and is more
#  recent than all the source files and the date stamp file (which
#  records the time of the last build which modified any files).

$(EXPORT)/$(PKG_NAME)_$(SYSTEM)_run.tar.Z: $(SOURCE_FILES) $(DATE_STAMP)
#
#  Issue a warning if the package has not been tested.
	@ if test ! -f .TESTED_$(SYSTEM); then \
           echo;\
           echo '*** Warning: the $(PACK_NAME) package has not been tested';\
           echo;\
        else :; fi
#
#  Remove any pre-existing tar files before creating new ones.
	if test -f $(EXPORT)/$(PKG_NAME)_$(SYSTEM)_run.tar.Z; then \
           rm -f $(EXPORT)/$(PKG_NAME)_$(SYSTEM)_run.tar.Z; else :; fi
	$(TAR_IN) - mk makefile $(DOCUMENTATION) $(BUILT_FILES) \
           $(DATE_STAMP) .BUILT \
           | compress -v > $(EXPORT)/$(PKG_NAME)_$(SYSTEM)_run.tar.Z


#-------------------------------------------------------------------------------
#  export_source: Export the source.
#  --------------------------------
#
#  Export the source files only to a new user.

#  This target depends on the resulting compressed tar file being up to
#  date.

export_source: $(EXPORT)/$(PKG_NAME).tar.Z
	@ echo
	@ echo \
'*** Export copy of the $(PACK_NAME) package source is in the compressed'
	@ echo \
'    tar file $(EXPORT)/$(PKG_NAME).tar.Z'
	@ echo

#  The compressed tar file is up to date if it exists and is more
#  recent than all the source files.

$(EXPORT)/$(PKG_NAME).tar.Z: $(SOURCE_FILES)
#
#  Remove any pre-existing tar files before creating new ones.
	if test -f $(EXPORT)/$(PKG_NAME).tar.Z; then \
           rm -f $(EXPORT)/$(PKG_NAME).tar.Z; else :; fi
	$(TAR_IN) - $(SOURCE_FILES) \
           | compress -v > $(EXPORT)/$(PKG_NAME).tar.Z

#-------------------------------------------------------------------------------
clean:
	@ rm -rf $(PKGDIR1) $(PKGDIR2) $(PKGDIR3) $(PKGDIR4) $(PKGDIR5) $(PKGDIR6)
	@ echo
	@ echo '*** Intermediate files removed'
	@ echo

#-------------------------------------------------------------------------------
unbuild: clean
	@ rm -rf $(BUILT_DIRS) $(BUILT_FILES) .BUILT $(DATE_STAMP) 
	@ echo
	@ echo '*** Built files removed'
	@ echo

#-------------------------------------------------------------------------------
strip:
	@ echo
	@ echo '*** No Binaries to be stripped'
	@ echo

#-------------------------------------------------------------------------------
rebuild: build install

#-------------------------------------------------------------------------------
#  Development targets.  Not for general use.

starlinkconfig: .BUILT_$(PKGNAME1) .INSTALL_$(PKGNAME1)
ndfperl: .BUILT_$(PKGNAME2) .INSTALL_$(PKGNAME2)
starlink: .BUILT_$(PKGNAME3) .INSTALL_$(PKGNAME3)
gsd: .BUILT_$(PKGNAME4) .INSTALL_$(PKGNAME4)
astro-sla: .BUILT_$(PKGNAME5) .INSTALL_$(PKGNAME5)
astro-telescope: .BUILT_$(PKGNAME6) .INSTALL_$(PKGNAME6)
time-piece: .BUILT_$(PKGNAME7) .INSTALL_$(PKGNAME7)
astro-coords: .BUILT_$(PKGNAME8) .INSTALL_$(PKGNAME8)

unbuild_starlinkconfig:
	rm -rf .BUILT_$(PKGNAME1) .INSTALL_$(PKGNAME1) $(PKGDIR1)

unbuild_ndfperl:
	rm -rf .BUILT_$(PKGNAME2) .INSTALL_$(PKGNAME2) $(PKGDIR2)

unbuild_starlink:
	rm -rf .BUILT_$(PKGNAME3) .INSTALL_$(PKGNAME3) $(PKGDIR3)

unbuild_gsd:
	rm -rf .BUILT_$(PKGNAME4) .INSTALL_$(PKGNAME4) $(PKGDIR4)

unbuild_astro-sla:
	rm -rf .BUILT_$(PKGNAME5) .INSTALL_$(PKGNAME5) $(PKGDIR5)

unbuild_astro-telescope:
	rm -rf .BUILT_$(PKGNAME6) .INSTALL_$(PKGNAME6) $(PKGDIR6)

unbuild_time-piece:
	rm -rf .BUILT_$(PKGNAME7) .INSTALL_$(PKGNAME7) $(PKGDIR7)

unbuild_astro-coords:
	rm -rf .BUILT_$(PKGNAME8) .INSTALL_$(PKGNAME8) $(PKGDIR8)
#-------------------------------------------------------------------------------
#
#  End of makefile.
#.

