common/makefiles/JavaCompilation.gmk
author jgish
Fri, 29 Jun 2012 15:36:14 -0700
changeset 13155 8140afb39557
parent 12801 948f8ad66ee7
child 13132 bd88bb8dd3af
permissions -rw-r--r--
7100996: (spec str) IndexOutOfBoundsException when using a StringBuffer from multiple threads Summary: add usage note to clarify thread safety Reviewed-by: briangoetz, mduigou Contributed-by: jim.gish@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     1
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     2
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     4
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    10
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    15
# accompanied this code).
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    16
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    20
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    23
# questions.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    24
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    25
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    26
# The complexity of this makefile is not the fault of make, but the fault
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    27
# of javac and javah. The basic problems are:
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    28
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    29
#    1) Compiling a single Java source file unpredictably generates anything
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    30
#       between zero (0!) and an infinite number of .class files!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    31
#    2) There is no hint, for which classes javah needs to be run,
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    32
#       and it happily generates .h files for classes with no native methods.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    33
#    3) javac and javah do not cleanup anything, for example if an internal
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    34
#       class (potentially with native methods) is removed from a Java source file.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    35
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    36
# This makefile is a tribute to GNU make. And yes, it was harder to write than it is
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    37
# to read. The include/excludes of directories and files are only a temporary measure
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    38
# to work around the messy jdk sources that put platform specific code in src/share/classes.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    39
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    40
# We should move most of the functionality of this makefile into a
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    41
# smart javac/javah/javadoc/jar combo tool. sjavac ?
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    42
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    43
# I.e. 1) It always generates a single output, a zip-file from a number of source roots.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    44
#         The zip file contains information that enable incremental builds with full 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    45
#         dependency tracking between packages.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    46
#      2) It automatically generates the right .h files.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    47
#      3) It keeps its house clean.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    48
#      *) Generates intermediate files to be used for javadoc generation later.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    49
#      and does all the other useful things that this makefile does, such as:
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    50
#          use all cores for compilation, reuse the running JVM for all compilations,
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    51
#          and has pubapi dependency tracking to minimize the number of files
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    52
#          that need to be recompiled during an incremental build.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    53
# 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    54
# A zip file, or several zip files combined, can then be converted to a .jar file, or to a .jmod file.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    55
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    56
# This would make this makefile much much simpler. I.e. make can be used
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    57
# for its real purpose, track dependencies and trigger a recompile if a
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    58
# dependency has changed.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    59
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    60
# When you read this source. Remember that $(sort ...) has the side effect
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    61
# of removing duplicates. It is actually this side effect that is
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    62
# desired whenever sort is used below!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    63
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    64
ifeq  (,$(_MAKEBASE_GMK))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    65
    $(error You must include MakeBase.gmk prior to including JavaCompilation.gmk)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    66
endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    67
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    68
FALSE_FIND_PATTERN:=-name FILE_NAME_THAT_DOESNT_EXIST
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    69
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    70
# If compilation of java package fails, then the public api file for that
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    71
# package will not be genereated. We add this fallback rule to generate
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    72
# an empty pubapi file. 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    73
%.api:
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    74
	if test ! -f $@; then $(MKDIR) -p $(@D); $(TOUCH) $@; fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    75
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    76
define SetupJavaCompiler
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    77
    # param 1 is for example BOOT_JAVAC or NEW_JAVAC
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    78
    # This is the name later used to decide which java compiler to use.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    79
    # param 2-9 are named args.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    80
    #   JVM:=The jvm used to run the javac/javah command
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    81
    #   JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    82
    #   JAVAH:=The javah jar and bootstrap classpath changes, or just bin/javah if JVM is left out
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    83
    #   FLAGS:=Flags to be supplied to javac
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    84
    #   MODE:=SINGLE_THREADED_BATCH (primarily for old javac) or MULTI_CORE_CONCURRENT
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    85
    #      only for MULTI_CORE_CONCURRENT are the options below relevant:
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    86
    #   SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    87
    #   SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    88
    #   USE_DEPS:=true means use -XDdeps,-XDpubapi and -XDnativeapi to track java dependencies
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    89
    $(if $2,$1_$(strip $2))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    90
    $(if $3,$1_$(strip $3))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    91
    $(if $4,$1_$(strip $4))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    92
    $(if $5,$1_$(strip $5))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    93
    $(if $6,$1_$(strip $6))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    94
    $(if $7,$1_$(strip $7))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    95
    $(if $8,$1_$(strip $8))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    96
    $(if $9,$1_$(strip $9))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    97
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    98
    ifeq ($$($1_MODE),MULTI_CORE_CONCURRENT)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    99
	ifneq (,$$($1_SERVER_DIR))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   100
            # A javac server has been requested.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   101
            # The port file contains the tcp/ip on which the server listens
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   102
            # and the cookie necessary to talk to the server.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   103
            $1_JAVAC_PORTFILE:=$$($1_SERVER_DIR)/$1.port
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   104
            ifeq ($$($1_SERVER_JVM),)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   105
                # You can use a different JVM to run the background javac server.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   106
                # But if not set, it defaults to the same JVM that is used to start
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   107
                # the javac command.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   108
                $1_SERVER_JVM:=$$($1_JVM)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   109
            endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   110
            # Set the $1_REMOTE to spawn a background javac server.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   111
	    $1_REMOTE:=-XDserver:portfile=$$($1_JAVAC_PORTFILE),poolsize=$(JAVAC_SERVER_CORES),javac=$$(subst $$(SPACE),%20,$$(subst $$(COMMA),%2C,$$(strip $$($1_SERVER_JVM) $$($1_JAVAC))))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   112
        endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   113
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   114
endef
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   115
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   116
define SetupArchive
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   117
    # param 1 is for example ARCHIVE_MYPACKAGE
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   118
    # param 2 are the dependecies
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   119
    # param 3,4,5,6,7,8,9 are named args.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   120
    #    SRCS:=List of directories in where to find files to add to archive
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   121
    #    SUFFIXES:=File suffixes to include in jar
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   122
    #    INCLUDES:=List of directories/packages in SRCS that should be included
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   123
    #    EXCLUDES:=List of directories/packages in SRCS that should be excluded
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   124
    #    EXCLUDE_FILES:=List of files in SRCS that should be excluded
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   125
    #    EXTRA_FILES:=List of files in SRCS that should be included regardless of suffix match.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   126
    #    JAR:=Jar file to create
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   127
    #    MANIFEST:=Optional manifest file template.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   128
    #    JARMAIN:=Optional main class to add to manifest
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   129
    #    JARINDEX := 
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   130
    #    SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   131
    #                  added to the archive.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   132
    #    EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   133
    $(if $3,$1_$(strip $3))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   134
    $(if $4,$1_$(strip $4))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   135
    $(if $5,$1_$(strip $5))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   136
    $(if $6,$1_$(strip $6))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   137
    $(if $7,$1_$(strip $7))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   138
    $(if $8,$1_$(strip $8))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   139
    $(if $9,$1_$(strip $9))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   140
    $(if $(10),$1_$(strip $(10)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   141
    $(if $(11),$1_$(strip $(11)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   142
    $(if $(12),$1_$(strip $(12)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   143
    $(if $(13),$1_$(strip $(13)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   144
    $(if $(14),$1_$(strip $(14)))
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   145
    $(if $(15),$1_$(strip $(15)))
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   146
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   147
    $1_JARMAIN:=$(strip $$($1_JARMAIN))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   148
    $1_JARNAME:=$$(notdir $$($1_JAR))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   149
    $1_MANIFEST_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_manifest
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   150
    $1_DELETESS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletess
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   151
    $1_DELETES_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletes
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   152
    $1_PUBAPI_NOTIFICATIONS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_pubapi_notifications
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   153
    $1_NATIVEAPI_NOTIFICATIONS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_native_notifications
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   154
    $1_NATIVEAPI_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_native
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   155
    $1_BIN:=$$(dir $$($1_JAR))
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   156
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   157
    ifeq (,$$($1_SUFFIXES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   158
        # No suffix was set, default to classes.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   159
        $1_SUFFIXES:=.class
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   160
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   161
    # Convert suffixes to a find expression
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   162
    $1_FIND_PATTERNS:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_SUFFIXES))
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   163
    # On windows, a lot of includes/excludes risk making the command line too long, so 
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   164
    # writing the grep patterns to files.
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   165
    ifneq (,$$($1_INCLUDES))
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   166
        $1_GREP_INCLUDE_PATTERNS:=$$(foreach src,$$($1_SRCS),\
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   167
					$$(addprefix $$(src)/,$$($1_INCLUDES)))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   168
        $$(eval $$(call ListPathsSafelyNow,$1_GREP_INCLUDE_PATTERNS,\n, \
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   169
			>> $$($1_BIN)/_the.$$($1_JARNAME)_include))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   170
        $1_GREP_INCLUDES:=| $(GREP) -f $$($1_BIN)/_the.$$($1_JARNAME)_include
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   171
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   172
    ifneq (,$$($1_EXCLUDES)$$($1_EXCLUDE_FILES))
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   173
        $1_GREP_EXCLUDE_PATTERNS:=$$(foreach src,$$($1_SRCS),$$(addprefix $$(src)/,\
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   174
		$$($1_EXCLUDES) $$($1_EXCLUDE_FILES)))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   175
        $$(eval $$(call ListPathsSafelyNow,$1_GREP_EXCLUDE_PATTERNS,\n, \
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   176
			>> $$($1_BIN)/_the.$$($1_JARNAME)_exclude))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   177
        $1_GREP_EXCLUDES:=| $(GREP) -v -f $$($1_BIN)/_the.$$($1_JARNAME)_exclude
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   178
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   179
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   180
    ifneq (,$$($1_JARINDEX))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   181
      $1_JARINDEX = (cd $$(dir $$@) && $(JAR) -i $$(notdir $$@))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   182
    else
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   183
      $1_JARINDEX = true
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   184
    endif
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   185
    # When this macro is run in the same makefile as the java compilation, dependencies are transfered
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   186
    # in make variables. When the macro is run in a different makefile than the java compilation, the 
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   187
    # dependencies need to be found in the filesystem.
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   188
    $1_ALL_SRCS:=$$(foreach src,$$($1_SRCS),$$(shell ($(FIND) $$(src) -type f \
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   189
			-a \( $$($1_FIND_PATTERNS) \) $$($1_GREP_INCLUDES) \
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   190
			$$($1_GREP_EXCLUDES) && $(ECHO) $$($1_EXTRA_FILES))))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   191
    ifeq (,$$($1_SKIP_METAINF))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   192
        $1_ALL_SRCS+=$$(foreach src,$$($1_SRCS),$$(shell $(FIND) $$(src)/META-INF -type f 2> /dev/null))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   193
    endif
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   194
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   195
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   196
    # Utility macros, to make the shell script receipt somewhat easier to dechipher.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   197
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   198
    # The capture contents macro finds all files (matching the patterns, typically
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   199
    # .class and .prp) that are newer than the jar-file, ie the new content to be put into the jar.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   200
    $1_CAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),(($(FIND) $$(src) -type f -a \( $$($1_FIND_PATTERNS) \) -a -newer $$@ $$($1_GREP_INCLUDES) $$($1_GREP_EXCLUDES) && $(ECHO) $$($1_EXTRA_FILES)) | $(SED) 's|$$(src)/||g' > $$(src)/_the.$$($1_JARNAME)_contents) && )
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   201
    # The capture metainf macro finds all files below the META-INF directory that are newer than the jar-file.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   202
    ifeq (,$$($1_SKIP_METAINF))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   203
        $1_CAPTURE_METAINF =$$(foreach src,$$($1_SRCS),($(FIND) $$(src)/META-INF -type f -a -newer $$@ 2> /dev/null | $(SED) 's|$$(src)/||g' >> $$(src)/_the.$$($1_JARNAME)_contents ) && )
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   204
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   205
    # The capture deletes macro finds all deleted files and concatenates them. The resulting file
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   206
    # tells us what to remove from the jar-file.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   207
    $1_CAPTURE_DELETES=$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name _the.package.deleted -newer $$@ -exec $(SED) 's|$$(src)||g' \{\} >> $$($1_DELETES_FILE) \;) &&)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   208
    # The capture pubapi notifications scans for pubapi change notifications. If such notifications are
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   209
    # found, then we will build the classes leading up to the jar again, to take into account the new timestamps
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   210
    # on the changed pubapi files.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   211
    $1_CAPTURE_PUBAPI_NOTIFICATIONS=$$(foreach src,$$($1_SRCS),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   212
                    (cd $$(src) && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   213
                    $(FIND) . -name _the.package.api.notify -exec dirname \{\} \; >> $$($1_PUBAPI_NOTIFICATIONS_FILE) ; \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   214
                    true) &&)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   215
    # The update contents macro updates the jar file with the previously capture contents.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   216
    $1_UPDATE_CONTENTS=$$(foreach src,$$($1_SRCS),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   217
                    (cd $$(src) && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   218
                     if [ -s _the.$$($1_JARNAME)_contents ]; then \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   219
                         $(ECHO) "  updating" `$(WC) -l _the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'` files && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   220
                         $(JAR) uf $$@ @_the.$$($1_JARNAME)_contents; \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   221
                     fi) &&)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   222
    # The s-variants of the above macros are used when the jar is created from scratch.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   223
    $1_SCAPTURE_CONTENTS=$$(foreach src,$$($1_SRCS),\
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   224
                    (($(FIND) $$(src) -type f -a \( $$($1_FIND_PATTERNS) \) $$($1_GREP_INCLUDES) \
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   225
			$$($1_GREP_EXCLUDES) && $(ECHO) $$($1_EXTRA_FILES)) | $(SED) 's|$$(src)/||g' > \
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   226
			$$(src)/_the.$$($1_JARNAME)_contents) && )
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   227
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   228
    ifeq (,$$($1_SKIP_METAINF))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   229
        $1_SCAPTURE_METAINF=$$(foreach src,$$($1_SRCS),\
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   230
                    ($(FIND) $$(src)/META-INF -type f 2> /dev/null | $(SED) 's|$$(src)/||g' >> \
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   231
			$$(src)/_the.$$($1_JARNAME)_contents) && )
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   232
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   233
    $1_SUPDATE_CONTENTS=$$(foreach src,$$($1_SRCS),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   234
                    (cd $$(src) && $(JAR) uf $$@ @$$(src)/_the.$$($1_JARNAME)_contents) &&)
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   235
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   236
    # The TOUCH macro is used to make sure all timestamps are identical for package files and the pubapi files.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   237
    # If we do not do this, we get random recompilations, the next time we run make, since the order of package building is random,
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   238
    # ie independent of package --dependes on-> public api of another package. This is of course
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   239
    # due to the fact that Java source often (always?) has circular dependencies. (Thus there is no correct order
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   240
    # to compile packages, and we can just as well do them in a random order. Which we do.)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   241
    $1_TOUCH_API_FILES=$$(foreach src,$$($1_SRCS),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   242
                    ($(FIND) $$(src) -name _the.package.api -exec $(TOUCH) -r $$($1_JAR) \{\} \; ; true) && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   243
                    ($(FIND) $$(src) -name _the.package -exec $(TOUCH) -r $$($1_JAR) \{\} \; ; true) &&)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   244
    # Use a slightly shorter name for logging, but with enough path to identify this jar.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   245
    $1_NAME:=$$(subst $$(OUTPUT_ROOT)/,,$$($1_JAR))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   246
    # Here is the rule that creates/updates the jar file.
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   247
    $$($1_JAR) : $2 $$($1_ALL_SRC)
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   248
	$(MKDIR) -p $$($1_BIN)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   249
	if [ -n "$$($1_MANIFEST)" ]; then \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   250
		$(SED) -e "s#@@RELEASE@@#$(RELEASE)#"           \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   251
		       -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" $$($1_MANIFEST) > $$($1_MANIFEST_FILE); \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   252
	else \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   253
		$(RM) $$($1_MANIFEST_FILE) && $(TOUCH) $$($1_MANIFEST_FILE); \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   254
	fi
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   255
	if [ -n "$$(strip $$($1_JARMAIN))" ]; then \
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   256
		$(ECHO) "Main-Class: $$(strip $$($1_JARMAIN))" >> $$($1_MANIFEST_FILE); \
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   257
	fi
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   258
	if [ -n "$$($1_EXTRA_MANIFEST_ATTR)" ]; then \
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   259
		$(PRINTF) "$$($1_EXTRA_MANIFEST_ATTR)\n" >> $$($1_MANIFEST_FILE); \
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   260
	fi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   261
	+if [ -s $$@ ]; then \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   262
		$(RM) -r $$($1_PUBAPI_NOTIFICATIONS_FILE) && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   263
		$$($1_CAPTURE_PUBAPI_NOTIFICATIONS) \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   264
		if [ -s $$($1_PUBAPI_NOTIFICATIONS_FILE) ]; then \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   265
			$(ECHO) Public api change detected in: && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   266
			$(CAT) $$($1_PUBAPI_NOTIFICATIONS_FILE) | $(TR) '/' '.' | $(SED) 's|^..||g' | $(SED) 's|\.$$$$||g' | $(AWK) '{print "  "$$$$1}' && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   267
			$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name _the.package.api.notify $(FIND_DELETE); true) &&) \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   268
			$(MAKE) -f $(word 1,$(MAKEFILE_LIST)) $$($1_JAR) ; \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   269
		else \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   270
			$(ECHO) Modifying $$($1_NAME) && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   271
			$$($1_CAPTURE_CONTENTS) \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   272
			$$($1_CAPTURE_METAINF) \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   273
			$(RM) $$($1_DELETES_FILE) && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   274
			$$($1_CAPTURE_DELETES) \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   275
			$(CAT) $$($1_DELETES_FILE) > $$($1_DELETESS_FILE) && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   276
			if [ -s $$($1_DELETESS_FILE) ]; then \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   277
				$(ECHO) "  deleting" `$(WC) -l $$($1_DELETESS_FILE) | $(AWK) '{ print $$$$1 }'` files && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   278
	                        $(ZIP) -q -d $$@ `$(CAT) $$($1_DELETESS_FILE)` ; \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   279
			fi && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   280
			$$($1_UPDATE_CONTENTS) true && \
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   281
			$$($1_JARINDEX) && \
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   282
			$$($1_TOUCH_API_FILES) true && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   283
			$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name _the.package.api.notify $(FIND_DELETE); true) &&) true ; \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   284
		fi ; \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   285
	else \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   286
		$(ECHO) Creating $$($1_NAME) && $(JAR) cfm $$@ $$($1_MANIFEST_FILE) && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   287
	        $$($1_SCAPTURE_CONTENTS) \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   288
		$$($1_SCAPTURE_METAINF) \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   289
		$$($1_SUPDATE_CONTENTS) \
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   290
		$$($1_JARINDEX) && \
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   291
		$$($1_TOUCH_API_FILES) true && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   292
		$(RM) -r $$($1_NATIVEAPI_NOTIFICATIONS_FILE) $$($1_NATIVEAPI_FILE) && \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   293
		$$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name "*.notify" $(FIND_DELETE); true) &&) true ; \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   294
	fi; 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   295
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   296
endef
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   297
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   298
define append_to
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   299
    $(ECHO) "$1" >> $2
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   300
endef
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   301
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   302
define SetupZipArchive
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   303
    # param 1 is for example ZIP_MYSOURCE
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   304
    # param 2,3,4,5,6,7,8,9 are named args.
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   305
    #    SRC,ZIP,INCLUDES,EXCLUDES,EXCLUDE_FILES,SUFFIXES,EXTRA_DEPS
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   306
    $(if $2,$1_$(strip $2))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   307
    $(if $3,$1_$(strip $3))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   308
    $(if $4,$1_$(strip $4))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   309
    $(if $5,$1_$(strip $5))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   310
    $(if $6,$1_$(strip $6))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   311
    $(if $7,$1_$(strip $7))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   312
    $(if $8,$1_$(strip $8))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   313
    $(if $9,$1_$(strip $9))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   314
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   315
    # Find all files in the source tree.
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   316
    $1_SUFFIX_FILTER := $$(patsubst %,-o -name $(DQUOTE)*%$(DQUOTE),$$($1_SUFFIXES))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   317
    $1_ALL_SRCS := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i -type f -a ! -name "_the.*" \( -name FALSE_DUMMY  $$($1_SUFFIX_FILTER) \) ))
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   318
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   319
    ifneq ($$($1_INCLUDES),)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   320
        $1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES))))
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   321
        ifneq ($$($1_SUFFIXES),)
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   322
            $1_ZIP_INCLUDES := $$(foreach s,$$($1_SUFFIXES),\
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   323
		$$(addprefix -i$(SPACE)$(DQUOTE),$$(addsuffix /*$$s$(DQUOTE),$$($1_INCLUDES))))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   324
        else
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   325
            $1_ZIP_INCLUDES := $$(addprefix -i$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_INCLUDES)))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   326
        endif
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   327
        $1_ALL_SRCS     := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_SRCS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   328
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   329
    ifneq ($$($1_EXCLUDES),)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   330
        $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES))))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   331
        $1_ZIP_EXCLUDES := $$(addprefix -x$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_EXCLUDES)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   332
        $1_ALL_SRCS     := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   333
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   334
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   335
    # Use a slightly shorter name for logging, but with enough path to identify this zip.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   336
    $1_NAME:=$$(subst $$(OUTPUT_ROOT)/,,$$($1_ZIP))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   337
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   338
    # Now $1_ALL_SRCS should contain all sources that are going to be put into the zip.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   339
    # I.e. the zip -i and -x options should match the filtering done in the makefile.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   340
    # Explicitly excluded files can be given with absolute path. The patsubst solution
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   341
    # isn't perfect but the likelyhood of an absolute path to match something in a src
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   342
    # dir is very small.
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   343
    $$($1_ZIP) : $$($1_ALL_SRCS) $$($1_EXTRA_DEPS)
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   344
		$(MKDIR) -p $$(@D)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   345
		$(ECHO) Updating $$($1_NAME)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   346
		$$(foreach i,$$($1_SRC),(cd $$i && $(ZIP) -qru $$@ . $$($1_ZIP_INCLUDES) $$($1_ZIP_EXCLUDES) -x \*_the.\* $$(addprefix -x$(SPACE),$$(patsubst $$i/%,%,$$($1_EXCLUDE_FILES)))) ;) true
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   347
		$(TOUCH) $$@
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   348
endef
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   349
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   350
define add_file_to_copy
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   351
    # param 1 = BUILD_MYPACKAGE
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   352
    # parma 2 = The source file to copy.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   353
    $2_TARGET:=$2
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   354
    # Remove the source prefix. 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   355
    $$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   356
    # Now we can setup the depency that will trigger the copying.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   357
    $$($1_BIN)$$($2_TARGET) : $2
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   358
	$(MKDIR) -p $$(@D)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   359
	$(CP) $$< $$@
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   360
	$(CHMOD) -f ug+w $$@
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   361
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   362
    # And do not forget this target
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   363
    $1_ALL_COPY_TARGETS += $$($1_BIN)$$($2_TARGET)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   364
endef
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   365
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   366
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   367
# This macro is used only for properties files that are to be
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   368
# copied over to the classes directory in cleaned form:
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   369
# Previously this was inconsistently done in different repositories.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   370
# This is the new clean standard.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   371
define add_file_to_copy_and_clean
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   372
    # param 1 = BUILD_MYPACKAGE
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   373
    # parma 2 = The source file to copy and clean.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   374
    $2_TARGET:=$2
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   375
    # Remove the source prefix. 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   376
    $$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   377
    # Now we can setup the depency that will trigger the copying.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   378
    $$($1_BIN)$$($2_TARGET) : $2
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   379
	$(MKDIR) -p $$(@D)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   380
	$(ECHO) Cleaning $$($2_TARGET)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   381
	$(CAT) $$< | $(SED) -e 's/\([^\\]\):/\1\\:/g' -e  's/\([^\\]\)=/\1\\=/g' -e 's/#.*/#/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   382
                   | $(SED) \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   383
-e 's/\\u0020/\x20/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   384
-e 's/\\u003A/\x3A/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   385
-e 's/\\u006B/\x6B/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   386
-e 's/\\u0075/\x75/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   387
-e 's/\\u00A0/\xA0/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   388
-e 's/\\u00A3/\xA3/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   389
-e 's/\\u00B0/\xB0/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   390
-e 's/\\u00B7/\xB7/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   391
-e 's/\\u00BA/\xBA/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   392
-e 's/\\u00BF/\xBF/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   393
-e 's/\\u00C0/\xC0/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   394
-e 's/\\u00C1/\xC1/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   395
-e 's/\\u00C2/\xC2/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   396
-e 's/\\u00C4/\xC4/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   397
-e 's/\\u00C5/\xC5/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   398
-e 's/\\u00C8/\xC8/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   399
-e 's/\\u00C9/\xC9/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   400
-e 's/\\u00CA/\xCA/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   401
-e 's/\\u00CD/\xCD/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   402
-e 's/\\u00CE/\xCE/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   403
-e 's/\\u00D3/\xD3/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   404
-e 's/\\u00D4/\xD4/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   405
-e 's/\\u00D6/\xD6/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   406
-e 's/\\u00DA/\xDA/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   407
-e 's/\\u00DC/\xDC/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   408
-e 's/\\u00DD/\xDD/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   409
-e 's/\\u00DF/\xDF/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   410
-e 's/\\u00E0/\xE0/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   411
-e 's/\\u00E1/\xE1/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   412
-e 's/\\u00E2/\xE2/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   413
-e 's/\\u00E3/\xE3/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   414
-e 's/\\u00E4/\xE4/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   415
-e 's/\\u00E5/\xE5/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   416
-e 's/\\u00E6/\xE6/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   417
-e 's/\\u00E7/\xE7/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   418
-e 's/\\u00E8/\xE8/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   419
-e 's/\\u00E9/\xE9/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   420
-e 's/\\u00EA/\xEA/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   421
-e 's/\\u00EB/\xEB/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   422
-e 's/\\u00EC/\xEC/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   423
-e 's/\\u00ED/\xED/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   424
-e 's/\\u00EE/\xEE/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   425
-e 's/\\u00EF/\xEF/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   426
-e 's/\\u00F1/\xF1/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   427
-e 's/\\u00F2/\xF2/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   428
-e 's/\\u00F3/\xF3/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   429
-e 's/\\u00F4/\xF4/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   430
-e 's/\\u00F5/\xF5/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   431
-e 's/\\u00F6/\xF6/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   432
-e 's/\\u00F9/\xF9/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   433
-e 's/\\u00FA/\xFA/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   434
-e 's/\\u00FC/\xFC/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   435
-e 's/\\u0020/\x20/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   436
-e 's/\\u003f/\x3f/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   437
-e 's/\\u006f/\x6f/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   438
-e 's/\\u0075/\x75/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   439
-e 's/\\u00a0/\xa0/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   440
-e 's/\\u00a3/\xa3/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   441
-e 's/\\u00b0/\xb0/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   442
-e 's/\\u00ba/\xba/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   443
-e 's/\\u00bf/\xbf/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   444
-e 's/\\u00c1/\xc1/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   445
-e 's/\\u00c4/\xc4/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   446
-e 's/\\u00c5/\xc5/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   447
-e 's/\\u00c8/\xc8/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   448
-e 's/\\u00c9/\xc9/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   449
-e 's/\\u00ca/\xca/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   450
-e 's/\\u00cd/\xcd/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   451
-e 's/\\u00d6/\xd6/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   452
-e 's/\\u00dc/\xdc/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   453
-e 's/\\u00dd/\xdd/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   454
-e 's/\\u00df/\xdf/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   455
-e 's/\\u00e0/\xe0/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   456
-e 's/\\u00e1/\xe1/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   457
-e 's/\\u00e2/\xe2/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   458
-e 's/\\u00e3/\xe3/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   459
-e 's/\\u00e4/\xe4/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   460
-e 's/\\u00e5/\xe5/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   461
-e 's/\\u00e7/\xe7/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   462
-e 's/\\u00e8/\xe8/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   463
-e 's/\\u00e9/\xe9/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   464
-e 's/\\u00ea/\xea/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   465
-e 's/\\u00eb/\xeb/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   466
-e 's/\\u00ec/\xec/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   467
-e 's/\\u00ed/\xed/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   468
-e 's/\\u00ee/\xee/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   469
-e 's/\\u00ef/\xef/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   470
-e 's/\\u00f0/\xf0/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   471
-e 's/\\u00f1/\xf1/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   472
-e 's/\\u00f2/\xf2/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   473
-e 's/\\u00f3/\xf3/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   474
-e 's/\\u00f4/\xf4/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   475
-e 's/\\u00f5/\xf5/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   476
-e 's/\\u00f6/\xf6/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   477
-e 's/\\u00f7/\xf7/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   478
-e 's/\\u00f8/\xf8/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   479
-e 's/\\u00f9/\xf9/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   480
-e 's/\\u00fa/\xfa/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   481
-e 's/\\u00fc/\xfc/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   482
-e 's/\\u00ff/\xff/g' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   483
		   | $(SED) -e '/^#/d' -e '/^$$$$/d' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   484
		            -e :a -e '/\\$$$$/N; s/\\\n//; ta' \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   485
			    -e 's/^[ \t]*//;s/[ \t]*$$$$//' \
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   486
			    -e 's/\\=/=/' | LANG=C $(SORT) > $$@
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   487
	$(CHMOD) -f ug+w $$@
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   488
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   489
    # And do not forget this target
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   490
    $1_ALL_COPY_CLEAN_TARGETS += $$($1_BIN)$$($2_TARGET)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   491
endef
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   492
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   493
define add_java_package
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   494
    # param 1 = BUILD_MYPACKAGE
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   495
    # param 2 = the package target file (_the.package)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   496
    # param 3 = src roots, all of them, separated with space
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   497
    # param 4 = bin root
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   498
    # param 5 = include these dependecies
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   499
    # param 6 = not used
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   500
    # param 7 = if non-empty, then use -Xdeps and -Xpubapi
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   501
    # param 8 = xremote configuration, or empty.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   502
    # param 9 = javac command
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   503
    # param 10 = javac flags
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   504
    # param 11 = exclude these files!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   505
    # param 12 = only include these files!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   506
    # param 13 = javah command
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   507
    # param 14 = override src roots to be passed into -sourcepath, ugly ugly ugly, do not use this!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   508
    #            it is only here to workaround ugly things in the source code in the jdk that ought
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   509
    #            to be fixed instead!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   510
    ifdef $2_USED_BY
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   511
        $$(error Attempting to add the package $2 from $3 which is already added with sources from $$($2_USED_BY))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   512
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   513
    $2_USED_BY:=$3
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   514
    # Remove the _the.package file to get the target bin dir for the classes in this package.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   515
    $2_PACKAGE_BDIR:=$(dir $2)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   516
    # The source roots separated with a path separator (: or ; depending on os)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   517
    # (The patsubst is necessary to trim away unnecessary spaces.)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   518
    ifneq ($(14),)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   519
      $2_SRCROOTSC:=$(subst $(SPACE),$(PATH_SEP),$(strip $(patsubst %,%,$(14))))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   520
    else
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   521
      $2_SRCROOTSC:=$(subst $(SPACE),$(PATH_SEP),$(strip $(patsubst %,%,$3)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   522
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   523
    # Suffix the package path to the src roots, to get a list of all possible source locations
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   524
    # for this package.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   525
    $2_PACKAGE_SDIRS:=$$(foreach i,$3,$$(subst $4,$$i,$$($2_PACKAGE_BDIR)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   526
    # Use wildcard in all potential source locations to find the actual sources.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   527
    $2_PACKAGE_SRCS:=$$(filter-out $(11),$$(wildcard $$(addsuffix *.java,$$($2_PACKAGE_SDIRS))))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   528
    ifneq ($(12),)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   529
      # Filter on include file filter if set.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   530
      $2_PACKAGE_SRCS:=$$(filter $(12),$$($2_PACKAGE_SRCS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   531
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   532
    # Generate a proper package name from the file name.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   533
    $2_PACKAGE:=$(patsubst .%.,%,$(subst /,.,$(subst $4,,$(dir $2))))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   534
    # Use a javac server for this package?
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   535
    $2_REMOTE:=$8
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   536
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   537
    # Include previously generated information about what classes are output by this package
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   538
    # and what sources were used for the compile.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   539
    -include $$($2_PACKAGE_BDIR)_the.package.d
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   540
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   541
    # Include the notify, file, that exists if the package has been compiled during a previous make round.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   542
    # I.e. we are now dealing with a compile triggered by a pubapi change.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   543
    -include $$($2_PACKAGE_BDIR)_the.package.notify
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   544
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   545
    # If the notify file existed, then $$($2_NOTIFIED) will be equal to true.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   546
    # Use this information to block dependency tracking for this package. 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   547
    # This is necessary to cut the circular dependency chains that are so common in Java sources.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   548
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   549
    ifneq ($$($2_NOTIFIED),true)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   550
        # No need to block, since this package has not yet been recompiled.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   551
        # Thus include previously generated dependency information. (if it exists)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   552
        -include $$($2_PACKAGE_BDIR)_the.package.dddd
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   553
#    else
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   554
#        $$(info WAS NOTIFIED $2)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   555
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   556
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   557
    # Should we create proper dependencies between packages?
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   558
    ifneq ($7,)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   559
      # The flag: -XDpubapi:file=foo,package=mypack,notify writes a file foo that contains a 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   560
      # database of the public api of the classes supplied on the command line and are
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   561
      # inside the package mypack. If foo already exists, javac will only write to foo,
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   562
      # if there is a change in the pubapi. I.e. we can use the timestamp of this file
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   563
      # for triggering dependencies. "notify" means create a "file" suffixed with notify
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   564
      # if the pubapi really changed. 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   565
      $2_PUBAPI=-XDpubapi=file=$$($2_PACKAGE_BDIR)_the.package.api,notify,package=$$($2_PACKAGE)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   566
      # The flag: -XDnativeapi:file=foo,package=mypack,notify works similar to pubabi, but
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   567
      # instead tracks native methods. This file can be used to trigger dependencies for
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   568
      # native compilations.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   569
      $2_NATIVEAPI=-XDnativeapi=file=$$($2_PACKAGE_BDIR)_the.package.native,notify,package=$$($2_PACKAGE)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   570
      # The flag -XDdeps:file=foo.deps,groupon=package writes a foo.deps file containing packages dependencies:
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   571
      #     java.net : java.io java.lang
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   572
      # I.e. the classes in .net depend on the public apis of java.io and java.lang
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   573
      # The dependencies can be grouped on classes instead (groupon=class)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   574
      #     java.net.Bar : java.io.Socket java.lang.String
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   575
      $2_DEPS:=-XDdeps=file=$$($2_PACKAGE_BDIR)_the.package.deps,groupon=package
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   576
      # The next command rewrites the deps output from javac into a proper makefile dependency.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   577
      # The dependencies are always to an .api file generated by the pubapi option above.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   578
      # This is necessary since java package dependencies are almost always circular.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   579
      $2_APPEND_DEPS:=($(CAT) $$($2_PACKAGE_BDIR)_the.package.deps | $(TR) '.' '/' | $(AWK) '{ print "$4/" $$$$3 }' | sort > $$($2_PACKAGE_BDIR)_the.package.ddd && $(GREP) -f $$($2_PACKAGE_BDIR)_the.package.ddd $5 | $(AWK) '{ print "$(dir $2)_the.package : " $$$$1 "_the.package.api" }' > $$($2_PACKAGE_BDIR)_the.package.dddd ; true)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   580
    else
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   581
        # If not using dependencies, use $2 as fallback to trigger regeneration of javah header files.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   582
        # This will generate a surplus of header files, but this does not hurt compilation.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   583
        $2_NATIVEAPICHANGE_TRIGGER:=$2
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   584
        $2_FETCH_NATIVEAPICHANGE_CLASSES:=$(CAT) $$($2_PACKAGE_BDIR)_the.package.now|$(GREP) -v '\$$$$'|$(SED) -e 's|$4/||g'|$(SED) 's|.class||g'| $(TR) '/' '.'
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   585
    endif 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   586
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   587
    # The _the.package file is dependent on the java files inside the package.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   588
    # Fill the _the.package file with a list of the java files and compile them
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   589
    # to class files.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   590
    $2 : $$($2_PACKAGE_SRCS)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   591
	$(MKDIR) -p $$($2_PACKAGE_BDIR)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   592
	$(RM) $2.tmp
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   593
	$$(call ListPathsSafely,$2_PACKAGE_SRCS,\n, >> $2.tmp)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   594
	$(ECHO) $$($2_PACKAGE_BDIR)*.class | $(GREP) -v \*.class | $(TR) ' ' '\n' > $$($2_PACKAGE_BDIR)_the.package.prev
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   595
	$(RM) $$($2_PACKAGE_BDIR)*.class $$($2_PACKAGE_BDIR)*.notify $$($2_PACKAGE_BDIR)*.deleted
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   596
	$(ECHO) Compiling `$(WC) $2.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files in package $(patsubst $4/%/,%,$(dir $2.tmp))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   597
	$9 $$($2_REMOTE) $$($2_DEPS) $$($2_PUBAPI) $$($2_NATIVEAPI) $(10) -implicit:none -sourcepath "$$($2_SRCROOTSC)" -d $4 @$2.tmp
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   598
	$(ECHO) $$($2_PACKAGE_BDIR)*.class | $(GREP) -v \*.class | $(TR) ' ' '\n' > $$($2_PACKAGE_BDIR)_the.package.now
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   599
	($(GREP) -xvf $$($2_PACKAGE_BDIR)_the.package.now $$($2_PACKAGE_BDIR)_the.package.prev > $$($2_PACKAGE_BDIR)_the.package.deleted;true)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   600
	$(ECHO) $1_CLASSES += `$(CAT) $$($2_PACKAGE_BDIR)_the.package.now` | \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   601
		$(SED) 's/\$$$$/\$$$$\$$$$/g' > $$($2_PACKAGE_BDIR)_the.package.d
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   602
	$(ECHO) $1_JAVAS += $$($2_PACKAGE_SRCS) >> $$($2_PACKAGE_BDIR)_the.package.d
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   603
	$(ECHO) $2_NOTIFIED:=true > $$($2_PACKAGE_BDIR)_the.package.notify
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   604
	$$($2_APPEND_DEPS)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   605
	$$($2_COPY_FILES)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   606
	$(MV) -f $2.tmp $2
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   607
endef
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   608
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   609
define remove_string
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   610
    $2 := $$(subst $1,,$$($2))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   611
endef
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   612
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   613
define replace_space_with_pathsep
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   614
    $1:=$(subst $(SPACE),$(PATH_SEP),$(strip $(patsubst %,%,$2)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   615
endef
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   616
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   617
define SetupJavaCompilation
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   618
    # param 1 is for example BUILD_MYPACKAGE
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   619
    # param 2,3,4,5,6,7,8 are named args.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   620
    #    SETUP:=must point to a previously setup java compiler, for example: SETUP:=BOOTJAVAC
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   621
    #    JVM:=path to ..bin/java
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   622
    #    ADD_JAVAC_FLAGS:=javac flags to append to the default ones.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   623
    #    SRC:=one or more directories to search for sources
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   624
    #    BIN:=store classes here
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   625
    #    INCLUDES:=myapp.foo means will only compile java files in myapp.foo or any of its sub-packages.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   626
    #    EXCLUDES:=myapp.foo means will do not compile java files in myapp.foo or any of its sub-packages.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   627
    #    COPY:=.prp means copy all prp files to the corresponding package in BIN.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   628
    #    CLEAN:=.properties means copy and clean all properties file to the corresponding package in BIN.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   629
    #    COPY_FILES:=myapp/foo/setting.txt means copy this file over to the package myapp/foo
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   630
    #    SRCZIP:=Create a src.zip based on the found sources and copied files.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   631
    #    INCLUDE_FILES:="com/sun/SolarisFoobar.java" means only compile this file!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   632
    #    EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   633
    #                   "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   634
    #    JAVAC_SOURCE_PATH_UGLY_OVERRIDE:=Don't use this. This forces an explicit -sourcepath to javac.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   635
    #                                     Its only here until we cleanup some nasty source code pasta in the jdk.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   636
    #    HEADERS:=path to directory where all generated c-headers are written.
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   637
    #    DEPENDS:=Extra dependecy
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   638
    $(if $2,$1_$(strip $2))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   639
    $(if $3,$1_$(strip $3))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   640
    $(if $4,$1_$(strip $4))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   641
    $(if $5,$1_$(strip $5))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   642
    $(if $6,$1_$(strip $6))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   643
    $(if $7,$1_$(strip $7))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   644
    $(if $8,$1_$(strip $8))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   645
    $(if $9,$1_$(strip $9))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   646
    $(if $(10),$1_$(strip $(10)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   647
    $(if $(11),$1_$(strip $(11)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   648
    $(if $(12),$1_$(strip $(12)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   649
    $(if $(13),$1_$(strip $(13)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   650
    $(if $(14),$1_$(strip $(14)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   651
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   652
# Extract the info from the java compiler setup.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   653
$1_MODE := $$($$($1_SETUP)_MODE)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   654
ifneq (SINGLE_THREADED_BATCH,$$($1_MODE))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   655
    ifneq (MULTI_CORE_CONCURRENT,$$($1_MODE))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   656
        $$(error The Java compilation $1 refers to a non-existant java compiler setup $$($1_SETUP))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   657
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   658
endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   659
$1_USE_DEPS := $$($$($1_SETUP)_USE_DEPS)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   660
$1_REMOTE := $$($$($1_SETUP)_REMOTE)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   661
$1_JVM   := $$($$($1_SETUP)_JVM)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   662
$1_JAVAC := $$($$($1_SETUP)_JAVAC)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   663
$1_JAVAH := $$($$($1_SETUP)_JAVAH)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   664
$1_FLAGS := $$($$($1_SETUP)_FLAGS) $(JAVAC_FLAGS) $$($1_ADD_JAVAC_FLAGS)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   665
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   666
# Handle addons and overrides.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   667
$1_SRC:=$$(call ADD_SRCS,$$($1_SRC))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   668
# Make sure the dirs exist.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   669
$$(shell $(MKDIR) -p $$($1_SRC) $$($1_BIN))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   670
# Find all files in the source trees.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   671
$1_ALL_SRCS := $$(filter-out $(OVR_SRCS),$$(foreach i,$$($1_SRC),$$(shell $(FIND) $$i -type f)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   672
# Extract the java files.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   673
ifneq ($$($1_EXCLUDE_FILES),)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   674
  $1_EXCLUDE_FILES_PATTERN:=$$(addprefix %,$$($1_EXCLUDE_FILES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   675
endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   676
$1_SRCS     := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$(filter %.java,$$($1_ALL_SRCS)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   677
ifneq ($$($1_INCLUDE_FILES),)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   678
  $1_INCLUDE_FILES:=$$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$($1_INCLUDE_FILES)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   679
  $1_SRCS := $$(filter $$($1_INCLUDE_FILES), $$($1_SRCS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   680
endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   681
$1_PKGS     := $$(sort $$(dir $$($1_SRCS)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   682
# Remove the source root from each found path.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   683
$$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$1_PKGS)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   684
$1_PKGS     := $$(sort $$($1_PKGS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   685
# There can be only a single bin dir root, no need to foreach over the roots.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   686
$1_BINS     := $$(shell $(FIND) $$($1_BIN) -name "*.class")
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   687
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   688
# Now we have a list of all java files to compile: $$($1_SRCS)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   689
# and we have a list of all existing class files: $$($1_BINS)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   690
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   691
# Prepend the source/bin path to the filter expressions.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   692
ifneq ($$($1_INCLUDES),)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   693
  $1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES))))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   694
  $1_PKG_INCLUDES := $$(addprefix /,$$(addsuffix /%,$$($1_INCLUDES)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   695
  $1_BIN_INCLUDES := $$(addprefix $$($1_BIN)/,$$(addsuffix /%,$$($1_INCLUDES)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   696
  $1_SRCS     := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   697
  $1_PKGS     := $$(filter $$($1_PKG_INCLUDES),$$($1_PKGS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   698
  $1_BINS     := $$(filter $$($1_BIN_INCLUDES),$$($1_BINS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   699
endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   700
ifneq ($$($1_EXCLUDES),)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   701
  $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES))))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   702
  $1_PKG_EXCLUDES := $$(addprefix /,$$(addsuffix /%,$$($1_EXCLUDES)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   703
  $1_BIN_EXCLUDES := $$(addprefix $$($1_BIN)/,$$(addsuffix /%,$$($1_EXCLUDES)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   704
  $1_SRCS     := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   705
  $1_PKGS     := $$(filter-out $$($1_PKG_EXCLUDES),$$($1_PKGS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   706
  $1_BINS     := $$(filter-out $$($1_BIN_EXCLUDES),$$($1_BINS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   707
endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   708
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   709
# Find all files to be copied from source to bin.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   710
ifneq (,$$($1_COPY))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   711
    # Rewrite list of patterns into a find statement.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   712
    $1_COPY_PATTERN:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_COPY))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   713
    # Search for all files to be copied.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   714
    $1_ALL_COPIES := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i \( $$($1_COPY_PATTERN) \) -a -type f))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   715
    # Copy these explicitly
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   716
    $1_ALL_COPIES += $$($1_COPY_FILES)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   717
    # Copy must also respect filters.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   718
    ifneq (,$$($1_INCLUDES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   719
        $1_ALL_COPIES := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_COPIES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   720
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   721
    ifneq (,$$($1_EXCLUDES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   722
        $1_ALL_COPIES := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_COPIES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   723
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   724
    ifneq (,$$($1_EXCLUDE_FILES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   725
        $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_COPIES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   726
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   727
    # All files below META-INF are always copied.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   728
    $1_ALL_COPIES += $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i/META-INF -type f 2> /dev/null))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   729
    ifneq (,$$($1_ALL_COPIES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   730
        # Yep, there are files to be copied!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   731
        $1_ALL_COPY_TARGETS:=
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   732
        $$(foreach i,$$($1_ALL_COPIES),$$(eval $$(call add_file_to_copy,$1,$$i)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   733
        # Now we can depend on $$($1_ALL_COPY_TARGETS) to copy all files!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   734
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   735
endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   736
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   737
# Find all property files to be copied and cleaned from source to bin.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   738
ifneq (,$$($1_CLEAN))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   739
    # Rewrite list of patterns into a find statement.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   740
    $1_CLEAN_PATTERN:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_CLEAN))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   741
    # Search for all files to be copied.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   742
    $1_ALL_CLEANS := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i \( $$($1_CLEAN_PATTERN) \) -a -type f))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   743
    # Copy and clean must also respect filters.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   744
    ifneq (,$$($1_INCLUDES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   745
        $1_ALL_CLEANS := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_CLEANS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   746
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   747
    ifneq (,$$($1_EXCLUDES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   748
        $1_ALL_CLEANS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_CLEANS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   749
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   750
    ifneq (,$$($1_EXCLUDE_FILES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   751
        $1_ALL_CLEANS := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_CLEANS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   752
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   753
    ifneq (,$$($1_ALL_CLEANS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   754
        # Yep, there are files to be copied and cleaned!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   755
        $1_ALL_COPY_CLEAN_TARGETS:=
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   756
        $$(foreach i,$$($1_ALL_CLEANS),$$(eval $$(call add_file_to_copy_and_clean,$1,$$i)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   757
        # Now we can depend on $$($1_ALL_COPY_CLEAN_TARGETS) to copy all files!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   758
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   759
endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   760
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   761
# Find all the directories that contain java sources, each directory
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   762
# corresponds to a package because we expect the source
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   763
# code to be organized in this standardized way!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   764
$1_SDIRS := $$(sort $$(dir $$($1_SRCS)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   765
# Now prefix each package with the bin root.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   766
$1_BDIRS := $$(foreach i,$$($1_PKGS),$$(addprefix $$($1_BIN),$$i))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   767
# Now create a list of the packages that are about to compile. This list is
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   768
# later used to filter out dependencies that point outside of this set.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   769
$$(shell $(RM) $$($1_BIN)/_the.list_of_packages)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   770
$$(eval $$(call ListPathsSafelyNow,$1_BDIRS,\n, >> $$($1_BIN)/_the.list_of_packages))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   771
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   772
ifeq ($$($1_MODE),SINGLE_THREADED_BATCH)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   773
    # Ok, we will feed all the found java files into a single javac invocation.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   774
    # There can be no dependency checking, nor incremental builds. It is
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   775
    # the best we can do with the old javac. If the javac supports a javac server
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   776
    # then we can use the javac server.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   777
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   778
    # We can depend on this target file to trigger a regeneration of all the sources
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   779
    $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/_the.batch
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   780
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   781
    # Prep the source paths.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   782
    ifneq ($$($1_JAVAC_SOURCE_PATH_UGLY_OVERRIDE),)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   783
      $$(eval $$(call replace_space_with_pathsep,$1_SRCROOTSC,$$($1_JAVAC_SOURCE_PATH_UGLY_OVERRIDE)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   784
    else
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   785
      $$(eval $$(call replace_space_with_pathsep,$1_SRCROOTSC,$$($1_SRC)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   786
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   787
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   788
    ifneq (,$$($1_HEADERS))
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   789
      $1_HEADERS_ARG := -h $$($1_HEADERS)
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   790
    endif
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   791
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   792
    # Create a sed expression to remove the source roots and to replace / with .
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   793
    # and remove .java at the end. 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   794
    $1_REWRITE_INTO_CLASSES:=$$(foreach i,$$($1_SRC),-e 's|$$i/||g') -e 's|/|.|g' -e 's|.java$$$$||g'
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   795
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   796
    # Here is the batch rules that depends on all the sources.
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   797
    $$($1_BIN)/_the.batch: $$($1_SRCS) $$($1_DEPENDS)
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   798
	$(MKDIR) -p $$(@D)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   799
	$(RM) $$($1_BIN)/_the.batch $$($1_BIN)/_the.batch.tmp
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   800
	$$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   801
	$(ECHO) Compiling `$(WC) $$($1_BIN)/_the.batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files in batch $1
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   802
	($$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) -implicit:none -sourcepath "$$($1_SRCROOTSC)" -d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_BIN)/_the.batch.tmp && \
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   803
         $(MV) $$($1_BIN)/_the.batch.tmp $$($1_BIN)/_the.batch)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   804
else
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   805
    # Ok, we have a modern javac server running!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   806
    # Since a single Java file can generate zero to an infinity number of .class files
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   807
    # the exact number and names of the .class files will only be known after the compile.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   808
    # Thus after the compile, a list of the generated classes will be stored in _the.package.d
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   809
    # which is included by the makefile during the next compile. These .d files will
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   810
    # add the generated class names to the BUILD_MYPACKAGE_CLASSES variable and used java file names
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   811
    # to the BUILD_MYPACKAGE_JAVAS variable.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   812
    $1_CLASSES := 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   813
    $1_JAVAS   := 
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   814
    # Create a file in each package that represents the package dependency.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   815
    # This file (_the.package) will also contain a list of the source files
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   816
    # to be compiled for this package.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   817
    $1 := $$(sort $$(patsubst %,%_the.package,$$($1_BDIRS)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   818
    # Now call add_java_package for each package to create the dependencies.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   819
    $$(foreach p,$$($1),$$(eval $$(call add_java_package,$1,$$p,$$($1_SRC),$$($1_BIN),$$($1_BIN)/_the.list_of_packages,NOTUSED,$$($1_USE_DEPS),$$($1_REMOTE),$$($1_JVM) $$($1_JAVAC),$$($1_FLAGS),$$($1_EXCLUDE_FILES_PATTERN) $(OVR_SRCS),$$($1_INCLUDE_FILES),$$($1_JVM) $$($1_JAVAH),$$($1_JAVAC_SOURCE_PATH_UGLY_OVERRIDE))))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   820
    # All dependencies are setup, now we only need to depend on $1 (aka $(BUILD_MYPACKAGE))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   821
    # and they will automatically be built!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   822
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   823
    # Now add on any files to copy targets
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   824
    $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   825
    # Remove the set of found classes from the set of all previously known classes
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   826
    # and the remainder is the set of missing classes.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   827
    $1_MISSING_CLASSES:=$$(filter-out $$($1_BINS),$$($1_CLASSES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   828
    $1_PKGS_MISSING_CLASSES:=$$(sort $$(dir $$($1_MISSING_CLASSES)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   829
    # Remove the set of found java files from the set of all previously known java files
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   830
    # the remainder is Java files that have gone missing.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   831
    $1_MISSING_JAVAS:=$$(filter-out $$($1_SRCS),$$($1_JAVAS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   832
    $1_PKGS_MISSING_JAVAS:=$$(sort $$(dir $$($1_MISSING_JAVAS)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   833
    # Remove each source root from the found paths.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   834
    $$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$1_PKGS_MISSING_JAVAS)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   835
    # Finally remove duplicates and prefix with the binary path instead.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   836
    $1_PKGS_MISSING_JAVAS:= $$(addprefix $$($1_BIN),$$(sort $$($1_PKGS_MISSING_JAVAS)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   837
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   838
    # Remove the set of all theoretical classes from the set of found classes.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   839
    # the remainder is the set of superfluous classes.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   840
    $1_SUPERFLUOUS_CLASSES:=$$(sort $$(filter-out $$($1_CLASSES),$$($1_BINS)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   841
    $1_PKGS_SUPERFLUOUS_CLASSES:=$$(sort $$(dir $$($1_SUPERFLUOUS_CLASSES)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   842
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   843
    # Now delete the _the.package files inside the problematic dirs.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   844
    # This will force a rebuild of these packages!
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   845
    $1_FOO:=$$(sort $$($1_PKGS_MISSING_CLASSES) \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   846
                                                 $$($1_PKGS_SUPERFLUOUS_CLASSES) \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   847
                                                 $$($1_PKGS_MISSING_JAVAS))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   848
#    ifneq (,$$($1_FOO))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   849
#            $$(info MESSED UP PACKAGES $$($1_FOO))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   850
#    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   851
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   852
    $$(shell $(RM) $$(addsuffix _the.package,$$(sort $$($1_PKGS_MISSING_CLASSES) \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   853
                                                 $$($1_PKGS_SUPERFLUOUS_CLASSES) \
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   854
                                                 $$($1_PKGS_MISSING_JAVAS))))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   855
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   856
    # Normal makefile dependencies based on timestamps will detect the normal use case
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   857
    # when Java files are simply added or modified.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   858
endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   859
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   860
ifneq (,$$($1_JAR))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   861
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   862
    ifeq (,$$($1_SUFFIXES))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   863
        $1_SUFFIXES:=.class $$($1_CLEAN) $$($1_COPY)
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   864
    endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   865
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   866
    # A jar file was specified. Set it up.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   867
    $$(eval $$(call SetupArchive,ARCHIVE_$1,$$($1),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   868
	SRCS:=$$($1_BIN),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   869
	SUFFIXES:=$$($1_SUFFIXES),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   870
	EXCLUDE:=$$($1_EXCLUDES),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   871
	INCLUDES:=$$($1_INCLUDES),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   872
	EXTRA_FILES:=$$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   873
	JAR:=$$($1_JAR),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   874
	JARMAIN:=$$($1_JARMAIN),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   875
	MANIFEST:=$$($1_MANIFEST),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   876
	EXTRA_MANIFEST_ATTR:=$$($1_EXTRA_MANIFEST_ATTR),\
12801
948f8ad66ee7 7170079: Adjustments to build-infra makefiles
erikj
parents: 12258
diff changeset
   877
	JARINDEX:=$$($1_JARINDEX),\
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   878
	HEADERS:=$$($1_HEADERS),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   879
	SETUP:=$$($1_SETUP)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   880
endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   881
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   882
ifneq (,$$($1_SRCZIP))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   883
    # A srczip file was specified. Set it up.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   884
    $$(eval $$(call SetupZipArchive,ARCHIVE_$1,\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   885
		SRC:=$$($1_SRC),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   886
		ZIP:=$$($1_SRCZIP),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   887
		INCLUDES:=$$($1_INCLUDES),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   888
		EXCLUDES:=$$($1_EXCLUDES),\
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   889
		EXCLUDE_FILES:=$$($1_EXCLUDE_FILES)))
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   890
endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   891
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   892
endef
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   893
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   894