# --------------------------------------------------------------------------- #
# --------------------------------------------------------------------------- #
#									      #
#                 OOO    HH   HH    AAA    NN   NN    AAA		      #
#               OO   OO  HH   HH  AA   AA  NNN  NN  AA   AA		      #
#               OO   OO  HHHHHHH  AAAAAAA  NN N NN  AAAAAAA		      #
#               OO   OO  HH   HH  AA   AA  NN  NNN  AA   AA		      #
#                 OOO    HH   HH  AA   AA  NN   NN  AA   AA		      #
#      								              #
# --------------------------------------------------------------------------- #
# --------------------------------------------------------------------------- #

# This makefile compiles all Ohana package programs in the Elixir
# system, and their libraries.  Most of the components in this
# directory were created for Ohana, but there are a few libraries
# which are from external sources: libjpeg, libpng, zlib, and
# readline.  Extra care should be taken in compiling those libraries. 

# Edit Configure to reflect the location of your installation (or use ./configure)
include Configure

# .SILENT:								       
default: all

# The collection of Ohana programs.  Other components in the src
# directory may be compiled by going to those directories. 
PROGRAM =   \
addrefs     \
addspphot   \
addstar     \
delstar     \
elixir      \
gastro      \
gastro2     \
gcompare    \
gophot      \
imclean     \
imregister  \
kapa        \
kii         \
misc        \
mosastro.v2 \
nightd      \
opihi.v2    \
perl        \
photdbc     \
relphot     \
shell       \
tcl         \
uniphot

# dvo        \
# need to fix up typecode,typename static vars in imregister
# need to be sure the default make is correctly define for every package
# drop shell1 from cvs

SKIP = addusno fixcat getstar getusno lightcurve markrock markstar mosastro.v1 skycalc skyprobe

OLD = mana status 

# Required libraries depends on the architecture
LIBS-linux = libfits libohana libdummy
LIBS-lin64 = libfits libohana libdummy

# general build targets:
libs:
	mkdir -p $(LINC)
	mkdir -p $(LLIB)
	for i in $(LIBS-$(ARCH)); do make $$i.install; done

bins: 
	for i in $(PROGRAM); do make $$i; done

all:
	for i in $(LIBS-$(ARCH)); do make $$i.install || exit; done
	for i in $(PROGRAM); do make $$i || exit; done
	for i in $(EXTRA); do make $$i || exit; done

clean:
	for i in $(LIBS-$(ARCH)); do make $$i.clean || exit; done
	for i in $(PROGRAM); do make $$i.clean || exit; done

dist:
	for i in $(LIBS-$(ARCH)); do make $$i.dist || exit; done
	for i in $(PROGRAM); do make $$i.dist || exit; done

install:
	for i in $(LIBS-$(ARCH)); do make $$i.install || exit; done
	for i in $(PROGRAM); do make $$i.install || exit; done

# standard rules: targets are foo, foo.clean, foo.install, foo.dist
$(PROGRAM) $(LIBS-$(ARCH)): 
	(cd src/$@ && make)

%.install:
	mkdir -p bin/$(ARCH)
	(cd src/$* && make install)

%.clean:
	(cd src/$* && make clean)

%.dist:
	(cd src/$* && make dist)
