default: install
help:
	@echo "make options: install libskycalc all programs clean dist"

include ../../Makefile.System
HOME	=	$(ROOT)/src/skycalc
BIN	= 	$(HOME)/bin
LIB	=	$(HOME)/lib
SRC	=	$(HOME)/src
MAN	= 	$(HOME)/doc
INC	=	$(HOME)/include
include ../../Makefile.Common

# programs may add their own internal requirements here
FULL_CFLAGS   = $(BASE_CFLAGS) -fPIC
FULL_CPPFLAGS = $(BASE_CPPFLAGS)
FULL_LDFLAGS  = $(BASE_LDFLAGS) -lskycalc -lohana

install: $(DESTINC)/skycalc.h $(DESTLIB)/libskycalc.a
libskycalc: $(DESTLIB)/libskycalc.a $(DESTLIB)/libskycalc.$(DLLTYPE)

all: libskycalc dusktime moondata sundata
programs: all

INCS = $(DESTINC)/skycalc.h

MYINCS = $(INCS) $(INC)/skycalc_internal.h

OBJS = 	\
$(SRC)/time.$(ARCH).o     \
$(SRC)/geometry.$(ARCH).o \
$(SRC)/astro.$(ARCH).o    \
$(SRC)/sun.$(ARCH).o      \
$(SRC)/moon.$(ARCH).o

$(OBJS): $(MYINCS)

$(LIB)/libskycalc.$(ARCH).a: $(OBJS)
$(LIB)/libskycalc.$(ARCH).$(DLLTYPE): $(OBJS)

$(DESTLIB)/libskycalc.a:  $(LIB)/libskycalc.$(ARCH).a
$(DESTLIB)/libskycalc.$(DLLTYPE): $(LIB)/libskycalc.$(ARCH).$(DLLTYPE)

dusktime : $(BIN)/dusktime.$(ARCH)
moondata : $(BIN)/moondata.$(ARCH)
sundata  : $(BIN)/sundata.$(ARCH)
sunmoon  : $(BIN)/sunmoon.$(ARCH)

DUSKTIME = $(SRC)/dusktime.$(ARCH).o
MOONDATA = $(SRC)/moondata.$(ARCH).o
SUNDATA  = $(SRC)/sundata.$(ARCH).o
SUNMOON  = $(SRC)/sunmoon.$(ARCH).o

$(DUSKTIME) : $(MYINCS)
$(MOONDATA) : $(MYINCS)
$(SUNDATA)  : $(MYINCS)
$(SUNMOON)  : $(MYINCS)

$(BIN)/dusktime.$(ARCH) : $(DUSKTIME)
$(BIN)/moondata.$(ARCH) : $(MOONDATA)
$(BIN)/sundata.$(ARCH)  : $(SUNDATA)
$(BIN)/sunmoon.$(ARCH)  : $(SUNMOON)

INSTALL = dusktime moondata sundata sunmoon

# dependancy rules for binary code #########################
$(INSTALL): % : $(BIN)/%.$(ARCH)

%.clean :
	rm -f $(BIN)/$*.$(ARCH)

%.install:
	make $(DESTBIN)/$*

install:
	for i in $(INSTALL); do make $$i.install || exit; done
