include make.include
include make.pkgs

.NOTPARALLEL :

#--------------------------defines

export root := $(shell pwd)

USER	= joye
#DEST	= bokhara.cfa.harvard.edu
DEST	= bokhara

DIRS	= bin lib include man html share dist

#--------------------------dirs

SRCDIR	= src
DOCDIR	= doc
DS9DIR	= ds9

#--------------------------cache

CACHE = $(root)/myconfig.cache
LOCALCACHE = myconfig.cache

#--------------------------dist

DS9APP=SAOImage\ DS9\ $(DS9VERSION)
XPAAPP=XPA\ $(XPAVERSION)

#--------------------------blt stuff
BLTINCL	= blt.h bltVector.h

BLTWITHOUT = \
	--without-jpegincdir --without-jpeglibdir \
	--without-pngincdir --without-pnglibdir \
	--without-tiffincdir --without-tifflibdir \
	--without-xpmincdir --without-xpmlibdir \
	--without-xrandrincdir --without-xrandrlibdir \
	--without-expatincdir --without-expatlibdir \
	--without-mysqlincdir --without-mysqllibdir

#--------------------------flags
ifeq ($(OS),unix)
  TCLDIRDIR= $(TCLDIR)/unix
  TKDIRDIR= $(TKDIR)/unix

  XFLAGS = --x-includes=$(X11INCLUDE) --x-libraries=$(X11LIB)

  TCLFLAGS = $(XFLAGS) $(EXTTCLFLAGS)
  TKTABLEFLAGS = $(XFLAGS)
  BLTFLAGS = $(XFLAGS) $(BLTWITHOUT)
  TKIMGFLAGS = $(XFLAGS)
  XPAFLAGS = $(XFLAGS)

  SIGNAL= signal
  SIGNALCLEAN= signalclean

  OPTDIR= unix
  OPTDIRCLEAN= unixclean
endif

ifeq ($(OS),windows)
  TCLDIRDIR= $(TCLDIR)/win
  TKDIRDIR= $(TKDIR)/win

  TCLFLAGS = --enable-symbols
  TKTABLEFLAGS = --enable-symbols
  BLTFLAGS = --without-x $(BLTWITHOUT) \
	--without-xftincdir --without-xftlibdir
  TKIMGFLAGS = --enable-symbols
  XPAFLAGS = --without-x
  PREHTMLFLAGS = config_BUILD_TCLSH=tclsh85sg \
	config_TARGET_TCL_SCRIPT_DIR=$(root)/lib/tcl8.5

  SIGNAL=
  SIGNALCLEAN=

  OPTDIR= win
  OPTDIRCLEAN= winclean
endif

ifeq ($(OS),macosx)
  TCLDIRDIR= $(TCLDIR)/unix
  TKDIRDIR= $(TKDIR)/unix

  TCLFLAGS = --enable-aqua
  BLTFLAGS = --x-includes=/usr/X11/include --x-libraries=/usr/X11/lib \
	$(BLTWITHOUT)

# xpa configure will not accept --without-x
  XPAFLAGS = --with-x=disabled --enable-posix_spawn
  PREHTMLFLAGS = config_TARGET_LIBS="-framework CoreFoundation -framework Carbon" \
	config_TARGET_X_INC="-I$(root)/$(TKDIR)/xlib" \
	config_TARGET_X_LIBS=" "

  FUNTOOLSFLAGS = --enable-posix_spawn

  SIGNAL= signal
  SIGNALCLEAN= signalclean

  OPTDIR= macosx
  OPTDIRCLEAN= macosxclean
endif

CVSFILES = admin \
	checkdns \
	tkmpeg \
	COPYING \
	copyright \
	iis \
	make.darwin64x86mountainlion \
	make.darwinx86mountainlion \
	make.darwinmountainlion \
	make.darwin64x86lion \
	make.darwinx86lion \
	make.darwinlion \
	make.darwin64x86snowleopard \
	make.darwinx86snowleopard \
	make.darwinsnowleopard \
	make.darwin64x86leopard \
	make.darwinx86leopard \
	make.darwinppcleopard \
	make.darwinleopard \
	make.darwinx86tiger \
	make.darwinppctiger \
	make.darwintiger \
	make.linux \
	make.linux64 \
	make.macosxsnowleopard \
	make.macosxx86leopard \
	make.macosxppcleopard \
	make.macosxleopard \
	make.macosxx86tiger \
	make.macosxppctiger \
	make.macosxtiger \
	make.solaris \
	make.source \
	make.windows \
	make.pkgs \
	Makefile \
	notes.txt \
	mods \
	README \
	saotk \
	unix \
	win \
	macosx \
	tests \
	doc \
	cmaps \
	template \
	src \
	msgs \
	ds9 \
	util \
	compilers \
	$(ZVFSDIR)/Makefile \
	$(WCSSUBSDIR)/Makefile \
	$(RICEDIR)/Makefile \
	$(HCOMPRESSDIR)/Makefile \
	$(PLIODIR)/Makefile

#	$(BLTDIR)/src/Makefile-macosx.in \
#	$(BLTDIR)/src/bltMacOSX.h \
#	$(BLTDIR)/src/bltMacOSX.c \
#	$(BLTDIR)/src/macosx.c

ZIPOBJS	 = zipfile.o \
	zipup.o \
	fileio.o \
	util.o \
	globals.o \
	crypt.o \
	ttyio.o \
	unix.o \
	crc32.o \
	deflate.o \
	trees.o

#--------------------------build
all	: build

build : dirs \
	tcl tk \
	tktable tkcon xmlrpc blt \
	zlib tclxml tkimg tkmpeg html \
	xpa iis checkdns $(SIGNAL) funtools \
	ast wcssubs \
	rice hcompress plio \
	$(OPTDIR) \
	saotk zip zvfs ds9

doc	: FORCE
	@echo "Making Documentation..."
	cd $(DOCDIR); $(MAKE)

#--------------------------language

language: FORCE
	grep 'msgcat::mc' src/*.tcl | tclsh8.5 util/mergedict.tcl da iso8859-1
	grep 'msgcat::mc' src/*.tcl | tclsh8.5 util/mergedict.tcl de iso8859-1
	grep 'msgcat::mc' src/*.tcl | tclsh8.5 util/mergedict.tcl es iso8859-1
	grep 'msgcat::mc' src/*.tcl | tclsh8.5 util/mergedict.tcl fr iso8859-1
	grep 'msgcat::mc' src/*.tcl | tclsh8.5 util/mergedict.tcl pt iso8859-1
	grep 'msgcat::mc' src/*.tcl | tclsh8.5 util/mergedict.tcl cs iso8859-2
	grep 'msgcat::mc' src/*.tcl | tclsh8.5 util/mergedict.tcl ja euc-jp
	grep 'msgcat::mc' src/*.tcl | tclsh8.5 util/mergedict.tcl zh big5

#--------------------------items

ds9	: scrub
	@echo "Making DS9..."
	cd $(DS9DIR); $(MAKE)

ifeq ($(OS),macosx)
ds9app	: ds9
	cd $(DS9DIR); $(MAKE) ds9app

ds9dmg	: FORCE
	rm -rf dist/$(DS9APP)
	rm -rf dist/$(DS9APP).dmg
	mkdir dist/$(DS9APP)
	ln -s /Applications dist/$(DS9APP)/.
	cp -r ds9/macosx/README dist/$(DS9APP)/.
	cp -rp bin/SAOImage\ DS9.app dist/$(DS9APP)/.
	hdiutil create -srcfolder dist/$(DS9APP) dist/$(DS9APP) 

endif

ifeq ($(OS),windows)
ds9app	: ds9
	cd $(DS9DIR); $(MAKE) ds9app

ds9winzip : FORCE
	$(RM) -f dist/$(DS9APP)\ Install.*
	/cygdrive/c/Program\ Files\ \(x86\)/WinZip/wzzip -p -r dist/$(DS9APP)\ Install.zip bin/ds9app
#	/cygdrive/c/Program\ Files\ \(x86\)/WinZip\ Self-Extractor/WINZIPSE.EXE  dist/$(DS9APP)\ Install.zip -setup -i ds9/win/ds9.ico -le -runasuser -t ds9/win/message.txt -a ds9/win/about.txt -c cscript install.vbs 
	/cygdrive/c/Program\ Files\ \(x86\)/WinZip\ Self-Extractor/WINZIPSE.EXE  dist/$(DS9APP)\ Install.zip -d C:\\ds9 -i ds9/win/ds9.ico -le -overwrite -runasuser -c cscript install.vbs

xpawinzip : FORCE
	$(RM) -f dist/$(XPAAPP)\ Install.*
	/cygdrive/c/Program\ Files\ \(x86\)/WinZip/wzzip dist/$(XPAAPP)\ Install.zip bin/xpa* bin/cygwin1.dll
	/cygdrive/c/Program\ Files\ \(x86\)/WinZip\ Self-Extractor/WINZIPSE.EXE  dist/$(XPAAPP)\ Install.zip -d C:\\ds9 -le -overwrite -runasuser
endif

debug	: FORCE
	@echo "Making DS9..."
	cd $(DS9DIR); $(MAKE) debug

dirs	: FORCE
	@echo "Installing Directories..."
	@for d in $(DIRS); do if [ ! -d $$d ]; then mkdir $$d; fi done

tcl	: FORCE
	@echo "Installing Tcl..."
	cd $(TCLDIRDIR); CC='$(CC)' CFLAGS='$(OPTS)' LDFLAGS='$(LIBS)' ./configure --prefix $(root) $(TCLFLAGS) --disable-shared --cache-file=$(CACHE)
	cd $(TCLDIRDIR); $(MAKE) -j $(JOBS); $(MAKE) install

tk	: FORCE
	@echo "Installing Tk..."
	cd $(TKDIRDIR); CC='$(CC)' CFLAGS='$(OPTS)' LDFLAGS='$(LIBS)' ./configure --prefix $(root) $(TCLFLAGS) --disable-shared --cache-file=$(CACHE)
	cd $(TKDIRDIR); $(MAKE) -j $(JOBS); $(MAKE) install
	$(RM) -r lib/$(TKVER)/demos

tktable	: FORCE
	@echo "Installing TkTable..."
	cd $(TKTABLEDIR); CC='$(CC)' CFLAGS='$(OPTS)' LDFLAGS='$(LIBS)' ./configure --prefix $(root) $(TKTABLEFLAGS) --disable-shared --cache-file=$(CACHE)
	cd $(TKTABLEDIR); $(MAKE) -j $(JOBS) ; $(MAKE) install

tkcon	: FORCE
	@echo "Installing TkCon..."
	$(RM) -r lib/$(TKCONVER)
	mkdir lib/$(TKCONVER)
	cp $(TKCONDIR)/*.tcl lib/$(TKCONVER)

xmlrpc	: FORCE
	@echo "Installing XMLRPC..."
	$(RM) -r lib/$(XMLRPCVER)
	mkdir lib/$(XMLRPCVER)
	cp $(XMLRPCDIR)/xmlrpc.tcl lib/$(XMLRPCVER)

blt	: FORCE
	@echo "Installing BLT..."
	cd $(BLTDIR); CC='$(CC)' CFLAGS='$(OPTS)' LDFLAGS='$(LIBS)' ./configure --prefix $(root) --with-tcl=$(root)/$(TCLDIR) --with-tk=$(root)/$(TKDIR) $(BLTFLAGS) --disable-shared --cache-file=$(CACHE)
	cd $(BLTDIR)/src; $(MAKE) -j $(JOBS) build_static
	cp $(BLTDIR)/src/*.a lib/.
	cd $(BLTDIR)/src; cp $(BLTINCL) ../../include/.

zlib  : FORCE
	@echo "Installing zlib..."
	cd $(ZLIBDIR); CC='$(CC)' CFLAGS='$(OPTS)' LDFLAGS='$(LIBS)' ./configure --prefix $(root) --static
	cd $(ZLIBDIR); $(MAKE) -j $(JOBS) install

tclxml	: FORCE
	@echo "Installing TCLXML..."
	cd $(TCLXMLDIR); CC='$(CC)' CFLAGS='$(OPTS)' LDFLAGS='$(LIBS)' ./configure --prefix $(root) --disable-shared --disable-threads --with-xml-static=1 $(TCLXMLFLAGS) --cache-file=$(CACHE)
	cd $(TCLXMLDIR); $(MAKE) -j $(JOBS) ; $(MAKE) install

tkimg	: libtiff
	@echo "Installing TKIMG..."
	cd $(TKIMGDIR); CC='$(CC)' CFLAGS='$(OPTS) -DPNG_NO_WRITE_gAMA' LDFLAGS='$(LIBS)' ./configure --prefix $(root) --with-tcl=$(root)/$(TCLDIRDIR) --with-tk=$(root)/$(TKDIRDIR) $(TKIMGFLAGS) --disable-shared --disable-threads --cache-file=$(LOCALCACHE)
	cd $(TKIMGDIR); $(MAKE) -j $(JOBS) all; $(MAKE) install

libtiff	: FORCE
	@echo "Installing LIBTIFF..."
	cd $(TKIMGDIR)/compat/libtiff; CC='$(CC)' CFLAGS='$(OPTS)' CXX='$(CC)' CXXFLAGS='$(OPTS)' LDFLAGS='$(LIBS)' ./configure --prefix $(root) --disable-shared --cache-file=$(LOCALCACHE)
	cd $(TKIMGDIR)/compat/libtiff; $(MAKE) -j $(JOBS) ; $(MAKE) install

tkmpeg	: FORCE
	@echo "Installing TKMPEG..."
	cd $(TKMPEGDIR); $(MAKE) -j $(JOBS)
	cd $(TKMPEGDIR); $(MAKE) install

html	: FORCE
	@echo "Installing HTMLWIDGET..."
	cd $(HTMLDIR); CC='$(CC)' CFLAGS='$(OPTS)' LDFLAGS='$(LIBS)' $(PREHTMLFLAGS) $(root)/htmlwidget/configure --prefix $(root) --with-tcl=$(root)/$(TCLDIR) --with-tk=$(root)/$(TKDIR) $(XFLAGS) --enable-shared=no --cache-file=$(CACHE)
	cd $(HTMLDIR); $(MAKE) headers libtkhtml.a
	cp $(HTMLDIR)/libtkhtml.a lib/.

xpa	: FORCE
	@echo "Installing XPA..."
	cd $(XPADIR); CC='$(CC)' CFLAGS='$(OPTS)' LDFLAGS='$(LIBS)' ./configure --prefix $(root) --with-tcl=$(root)/$(TCLDIRDIR) $(XPAFLAGS) --disable-shared --cache-file=$(CACHE)
	cd $(XPADIR); $(MAKE) -j $(JOBS); $(MAKE) install
	cd bin; strip xpa*

iis	: FORCE
	@echo "Installing IIS..."
	cd $(IISDIR); $(MAKE) -j $(JOBS) install

checkdns: FORCE
	@echo "Installing CheckDNS..."
	cd $(CHECKDNSDIR); $(MAKE) -j $(JOBS) install

signal: FORCE
	@echo "Installing Signal..."
	cd $(SIGNALDIR); $(MAKE) -j $(JOBS) install

funtools: FORCE
	@echo "Installing Funtools..."
	cd $(FUNTOOLSDIR); CC='$(CC)' CFLAGS='$(OPTS)' LDFLAGS='$(LIBS)' ./configure --prefix $(root) --with-zlib=../../lib/libz.a --with-wcslib=../lib/libwcs.a --enable-mainlib $(FUNTOOLSFLAGS)
	cd $(FUNTOOLSDIR); $(MAKE) lib
	cp $(FUNTOOLSDIR)/libfuntools.a lib/.

ast	: FORCE
	@echo "Installing AST..."
	cd $(ASTDIR); \
	touch aclocal.m4; sleep 1; \
	touch Makefile.in; sleep 1; \
	touch configure; \
	./configure --enable-shared=no --prefix=$(root) $(ASTFLAGS) CC='$(CC)' CFLAGS='$(OPTS) -I.'; \
	$(MAKE) -j $(JOBS) ast.h install-libLTLIBRARIES install-nodist_includeHEADERS install-includeHEADERS

wcssubs	: FORCE
	@echo "Installing WCSSUBS..."
	cd $(WCSSUBSDIR); $(MAKE) -j $(JOBS) install

rice	: FORCE
	@echo "Installing RICE..."
	cd $(RICEDIR); $(MAKE) -j $(JOBS) install

hcompress: FORCE
	@echo "Installing HCOMPRESS..."
	cd $(HCOMPRESSDIR); $(MAKE) -j $(JOBS) install

plio: FORCE
	@echo "Installing PLIO..."
	cd $(PLIODIR); $(MAKE) -j $(JOBS) install

ifdef OPTDIR
$(OPTDIR) : FORCE
	@echo "Installing $(OPTDIR)..."
	cd $(OPTDIR); $(MAKE) -j $(JOBS) install
endif

saotk	: FORCE
	@echo "Installing SAOTK..."
	cd $(SAOTKDIR); $(MAKE) -j $(JOBS) install

zip	: FORCE
	@echo "Installing ZIP..."
	cd $(ZIPDIR); PREFIX=$(root) $(MAKE) -j $(JOBS) CC='$(CC)' CFLAGS='$(OPTS) -I. -DUNIX' LFLAGS1='$(OPTS)' -f unix/Makefile generic
	cd $(ZIPDIR); PREFIX=$(root) $(MAKE) -j $(JOBS) CC='$(CC)' CFLAGS='$(OPTS) -I. -DUNIX' LFLAGS1='$(OPTS)' -f unix/Makefile install
	cd $(ZIPDIR); $(RM) libzip.a
	cd $(ZIPDIR); $(AR) -cr libzip.a $(ZIPOBJS)
	cp $(ZIPDIR)/libzip.a lib/.

zvfs	: FORCE
	@echo "Installing ZVFS..."
	cd $(ZVFSDIR); $(MAKE)
	cd $(ZVFSDIR); $(MAKE) install

#--------------------------clean

scrub : FORCE
	find . -name "*[~#]" -exec rm {} \;
ifeq ($(OS),windows)
	find . -name "*stackdump*" -exec rm {} \;
endif

distclean : filesclean \
	tclclean tkclean \
	tktableclean bltclean \
	zlibclean tclxmlclean tkimgclean tkmpegclean htmlclean \
	xpaclean iisclean checkdnsclean $(SIGNALCLEAN) funtoolsclean \
	astclean wcssubsclean \
	riceclean hcompressclean plioclean \
	$(OPTDIRCLEAN) \
	saotkclean zipclean zvfsclean ds9clean srcclean \
	dirsclean 

filesclean: FORCE
	find . -name "myconfig.cache" -exec rm {} \;
	$(RM) core *~ *#

dirsclean: FORCE
	@for d in $(DIRS); do rm -rf $$d; done

tclclean : FORCE
	cd $(TCLDIRDIR); $(MAKE) distclean

tkclean : FORCE
	cd $(TKDIRDIR); $(MAKE) distclean

tktableclean: FORCE
	cd $(TKTABLEDIR); $(MAKE) distclean

bltclean: FORCE
	cd $(BLTDIR); $(MAKE) distclean

zlibclean: FORCE
	cd $(ZLIBDIR); $(MAKE) distclean

tclxmlclean: FORCE
	cd $(TCLXMLDIR); $(MAKE) distclean

tkimgclean: libtiffclean
	rm -fr $(TKIMGDIR)/Img/*
	rm -fr $(LIB)/Img1.*
	cd $(TKIMGDIR); $(MAKE) distclean

libtiffclean: FORCE
	cd $(TKIMGDIR)/compat/libtiff; $(MAKE) distclean

tkmpegclean: FORCE
	cd $(TKMPEGDIR); $(MAKE) distclean

htmlclean: FORCE
	cd $(HTMLDIR); $(MAKE) distclean

xpaclean : FORCE
	cd $(XPADIR); $(MAKE) distclean

iisclean : FORCE
	cd $(IISDIR); $(MAKE) distclean

checkdnsclean : FORCE
	cd $(CHECKDNSDIR); $(MAKE) distclean

signalclean : FORCE
	cd $(SIGNALDIR); $(MAKE) distclean

funtoolsclean: FORCE
	cd $(FUNTOOLSDIR); $(MAKE) distclean

astclean: FORCE
	cd $(ASTDIR); $(MAKE) distclean

wcssubsclean: FORCE
	cd $(WCSSUBSDIR); $(MAKE) distclean

riceclean: FORCE
	cd $(RICEDIR); $(MAKE) distclean

hcompressclean: FORCE
	cd $(HCOMPRESSDIR); $(MAKE) distclean

plioclean: FORCE
	cd $(PLIODIR); $(MAKE) distclean

saotkclean : FORCE
	cd $(SAOTKDIR); $(MAKE) distclean

zipclean: FORCE
	cd $(ZIPDIR); PREFIX=$(root) $(MAKE) -f unix/Makefile clean

zvfsclean: FORCE
	cd $(ZVFSDIR); $(MAKE) distclean

ds9clean : FORCE
	cd $(DS9DIR); $(MAKE) distclean

srcclean : FORCE
	cd $(SRCDIR); $(MAKE) distclean

unixclean : FORCE
	cd unix; $(MAKE) distclean

winclean : FORCE
	cd win; $(MAKE) distclean

macosxclean : FORCE
	cd macosx; $(MAKE) distclean


#--------------------------cvs

commit : FORCE
	cvs commit -m "" $(CVSFILES)

update : FORCE
	cvs update $(CVSFILES)

#--------------------------distribution

dist	: distds9 distxpa

distall	: distds9 distxpa distdoc distsource

ifeq ($(OS),windows)
distapp	: distds9app distxpaapp
endif

ifeq ($(OS),macosx)
distapp	: distds9app
endif

ifdef CVS_SERVER

#--------------------------remote

distds9 : FORCE
	@echo "Creating SAODS9 Distribution"
	cd bin; tar cvf - ds9$(EXE) $(ZIPFILE) | gzip > ../dist/ds9.$(ARCH).$(DS9VERSION).tar.gz
	scp dist/ds9.$(ARCH).$(DS9VERSION).tar.gz $(USER)@$(DEST):build/$(ARCH)/.
	ssh $(USER)@$(DEST) 'cd build/$(ARCH); zcat ds9.$(ARCH).$(DS9VERSION).tar.gz | tar -xvf -'

ifeq ($(OS),windows)
distds9app : ds9winzip
	scp dist/$(DS9APP)\ Install.exe $(USER)@$(DEST):build/$(ARCH)/.
endif

ifeq ($(OS),macosx)
distds9app : ds9dmg
	scp -r dist/$(DS9APP)/SAOImage\ DS9.app $(USER)@$(DEST):build/$(ARCH)/.
	scp dist/$(DS9APP).dmg $(USER)@$(DEST):build/$(ARCH)/.
endif

distxpa : FORCE
	@echo "Creating XPA Distribution"
	cd bin; tar cvf - xpa*$(EXE) |gzip > ../dist/xpa.$(ARCH).$(XPAVERSION).tar.gz
	scp dist/xpa.$(ARCH).$(XPAVERSION).tar.gz $(USER)@$(DEST):build/$(ARCH)/.
	ssh $(USER)@$(DEST) 'cd build/$(ARCH); zcat xpa.$(ARCH).$(XPAVERSION).tar.gz | tar -xvf -'

ifeq ($(OS),windows)
distxpaapp : xpawinzip
	@echo "Creating XPA Distribution"
	scp dist/$(XPAAPP)\ Install.exe $(USER)@$(DEST):build/$(ARCH)/.
endif

distdoc	: doc
	@echo "Creating Documentation Distribution"
	scp -r doc $(USER)@$(DEST):build/.

distsource : FORCE
	@echo "Creating Source Distribution"
	rm -rf dist/saods9
	cd dist; cvs export -Dtoday saods9
	cd dist/saods9; rm -rf notes mods admin
	cd dist; tar cvf - saods9 | gzip > ds9.$(DS9VERSION).tar.gz
	rm -rf dist/saods9
	scp dist/ds9.$(DS9VERSION).tar.gz $(USER)@$(DEST):build/source/.

#--------------------------remote

else

#--------------------------local

distds9 : FORCE
	@echo "Creating SAODS9 Distribution"
	cd bin; tar cvf - ds9$(EXE) $(ZIPFILE) | gzip > ../dist/ds9.$(ARCH).$(DS9VERSION).tar.gz
	cp dist/ds9.$(ARCH).$(DS9VERSION).tar.gz $(HOME)/build/$(ARCH)/.
	cd $(HOME)/build/$(ARCH); $(ZCAT) ds9.$(ARCH).$(DS9VERSION).tar.gz | tar -xvf -
ifeq ($(OS),windows)
distds9app : ds9winzip
	cp dist/ds9.$(ARCH).$(DS9VERSION).exe $(HOME)/build/$(ARCH)/.
endif

ifeq ($(OS),macosx)
distds9app : ds9dmg
	cp -r dist/$(DS9APP)/SAOImage\ DS9.app $(HOME)/build/$(ARCH)/.
	cp dist/$(DS9APP).dmg $(HOME)/build/$(ARCH)/.
endif

distxpa : FORCE
	@echo "Creating XPA Distribution"
	cd bin; tar cvf - xpa*$(EXE) |gzip > ../dist/xpa.$(ARCH).$(XPAVERSION).tar.gz
	cp dist/xpa.$(ARCH).$(XPAVERSION).tar.gz $(HOME)/build/$(ARCH)/.
	cd $(HOME)/build/$(ARCH); $(ZCAT) xpa.$(ARCH).$(XPAVERSION).tar.gz | tar -xvf -
ifeq ($(OS),windows)
distxpaapp : xpawinzip
	cp dist/xpa.$(ARCH).$(XPAVERSION).exe $(HOME)/build/$(ARCH)/.
endif

distdoc	: doc
	@echo "Creating Documentation Distribution"
	cp -r doc $(HOME)/build/.

distsource : FORCE
	@echo "Creating Source Distribution"
	rm -rf dist/saods9
	cd dist; cvs export -Dtoday saods9
	cd dist/saods9; rm -rf notes mods admin
	cd dist; tar cvf - saods9 | gzip > ds9.$(DS9VERSION).tar.gz
	rm -rf dist/saods9
	cp dist/ds9.$(DS9VERSION).tar.gz $(HOME)/build/source/.

#--------------------------local

endif

FORCE	:
