###############################################################################
##
##  Makefile:  psLib
##
##  $Revision: 1.17 $  $Name: not supported by cvs2svn $
##  $Date: 2004-07-29 21:55:44 $
##
##  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
##
###############################################################################

# Define variable prefix to the top level project - psLib
# This is necessary for definition in Makefile.Globals

ifndef prefix
    export prefix=$(shell cd ..;pwd)
endif

# Include the make global definitions for the project

include Makefile.Globals

# Detect and save the CVS for this makefile

NAME:= "$Name: not supported by cvs2svn $ "
ifeq ($(NAME), "ame:  $ ")
   VERSION:= ": Project Version: Unknown "
else
   VERSION:= ": Project Version: $(NAME) "
endif

# Define the target to build

ALLTARGETS = sysUtils collections image dataManip astronomy

TARGET_DYNAMIC = libpslib.$(DLL)
TARGET_STATIC = libpslib.a

# Define the installation targets

INSTALLTARGETS = installSysUtils installCollections installImage installDataManip installAstronomy

# Define the clean up targets

CLEANTARGETS = cleanSysUtils cleanCollections cleanImage cleanDataManip cleanAstronomy

CLEANDEPTARGETS = cleandepSysUtils cleandepCollections cleandepImage cleandepDataManip cleandepAstronomy

# Define the distribution clean up targets

DISTCLEANTARGETS = distcleanSysUtils distcleanCollections distcleanImage distcleanDataManip distcleanAstronomy

# Define PHONY target "all" which will make all necessary items

all:	$(ALLTARGETS)
	$(BUILD_DYNAMIC1) $(TARGET_STATIC) $(BUILD_DYNAMIC2) $(TARGET_DYNAMIC)
	@echo ""
	@echo "    ---- All targets built successfully $(VERSION) ----"
	@echo ""

# Define PHONY target "sysUtils" which will make the system utilites
# portion of the psLib

sysUtils:
	$(MAKE) --directory=sysUtils all

image:
	$(MAKE) --directory=image all

collections:
	$(MAKE) --directory=collections all

dataManip:
	$(MAKE) --directory=dataManip all

astronomy:
	$(MAKE) --directory=astronomy all

## ADD ADDITIONAL PORTIONS OF PSLIB HERE

# Define PHONY target "installSysUtils" which will install all the necessary
# files for system utilities portion of psLib

installSysUtils:
	$(MAKE) --directory=sysUtils install

installImage:
	$(MAKE) --directory=image install

installCollections:
	$(MAKE) --directory=collections install

installDataManip:
	$(MAKE) --directory=dataManip install

installAstronomy:
	$(MAKE) --directory=astronomy install

# Define PHONY target "cleanSysUtils" which will clean up the development
# area for system utilites

cleanSysUtils:
	$(MAKE) --directory=sysUtils clean

cleanImage:
	$(MAKE) --directory=image clean

cleanCollections:
	$(MAKE) --directory=collections clean

cleanDataManip:
	$(MAKE) --directory=dataManip clean

cleanAstronomy:
	$(MAKE) --directory=astronomy clean

#Define PHONY target "cleandep*" which will clean up the dependency files

cleandepSysUtils:
	$(MAKE) --directory=sysUtils cleandep

cleandepImage:
	$(MAKE) --directory=image cleandep

cleandepCollections:
	$(MAKE) --directory=collections cleandep

cleandepDataManip:
	$(MAKE) --directory=dataManip cleandep

cleandepAstronomy:
	$(MAKE) --directory=astronomy cleandep

# Define PHONY target "distcleanSysUtils which will clean up the distribution
# files related to system utilities

distcleanSysUtils:
	$(MAKE) --directory=sysUtils distclean
        
distcleanImage:
	$(MAKE) --directory=image distclean
        
distcleanCollections:
	$(MAKE) --directory=collections distclean

distcleanDataManip:
	$(MAKE) --directory=dataManip distclean

distcleanAstronomy:
	$(MAKE) --directory=astronomy distclean


# Rule to make include directory if needed

$(includedir):
	mkdir -p $(includedir)

# Rule to make bin directory if needed

$(bindir):
	mkdir -p $(bindir)

# Rule to make lib directory if needed

$(libexecdir):
	mkdir -p $(libexecdir)

# Rule to make man directory if needed
       
$(mandir): 
	mkdir -p $(mandir)
        
$(mandir)/man3: $(mandir)
	mkdir -p $(mandir)/man3

# Rule to make the installation directories if needed

installdirs: $(includedir) $(bindir) $(libexecdir) $(mandir)

# Define PHONY target "install" to make the necessary directories for
# the installation

install: all installdirs $(INSTALLTARGETS)
	install *.h $(includedir)
	install $(TARGET_STATIC) $(libexecdir)
	install $(TARGET_DYNAMIC) $(libexecdir)

# Define PHONY target "clean" to clean up the development areas for
# psLib

clean: $(CLEANTARGETS)
	$(RM) -f $(TARGET_STATIC)
	$(RM) -f $(TARGET_DYNAMIC)

cleandep: $(CLEANDEPTARGETS)

# Define PHONY target "distclean" to clean up the distribution area for
# psLib

distclean: $(DISTCLEANTARGETS)
	$(RM) -f $(libexecdir)/$(TARGET_STATIC)
	$(RM) -f $(libexecdir)/$(TARGET_DYNAMIC)
	$(RM) -f $(TARGET_DYNAMIC)
	$(RM) -f $(TARGET_STATIC)

# Define PHONY target "docs" to generate the Doxygen files for psLib
        
docs:
	$(DOCS)

tags:	
	cd $(IPPROOT) ; etags `find . \( -name \*.[chy] -o -name \*.cpp \) -print`

# List of PHONY targets with make file
.PHONY:  sysUtils collections image dataManip astronomy
