#
# @(#)install.gmk	1.136 06/10/30
# 
# Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# 
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun in the LICENSE file that accompanied this code.
# 
# This code 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
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
# 
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
# 
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#

# Install for JavaHelp.
# This is a Solaris GNUmakefile

NAME=jh2.0
#
# needs resolve the hardcoding 
#
REALNAME=javahelp2_0_04
REALNAME-SOLSPARC-12=$(REALNAME)-solsparc
REALNAME-WIN32-12=$(REALNAME)-win
DJH=../$(NAME)

ifeq ($(UNZIPSFX),)
UNZIPSFX=/usr/green/bin/unzipsfx.sparc
endif

ifeq ($(JHUGDIR),)
JHUGDIR=../doc/jhug
endif
JHUG=jhug.pdf

Dlib=$(DJH)/javahelp/lib
Ddtd=$(Dlib)/dtd
Dbin=$(DJH)/javahelp/bin

LIBS=\
	$(Dlib)/jh.jar \
	$(Dlib)/jhall.jar \
	$(Dlib)/jhbasic.jar \
	$(Dlib)/jsearch.jar

DTDS=\
	$(Ddtd)/helpset_2_0.dtd \
	$(Ddtd)/favorites_2_0.dtd \
	$(Ddtd)/map_2_0.dtd \
	$(Ddtd)/toc_2_0.dtd \
	$(Ddtd)/index_2_0.dtd

Ddemos=$(DJH)/demos/bin $(DJH)/demos/hsjar \
       $(DJH)/demos/lib $(DJH)/demos/hs \
       $(DJH)/demos/browser $(DJH)/demos/serverhelp

Ddemosrc=$(DJH)/demos/src/sunw/demo/jhdemo \
	 $(DJH)/demos/src/sunw/demo/idedemo \
         $(DJH)/demos/src/sunw/demo/classviewer \
         $(DJH)/demos/src/sunw/demo/classviewer/plaf/basic \
         $(DJH)/demos/src/sunw/demo/classviewer/plaf/metal \
         $(DJH)/demos/src/sunw/demo/classviewer/plaf/motif \
         $(DJH)/demos/src/sunw/demo/classviewer/plaf/windows \
         $(DJH)/demos/src/sunw/demo/searchdemo \
         $(DJH)/demos/src/sunw/demo/merge \
         $(DJH)/demos/src/sunw/demo/newmerge \
         $(DJH)/demos/src/sunw/demo/browser
	
Dimplsrc=com/sun/java/help/impl/JHSecondaryViewer.java \
	 com/sun/java/help/impl/JHSecondaryViewerBeanInfo.java \
	 com/sun/java/help/impl/ViewAwareComponent.java
	
DDOC=$(DJH)/doc

Ddocs=$(DDOC)/jhug $(DDOC)/jhug/overview $(DDOC)/jhug/author \
      $(DDOC)/jhug/images $(DDOC)/jhug/images/overview \
      $(DDOC)/api $(DDOC)/css

Ddocimages=$(DDOC)/images

Dspecs=$(DDOC)/spec

Djre=$(DJH)/jre

ifeq ($(JRE_WIN32_12_HOME),)
JRE_WIN32_12_HOME=/java/javahelp/jres/jre-win32-12
endif

ifeq ($(JRE_SOLSPARC_12_HOME),)
JRE_SOLSPARC_12_HOME=/java/javahelp/jres/jre-solsparc-12
endif

DSRC=$(DJH)/src


DD=../demos
JD=../javahelp
DOCD=../doc
SRCD=../src
TOP=..

CP=/bin/cp -p -f
RM=/bin/rm -f
TAR=/usr/sbin/tar
MV=/bin/mv -f
JAR=jar

CPDIR=/bin/cp -pr -f

# Instructions to build packages
#
# To build .zip & 1.2 packages
#
# [0] gnumake -f install.gmk clean (remove the release directory)
# [1] gnumake -f install.gmk common package-zip (small release)
#


all:
	echo "read the instructions"

common: misc libs bins spec docs helpset demo demosrc source

update: updatemisc jars source

#
# Create the packages
#

package-updatezip:
	cd .. ; $(RM) $(REALNAME)update.zip ; \
	zip -r $(REALNAME)update.zip $(NAME)

package-zip:
	cd .. ; $(RM) $(REALNAME).zip ; \
	zip -r $(REALNAME).zip $(NAME) -x $(NAME)/apiviewer $(NAME)/apiviewer.bat $(NAME)/hsviewer $(NAME)/hsviewer.bat $(NAME)/README_SOLSPARC $(NAME)/README_WIN32

#
# Miscellaneous information
#
misc: $(DJH)
	$(CP) $(TOP)/LICENSE.html $(DJH)/LICENSE.html
	$(CP) $(TOP)/README $(DJH)/
	$(CP) $(TOP)/README.html $(DJH)/


#
# Miscellaneous information
#
updatemisc: $(DJH)
	$(CP) $(TOP)/LICENSE.html $(DJH)/LICENSE.html

#
# the JavaHelp libraries
#

libs: jars $(Ddtd) $(DTDS)

$(Ddtd)/%.dtd: $(DOCD)/public-spec/dtd/%.dtd
	$(CP) $< $@

jars: $(Dlib) $(LIBS)

$(Dlib)/%.jar: $(JD)/lib/%.jar
	$(CP) $< $@

#
# predefined commands
#

bins: $(Dbin)
	$(CP) $(JD)/bin/jhindexer $(Dbin)/jhindexer
	chmod ugo+x $(Dbin)/jhindexer
	$(CP) $(JD)/bin/jhindexer.bat $(Dbin)/jhindexer.bat
	$(CP) $(JD)/bin/jhindexer.jar $(Dbin)/jhindexer.jar

	$(CP) $(JD)/bin/jhsearch $(Dbin)/jhsearch
	chmod ugo+x $(Dbin)/jhsearch
	$(CP) $(JD)/bin/jhsearch.bat $(Dbin)/jhsearch.bat
	$(CP) $(JD)/bin/jhsearch.jar $(Dbin)/jhsearch.jar


#
# JavaHelp Specification 
#
spec: $(Dspecs) docimages
	mkdir -p $(DDOC)/spec
	cp $(DOCD)/public-spec/V2.0/JavaHelp_V2_0_Specification.pdf $(DDOC)/spec

#
# Generic Documentation
#
docs: $(Ddocs) docimages $(JHUGDIR)/$(JHUG)
	cd $(DOCD) ; \
	$(TAR) cFFf - jhug | (cd $(DDOC) ; $(TAR) xf - )
	$(MV) $(DDOC)/jhug/$(JHUG) $(DDOC)/$(JHUG)
	$(CPDIR) $(DOCD)/api/* $(DDOC)/api/
	$(CP) $(DOCD)/css/default.css $(DDOC)/css/default.css

docimages: $(Ddocimages)
	cd $(DOCD) ; \
	$(TAR) cFFf - images | (cd $(DDOC) ; $(TAR) xf - )

#
# HelpSets
#

helpset: $(Ddemos)
	$(CP) $(DD)/hsjar/holidays.jar $(DJH)/demos/hsjar/holidays.jar
	$(CP) $(DD)/hsjar/apidoc.jar $(DJH)/demos/hsjar/apidoc.jar
	$(CP) $(DD)/hsjar/idehelp.jar $(DJH)/demos/hsjar/idehelp.jar
	$(CP) $(DD)/hsjar/object.jar $(DJH)/demos/hsjar/object.jar
	$(CP) $(DD)/hsjar/animals.jar $(DJH)/demos/hsjar/animals.jar
	$(CP) $(DD)/hsjar/vertebrates.jar $(DJH)/demos/hsjar/vertebrates.jar
	$(CP) $(DD)/hsjar/invertebrates.jar $(DJH)/demos/hsjar/invertebrates.jar
	$(CP) $(DD)/hsjar/idehelp_de.jar $(DJH)/demos/hsjar/idehelp_de.jar
	$(CP) $(DD)/hsjar/idehelp_en.jar $(DJH)/demos/hsjar/idehelp_en.jar
	$(CP) $(DD)/hsjar/idehelp_ja.jar $(DJH)/demos/hsjar/idehelp_ja.jar
	mkdir -p $(DJH)/demos/hs ; \
	( cd $(DD)/hs ; echo merge/GNUmakefile > exclude.tmp ) ; \
	( cd $(DD)/hs ; $(TAR) cFFXf exclude.tmp - merge ) | (cd $(DJH)/demos/hs ; $(TAR) xf - ) ; \
	rm $(DD)/hs/exclude.tmp
	mkdir -p $(DJH)/demos/hs ; \
	( cd $(DD)/hs ; echo newmerge/GNUmakefile > exclude.tmp ) ; \
	( cd $(DD)/hs ; $(TAR) cFFXf exclude.tmp - newmerge ) | (cd $(DJH)/demos/hs ; $(TAR) xf - ) ; \
	rm $(DD)/hs/exclude.tmp
	cd $(DJH)/demos/hs ; find . -name "META-INF" -exec /bin/rm -rf {} \;

#
# Demos
#

demo: $(Ddemos)
	$(CP) $(DD)/jhdemo/hsviewer.jar $(DJH)/demos/bin
	$(CP) $(DD)/idedemo/idedemo.jar $(DJH)/demos/bin
	$(CP) $(DD)/bin/UserGuide.jar $(DJH)/demos/bin
	$(CP) $(DD)/bin/object.jar $(DJH)/demos/bin
	$(CP) $(DD)/bin/apiviewer.jar $(DJH)/demos/bin
	$(CP) $(DD)/merge/merge.jar $(DJH)/demos/bin
	$(CP) $(DD)/newmerge/newmerge.jar $(DJH)/demos/bin

	$(CP) $(DD)/lib/classviewer.jar $(DJH)/demos/lib/classviewer.jar
	$(CP) $(DD)/lib/searchdemo.jar $(DJH)/demos/lib/searchdemo.jar
	$(CP) $(DD)/lib/browserdemo.jar $(DJH)/demos/browser/browserdemo.jar \

	$(CP) $(DD)/newbrowser/*.html $(DJH)/demos/browser/
	$(CP) $(DD)/newbrowser/demo_instructions $(DJH)/demos/browser/
	cd $(DD)/serverhelp ; \
	$(TAR) cFFf - . | (cd ../$(DJH)/demos/serverhelp ; $(TAR) xf - )

#
# Demo sources
#

demosrc: $(Ddemosrc) 
	$(CP) $(DD)/jhdemo/sunw/demo/jhdemo/Runner.java $(DJH)/demos/src/sunw/demo/jhdemo/
	$(CP) $(DD)/jhdemo/sunw/demo/jhdemo/JHLauncher.java $(DJH)/demos/src/sunw/demo/jhdemo/
	$(CP) $(DD)/jhdemo/sunw/demo/jhdemo/ElementTreePanel.java $(DJH)/demos/src/sunw/demo/jhdemo/
	$(CP) $(DD)/README.install $(DJH)/demos/README
	$(CP) $(DD)/idedemo/sunw/demo/idedemo/ApiDemo.java $(DJH)/demos/src/sunw/demo/idedemo/
	$(CP) $(DD)/idedemo/sunw/demo/idedemo/IdeDemo.properties $(DJH)/demos/src/sunw/demo/idedemo/
	here=`pwd` ; \
	  cd  $(DJH)/demos/src/sunw/demo/idedemo ; \
	  $(JAR) -xf $$here/$(DD)/idedemo/images.jar
	$(CP) $(DD)/searchdemo/sunw/demo/searchdemo/ClientSearchEngine.java $(DJH)/demos/src/sunw/demo/searchdemo/
	$(CP) $(DD)/searchdemo/sunw/demo/searchdemo/ClientSearchQuery.java $(DJH)/demos/src/sunw/demo/searchdemo/
	$(CP) $(DD)/apidoc/sunw/demo/classviewer/ClassViewerView.java $(DJH)/demos/src/sunw/demo/classviewer/
	$(CP) $(DD)/apidoc/sunw/demo/classviewer/ClassViewerNavigator.java $(DJH)/demos/src/sunw/demo/classviewer/
	$(CP) $(DD)/apidoc/sunw/demo/classviewer/plaf/basic/BasicClassViewerNavigatorUI.java $(DJH)/demos/src/sunw/demo/classviewer/plaf/basic/
	$(CP) $(DD)/apidoc/sunw/demo/classviewer/plaf/metal/MetalClassViewerNavigatorUI.java $(DJH)/demos/src/sunw/demo/classviewer/plaf/metal/
	$(CP) $(DD)/apidoc/sunw/demo/classviewer/plaf/motif/MotifClassViewerNavigatorUI.java $(DJH)/demos/src/sunw/demo/classviewer/plaf/motif/
	$(CP) $(DD)/apidoc/sunw/demo/classviewer/plaf/windows/WindowsClassViewerNavigatorUI.java $(DJH)/demos/src/sunw/demo/classviewer/plaf/windows/
	$(CP) $(DD)/merge/sunw/demo/merge/Merge.java $(DJH)/demos/src/sunw/demo/merge/
	$(CP) $(DD)/newmerge/sunw/demo/newmerge/Merge.java $(DJH)/demos/src/sunw/demo/newmerge/
	$(CP) $(DD)/newmerge/sunw/demo/newmerge/HSFilter.java $(DJH)/demos/src/sunw/demo/newmerge/
	$(CP) $(DD)/newmerge/sunw/demo/newmerge/JarAccessory.java $(DJH)/demos/src/sunw/demo/newmerge/
	$(CP) $(DD)/newbrowser/sunw/demo/browser/HelpButton.java $(DJH)/demos/src/sunw/demo/browser/

#
# source
#
source:
	mkdir -p $(DSRC)
	rm -rf $(DSRC)/*
	cd $(SRCD)/new ; \
	$(TAR) cFFf - . | (cd ../$(DSRC) ; $(TAR) xf - )
	cd $(SRCD)/impl; \
	$(TAR) cf - $(Dimplsrc) | (cd ../$(DSRC) ; $(TAR) xf - )
	cd $(DSRC); cd .. ;jar -cMvf $(DJH)/src.jar src
	rm -rf $(DSRC);

#
# Directory creation
#
$(DJH) $(Ddemos) $(Ddemosrc) $(Dlib) $(Ddtd) $(Dbin) $(Djre) $(Ddocs) $(Ddocimages) $(Dspecs):
	mkdir -p $@

#
# Cleanup
#
clean:
	rm -rf $(DJH)/*

clean-jre:
	rm -rf $(DJH)/jre
