#
# Copyright 1999-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.
#

#
# Makefile for building the Java Sound demo
#

BUILDDIR = ../..
DEMOS    = JavaSound

# identify this as a demo/sound product - used to identify a
# unique name for OBJDIR
PRODUCT = demo/sound

include $(BUILDDIR)/common/Defs.gmk

#
# What do we compile?
#
DEMODST  = $(DEMODIR)/sound
DEMOSRC  = $(SHARE_SRC)/demo/sound
include FILES.gmk


#
# Activate some hooks so Classes.gmk looks elsewhere for sources, and
# dumps classes where we want.
#
SOURCEPATH              = $(DEMOSRC)

# use "simple expansion" (GNU Make 6.2) for setting BOOTCLASSPATH 
# because CLASSBINDIR is changed a few lines down:
BOOTCLASSPATH           := $(CLASSBINDIR)

DEMOJAR			= $(DEMODST)/JavaSound.jar
ALT_CLASSES_DISPOSITION = src $(DEMOJAR) docs
ALT_CLASSBINDIR         = $(TEMPDIR)/class
CLASSDESTDIR            = $(ALT_CLASSBINDIR)
CLASSBINDIR             = $(ALT_CLASSBINDIR)

#
# Rules.
#
include $(BUILDDIR)/common/Classes.gmk

build: src $(DEMOJAR) docs

#
# Sources.
#
SRCSRC = $(DEMOSRC)
SRCDST = $(DEMODST)/src
FILES_src = $(FILES_java:%.java=$(SRCDST)/%.java)

src: $(FILES_src)

$(SRCDST)/Runner.java:
	@$(ECHO) Skipping Runner.java

$(SRCDST)/%.java: $(SRCSRC)/%.java
	$(install-file)

#
# Docs.
#
docs: $(DEMODST)/README.txt $(DEMODST)/JavaSound.html

$(DEMODST)/README.txt: $(DEMOSRC)/README.txt
	$(install-file)

$(DEMODST)/JavaSound.html: $(DEMOSRC)/JavaSound.html
	$(install-file)

#
# Jar file.
#
jar: $(DEMODST)/JavaSound.jar

$(DEMODST)/JavaSound.jar: $(FILES_class) $(FILES_java:%.java=$(DEMOSRC)/%.java)
		$(ECHO) Main-Class: JavaSound > $(TEMPDIR)/manifest
		$(JAR) -cvfm $@ $(TEMPDIR)/manifest -C $(TEMPDIR)/class .  \
		     $(JAR_JFLAGS)
		$(RM) $(TEMPDIR)/manifest
		@$(java-vm-cleanup)

