# BEGIN COPYRIGHT BLOCK
# Copyright (C) 2001 Sun Microsystems, Inc.  Used by permission.
# Copyright (C) 2005 Red Hat, Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#

# END COPYRIGHT BLOCK
#
# Makefile to Create packages for UNIX-based specific product
#
# By Whom		Date		History			
# Phong Vo
#

BUILD_ROOT=..
override BUILD_MODULE=SETUP_MCC

include $(BUILD_ROOT)/nsconfig.mk

BUILT_DIR=$(PLATFORM_OBJDIR)
PKGTOP=$(PLATFORM_PACKAGE_DIR)

#
MCC_TOP=$(BUILD_ROOT)/built

# built/mcc
MCC_DIR=$(BUILD_SECURITY)/$(DIR)
MCC_DEST=$(MCC_TOP)/$(MCC_DIR)

# built/mcc/dist
DIST_DIR=$(MCC_DEST)/dist

# built/mcc/dist/SOLARIS, AIX, etc.
OS_DIST_DIR = $(DIST_DIR)/$(NSPLATFORM_DIR)
EXTRA_ARCH  = Other-UNIX
EXTRA_DIST_DIR = $(DIST_DIR)/$(EXTRA_ARCH)

# OS available for MCCs
MCC_OS = SOLARIS OSF1 IRIX AIX HPUX Linux

CHMOD=chmod
CPIO=cpio -pdum$(VERBOSE)
MV=mv
MKDIR=mkdir -p


all:
ifeq ($(DEBUG), optimize)
	rm -rf $(OS_DIST_DIR)
	rm -rf $(EXTRA_DIST_DIR)

ifneq ($(ARCH), WINNT)
	$(MKDIR) $(OS_DIST_DIR)
else
	$(MKDIR) $(DIST_DIR)/WINDOWS
endif

ifeq  ($(ARCH), SOLARIS)
	$(MKDIR) $(EXTRA_DIST_DIR)
endif

ifneq ($(ARCH), WINNT)
	# Combine the client zip files from base and admin
	cd $(PKGTOP)/base/unzipped/client; \
	    tar cvf ../../../../../$(MCC_DIR)/dist/$(NSPLATFORM_DIR)/uxmcc.tar *

	cd $(PKGTOP)/admin/unzipped/admin/; \
            tar rvf ../../../../../$(MCC_DIR)/dist/$(NSPLATFORM_DIR)/uxmcc.tar java

	cd $(MCC_DEST)/dist/$(NSPLATFORM_DIR) ; gzip uxmcc.tar

	$(PERL) fixPI.pl SETUP_MCC ../include/version.h ../$(BUILD_ARCH)/buildnum.dat $(BUILD_SECURITY) mcc.inf $(MCC_DEST)/mcc.inf

else
	cd $(BUILD_ROOT)/mcc/nt; $(MAKE) BUILD_MODULE=SETUP_MCC $(MFLAGS)
	$(PERL) fixPI.pl SETUP_MCC ../include/version.h ../$(BUILD_ARCH)/buildnum.dat $(BUILD_SECURITY) mcc.inf $(MCC_DEST)/mcc.inf

endif

endif

# Built the final destribution package
# This has to be done by release engineer when ALL platforms builds
# have been completed
package:
	cd $(MCC_DEST) ; $(ZIP) -r0 nsmcc.zip dist
	rm -rf $(MCC_DEST)/dist
	$(MKDIR) $(PKGTOP)/bin/setup/mcc
	+$(LOOP_OVER_DIRS)

LOOP_OVER_DIRS          =               			\
	@for DEST_DIR in $(MCC_OS); do                 \
        done
#	cp -r $(MCC_DEST) $(PKGTOP); \
