# Make the package.

$call update
$exit

update:
	# Do some defensive coding first to be sure the proper compiler
	# and files are defined.

	$ifeq (MACH, hp700) then
	    $ifdef (XC-CC) then
	        $ifeq (XC-CC,c89) then
		    $call build
	        $else
	            $echo " "
		    $echo "*** On HP systems you must first define"
		    $echo "*** "
		    $echo "***		setenv XC-CC c89"
		    $echo "*** "
		    $echo "*** so the proper ANSI-C compiler will be used."
	            $echo " "
	        $endif
	    $else
	        $echo " "
		$echo "*** On HP systems you must first define"
		$echo "*** "
		$echo "*** 		setenv XC-CC c89"
		$echo "*** "
		$echo "*** so the proper ANSI-C compiler will be used."
	        $echo " "
	    $endif
	$else $ifeq (MACH, sparc) then
	    $ifdef (XC-CC) then
	        $ifeq (XC-CC,acc) then
		    $call build
	        $else
	            $echo " "
		    $echo "*** On SunOS systems you must first define"
		    $echo "*** "
		    $echo "*** 		setenv XC-CC acc"
		    $echo "*** "
		    $echo "*** so the proper ANSI-C compiler will be used."
	            $echo " "
	        $endif
	    $else
	        $echo " "
		$echo "*** On SunOS systems you must first define"
		$echo "*** "
		$echo "*** 		setenv XC-CC acc"
		$echo "*** "
		$echo "*** so the proper ANSI-C compiler will be used."
	        $echo " "
	    $endif

	$else
	    $call build
	$endif
	;


build:
	$iffile (stsdas$bin.$(IRAFARCH)/libcvos.a)
	    $iffile (stsdas$lib/xxtools.h)
	        $call lib
	        $call src
	    $else
	        $echo " "
	        $echo "*** You're STSDAS appears to be an older version,"
	        $echo "*** you must install STSDAS V2.1 or later before"
	        $echo "*** building MXTOOLS."
	        $echo " "
	    $endif
	$else
	    $echo " "
	    $echo "*** You must have the STSDAS package installed"
	    $echo "*** before building MXTOOLS."
	    $echo " "
	$endif
	;

lib:
        $echo ""
        $echo "===================== LIB ========================="
        $echo ""
        $call update@lib
	;

src:
        $echo ""
        $echo "===================== SRC ========================="
        $echo ""
        $call update@src
	;



# STRIP -- Strip the package directories of all sources and other files
# not required to run the system, or for user programming.

strip:
	!rmfiles -f lib/strip.mxtools
	;


# SUMMARY -- [UNIX] mkpkg summary: output a summary of the spooled mkpkg
# output, omitting most of the mundane chatter.  Used to scan large spool
# files for errors.

summary:
	$ifeq (HOSTID, unix)
            $ifndef (spool)
                $set spool = spool
            $endif
	    ! grep -v ':$$' spool | grep -v '^xc' | grep -v '^ar'\
	    | grep -v '^check file'
	$else
	    $echo "mkpkg summary only available on a UNIX system"
	$endif
	;



# IRAF multiple architecture support.
# ----------------------------------------

arch:					# show current float option
showfloat:
	$verbose off
	!$(hlib)/mkfloat.csh
	;
generic:				# generic installation (no bin)
	$ifnfile (bin.generic)
	    !mkdir bin.generic
	$endif
	$verbose off
	$set DIRS = "lib src"
	!$(hlib)/mkfloat.csh generic -d $(DIRS)
	;
sparc:					# install sparc binaries
	$ifnfile (bin.sparc)
	    !mkdir bin.sparc
	$endif
	$verbose off
	$set DIRS = "lib src"
	!$(hlib)/mkfloat.csh sparc -d $(DIRS)
	;
ssun:					# install Solaris binaries
	$ifnfile (bin.ssun)
	    !mkdir bin.ssun
	$endif
	$verbose off
	$set DIRS = "lib src"
	!$(hlib)/mkfloat.csh ssun -d $(DIRS)
	;
irix:					# install SGI IRIX binaries
	$ifnfile (bin.irix)
	    !mkdir bin.irix
	$endif
	$verbose off
	$set DIRS = "lib src"
	!$(hlib)/mkfloat.csh irix -d $(DIRS)
	;
rs6000:					# install IBM AIX binaries
	$ifnfile (bin.rs6000)
	    !mkdir bin.rs6000
	$endif
	$verbose off
	$set DIRS = "lib src"
	!$(hlib)/mkfloat.csh aix -d $(DIRS)
	;
hp700:					# install HP/UX binaries
	$ifnfile (bin.hp700)
	    !mkdir bin.hp700
	$endif
	$verbose off
	$set DIRS = "lib src"
	!$(hlib)/mkfloat.csh hp700 -d $(DIRS)
	;
alpha:                                  # install DEC Alpha binaries
	$ifnfile (bin.alpha)
	    !mkdir bin.alpha
	$endif
        $verbose off
        $set DIRS = "lib src"
        !$(hlib)/mkfloat.csh alpha -d $(DIRS)
        ;
freebsd:                                # install FreeBSD binaries
	$ifnfile (bin.freebsd)
	    !mkdir bin.freebsd
	$endif
        $verbose off
        $set DIRS = "lib src"
        !$(hlib)/mkfloat.csh freebsd -d $(DIRS)
        ;
linux:                                  # install Linux binaries
	$ifnfile (bin.linux)
	    !mkdir bin.linux
	$endif
        $verbose off
        $set DIRS = "lib src"
        !$(hlib)/mkfloat.csh linux -d $(DIRS)
        ;
redhat:                                 # install Redhat Linux binaries
	$ifnfile (bin.redhat)
	    !mkdir bin.redhat
	$endif
        $verbose off
        $set DIRS = "lib src"
        !$(hlib)/mkfloat.csh redhat -d $(DIRS)
        ;
suse:                                  # install SuSE binaries
	$ifnfile (bin.suse)
	    !mkdir bin.suse
	$endif
        $verbose off
        $set DIRS = "lib src"
        !$(hlib)/mkfloat.csh suse -d $(DIRS)
        ;
sunos:                                 # install Solaris x86 binaries
	$ifnfile (bin.sunos)
	    !mkdir bin.sunos
	$endif
        $verbose off
        $set DIRS = "lib src"
        !$(hlib)/mkfloat.csh sunos -d $(DIRS)
        ;
