6887710: Jar index should avoid putting META-INF in the INDEX.LIST
Reviewed-by: michaelm
## Copyright (c) 2004, 2010, Oracle and/or its affiliates. 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. Oracle designates this# particular file as subject to the "Classpath" exception as provided# by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA# or visit www.oracle.com if you need additional information or have any# questions.## JDK Demo building jar file.MODULE = demos# Some names are defined with LIBRARY inside the Defs.gmk fileLIBRARY=$(DEMONAME)OBJDIR=$(TEMPDIR)/$(DEMONAME)# Input:# DEMONAME - name of the demo# DEMO_ROOT - path to root of all demo files# DEMO_DESTDIR - path to final demo destination directory## Optional Input:# DEMO_SRCDIR - path to source if different from DEMO_ROOT# DEMO_PSRCDIR - path to additional platform specific source# DEMO_PKGDIR - sub directory of sources we want# DEMO_TOPFILES - names of top-level files relative to DEMO_ROOT# DEMO_MAINCLASS - name of the main class for the jar manifest# DEMO_NATIVECLASS - name of the class with native methods# DEMO_DESCRIPTOR - name of service file for jar (relative to DEMO_SRCDIR)# DEMO_EXTRA_SRCDIR - path to directory that holds extra sources to add# DEMO_EXTRA_FILES - extra sources relative to DEMO_EXTRA_SRCDIR# DEMO_OBJECTS - extra native object files needed# DEMO_MANIFEST_ATTR - extra line to add to the jar manifest file# Assume the source directory is the root directory if not setifndef DEMO_SRCDIR DEMO_SRCDIR = $(DEMO_ROOT)endififndef DEMO_PKGDIR DEMO_PKGDIR = .endif# Some demos have special needsifneq ($(DEMONAME),agent_util) DEMO_NEEDS_AGENT_UTIL = $(findstring agent_util,$(DEMO_OBJECTS))endififneq ($(DEMONAME),java_crw_demo) DEMO_NEEDS_JAVA_CRW_DEMO = $(findstring java_crw_demo,$(DEMO_OBJECTS))endififeq ($(DEMONAME),hprof) DEMO_NEEDS_NPT = trueendif# Place to hold the build area (kind of a temp area)DEMO_BUILD_AREA = $(DEMOCLASSDIR)/$(PRODUCT)/$(DEMONAME)# Destination "src" directoryDEMO_BUILD_SRCDIR = $(DEMO_BUILD_AREA)/srcDEMO_BUILD_SRCZIP = $(DEMO_BUILD_AREA)/src.zipDEMO_SOURCE_ZIP = $(DEMO_DESTDIR)/src.zip# Place to hold the jar image we are creatingDEMO_JAR_IMAGE = $(DEMO_BUILD_AREA)/jar_image# The jar manifest file we will create and useDEMO_MANIFEST = $(DEMO_BUILD_AREA)/manifest.mf# The list of source files or options we will supply to javacDEMO_JAVAC_INPUT = $(DEMO_BUILD_AREA)/javac_input.txt# Any name of javah fileDEMO_JAVAH_FILE = $(DEMO_NATIVECLASS:%=$(DEMO_BUILD_SRCDIR)/%.h)# Get complete list of files for this demoifdef DEMO_PSRCDIR DEMO_ALL_FILES2 := $(shell ( $(CD) $(DEMO_PSRCDIR) \ && $(FIND) $(DEMO_PKGDIR) $(SCM_DIRS_prune) -o -type f -print ) \ | $(SED) 's@^\./@@' ) DEMO_ALL_FILES += $(DEMO_ALL_FILES2)endififdef DEMO_EXTRA_SRCDIR DEMO_ALL_FILES += $(DEMO_EXTRA_FILES)endifDEMO_ALL_FILES1 := $(shell ( $(CD) $(DEMO_SRCDIR) \ && $(FIND) $(DEMO_PKGDIR) $(SCM_DIRS_prune) -o -type f -print ) \ | $(SED) 's@^\./@@' )DEMO_ALL_FILES += $(DEMO_ALL_FILES1)# Just the java sourcesDEMO_JAVA_SOURCES = $(filter %.java,$(DEMO_ALL_FILES))# Just the C and C++ sourcesDEMO_C_SRC_FILES = $(filter %.c,$(DEMO_ALL_FILES))DEMO_CPP_SRC_FILES = $(filter %.cpp,$(DEMO_ALL_FILES))# All the native source filesDEMO_ALL_NATIVE_SOURCES = $(DEMO_C_SRC_FILES)DEMO_ALL_NATIVE_SOURCES += $(DEMO_CPP_SRC_FILES)DEMO_ALL_NATIVE_SOURCES += $(filter %.h,$(DEMO_ALL_FILES))DEMO_ALL_NATIVE_SOURCES += $(filter %.hpp,$(DEMO_ALL_FILES))# If we have java sources, then define the jar file we will createifneq ($(strip $(DEMO_JAVA_SOURCES)),) DEMO_JAR = $(DEMO_DESTDIR)/$(DEMONAME).jarendif# If we have native sources, define the native library we will createifneq ($(strip $(DEMO_ALL_NATIVE_SOURCES)),) # Path to native library we will create DEMO_LIBRARY = \ $(DEMO_DESTDIR)/lib$(ISA_DIR)/$(LIB_PREFIX)$(DEMONAME).$(LIBRARY_SUFFIX) # C and C++ compiler flags we need to add to standard flags DEMO_CPPFLAGS += -I$(DEMO_BUILD_SRCDIR) # If the npt library is used we need to find the npt.h file ifneq ($(DEMO_NEEDS_NPT),) # The npt library is delivered as part of the JRE DEMO_CPPFLAGS += -I$(SHARE_SRC)/npt -I$(PLATFORM_SRC)/npt endif # Is the shared agent_util code needed ifneq ($(DEMO_NEEDS_AGENT_UTIL),) DEMO_FULL_SOURCES += $(DEMO_BUILD_SRCDIR)/agent_util.c DEMO_FULL_SOURCES += $(DEMO_BUILD_SRCDIR)/agent_util.h endif # Is the shared java_crw_demo code needed ifneq ($(DEMO_NEEDS_JAVA_CRW_DEMO),) DEMO_FULL_SOURCES += $(DEMO_BUILD_SRCDIR)/java_crw_demo.c DEMO_FULL_SOURCES += $(DEMO_BUILD_SRCDIR)/java_crw_demo.h endif # All the native object files we need to build the library DEMO_OBJECTS += $(DEMO_C_SRC_FILES:%.c=%.$(OBJECT_SUFFIX)) \ $(DEMO_CPP_SRC_FILES:%.cpp=%.$(OBJECT_SUFFIX)) # Linking is special depending on whether we had C++ code or on windows DEMO_NEEDS_CPP = $(strip $(DEMO_CPP_SRC_FILES)) CPPFLAGS += $(DEMO_CPPFLAGS) ifeq ($(PLATFORM),windows) # Note: This is a link with cl.exe, not link.exe, options differ quite # bit between them. LINK.demo = $(LINK.c) LDLIBS.demo = $(EXTRA_LIBS) $(LFLAGS_$(COMPILER_VERSION)) else ifneq ($(DEMO_NEEDS_CPP),) LINK.demo = $(LINK.cpp) LDLIBS.demo = $(LIBCXX) ifeq ($(PLATFORM),solaris) LDLIBS.demo += -lc endif else LINK.demo = $(LINK.c) LDLIBS.demo = $(LDLIBS) endif endifendif# Files that are considered resources (need to be in the jar file)DEMO_RESOURCES += $(filter-out %.java,$(DEMO_ALL_FILES))# All destination files (top level readme files and all sources)# Note: We exclude the topfiles from the src tree.DEMO_DEST_TOPFILES = $(DEMO_TOPFILES:%=$(DEMO_DESTDIR)/%)DEMO_FILTERED_SOURCES = $(filter-out $(DEMO_TOPFILES),$(DEMO_ALL_FILES))DEMO_FULL_SOURCES += $(DEMO_FILTERED_SOURCES:%=$(DEMO_BUILD_SRCDIR)/%)# Default ruleall: build demo_info# Used to populate the destination directories$(DEMO_DESTDIR)/%: $(DEMO_ROOT)/% $(install-file)ifneq ($(DEMO_SRCDIR),$(DEMO_ROOT))$(DEMO_DESTDIR)/%: $(DEMO_SRCDIR)/% $(install-file)endif$(DEMO_BUILD_SRCDIR)/%: $(DEMO_SRCDIR)/% $(install-file)ifdef DEMO_PSRCDIR$(DEMO_BUILD_SRCDIR)/%: $(DEMO_PSRCDIR)/% $(install-file)endififdef DEMO_EXTRA_SRCDIR$(DEMO_BUILD_SRCDIR)/%: $(DEMO_EXTRA_SRCDIR)/% $(install-file)endififneq ($(DEMO_NEEDS_AGENT_UTIL),)$(DEMO_BUILD_SRCDIR)/%: $(DEMO_SRCDIR)/../agent_util/% $(install-file)endififneq ($(DEMO_NEEDS_JAVA_CRW_DEMO),)$(DEMO_BUILD_SRCDIR)/%: $(DEMO_SRCDIR)/../java_crw_demo/% $(install-file)endif# Jar manifest file$(DEMO_MANIFEST): @$(prep-target) $(ECHO) "Main-Class: $(DEMO_MAINCLASS)" > $@ifdef DEMO_MANIFEST_ATTR $(ECHO) "$(DEMO_MANIFEST_ATTR)" >> $@endif# Populating the jar image directory$(DEMO_JAR_IMAGE)/%: $(DEMO_SRCDIR)/% $(install-file)ifdef DEMO_PSRCDIR$(DEMO_JAR_IMAGE)/%: $(DEMO_PSRCDIR)/% $(install-file)endififdef DEMO_EXTRA_SRCDIR$(DEMO_JAR_IMAGE)/%: $(DEMO_EXTRA_SRCDIR)/% $(install-file)endififdef DEMO_DESCRIPTOR$(DEMO_JAR_IMAGE)/META-INF/services/$(DEMO_DESCRIPTOR): \ $(DEMO_SRCDIR)/$(DEMO_DESCRIPTOR) $(install-file)endif# If we are creating a jar file (we have java code)ifdef DEMO_JAR# Input file for javac$(DEMO_JAVAC_INPUT): $(DEMO_JAVA_SOURCES:%=$(DEMO_BUILD_SRCDIR)/%) @$(prep-target) @for i in $(DEMO_JAVA_SOURCES) ; do \ $(ECHO) "$(DEMO_BUILD_SRCDIR)/$$i" >> $@ ; \ done# Jar file creation$(DEMO_JAR): \ $(DEMO_JAVAC_INPUT) \ $(DEMO_MANIFEST) \ $(DEMO_DESCRIPTOR:%=$(DEMO_JAR_IMAGE)/META-INF/services/%) \ $(DEMO_RESOURCES:%=$(DEMO_JAR_IMAGE)/%) @$(prep-target) $(MKDIR) -p $(DEMO_JAR_IMAGE) $(JAVAC_CMD) -d $(DEMO_JAR_IMAGE) -sourcepath $(DEMO_BUILD_SRCDIR) \ @$(DEMO_JAVAC_INPUT) $(BOOT_JAR_CMD) -cfm $@ $(DEMO_MANIFEST) \ -C $(DEMO_JAR_IMAGE) . \ $(BOOT_JAR_JFLAGS) @$(java-vm-cleanup)endif# Create a src.zip file$(DEMO_BUILD_SRCZIP): $(DEMO_FULL_SOURCES) @$(prep-target) $(CD) $(DEMO_BUILD_AREA)/src && $(ZIPEXE) -q -r ../$(@F) .# Install the destination src.zip file and create the src tree$(DEMO_SOURCE_ZIP): $(DEMO_BUILD_SRCZIP) $(install-file)# Native library buildingifdef DEMO_LIBRARY # Full paths to object files DEMO_FULL_OBJECTS = $(DEMO_OBJECTS:%=$(OBJDIR)/%) VPATH=# Native compile rules$(OBJDIR)/%.$(OBJECT_SUFFIX): $(DEMO_BUILD_SRCDIR)/%.c @$(prep-target) $(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ $< ifneq ($(DEMO_NEEDS_CPP),)$(OBJDIR)/%.$(OBJECT_SUFFIX): $(DEMO_BUILD_SRCDIR)/%.cpp @$(prep-target) $(COMPILE.cpp) $(CC_OBJECT_OUTPUT_FLAG)$@ $< endif # Actual creation of the native shared library (C++ and C are different)$(DEMO_LIBRARY): $(DEMO_FULL_OBJECTS) @$(prep-target) $(LINK.demo) $(SHARED_LIBRARY_FLAG) $(CC_PROGRAM_OUTPUT_FLAG)$@ \ $(DEMO_FULL_OBJECTS) $(LDLIBS.demo) # Generation of any javah include file, make sure objects are dependent on it ifdef DEMO_NATIVECLASS$(DEMO_JAVAH_FILE): $(DEMO_JAR) @$(prep-target) $(JAVAH_CMD) -d $(DEMO_BUILD_SRCDIR) -classpath $(DEMO_JAR) \ $(DEMO_NATIVECLASS) @$(java-vm-cleanup)$(DEMO_FULL_OBJECTS): $(DEMO_JAVAH_FILE) endifendif# Build involves populating the destination "src" tree, building the jar and# native library, and creating a source bundlesources: $(DEMO_FULL_SOURCES) @$(ECHO) "Created $@"objects: @$(ECHO) "Created $@"# Why the nested make here? It only works this way, don't know why.bundles: $(DEMO_BUILD_SRCZIP) $(RM) -r $(DEMO_DESTDIR) $(MKDIR) -p $(DEMO_DESTDIR) $(MAKE) $(DEMO_LIBRARY) $(DEMO_JAR) $(DEMO_SOURCE_ZIP) $(DEMO_DEST_TOPFILES)# Applets are special, no jar file, no src.zip, everything expanded.ifdef DEMO_IS_APPLET @$(ECHO) "Expanding jar file into demos area at $(DEMO_DESTDIR)" ( $(CD) $(DEMO_DESTDIR) && \ $(BOOT_JAR_CMD) -xfv $(DEMONAME).jar \ $(BOOT_JAR_JFLAGS) && \ $(RM) -r META-INF $(DEMONAME).jar && \ $(java-vm-cleanup) ) @( $(CD) $(DEMO_DESTDIR) && $(java-vm-cleanup) ) @$(ECHO) "Expanding source into demos area at $(DEMO_DESTDIR)" ( $(CD) $(DEMO_DESTDIR) && $(UNZIP) -o src.zip && $(RM) src.zip )endifbuild: sources bundles# Printing out a demo information linedefine printDemoSettingif [ "$2" != "" ] ; then $(PRINTF) "%-20s %s\n" "$1:" "$2"; fiendef# Print out the demo informationdemo_info: @$(ECHO) "=========================================================" @$(call printDemoSetting,DEMONAME,$(DEMONAME)) @$(call printDemoSetting,DEMO_ROOT,$(DEMO_ROOT)) @$(call printDemoSetting,DEMO_SRCDIR,$(DEMO_SRCDIR)) @$(call printDemoSetting,DEMO_DESTDIR,$(DEMO_DESTDIR)) @$(call printDemoSetting,DEMO_JAR,$(DEMO_JAR)) @$(call printDemoSetting,DEMO_MANIFEST_ATTR,$(DEMO_MANIFEST_ATTR)) @$(call printDemoSetting,DEMO_PSRCDIR,$(DEMO_PSRCDIR)) @$(call printDemoSetting,DEMO_EXTRA_SRCDIR,$(DEMO_EXTRA_SRCDIR)) @$(call printDemoSetting,DEMO_EXTRA_FILES,$(DEMO_EXTRA_FILES)) @$(call printDemoSetting,DEMO_TOPFILES,$(DEMO_TOPFILES)) @$(call printDemoSetting,DEMO_MAINCLASS,$(DEMO_MAINCLASS)) @$(call printDemoSetting,DEMO_DESCRIPTOR,$(DEMO_DESCRIPTOR)) @$(call printDemoSetting,DEMO_NATIVECLASS,$(DEMO_NATIVECLASS)) @$(call printDemoSetting,DEMO_LIBRARY,$(DEMO_LIBRARY)) @$(call printDemoSetting,DEMO_OBJECTS,$(DEMO_OBJECTS)) @$(call printDemoSetting,DEMO_SOURCE_ZIP,$(DEMO_SOURCE_ZIP)) @$(ECHO) "========================================================="# Clean ruleclean clobber: $(RM) -r $(DEMO_BUILD_AREA) $(RM) -r $(DEMO_DESTDIR)# This should not be needed, but some versions of GNU amke have a bug that# sometimes deleted these files for some strange and unknown reason # (GNU make version 3.78.1 has the problem, GNU make version 3.80 doesn't?).PRECIOUS: $(DEMO_FULL_SOURCES) $(DEMO_BUILD_SRCZIP) $(DEMO_SOURCE_ZIP)# List phony targets.PHONY: all build clean clobber demo_info \ sources bundles