###############################################################################
##
##  Makefile:  psLib
##
##  $Revision: 1.19.2.1 $  $Name: not supported by cvs2svn $
##  $Date: 2005-01-19 02:17:04 $
##
##  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 fileUtils

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

# Define the installation targets

INSTALLTARGETS = installSysUtils installCollections installImage installDataManip installAstronomy installFileUtils

# Define the clean up targets

CLEANTARGETS = cleanSysUtils cleanCollections cleanImage cleanDataManip cleanAstronomy cleanFileUtils

CLEANDEPTARGETS = cleandepSysUtils cleandepCollections cleandepImage cleandepDataManip cleandepAstronomy cleandepFileUtils

# Define the distribution clean up targets

DISTCLEANTARGETS = distcleanSysUtils distcleanCollections distcleanImage distcleanDataManip distcleanAstronomy distcleanFileUtils

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

all:	$(ALLTARGETS)
	sed 's|PREFIX|$(prefix)|' $(TIME_CONFIG_FILE).template > $(TIME_CONFIG_FILE)
	$(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

fileUtils:
	$(MAKE) --directory=fileUtils 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

installFileUtils:
	$(MAKE) --directory=fileUtils 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

cleanFileUtils:
	$(MAKE) --directory=fileUtils 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

cleandepFileUtils:
	$(MAKE) --directory=fileUtils 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

distcleanFileUtils:
	$(MAKE) --directory=fileUtils 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)
	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:
	etags `find . \( -name \*.[chy] \) -print`

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