jdk/makefiles/sun/security/pkcs11/Makefile
changeset 13164 72c5d01a857d
parent 13082 9b19b2302c28
child 13167 efec101d7d87
equal deleted inserted replaced
13082:9b19b2302c28 13164:72c5d01a857d
     1 #
       
     2 # Copyright (c) 2003, 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 sunpkcs11.jar and native libraries.
       
    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 sunpkcs11.jar.
       
    64 #                                  If JDK, installs prebuilt
       
    65 #                                      sunpkcs11.jar.
       
    66 #
       
    67 #     jar                      Builds/installs sunpkcs11.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 sunpkcs11.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 sunpkcs11.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.pkcs11
       
    93 LIBRARY = j2pkcs11
       
    94 PRODUCT = sun
       
    95 
       
    96 #
       
    97 # The following is for when we need to do postprocessing
       
    98 # (signing/obfuscation) against a read-only build.  If the OUTPUTDIR
       
    99 # isn't writable, the build currently crashes out.
       
   100 #
       
   101 ifndef OPENJDK
       
   102   ifdef ALT_JCE_BUILD_DIR
       
   103     # =====================================================
       
   104     # Where to place the output, in case we're building from a read-only
       
   105     # build area.  (e.g. a release engineering build.)
       
   106     JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR}
       
   107     IGNORE_WRITABLE_OUTPUTDIR_TEST=true
       
   108   else
       
   109     JCE_BUILD_DIR=${TEMPDIR}
       
   110   endif
       
   111 endif
       
   112 
       
   113 JAVAC_MAX_WARNINGS=false
       
   114 JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation
       
   115 JAVAC_WARNINGS_FATAL=true
       
   116 include $(BUILDDIR)/common/Defs.gmk
       
   117 
       
   118 #
       
   119 # C and Java Files
       
   120 #
       
   121 include FILES_c.gmk
       
   122 
       
   123 #
       
   124 # Subdirectories of these are automatically included.
       
   125 #
       
   126 AUTO_FILES_JAVA_DIRS = sun/security/pkcs11
       
   127 
       
   128 #
       
   129 # Java files that define native methods
       
   130 #
       
   131 FILES_export = \
       
   132     sun/security/pkcs11/wrapper/PKCS11.java \
       
   133     sun/security/pkcs11/Secmod.java
       
   134 
       
   135 #
       
   136 # Find native code
       
   137 #
       
   138 vpath %.c \
       
   139   $(SHARE_SRC)/native/sun/security/pkcs11/wrapper \
       
   140   $(PLATFORM_SRC)/native/sun/security/pkcs11/wrapper \
       
   141 
       
   142 #
       
   143 # Find include files
       
   144 #
       
   145 OTHER_INCLUDES += \
       
   146   -I$(SHARE_SRC)/native/sun/security/pkcs11/wrapper \
       
   147   -I$(PLATFORM_SRC)/native/sun/security/pkcs11/wrapper
       
   148 
       
   149 #
       
   150 # Rules
       
   151 #
       
   152 CLASSDESTDIR = $(TEMPDIR)/classes
       
   153 JAVAHFLAGS = -bootclasspath \
       
   154   "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)"
       
   155 
       
   156 include $(BUILDDIR)/common/Mapfile-vers.gmk
       
   157 
       
   158 include $(BUILDDIR)/common/Library.gmk
       
   159 
       
   160 #
       
   161 # Libraries to link
       
   162 #
       
   163 ifneq ($(PLATFORM), windows)
       
   164   OTHER_LDLIBS = $(LIBDL)
       
   165 endif
       
   166 
       
   167 # Other config files
       
   168 SUNPKCS11_CFG   =
       
   169 
       
   170 ifeq ($(PLATFORM), solaris)
       
   171 #SUNPKCS11_CFG   = sunpkcs11-cfg
       
   172 endif # PLATFORM
       
   173 
       
   174 SUNPKCS11_CFG_SRC   = $(TOPDIR)/src/share/lib/security/sunpkcs11-solaris.cfg
       
   175 SUNPKCS11_CFG_BUILD = $(LIBDIR)/security/sunpkcs11-solaris.cfg
       
   176 
       
   177 #
       
   178 # We use a variety of subdirectories in the $(TEMPDIR) depending on what
       
   179 # part of the build we're doing.  Both OPENJDK/JDK builds are initially
       
   180 # done in the unsigned area.  When files are signed in JDK,
       
   181 # they will be placed in the appropriate area.
       
   182 #
       
   183 UNSIGNED_DIR = $(TEMPDIR)/unsigned
       
   184 
       
   185 #
       
   186 # Rules
       
   187 #
       
   188 
       
   189 ifdef OPENJDK
       
   190 all: $(SUNPKCS11_CFG) build-jar install-jar
       
   191 else
       
   192 all: $(SUNPKCS11_CFG) build-jar install-prebuilt
       
   193 	$(build-warning)
       
   194 endif
       
   195 
       
   196 sunpkcs11-cfg: $(SUNPKCS11_CFG_BUILD)
       
   197 
       
   198 $(SUNPKCS11_CFG_BUILD): $(SUNPKCS11_CFG_SRC)
       
   199 	$(install-file)
       
   200 
       
   201 include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
       
   202 
       
   203 
       
   204 # =====================================================
       
   205 # Build the unsigned sunpkcs11.jar file.
       
   206 #
       
   207 
       
   208 JAR_DESTFILE = $(EXTDIR)/sunpkcs11.jar
       
   209 
       
   210 #
       
   211 # The sunpkcs11.jar needs to be in the extension class directory,
       
   212 # therefore none of its classes can appear in $(CLASSBINDIR). 
       
   213 # Currently no one is using any of the PKCS11 internals, so these files
       
   214 # should not have been built.
       
   215 #
       
   216 
       
   217 #
       
   218 # Since the -C option to jar is used below, each directory entry must be
       
   219 # preceded with the appropriate directory to "cd" into.
       
   220 #
       
   221 JAR_DIRS = $(patsubst %, -C $(CLASSDESTDIR) %, $(AUTO_FILES_JAVA_DIRS))
       
   222 
       
   223 build-jar: $(UNSIGNED_DIR)/sunpkcs11.jar
       
   224 
       
   225 #
       
   226 # Build sunpkcs11.jar.
       
   227 #
       
   228 $(UNSIGNED_DIR)/sunpkcs11.jar: build
       
   229 	$(prep-target)
       
   230 	$(BOOT_JAR_CMD) cf $@ $(JAR_DIRS) \
       
   231 	    $(BOOT_JAR_JFLAGS)
       
   232 	@$(java-vm-cleanup)
       
   233 
       
   234 
       
   235 ifndef OPENJDK
       
   236 # =====================================================
       
   237 # Sign the provider jar file.  Not needed for OpenJDK.
       
   238 #
       
   239 
       
   240 SIGNED_DIR = $(JCE_BUILD_DIR)/signed
       
   241 
       
   242 sign: sign-jar
       
   243 
       
   244 sign-jar: $(SIGNED_DIR)/sunpkcs11.jar
       
   245 
       
   246 ifndef ALT_JCE_BUILD_DIR
       
   247 $(SIGNED_DIR)/sunpkcs11.jar: $(UNSIGNED_DIR)/sunpkcs11.jar
       
   248 else
       
   249 #
       
   250 # We have to remove the build dependency, otherwise, we'll try to rebuild it
       
   251 # which we can't do on a read-only filesystem.
       
   252 #
       
   253 $(SIGNED_DIR)/sunpkcs11.jar:
       
   254 	@if [ ! -r $(UNSIGNED_DIR)/sunpkcs11.jar ] ; then \
       
   255             $(ECHO) "Couldn't find $(UNSIGNED_DIR)/sunpkcs11.jar"; \
       
   256             exit 1; \
       
   257         fi
       
   258 endif
       
   259 	$(call sign-file, $(UNSIGNED_DIR)/sunpkcs11.jar)
       
   260 
       
   261 
       
   262 # =====================================================
       
   263 # Create the Release Engineering files.  Signed builds, etc.
       
   264 #
       
   265 
       
   266 release: $(SIGNED_DIR)/sunpkcs11.jar
       
   267 	$(RM) $(JCE_BUILD_DIR)/release/sunpkcs11.jar
       
   268 	$(MKDIR) -p $(JCE_BUILD_DIR)/release
       
   269 	$(CP) $(SIGNED_DIR)/sunpkcs11.jar $(JCE_BUILD_DIR)/release
       
   270 	$(release-warning)
       
   271 
       
   272 endif # OPENJDK
       
   273 
       
   274 
       
   275 # =====================================================
       
   276 # Install routines.
       
   277 #
       
   278 
       
   279 #
       
   280 # Install sunpkcs11.jar, depending on which type is requested.
       
   281 #
       
   282 install-jar jar: $(JAR_DESTFILE)
       
   283 ifndef OPENJDK
       
   284 	$(release-warning)
       
   285 endif
       
   286 
       
   287 ifdef OPENJDK
       
   288 $(JAR_DESTFILE): $(UNSIGNED_DIR)/sunpkcs11.jar
       
   289 else
       
   290 $(JAR_DESTFILE): $(SIGNED_DIR)/sunpkcs11.jar
       
   291 endif
       
   292 	$(install-file)
       
   293 
       
   294 ifndef OPENJDK
       
   295 install-prebuilt:
       
   296 	@$(ECHO) "\n>>>Installing prebuilt SunPKCS11 provider..."
       
   297 	$(RM) $(JAR_DESTFILE)
       
   298 	$(CP) $(PREBUILT_DIR)/pkcs11/sunpkcs11.jar $(JAR_DESTFILE)
       
   299 endif
       
   300 
       
   301 
       
   302 # =====================================================
       
   303 # Support routines.
       
   304 #
       
   305 
       
   306 clobber clean::
       
   307 	$(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
       
   308 	$(RM) $(SUNPKCS11_CFG_BUILD) 
       
   309 
       
   310 .PHONY: build-jar jar install-jar
       
   311 ifndef OPENJDK
       
   312 .PHONY: sign sign-jar release install-prebuilt
       
   313 endif