jdk/makefiles/sun/security/ec/Makefile
changeset 13164 72c5d01a857d
parent 13082 9b19b2302c28
child 13167 efec101d7d87
equal deleted inserted replaced
13082:9b19b2302c28 13164:72c5d01a857d
     1 #
       
     2 # Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
       
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4 #
       
     5 # This code is free software; you can redistribute it and/or modify it
       
     6 # under the terms of the GNU General Public License version 2 only, as
       
     7 # published by the Free Software Foundation.  Oracle designates this
       
     8 # particular file as subject to the "Classpath" exception as provided
       
     9 # by Oracle in the LICENSE file that accompanied this code.
       
    10 #
       
    11 # This code is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14 # version 2 for more details (a copy is included in the LICENSE file that
       
    15 # accompanied this code).
       
    16 #
       
    17 # You should have received a copy of the GNU General Public License version
       
    18 # 2 along with this work; if not, write to the Free Software Foundation,
       
    19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20 #
       
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22 # or visit www.oracle.com if you need additional information or have any
       
    23 # questions.
       
    24 #
       
    25 
       
    26 #
       
    27 # Makefile for building sunec.jar and sunec native library.
       
    28 #
       
    29 # This file was derived from make/com/sun/crypto/provider/Makefile.
       
    30 #
       
    31 
       
    32 #
       
    33 # (The terms "OpenJDK" and "JDK" below refer to OpenJDK and Sun JDK builds
       
    34 # respectively.)
       
    35 #
       
    36 # JCE builds are very different between OpenJDK and JDK.  The OpenJDK JCE
       
    37 # jar files do not require signing, but those for JDK do.  If an unsigned
       
    38 # jar file is installed into JDK, things will break when the crypto
       
    39 # routines are called.
       
    40 #
       
    41 # This Makefile does the "real" build of the JCE files.  For OpenJDK,
       
    42 # the jar files built here are installed directly into the OpenJDK.
       
    43 #
       
    44 # For JDK, the binaries use pre-built/pre-signed binary files stored in
       
    45 # the closed workspace that are not shipped in the OpenJDK workspaces.
       
    46 # We still build the JDK files here to verify the files compile, and in
       
    47 # preparation for possible signing.  Developers working on JCE in JDK
       
    48 # must sign the JCE files before testing.  The JCE signing key is kept
       
    49 # separate from the JDK workspace to prevent its disclosure.
       
    50 #
       
    51 # SPECIAL NOTE TO JCE/JDK developers:  The source files must eventually
       
    52 # be built, signed, and then the resulting jar files MUST BE CHECKED
       
    53 # INTO THE CLOSED PART OF THE WORKSPACE*.  This separate step *MUST NOT
       
    54 # BE FORGOTTEN*, otherwise a bug fixed in the source code will not be
       
    55 # reflected in the shipped binaries.  The "release" target should be
       
    56 # used to generate the required files.
       
    57 #
       
    58 # There are a number of targets to help both JDK/OpenJDK developers.
       
    59 #
       
    60 # Main Targets (JDK/OPENJDK):
       
    61 #
       
    62 #     all/clobber/clean		The usual, plus the native libraries.
       
    63 #				    If OpenJDK, installs sunec.jar.
       
    64 #				    If JDK, installs prebuilt
       
    65 #				    sunec.jar.
       
    66 #
       
    67 #     jar			Builds/installs sunec.jar
       
    68 #				    If OpenJDK, does not sign.
       
    69 #				    If JDK, tries to sign.
       
    70 #
       
    71 # Other lesser-used Targets (JDK/OPENJDK):
       
    72 #
       
    73 #     build-jar			Builds sunec.jar
       
    74 #				    (does not sign/install)
       
    75 #
       
    76 #     install-jar		Alias for "jar" above.
       
    77 #
       
    78 # Other targets (JDK only):
       
    79 #
       
    80 #     sign			Alias for sign-jar
       
    81 #	  sign-jar		Builds/signs sunec.jar (no install)
       
    82 #
       
    83 #     release			Builds all targets in preparation
       
    84 #				for workspace integration.
       
    85 #
       
    86 #     install-prebuilt		Installs the pre-built jar files
       
    87 #
       
    88 # This makefile was written to support parallel target execution.
       
    89 #
       
    90 
       
    91 BUILDDIR = ../../..
       
    92 PACKAGE = sun.security.ec
       
    93 PRODUCT = sun
       
    94 
       
    95 #
       
    96 # The following is for when we need to do postprocessing
       
    97 # (signing) against a read-only build.  If the OUTPUTDIR
       
    98 # isn't writable, the build currently crashes out.
       
    99 #
       
   100 ifndef OPENJDK
       
   101   ifdef ALT_JCE_BUILD_DIR
       
   102     # =====================================================
       
   103     # Where to place the output, in case we're building from a read-only
       
   104     # build area.  (e.g. a release engineering build.)
       
   105     JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR}
       
   106     IGNORE_WRITABLE_OUTPUTDIR_TEST=true
       
   107   else
       
   108     JCE_BUILD_DIR=${TEMPDIR}
       
   109   endif
       
   110 endif
       
   111 
       
   112 JAVAC_MAX_WARNINGS=false
       
   113 JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation
       
   114 JAVAC_WARNINGS_FATAL=true
       
   115 include $(BUILDDIR)/common/Defs.gmk
       
   116 
       
   117 #
       
   118 # Location for the newly built classfiles.
       
   119 #
       
   120 CLASSDESTDIR = $(TEMPDIR)/classes
       
   121 
       
   122 #
       
   123 # Java files
       
   124 #
       
   125 AUTO_FILES_JAVA_DIRS = $(PKGDIR)
       
   126 
       
   127 #
       
   128 # Exclude the sources that get built by ../other/Makefile
       
   129 #
       
   130 AUTO_JAVA_PRUNE = \
       
   131     ECKeyFactory.java \
       
   132     ECParameters.java \
       
   133     ECPrivateKeyImpl.java \
       
   134     ECPublicKeyImpl.java \
       
   135     NamedCurve.java
       
   136 
       
   137 #
       
   138 # Some licensees do not get the native ECC sources, but we still need to
       
   139 # be able to build "all" for them.  Check here to see if the sources are
       
   140 # available.  If not, then skip them.
       
   141 #
       
   142 
       
   143 NATIVE_ECC_AVAILABLE := $(shell \
       
   144     if [ -d $(SHARE_SRC)/native/$(PKGDIR)/impl ] ; then \
       
   145 	$(ECHO) true; \
       
   146     else \
       
   147 	$(ECHO) false; \
       
   148     fi)
       
   149 
       
   150 ifeq ($(NATIVE_ECC_AVAILABLE), true)
       
   151 
       
   152   LIBRARY = sunec
       
   153 
       
   154   #
       
   155   # Java files that define native methods
       
   156   #
       
   157   FILES_export = \
       
   158       $(PKGDIR)/ECDHKeyAgreement.java \
       
   159       $(PKGDIR)/ECDSASignature.java \
       
   160       $(PKGDIR)/ECKeyPairGenerator.java
       
   161 
       
   162   JAVAHFLAGS = -bootclasspath \
       
   163     "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)"
       
   164 
       
   165   #
       
   166   # C and C++ files
       
   167   #
       
   168   include FILES_c.gmk
       
   169 
       
   170   FILES_cpp = ECC_JNI.cpp
       
   171 
       
   172   CPLUSPLUSLIBRARY=true
       
   173 
       
   174   FILES_m = mapfile-vers
       
   175 
       
   176   #
       
   177   # Find native code
       
   178   #
       
   179   vpath %.cpp $(SHARE_SRC)/native/$(PKGDIR)
       
   180 
       
   181   vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/impl
       
   182 
       
   183   #
       
   184   # Find include files
       
   185   #
       
   186   OTHER_INCLUDES += -I$(SHARE_SRC)/native/$(PKGDIR)/impl
       
   187 
       
   188   #
       
   189   # Compiler flags
       
   190   #
       
   191   OTHER_CFLAGS += -DMP_API_COMPATIBLE -DNSS_ECC_MORE_THAN_SUITE_B
       
   192 
       
   193   #
       
   194   # Libraries to link
       
   195   #
       
   196   ifneq ($(PLATFORM), windows)
       
   197     OTHER_LDLIBS = $(LIBCXX)
       
   198   endif
       
   199 
       
   200   include $(BUILDDIR)/common/Mapfile-vers.gmk
       
   201 
       
   202   include $(BUILDDIR)/common/Library.gmk
       
   203 
       
   204 else # NATIVE_ECC_AVAILABLE
       
   205 
       
   206   include $(BUILDDIR)/common/Classes.gmk
       
   207 
       
   208 endif # NATIVE_ECC_AVAILABLE
       
   209 
       
   210 #
       
   211 # We use a variety of subdirectories in the $(TEMPDIR) depending on what
       
   212 # part of the build we're doing.  Both OPENJDK/JDK builds are initially
       
   213 # done in the unsigned area.  When files are signed in JDK,
       
   214 # they will be placed in the appropriate area.
       
   215 #
       
   216 UNSIGNED_DIR = $(TEMPDIR)/unsigned
       
   217 
       
   218 include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
       
   219 
       
   220 #
       
   221 # Rules
       
   222 #
       
   223 
       
   224 ifdef OPENJDK
       
   225 all: build-jar install-jar
       
   226 else
       
   227 all: build-jar install-prebuilt
       
   228 	$(build-warning)
       
   229 endif
       
   230 
       
   231 
       
   232 # =====================================================
       
   233 # Build the unsigned sunec.jar file.
       
   234 #
       
   235 
       
   236 JAR_DESTFILE = $(EXTDIR)/sunec.jar
       
   237 
       
   238 #
       
   239 # Since the -C option to jar is used below, each directory entry must be
       
   240 # preceded with the appropriate directory to "cd" into.
       
   241 #
       
   242 JAR_DIRS = $(patsubst %, -C $(CLASSDESTDIR) %, $(AUTO_FILES_JAVA_DIRS))
       
   243 
       
   244 build-jar: $(UNSIGNED_DIR)/sunec.jar
       
   245 
       
   246 #
       
   247 # Build sunec.jar.
       
   248 #
       
   249 $(UNSIGNED_DIR)/sunec.jar: build
       
   250 	$(prep-target)
       
   251 	$(BOOT_JAR_CMD) cf $@ $(JAR_DIRS) \
       
   252 	    $(BOOT_JAR_JFLAGS)
       
   253 	@$(java-vm-cleanup)
       
   254 
       
   255 
       
   256 ifndef OPENJDK
       
   257 # =====================================================
       
   258 # Sign the provider jar file.  Not needed for OpenJDK.
       
   259 #
       
   260 
       
   261 SIGNED_DIR = $(JCE_BUILD_DIR)/signed
       
   262 
       
   263 sign: sign-jar
       
   264 
       
   265 sign-jar: $(SIGNED_DIR)/sunec.jar
       
   266 
       
   267 ifndef ALT_JCE_BUILD_DIR
       
   268 $(SIGNED_DIR)/sunec.jar: $(UNSIGNED_DIR)/sunec.jar
       
   269 else
       
   270 #
       
   271 # We have to remove the build dependency, otherwise, we'll try to rebuild it
       
   272 # which we can't do on a read-only filesystem.
       
   273 #
       
   274 $(SIGNED_DIR)/sunec.jar:
       
   275 	@if [ ! -r $(UNSIGNED_DIR)/sunec.jar ] ; then \
       
   276 	    $(ECHO) "Couldn't find $(UNSIGNED_DIR)/sunec.jar"; \
       
   277 	    exit 1; \
       
   278 	fi
       
   279 endif
       
   280 	$(call sign-file, $(UNSIGNED_DIR)/sunec.jar)
       
   281 
       
   282 
       
   283 # =====================================================
       
   284 # Create the Release Engineering files.  Signed builds, etc.
       
   285 #
       
   286 
       
   287 release: $(SIGNED_DIR)/sunec.jar
       
   288 	$(RM) $(JCE_BUILD_DIR)/release/sunec.jar
       
   289 	$(MKDIR) -p $(JCE_BUILD_DIR)/release
       
   290 	$(CP) $(SIGNED_DIR)/sunec.jar $(JCE_BUILD_DIR)/release
       
   291 	$(release-warning)
       
   292 
       
   293 endif # OPENJDK
       
   294 
       
   295 
       
   296 # =====================================================
       
   297 # Install routines.
       
   298 #
       
   299 
       
   300 #
       
   301 # Install sunec.jar, depending on which type is requested.
       
   302 #
       
   303 install-jar jar: $(JAR_DESTFILE)
       
   304 ifndef OPENJDK
       
   305 	$(release-warning)
       
   306 endif
       
   307 
       
   308 ifdef OPENJDK
       
   309 $(JAR_DESTFILE): $(UNSIGNED_DIR)/sunec.jar
       
   310 else
       
   311 $(JAR_DESTFILE): $(SIGNED_DIR)/sunec.jar
       
   312 endif
       
   313 	$(install-file)
       
   314 
       
   315 ifndef OPENJDK
       
   316 install-prebuilt:
       
   317 	@$(ECHO) "\n>>>Installing prebuilt SunEC provider..."
       
   318 	$(RM) $(JAR_DESTFILE)
       
   319 	$(CP) $(PREBUILT_DIR)/ec/sunec.jar $(JAR_DESTFILE)
       
   320 endif
       
   321 
       
   322 
       
   323 # =====================================================
       
   324 # Support routines.
       
   325 #
       
   326 
       
   327 clobber clean::
       
   328 	$(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
       
   329 
       
   330 .PHONY: build-jar jar install-jar
       
   331 ifndef OPENJDK
       
   332 .PHONY: sign sign-jar release install-prebuilt
       
   333 endif