jdk/makefiles/com/oracle/security/ucrypto/Makefile
changeset 12892 3ef14bab6254
parent 12891 5dbaa8f0f72e
child 12893 483a74a0b295
equal deleted inserted replaced
12891:5dbaa8f0f72e 12892:3ef14bab6254
     1 #
       
     2 # Copyright (c) 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 ucrypto.jar and its native libraries.
       
    28 #
       
    29 # This file was modified from make/sun/security/pkcs11/Makefile.
       
    30 #
       
    31 #
       
    32 # (The terms "OpenJDK" and "JDK" below refer to OpenJDK and Oracle
       
    33 # JDK builds respectively.)
       
    34 #
       
    35 # This Makefile does the "real" build of the Ucrypto provider files.
       
    36 # Since the sources are unavailable for OpenJDK, this Makefile is only
       
    37 # useful for JDK.
       
    38 #
       
    39 #
       
    40 # Main Targets (JDK on Solaris):
       
    41 #
       
    42 #     all                      The usual, ucrypto.jar plus the native libraries.
       
    43 #                                  builds and installs the prebuilt/signed jar.
       
    44 #
       
    45 #     clobber/clean            Cleans up the temp directory, ucrypto.jar, the
       
    46 #                              native libraries, and the config file from the
       
    47 #                              build area
       
    48 #
       
    49 #     jar                      Builds, signs and installs ucrypto.jar
       
    50 #                              (Can only be done on machines with access to
       
    51 #                               the signing keystore)
       
    52 #
       
    53 # Other lesser-used Targets (JDK on Solaris):
       
    54 #
       
    55 #     build-jar                Builds ucrypto.jar (no sign/install)
       
    56 #
       
    57 #     sign                     Builds/signs ucrypto.jar (no install)
       
    58 #
       
    59 #     release                  Builds all targets in preparation
       
    60 #                              for workspace integration.
       
    61 #                              (Can only be done on machines with access to
       
    62 #                               the signing keystore)
       
    63 #
       
    64 #     install-prebuilt         Installs the pre-built jar files
       
    65 #
       
    66 # NOTE: None of the above target will update the prebuilt provider binary
       
    67 # under the closed workspace. To update it, you must explicitly copy the
       
    68 # binary from either the tmp/signed or lib/ext directory.
       
    69 #
       
    70 # This makefile was written to support parallel target execution.
       
    71 #
       
    72 
       
    73 BUILDDIR = ../../../..
       
    74 
       
    75 include $(BUILDDIR)/common/Defs.gmk
       
    76 
       
    77 ifndef OPENJDK
       
    78   ifneq ($(PLATFORM), solaris)
       
    79     all:
       
    80   else
       
    81     PACKAGE = com.oracle.security.ucrypto
       
    82   LIBRARY = j2ucrypto
       
    83   PRODUCT = oracle
       
    84 
       
    85   #
       
    86   # The following is for when we need to do postprocessing
       
    87   # (signing/obfuscation) against a read-only build.  If the OUTPUTDIR
       
    88   # isn't writable, the build currently crashes out.
       
    89   #
       
    90   ifdef ALT_JCE_BUILD_DIR
       
    91     # =====================================================
       
    92     # Where to place the output, in case we're building from a read-only
       
    93     # build area.  (e.g. a release engineering build.)
       
    94     JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR}
       
    95     IGNORE_WRITABLE_OUTPUTDIR_TEST=true
       
    96   else
       
    97     JCE_BUILD_DIR=${TEMPDIR}
       
    98   endif
       
    99 
       
   100   JAVAC_MAX_WARNINGS=false
       
   101   JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation
       
   102   JAVAC_WARNINGS_FATAL=true
       
   103 
       
   104   #
       
   105   # C and Java Files
       
   106   #
       
   107   include FILES_c.gmk
       
   108 
       
   109   #
       
   110   # Subdirectories of these are automatically included.
       
   111   #
       
   112   AUTO_FILES_JAVA_DIRS = com/oracle/security/ucrypto
       
   113 
       
   114   #
       
   115   # Java files that define native methods
       
   116   #
       
   117   FILES_export = \
       
   118       com/oracle/security/ucrypto/UcryptoProvider.java \
       
   119       com/oracle/security/ucrypto/NativeCipher.java \
       
   120       com/oracle/security/ucrypto/NativeDigest.java \
       
   121       com/oracle/security/ucrypto/NativeKey.java \
       
   122       com/oracle/security/ucrypto/NativeRSASignature.java \
       
   123       com/oracle/security/ucrypto/NativeRSACipher.java
       
   124 
       
   125   #
       
   126   # Find native code
       
   127   #
       
   128   vpath %.c \
       
   129     $(CLOSED_PLATFORM_SRC)/native/com/oracle/security/ucrypto
       
   130 
       
   131   #
       
   132   # Find include files
       
   133   #
       
   134   OTHER_INCLUDES += \
       
   135     -I$(CLOSED_PLATFORM_SRC)/native/com/oracle/security/ucrypto
       
   136 
       
   137   #
       
   138   # Rules
       
   139   #
       
   140   CLASSDESTDIR = $(TEMPDIR)/classes
       
   141   JAVAHFLAGS = -bootclasspath \
       
   142     "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)"
       
   143 
       
   144   include $(BUILDDIR)/common/Mapfile-vers.gmk
       
   145   include $(BUILDDIR)/common/Library.gmk
       
   146 
       
   147   #
       
   148   # Libraries to link
       
   149   #
       
   150   OTHER_LDLIBS = -ldl
       
   151 
       
   152   # Default config file
       
   153   UCRYPTO_CFG_SRC   = $(CLOSED_SRC)/share/lib/security/ucrypto-solaris.cfg
       
   154   UCRYPTO_CFG_BUILD = $(LIBDIR)/security/ucrypto-solaris.cfg
       
   155 
       
   156   #
       
   157   # We use a variety of subdirectories in the $(TEMPDIR) depending on what
       
   158   # part of the build we're doing.  Build is initially done in the unsigned
       
   159   # area and when files are signed, they will be placed in the appropriate area.
       
   160   #
       
   161   UNSIGNED_DIR = $(TEMPDIR)/unsigned
       
   162 
       
   163   #
       
   164   # Rules
       
   165   #
       
   166   all: ucrypto-cfg build-jar install-prebuilt
       
   167 	$(build-warning)
       
   168 
       
   169   ucrypto-cfg: $(UCRYPTO_CFG_BUILD)
       
   170 
       
   171   $(UCRYPTO_CFG_BUILD): $(UCRYPTO_CFG_SRC)
       
   172 	$(install-file)
       
   173 
       
   174   include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
       
   175 
       
   176 
       
   177   # =====================================================
       
   178   # Build the unsigned ucrypto.jar file.
       
   179   #
       
   180 
       
   181   JAR_DESTFILE = $(EXTDIR)/ucrypto.jar
       
   182 
       
   183   #
       
   184   # The ucrypto.jar needs to be in the extension class directory,
       
   185   # therefore none of its classes can appear in $(CLASSBINDIR).
       
   186   # Currently no one is using any of the internals, so these files
       
   187   # should not have been built.
       
   188   #
       
   189 
       
   190   #
       
   191   # Since the -C option to jar is used below, each directory entry must be
       
   192   # preceded with the appropriate directory to "cd" into.
       
   193   #
       
   194   JAR_DIRS = $(patsubst %, -C $(CLASSDESTDIR) %, $(AUTO_FILES_JAVA_DIRS))
       
   195 
       
   196   build-jar: $(UNSIGNED_DIR)/ucrypto.jar
       
   197 
       
   198   #
       
   199   # Build ucrypto.jar.
       
   200   #
       
   201   $(UNSIGNED_DIR)/ucrypto.jar: build
       
   202 	$(prep-target)
       
   203 	$(BOOT_JAR_CMD) cf $@ $(JAR_DIRS) \
       
   204 	    $(BOOT_JAR_JFLAGS)
       
   205 	@$(java-vm-cleanup)
       
   206 
       
   207   #
       
   208   # Sign ucrypto.jar
       
   209   #
       
   210   SIGNED_DIR = $(JCE_BUILD_DIR)/signed
       
   211 
       
   212   sign: $(SIGNED_DIR)/ucrypto.jar
       
   213 
       
   214   ifndef ALT_JCE_BUILD_DIR
       
   215     $(SIGNED_DIR)/ucrypto.jar: $(UNSIGNED_DIR)/ucrypto.jar
       
   216   else
       
   217     #
       
   218     # We have to remove the build dependency, otherwise, we'll try to rebuild it
       
   219     # which we can't do on a read-only filesystem.
       
   220     #
       
   221     $(SIGNED_DIR)/ucrypto.jar:
       
   222 	@if [ ! -r $(UNSIGNED_DIR)/ucrypto.jar ] ; then \
       
   223             $(ECHO) "Couldn't find $(UNSIGNED_DIR)/ucrypto.jar"; \
       
   224             exit 1; \
       
   225         fi
       
   226   endif
       
   227 	$(call sign-file, $(UNSIGNED_DIR)/ucrypto.jar)
       
   228 
       
   229 
       
   230   # =====================================================
       
   231   # Create the Release Engineering files.  Signed builds, etc.
       
   232   #
       
   233 
       
   234   release: $(SIGNED_DIR)/ucrypto.jar
       
   235 	$(RM) $(JCE_BUILD_DIR)/release/ucrypto.jar
       
   236 	$(MKDIR) -p $(JCE_BUILD_DIR)/release
       
   237 	$(CP) $(SIGNED_DIR)/ucrypto.jar $(JCE_BUILD_DIR)/release
       
   238 	$(release-warning)
       
   239 
       
   240 
       
   241   # =====================================================
       
   242   # Install routines.
       
   243   #
       
   244 
       
   245   #
       
   246   # Install ucrypto.jar, depending on which type is requested.
       
   247   #
       
   248   jar: $(JAR_DESTFILE)
       
   249 	$(release-warning)
       
   250 
       
   251   $(JAR_DESTFILE): $(SIGNED_DIR)/ucrypto.jar
       
   252 	$(install-file)
       
   253 
       
   254   install-prebuilt:
       
   255 	@$(ECHO) "\n>>>Installing prebuilt OracleUcrypto provider..."
       
   256 	$(RM) $(JAR_DESTFILE)
       
   257 	$(CP) $(PREBUILT_DIR)/ucrypto/ucrypto.jar $(JAR_DESTFILE)
       
   258 
       
   259 
       
   260   # =====================================================
       
   261   # Support routines.
       
   262   #
       
   263   clobber clean::
       
   264 	$(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
       
   265 	$(RM) -r $(UCRYPTO_CFG_BUILD)
       
   266 
       
   267   .PHONY: build-jar jar sign release install-prebuilt
       
   268 
       
   269   endif #ifneq ($(PLATFORM), solaris)
       
   270 endif #ifndef OPENJDK