# Root MKPKG for IRAF.  The bootstrap utilities and libraries in the HOST
# subdirectory must be made before this can be run.

$verbose
$call	mkall			# make everything
$exit

mkall:
	$ifeq (hostid, unix)  !(clear;date)  $endif
	$echo "==================== MAKE IRAF! ========================="
	$echo "+"
	$call syslibs
	$call mathlibs
	$ifeq (USE_SHLIB, yes) $call shlib $endif
	# (fall through)
relink:
	$call sysexe
	$call packages
	$echo "====================== (done) ==========================="
	$ifeq (hostid, unix)  !(date)  $endif
	;

update:
	$call sysexe
	$call packages
	;

syslibs:
	$echo "====================== SYSLIBS =========================="
	$echo "+"
	$call sysgen@sys
	$echo "+" $echo "+"
	;

sysexe:
	$echo "====================== SYSEXE ==========================="
	$echo "+" $echo "+"
	$call update@sys
	$echo "+" $echo "+"
	;

mathlibs:
	$echo "====================== MATHLIBS ========================="
	$echo "+" $echo "+"
	$call mathgen@math
	$echo "+" $echo "+"
	;

packages:
	$echo "====================== PACKAGES ========================="
	$echo "+" $echo "+"

	# On the UNIX distribution, the BIN directory is excluded from the
	# tar tape in a "you relink" distribution.  Lets make sure we have
	# the directory before proceeding to relink all the packages.

	$ifeq (hostid, unix)  !(mkdir $(iraf)bin >& /dev/null)  $endif

	$call update@pkg
	$echo "+" $echo "+"
	;

shlib:
	$echo "====================== SHLIB ============================"
	$echo "+" $echo "+"
	$call update@host$shlib/
	$echo "+" $echo "+"
	;

# 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
	    $ifeq (MACH, dmip)
		! grep -v ':$$' $(spool) | grep -v '^xc' | grep -v '^ar'\
		    | grep -v '^check file' | grep -v 'never used$'
	    $else $ifeq (MACH, rs6000)
		! grep -v ':$$' $(spool) | grep -v '^xc' | grep -v '^ar'\
		    | grep -v '^check file' | grep -v 'Compilation successful'\
		    | grep -v 'End of Compilation'
	    $else
		! grep -v ':$$' $(spool) | grep -v '^xc' | grep -v '^ar'\
		    | grep -v '^check file'
	    $endif $endif
	$else
	    $echo "mkpkg summary only available on a UNIX system"
	$endif
	;

# REVIEW -- Full spool listing minus unwanted messages. [AIX]

review:
	$ifndef (spool)
	    $set spool = spool
	$endif
	! cat $(spool) | grep -v 'End of Compilation' |\
	    grep -v 'Compilation successful'
	;

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

strip:
	$echo "Ignore any messages about cannot delete a file."
	$echo "Be sure to do a `cd noao; mkpkg strip' as well."
	$echo "Stripping non-runtime files from IRAF source tree..."
	!rmfiles -f $(hlib)strip.iraf
	;

# SRCARC -- Make a source archive (TAR format) of the system.

srcarc:
	!wtar -of $(?tarfile) README mkpkg lib sys math pkg doc
	;


# UNIX/IRAF stuff (multiple architecture support).
# ---------------------------------------------------

arch:
showfloat:				# show current float option
	$verbose off
	!$(hlib)/mkfloat.csh
	;
generic:				# make architecture indep. (no bins)
	$verbose off
	!$(hlib)/mkfloat.csh generic
	!(cd ./unix; setenv MACH generic; sh -x setarch.sh)
	;
f68881:					# install f68881 binaries
	$verbose off
	!$(hlib)/mkfloat.csh f68881
	!(cd ./unix; setenv MACH mc68020; sh -x setarch.sh)
	;
ffpa:					# install ffpa binaries
	$verbose off
	!$(hlib)/mkfloat.csh ffpa
	!(cd ./unix; setenv MACH mc68020; sh -x setarch.sh)
	;
fswitch:				# install fswitch binaries
	$verbose off
	!$(hlib)/mkfloat.csh fswitch
	!(cd ./unix; setenv MACH mc68020; sh -x setarch.sh)
	;
fsoft:					# install fsoft binaries
	$verbose off
	!$(hlib)/mkfloat.csh fsoft
	!(cd ./unix; setenv MACH mc68020; sh -x setarch.sh)
	;
pg:					# install profiled binaries
	$verbose off
	!$(hlib)/mkfloat.csh pg
	!(cd ./unix; setenv MACH mc68020; sh -x setarch.sh)
	;
sparc:					# install sparc binaries
	$verbose off
	!$(hlib)/mkfloat.csh sparc
	!(cd ./unix; setenv MACH sparc; sh -x setarch.sh)
	;
ssun:					# install ssun binaries
	$verbose off
	!$(hlib)/mkfloat.csh ssun
	!(cd ./unix; setenv MACH ssol; sh -x setarch.sh)
	;
sf2c:					# install sf2c binaries
	$verbose off
	!$(hlib)/mkfloat.csh sf2c
	!(cd ./unix; setenv MACH ssol; sh -x setarch.sh)
	;
386i:
i386:					# install 386i binaries
	$verbose off
	!$(hlib)/mkfloat.csh i386
	!(cd ./unix; setenv MACH i386; sh -x setarch.sh)
	;
alpha:					# install DEC Alpha/OSF binaries
	$verbose off
	!$(hlib)/mkfloat.csh alpha
	!(cd ./unix; setenv MACH alpha; sh -x setarch.sh)
	;
ddec:					# install DSUX DEC Fortran binaries
	$verbose off
	!$(hlib)/mkfloat.csh ddec
	#!(cd ./unix; setenv MACH ddec; sh -x setarch.sh)
	;
dmip:					# install DSUX MIPS Fortran binaries
	$verbose off
	!$(hlib)/mkfloat.csh dmip
	#!(cd ./unix; setenv MACH dmip; sh -x setarch.sh)
	;
rs6000:					# install rs6000 binaries
	$verbose off
	!$(hlib)/mkfloat.csh rs6000
	!(cd ./unix; setenv MACH rs6000; sh -x setarch.sh)
	;
mips:					# install mips binaries
	$verbose off
	!$(hlib)/mkfloat.csh mips
	!(cd ./unix; setenv MACH mips; sh -x setarch.sh)
	;
f2c:					# install F2C/GCC binaries
	$verbose off
	!$(hlib)/mkfloat.csh f2c
	!(cd ./unix; setenv MACH mac; sh -x setarch.sh)
	;
irix:                                   # install irix binaries
        $verbose off
        !$(hlib)/mkfloat.csh irix
        !(cd ./unix; setenv MACH irix; sh -x setarch.sh)
        ;
hp300:                                  # install HPUX series 300 binaries
        $verbose off
        !$(hlib)/mkfloat.csh hp300
        !(cd ./unix; setenv MACH hp300; sh -x setarch.sh)
        ;
hp700:                                  # install HPUX series 700 binaries
hp800:					# install HPUX series 800/700 binaries
        $verbose off
        !$(hlib)/mkfloat.csh hp700
        !(cd ./unix; setenv MACH hp700; sh -x setarch.sh)
        ;
freebsd:				# install freebsd binaries
        $verbose off
        !$(hlib)/mkfloat.csh freebsd
        !(cd ./unix; setenv MACH freebsd; sh -x setarch.sh)
        ;
        ;
sunos:					# install sunos binaries
        $verbose off
        !$(hlib)/mkfloat.csh sunos
        !(cd ./unix; setenv MACH sunos; sh -x setarch.sh)
        ;
linux:					# install linux binaries
        $verbose off
        !$(hlib)/mkfloat.csh linux
        !(cd ./unix; setenv MACH linux; sh -x setarch.sh)
        ;
redhat:					# install redhat binaries
        $verbose off
        !$(hlib)/mkfloat.csh redhat
        !(cd ./unix; setenv MACH redhat; sh -x setarch.sh)
        ;
suse:					# install suse binaries
        $verbose off
        !$(hlib)/mkfloat.csh suse
        !(cd ./unix; setenv MACH suse; sh -x setarch.sh)
        ;
linuz:					# install linuz binaries
        $verbose off
        !$(hlib)/mkfloat.csh linuz
        !(cd ./unix; setenv MACH linux; sh -x setarch.sh)
        ;
