changeset 21718:b5bbf03bc17a

Improve makefile generator, exporting files into shared dir (JBS:GRAAL-52)
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Thu, 04 Jun 2015 03:21:58 +0200
parents a3315bce5192
children cbe8cc0f79ce
files make/Makefile make/jvmci.make make/solaris/makefiles/defs.make mx/mx_graal.py mx/mx_graal_makefile.py mxtool/mx.py
diffstat 6 files changed, 243 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/make/Makefile	Wed Jun 03 20:24:04 2015 +0200
+++ b/make/Makefile	Thu Jun 04 03:21:58 2015 +0200
@@ -323,6 +323,7 @@
 # Builds code that can be shared among different build flavors
 buildshared:
 	$(PYTHON) -u $(GAMMADIR)/mxtool/mx.py build --no-native --export-dir $(SHARED_DIR)
+	#cd .. && $(MAKE) -f make/jvmci.make TARGET=build/make MX_TARGET=. HS_COMMON_SRC=$(HS_COMMON_SRC) JDK=$(ABS_BOOTDIR) EXPORT_DIR=$(SHARED_DIR) VERBOSE=0 export
 
 # Export file rule
 generic_export: $(EXPORT_LIST)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/jvmci.make	Thu Jun 04 03:21:58 2015 +0200
@@ -0,0 +1,154 @@
+[?1034hVERBOSE=
+TARGET=.
+JDK=
+
+WGET=wget
+JAVAC=$(JDK)/bin/javac -g -target 1.8
+JAR=$(JDK)/bin/jar
+
+EXPORT_DIR=export
+EXPORTED_FILES_ADDITIONAL=$(TARGET)/options $(TARGET)/services
+HS_COMMON_SRC=.
+# where all other stuff built by mx (graal.jar) resides
+MX_TARGET=.
+PROVIDERS_INF=/META-INF/providers/
+SERVICES_INF=/META-INF/services/
+OPTIONS_INF=/META-INF/options/
+
+ifeq ($(JDK),)
+    $(error Variable JDK must be set to a JDK installation.)
+    endif
+    ifneq ($(VERBOSE),)
+    SHELL=sh -x
+endif
+
+define process_options =
+    $(eval providers=$(1)/$(PROVIDERS_INF))
+    $(eval services=$(1)/$(SERVICES_INF))
+    $(eval options=$(1)/$(OPTIONS_INF))
+    test -d $(services) || mkdir -p $(services)
+    test ! -d $(providers) || (cd $(providers) && for i in $$(ls $(providers)); do c=$$(cat $$i); echo $$i >> $(services)$$c; rm $$i; done)
+
+    # We're building all projects together with one javac call; thus we cannot determine, from which project the generated file is thus we hardcode it for now
+    $(eval vmconfig=$(1)/hotspot/HotSpotVMConfig.inline.hpp)
+    $(eval vmconfigDest=$(HS_COMMON_SRC)/../graal/com.oracle.jvmci.hotspot/src_gen/hotspot)
+    test ! -f $(vmconfig) || (mkdir -p $(vmconfigDest) && cp $(vmconfig) $(vmconfigDest))
+endef
+
+define extract =
+    $(eval TMP := $(shell mktemp -d))
+    mkdir -p $(2);
+    cd $(TMP) && $(JAR) xf $(abspath $(1)) &&         ((test ! -d .$(SERVICES_INF) || cp -r .$(SERVICES_INF) $(abspath $(2))) &&  (test ! -d .$(OPTIONS_INF) || cp -r .$(OPTIONS_INF) $(abspath $(2))))
+    rm -r $(TMP)
+    cp $(1) $(2)
+endef
+
+
+all: default
+
+export: all
+	mkdir -p $(EXPORT_DIR)
+	$(foreach export,$(EXPORTED_FILES),$(call extract,$(export),$(EXPORT_DIR)))
+.PHONY: export
+
+
+
+EXPORTED_FILES += $(MX_TARGET)/build/truffle.jar
+
+EXPORTED_FILES += $(MX_TARGET)/build/graal.jar
+
+EXPORTED_FILES += $(MX_TARGET)/build/graal-truffle.jar
+
+JDK_BOOTCLASSPATH = $(JDK)/jre/lib/resources.jar:$(JDK)/jre/lib/rt.jar:$(JDK)/jre/lib/jsse.jar:$(JDK)/jre/lib/jce.jar:$(JDK)/jre/lib/charsets.jar:$(JDK)/jre/lib/jfr.jar
+
+COM_ORACLE_JVMCI_OPTIONS_PROCESSOR_SRC = $(shell find graal/com.oracle.jvmci.service/src -type f -name *.java 2> /dev/null)
+COM_ORACLE_JVMCI_OPTIONS_PROCESSOR_SRC += $(shell find graal/com.oracle.jvmci.options/src -type f -name *.java 2> /dev/null)
+COM_ORACLE_JVMCI_OPTIONS_PROCESSOR_SRC += $(shell find graal/com.oracle.jvmci.options.processor/src -type f -name *.java 2> /dev/null)
+
+COM_ORACLE_JVMCI_OPTIONS_PROCESSOR_JAR = $(TARGET)/graal/com.oracle.jvmci.options.processor/ap/com.oracle.jvmci.options.processor.jar
+
+COM_ORACLE_JVMCI_HOTSPOTVMCONFIG_PROCESSOR_SRC = $(shell find graal/com.oracle.jvmci.hotspotvmconfig/src -type f -name *.java 2> /dev/null)
+COM_ORACLE_JVMCI_HOTSPOTVMCONFIG_PROCESSOR_SRC += $(shell find graal/com.oracle.jvmci.common/src -type f -name *.java 2> /dev/null)
+COM_ORACLE_JVMCI_HOTSPOTVMCONFIG_PROCESSOR_SRC += $(shell find graal/com.oracle.jvmci.hotspotvmconfig.processor/src -type f -name *.java 2> /dev/null)
+
+COM_ORACLE_JVMCI_HOTSPOTVMCONFIG_PROCESSOR_JAR = $(TARGET)/graal/com.oracle.jvmci.hotspotvmconfig.processor/ap/com.oracle.jvmci.hotspotvmconfig.processor.jar
+
+JVMCI_SERVICE_SRC = $(shell find graal/com.oracle.jvmci.service/src -type f -name *.java 2> /dev/null)
+
+JVMCI_SERVICE_JAR = $(TARGET)/build/jvmci-service.jar
+
+JVMCI_SERVICE_DEP_JARS = lib/findbugs-SuppressFBWarnings.jar
+
+EXPORTED_FILES += $(JVMCI_SERVICE_JAR)
+
+JVMCI_HOTSPOT_SRC = $(shell find graal/com.oracle.jvmci.hotspotvmconfig/src -type f -name *.java 2> /dev/null)
+JVMCI_HOTSPOT_SRC += $(shell find graal/com.oracle.jvmci.hotspotvmconfig/graal/com.oracle.jvmci.hotspotvmconfig/src_gen -type f -name *.java 2> /dev/null)
+JVMCI_HOTSPOT_SRC += $(shell find graal/com.oracle.jvmci.hotspot/src -type f -name *.java 2> /dev/null)
+JVMCI_HOTSPOT_SRC += $(shell find graal/com.oracle.jvmci.hotspot/graal/com.oracle.jvmci.hotspot/src_gen -type f -name *.java 2> /dev/null)
+
+JVMCI_HOTSPOT_JAR = $(TARGET)/build/jvmci-hotspot.jar
+
+JVMCI_HOTSPOT_DEP_JARS = $(TARGET)/build/jvmci-service.jar $(TARGET)/build/jvmci-api.jar lib/findbugs-SuppressFBWarnings.jar
+
+EXPORTED_FILES += $(JVMCI_HOTSPOT_JAR)
+
+JVMCI_API_SRC = $(shell find graal/com.oracle.jvmci.meta/src -type f -name *.java 2> /dev/null)
+JVMCI_API_SRC += $(shell find graal/com.oracle.jvmci.code/src -type f -name *.java 2> /dev/null)
+JVMCI_API_SRC += $(shell find graal/com.oracle.jvmci.runtime/src -type f -name *.java 2> /dev/null)
+JVMCI_API_SRC += $(shell find graal/com.oracle.jvmci.options/src -type f -name *.java 2> /dev/null)
+JVMCI_API_SRC += $(shell find graal/com.oracle.jvmci.common/src -type f -name *.java 2> /dev/null)
+JVMCI_API_SRC += $(shell find graal/com.oracle.jvmci.debug/src -type f -name *.java 2> /dev/null)
+
+JVMCI_API_JAR = $(TARGET)/build/jvmci-api.jar
+
+JVMCI_API_DEP_JARS = $(TARGET)/build/jvmci-service.jar lib/findbugs-SuppressFBWarnings.jar
+
+EXPORTED_FILES += $(JVMCI_API_JAR)
+
+$(COM_ORACLE_JVMCI_OPTIONS_PROCESSOR_JAR): $(COM_ORACLE_JVMCI_OPTIONS_PROCESSOR_SRC)  
+	$(eval TMP := $(shell mktemp -d))
+	$(JAVAC) -d $(TMP)  -bootclasspath $(JDK_BOOTCLASSPATH)  $(COM_ORACLE_JVMCI_OPTIONS_PROCESSOR_SRC)
+	cp -r graal/com.oracle.jvmci.options.processor/src/META-INF $(TMP)
+	$(call process_options,$(TMP),False)
+	mkdir -p $$(dirname $(COM_ORACLE_JVMCI_OPTIONS_PROCESSOR_JAR))
+	$(JAR) cf $(COM_ORACLE_JVMCI_OPTIONS_PROCESSOR_JAR) -C $(TMP) .
+	rm -r $(TMP)
+
+$(COM_ORACLE_JVMCI_HOTSPOTVMCONFIG_PROCESSOR_JAR): $(COM_ORACLE_JVMCI_HOTSPOTVMCONFIG_PROCESSOR_SRC)  
+	$(eval TMP := $(shell mktemp -d))
+	$(JAVAC) -d $(TMP)  -bootclasspath $(JDK_BOOTCLASSPATH)  $(COM_ORACLE_JVMCI_HOTSPOTVMCONFIG_PROCESSOR_SRC)
+	cp -r graal/com.oracle.jvmci.hotspotvmconfig.processor/src/META-INF $(TMP)
+	$(call process_options,$(TMP),False)
+	mkdir -p $$(dirname $(COM_ORACLE_JVMCI_HOTSPOTVMCONFIG_PROCESSOR_JAR))
+	$(JAR) cf $(COM_ORACLE_JVMCI_HOTSPOTVMCONFIG_PROCESSOR_JAR) -C $(TMP) .
+	rm -r $(TMP)
+
+$(JVMCI_SERVICE_JAR): $(JVMCI_SERVICE_SRC)  $(JVMCI_SERVICE_DEP_JARS)
+	$(eval TMP := $(shell mktemp -d))
+	$(JAVAC) -d $(TMP)  -bootclasspath $(JDK_BOOTCLASSPATH) -cp lib/findbugs-SuppressFBWarnings.jar $(JVMCI_SERVICE_SRC)
+	
+	$(call process_options,$(TMP),True)
+	mkdir -p $$(dirname $(JVMCI_SERVICE_JAR))
+	$(JAR) cf $(JVMCI_SERVICE_JAR) -C $(TMP) .
+	rm -r $(TMP)
+
+$(JVMCI_HOTSPOT_JAR): $(JVMCI_HOTSPOT_SRC) $(COM_ORACLE_JVMCI_HOTSPOTVMCONFIG_PROCESSOR_JAR) $(COM_ORACLE_JVMCI_OPTIONS_PROCESSOR_JAR) $(JVMCI_HOTSPOT_DEP_JARS)
+	$(eval TMP := $(shell mktemp -d))
+	$(JAVAC) -d $(TMP) -processorpath $(COM_ORACLE_JVMCI_HOTSPOTVMCONFIG_PROCESSOR_JAR):$(COM_ORACLE_JVMCI_OPTIONS_PROCESSOR_JAR) -bootclasspath $(JDK_BOOTCLASSPATH) -cp $(TARGET)/build/jvmci-service.jar:$(TARGET)/build/jvmci-api.jar:lib/findbugs-SuppressFBWarnings.jar $(JVMCI_HOTSPOT_SRC)
+	
+	$(call process_options,$(TMP),True)
+	mkdir -p $$(dirname $(JVMCI_HOTSPOT_JAR))
+	$(JAR) cf $(JVMCI_HOTSPOT_JAR) -C $(TMP) .
+	rm -r $(TMP)
+
+$(JVMCI_API_JAR): $(JVMCI_API_SRC)  $(JVMCI_API_DEP_JARS)
+	$(eval TMP := $(shell mktemp -d))
+	$(JAVAC) -d $(TMP)  -bootclasspath $(JDK_BOOTCLASSPATH) -cp $(TARGET)/build/jvmci-service.jar:lib/findbugs-SuppressFBWarnings.jar $(JVMCI_API_SRC)
+	
+	$(call process_options,$(TMP),True)
+	mkdir -p $$(dirname $(JVMCI_API_JAR))
+	$(JAR) cf $(JVMCI_API_JAR) -C $(TMP) .
+	rm -r $(TMP)
+
+default: $(JVMCI_SERVICE_JAR) $(JVMCI_HOTSPOT_JAR) $(JVMCI_API_JAR)
+.PHONY: default
--- a/make/solaris/makefiles/defs.make	Wed Jun 03 20:24:04 2015 +0200
+++ b/make/solaris/makefiles/defs.make	Thu Jun 04 03:21:58 2015 +0200
@@ -304,3 +304,4 @@
   endif
 endif
 EXPORT_LIST += $(EXPORT_LIB_DIR)/sa-jdi.jar
+EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.jvmci.debug.DebugInitializationPropertyProvider
--- a/mx/mx_graal.py	Wed Jun 03 20:24:04 2015 +0200
+++ b/mx/mx_graal.py	Thu Jun 04 03:21:58 2015 +0200
@@ -579,8 +579,10 @@
         if os.path.isfile(jar):
             with zipfile.ZipFile(jar) as zf:
                 for member in zf.namelist():
-                    if member.startswith('META-INF/services'):
+                    if member.startswith('META-INF/services') and member:
                         serviceName = basename(member)
+                        if serviceName == "":
+                            continue # Zip files may contain empty entries for directories (jar -cf ... creates such)
                         # we don't handle directories
                         assert serviceName and member == 'META-INF/services/' + serviceName
                         with zf.open(member) as serviceFile:
@@ -591,6 +593,8 @@
                                     serviceImpls.append(line)
                     elif member.startswith('META-INF/options'):
                         filename = basename(member)
+                        if filename == "":
+                            continue # Zip files may contain empty entries for directories (jar -cf ... creates such)
                         # we don't handle directories
                         assert filename and member == 'META-INF/options/' + filename
                         targetpath = join(optionsDir, filename)
--- a/mx/mx_graal_makefile.py	Wed Jun 03 20:24:04 2015 +0200
+++ b/mx/mx_graal_makefile.py	Thu Jun 04 03:21:58 2015 +0200
@@ -24,7 +24,7 @@
 #
 # ----------------------------------------------------------------------------------------------------
 #
-import mx, os
+import mx, mx_graal, os
 from argparse import ArgumentParser, REMAINDER
 
 
@@ -32,16 +32,16 @@
     def __init__(self):
         self.rules = []
         self.definitions = []
-        
+
     def add_rule(self, s):
         self.rules.append(s)
-        
+
     def add_definition(self, s):
         self.definitions.append(s)
-        
+
     def generate(self):
         return "\n\n".join(self.definitions + self.rules)
-    
+
 
 def build_makefile(args):
     """Creates a Makefile which is able to build distributions without mx"""
@@ -49,7 +49,7 @@
     parser.add_argument('-o', action='store', dest='output', help='Write contents to this file.')
     parser.add_argument('selectedDists', help="Selected distribution names which are going to be built with make.", nargs=REMAINDER)
     args = parser.parse_args(args)
-    
+
     if args.selectedDists == None or len(args.selectedDists) == 0:
         parser.print_help()
         return
@@ -61,7 +61,7 @@
         else:
             with open(args.output, "w") as f:
                 f.write(contents)
-    
+
 
 def filter_projects(deps, t):
     def typeFilter(project): # filters
@@ -70,27 +70,31 @@
         return isinstance(project, t)
     return [d for d in deps if typeFilter(d)]
 
+def get_jdk_deployed_dists():
+    return [d.name for d in mx_graal._jdkDeployedDists]
 
 def make_dist_rule(dist, mf, bootClassPath=None):
     def path_dist_relative(p):
         return os.path.relpath(p, dist.suite.dir)
+    jdkDeployedDists = get_jdk_deployed_dists()
     jarPath = path_dist_relative(dist.path)
     sourcesVariableName = dist.name + "_SRC"
-    depJarVariableName = dist.name + "_DEP_JARS";
+    depJarVariableName = dist.name + "_DEP_JARS"
     sources = []
     resources = []
     sortedDeps = dist.sorted_deps(True, transitive=False, includeAnnotationProcessors=True)
     projects = filter_projects(sortedDeps, mx.Project)
     targetPathPrefix = "$(TARGET)" + os.path.sep
     libraryDeps = [path_dist_relative(l.get_path(False)) for l in filter_projects(sortedDeps, mx.Library)]
-    
+
     annotationProcessorDeps = set()
     distDeps = dist.get_dist_deps(includeSelf=False, transitive=True)
     distDepProjects = set()
-    for d in distDeps: 
+    for d in distDeps:
         distDepProjects.update(d.sorted_deps(includeLibs=False, transitive=True))
-    classPath = [targetPathPrefix + path_dist_relative(d.path) for d in distDeps] + libraryDeps
-    
+
+    classPath = [targetPathPrefix + path_dist_relative(d.path) for d in distDeps] + libraryDeps \
+        + [path_dist_relative(mx.dependency(name).path) for name in dist.excludedDependencies]
     for p in projects:
         if p.definedAnnotationProcessors != None and p.definedAnnotationProcessorsDist != dist:
             annotationProcessorDeps.add(p)
@@ -98,25 +102,25 @@
         projectDir = path_dist_relative(p.dir)
         if p not in distDepProjects and p not in annotationProcessorDeps:
             generatedSource = [path_dist_relative(p.source_gen_dir())] if len(annotationProcessorDeps) > 0 else []
-            
+
             for d in p.srcDirs + generatedSource:
                 src = projectDir + os.path.sep + d
-                sources.append("$(shell find {} -type file -name *.java 2> /dev/null)".format(src))
-                metaInf = src + os.path.sep + "META-INF";
+                sources.append("$(shell find {} -type f -name *.java 2> /dev/null)".format(src))
+                metaInf = src + os.path.sep + "META-INF"
                 if os.path.exists(metaInf):
                     resources.append(metaInf)
-        
-            
+
+
     sourceLines = sourcesVariableName + " = " + ("\n" + sourcesVariableName + " += ").join(sources)
-    annotationProcessorPaths = []
-    annotationProcessorDistNames = []
-    annotationProcessorDistVariableNames = []
+    apPaths = []
+    apDistNames = []
+    apDistVariableNames = []
     for p in annotationProcessorDeps:
-        annotationProcessorPaths.append(path_dist_relative(p.definedAnnotationProcessorsDist.path))
+        apPaths.append(path_dist_relative(p.definedAnnotationProcessorsDist.path))
         name = p.definedAnnotationProcessorsDist.name
-        annotationProcessorDistNames.append(name)
-        annotationProcessorDistVariableNames.append("$(" + name + "_JAR)")
-    
+        apDistNames.append(name)
+        apDistVariableNames.append("$(" + name + "_JAR)")
+    shouldExport = dist.name in jdkDeployedDists
     props = {
            "name": dist.name,
            "jarPath": targetPathPrefix + jarPath,
@@ -125,35 +129,38 @@
            "depJarsVariable": depJarVariableName,
            "sourceLines": sourceLines,
            "sourcesVariableName": sourcesVariableName,
-           "annotationProcessors": " ".join(annotationProcessorDistVariableNames),
-           "cpAnnotationProcessors": "-processorpath " + ":".join(annotationProcessorDistVariableNames) if len(annotationProcessorDistVariableNames) > 0 else "",
+           "annotationProcessors": " ".join(apDistVariableNames),
+           "cpAnnotationProcessors": "-processorpath " + ":".join(apDistVariableNames) if len(apDistVariableNames) > 0 else "",
            "bootCp": ("-bootclasspath " + bootClassPath) if bootClassPath != None else "",
            "cpDeps": ("-cp " + ":".join(classPath)) if len(classPath) > 0 else "",
            "jarDeps": " ".join(classPath),
            "copyResources": "cp -r {} $(TMP)".format(" ".join(resources)) if len(resources) > 0 else "",
-           "targetPathPrefix": targetPathPrefix
+           "targetPathPrefix": targetPathPrefix,
+           "shouldExport": shouldExport,
            }
-    
+
     mf.add_definition(sourceLines)
     mf.add_definition("{name}_JAR = {jarPath}".format(**props))
     if len(classPath) > 0: mf.add_definition("{depJarsVariable} = {jarDeps}".format(**props))
-    mf.add_rule("""$({name}_JAR): $({sourcesVariableName}) {annotationProcessors} {depJarsVariableAccess} $(TARGET)/build
+    if shouldExport: mf.add_definition("EXPORTED_FILES += $({name}_JAR)".format(**props))
+    mf.add_rule("""$({name}_JAR): $({sourcesVariableName}) {annotationProcessors} {depJarsVariableAccess}
 \t$(eval TMP := $(shell mktemp -d))
 \t$(JAVAC) -d $(TMP) {cpAnnotationProcessors} {bootCp} {cpDeps} $({sourcesVariableName})
 \t{copyResources}
-\t$(call process_options,$(TMP))
+\t$(call process_options,$(TMP),{shouldExport})
 \tmkdir -p $$(dirname $({name}_JAR))
 \t$(JAR) cf $({name}_JAR) -C $(TMP) .
 \trm -r $(TMP)""".format(**props))
     return
 
 
+
 def do_build_makefile(mf, selectedDists):
     java = mx.java()
     bootClassPath = java.bootclasspath()
     bootClassPath = bootClassPath.replace(java.jdk, "$(JDK)")
     jdkBootClassPathVariableName = "JDK_BOOTCLASSPATH"
-    
+
     mf.add_definition("""VERBOSE=
 TARGET=.
 JDK=
@@ -162,34 +169,57 @@
 JAVAC=$(JDK)/bin/javac -g -target """ + str(java.javaCompliance) + """
 JAR=$(JDK)/bin/jar
 
+EXPORT_DIR=export
+EXPORTED_FILES_ADDITIONAL=$(TARGET)/options $(TARGET)/services
+HS_COMMON_SRC=.
+# where all other stuff built by mx (graal.jar) resides
+MX_TARGET=.
+PROVIDERS_INF=/META-INF/providers/
+SERVICES_INF=/META-INF/services/
+OPTIONS_INF=/META-INF/options/
 
 ifeq ($(JDK),)
-$(error Variable JDK must be set to a JDK installation.)
-endif
-ifneq ($(VERBOSE),)
-SHELL=sh -x
+    $(error Variable JDK must be set to a JDK installation.)
+    endif
+    ifneq ($(VERBOSE),)
+    SHELL=sh -x
 endif
 
 define process_options =
-$(eval providers=$(1)/META-INF/providers/)
-$(eval services=$(1)/META-INF/services/)
-test -d $(services) || mkdir -p $(services)
-test ! -d $(providers) ||   (cd $(providers) && for i in $$(ls $(providers)); do c=$$(cat $$i); echo $$i >> $(services)$$c; rm $$i; done)
+    $(eval providers=$(1)/$(PROVIDERS_INF))
+    $(eval services=$(1)/$(SERVICES_INF))
+    $(eval options=$(1)/$(OPTIONS_INF))
+    test -d $(services) || mkdir -p $(services)
+    test ! -d $(providers) || (cd $(providers) && for i in $$(ls $(providers)); do c=$$(cat $$i); echo $$i >> $(services)$$c; rm $$i; done)
+
+    # We're building all projects together with one javac call; thus we cannot determine, from which project the generated file is thus we hardcode it for now
+    $(eval vmconfig=$(1)/hotspot/HotSpotVMConfig.inline.hpp)
+    $(eval vmconfigDest=$(HS_COMMON_SRC)/../graal/com.oracle.jvmci.hotspot/src_gen/hotspot)
+    test ! -f $(vmconfig) || (mkdir -p $(vmconfigDest) && cp $(vmconfig) $(vmconfigDest))
 endef
 
+define extract =
+    $(eval TMP := $(shell mktemp -d))
+    mkdir -p $(2);
+    cd $(TMP) && $(JAR) xf $(abspath $(1)) && \
+        ((test ! -d .$(SERVICES_INF) || cp -r .$(SERVICES_INF) $(abspath $(2))) &&  (test ! -d .$(OPTIONS_INF) || cp -r .$(OPTIONS_INF) $(abspath $(2))))
+    rm -r $(TMP)
+    cp $(1) $(2)
+endef
+
+
 all: default
 
-$(TARGET)/build:
-\tmkdir -p $(TARGET)/build
+export: all
+\tmkdir -p $(EXPORT_DIR)
+\t$(foreach export,$(EXPORTED_FILES),$(call extract,$(export),$(EXPORT_DIR)))
+.PHONY: export
 
-$(LIB):
-\tmkdir -p $(LIB)
 """)
     s = mx.suite("graal")
     dists = set()
     ap = set()
     projects = set()
-
     for d in s.dists:
         if d.name in selectedDists:
             dists.update(d.get_dist_deps(True, True))
@@ -200,7 +230,12 @@
             if d.definedAnnotationProcessorsDist != None:
                 apd = d.definedAnnotationProcessorsDist
                 ap.add(apd)
-    
+
+    for d in mx_graal._jdkDeployedDists:
+        dist = mx.distribution(d.name)
+        if dist not in dists: # this sould go away
+            mf.add_definition("EXPORTED_FILES += $(MX_TARGET)/{}".format(os.path.relpath(dist.path, dist.suite.dir)))
+
     if len(dists) > 0:
         mf.add_definition(jdkBootClassPathVariableName + " = " + bootClassPath)
         bootClassPathVarAccess = "$(" + jdkBootClassPathVariableName + ")"
@@ -212,8 +247,3 @@
         for d in dists:
             selectedDists.remove(d.name)
         print "Distribution(s) '" + "', '".join(selectedDists) + "' does not exist."
-            
-    
-            
-    
-
--- a/mxtool/mx.py	Wed Jun 03 20:24:04 2015 +0200
+++ b/mxtool/mx.py	Thu Jun 04 03:21:58 2015 +0200
@@ -142,10 +142,10 @@
 
     def add_update_listener(self, listener):
         self.update_listeners.add(listener)
-        
+
     def get_dist_deps(self, includeSelf=True, transitive=False):
         deps = set()
-        if includeSelf: 
+        if includeSelf:
             deps.add(self)
         deps.update([distribution(name) for name in self.distDependencies])
         if transitive: