1 # 2 # Copyright (c) 2007, 2011, 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 jce.jar and the various cryptographic strength 28 # policy jar files. 29 # 30 31 # 32 # (The terms "OpenJDK" and "JDK" below refer to OpenJDK and Sun JDK builds 33 # respectively.) 34 # 35 # JCE builds are very different between OpenJDK and JDK. The OpenJDK JCE 36 # jar files do not require signing, but those for JDK do. If an unsigned 37 # jar file is installed into JDK, things will break when the crypto 38 # routines are called. 39 # 40 # This Makefile does the "real" build of the JCE files. There are some 41 # javac options currently specific to JCE, so we recompile now to make 42 # sure any implicit compilations didn't use any incorrect flags. 43 # 44 # For OpenJDK, the jar files built here are installed directly into the 45 # OpenJDK. 46 # 47 # For JDK, the binaries use pre-built/pre-signed binary files stored in 48 # the closed workspace that are not shipped in the OpenJDK workspaces. 49 # We still build the JDK files here to verify the files compile, and in 50 # preparation for possible signing. Developers working on JCE in JDK 51 # must sign the JCE files before testing. The JCE signing key is kept 52 # separate from the JDK workspace to prevent its disclosure. 53 # 54 # SPECIAL NOTE TO JCE/JDK developers: The source files must eventually 55 # be built and signed, and the resulting jar files *MUST BE CHECKED INTO 56 # THE CLOSED PART OF THE WORKSPACE*. This separate step *MUST NOT BE 57 # FORGOTTEN*, otherwise a bug fixed in the source code will not be 58 # reflected in the shipped binaries. The "release" target should be 59 # used to generate the required files. 60 # 61 # There are a number of targets to help both JDK/OpenJDK developers. 62 # 63 # Main Targets (JDK/OPENJDK): 64 # 65 # all/clobber/clean The usual. 66 # If OpenJDK: builds/installs the 67 # jce.jar/limited policy files. 68 # If JDK: builds but does not install. 69 # During full tops-down builds, 70 # prebuilt/presigned jce.jar & 71 # limited policy files are copied 72 # in by make/java/redist/Makefile. 73 # If you are working in this directory 74 # and want to install the prebuilts, 75 # use the "install-prebuilt" target. 76 # 77 # jar Builds/installs jce.jar 78 # If OpenJDK, does not sign 79 # If JDK, tries to sign 80 # 81 # Other lesser-used Targets (JDK/OPENJDK): 82 # 83 # build-jar Builds jce.jar (does not sign/install) 84 # 85 # build-policy Builds policy files (does not sign/install) 86 # 87 # install-jar Alias for "jar" above 88 # 89 # install-limited Builds/installs limited policy files 90 # If OpenJDK, does not sign 91 # If JDK, tries to sign 92 # install-unlimited Builds/nstalls unlimited policy files 93 # If OpenJDK, does not sign 94 # If JDK, tries to sign 95 # 96 # Other targets (JDK only): 97 # 98 # sign Alias for sign-jar and sign-policy 99 # sign-jar Builds/signs jce.jar file (no install) 100 # sign-policy Builds/signs policy files (no install) 101 # 102 # release Builds all targets in preparation 103 # for workspace integration. 104 # 105 # install-prebuilt Installs the pre-built jar files 106 # 107 # This makefile was written to support parallel target execution. 108 # 109 110 BUILDDIR = ../.. 111 PACKAGE = javax.crypto 112 PRODUCT = sun 113 114 # 115 # The following is for when we need to do postprocessing 116 # (signing) against a read-only build. If the OUTPUTDIR 117 # isn't writable, the build currently crashes out. 118 # 119 ifndef OPENJDK 120 ifdef ALT_JCE_BUILD_DIR 121 # ===================================================== 122 # Where to place the output, in case we're building from a read-only 123 # build area. (e.g. a release engineering build.) 124 JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR} 125 IGNORE_WRITABLE_OUTPUTDIR_TEST=true 126 else 127 JCE_BUILD_DIR=${TEMPDIR} 128 endif 129 endif 130 131 JAVAC_MAX_WARNINGS = true 132 JAVAC_WARNINGS_FATAL = true 133 include $(BUILDDIR)/common/Defs.gmk 134 135 # 136 # Location for the newly built classfiles. 137 # 138 CLASSDESTDIR = $(TEMPDIR)/classes 139 140 # 141 # Subdirectories of these are automatically included. 142 # 143 AUTO_FILES_JAVA_DIRS = \ 144 javax/crypto \ 145 sun/security/internal/interfaces \ 146 sun/security/internal/spec 147 148 include $(BUILDDIR)/common/Classes.gmk 149 150 # 151 # Rules 152 # 153 154 # 155 # Some licensees do not get the security sources, but we still need to 156 # be able to build "all" for them. Check here to see if the sources were 157 # available. If not, then we don't need to continue this rule. 158 # 159 160 ifdef OPENJDK 161 ifdef UNLIMITED_CRYPTO 162 POLICY = install-unlimited 163 else 164 POLICY = install-limited 165 endif 166 all: build-jar install-jar build-policy $(POLICY) 167 else # OPENJDK 168 ifeq ($(strip $(FILES_java)),) 169 all: 170 $(no-source-warning) 171 else # FILES_java/policy files available 172 all: build-jar build-policy 173 $(build-warning) 174 endif # $(FILES_java)/policy files available 175 endif # OPENJDK 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, they will be 181 # placed in the appropriate areas. 182 # 183 UNSIGNED_DIR = $(TEMPDIR)/unsigned 184 185 include Defs-jce.gmk 186 187 188 # ===================================================== 189 # Build the unsigned jce.jar file. Signing comes later. 190 # 191 192 JAR_DESTFILE = $(LIBDIR)/jce.jar 193 194 # 195 # JCE building is somewhat involved. 196 # 197 # OpenJDK: Since we do not ship prebuilt JCE files, previous compiles 198 # in the build may have needed JCE class signatures. There were then 199 # implicitly built by javac (likely using the boot javac). While using 200 # those class files was fine for signatures, we need to rebuild using 201 # the right compiler. 202 # 203 # JDK: Even through the jce.jar was previously installed, since the 204 # source files are accessible in the source directories, they will 205 # always be "newer" than the prebuilt files inside the jar, and thus 206 # make will always rebuild them. (We could "hide" the JCE source in a 207 # separate directory, but that would make the build logic for JDK and 208 # OpenJDK more complicated.) 209 # 210 # Thus in either situation, we shouldn't use these files. 211 # 212 # To make sure the classes were built with the right compiler options, 213 # delete the existing files in $(CLASSBINDIR), rebuild the right way in a 214 # directory under $(TEMPDIR), then copy the files back to 215 # $(CLASSBINDIR). Building in $(TEMPDIR) allows us to use our make 216 # infrastructure without modification: .classes.list, macros, etc. 217 # 218 219 # 220 # The list of directories that will be remade from scratch, using the 221 # right compilers/options. 222 # 223 DELETE_DIRS = $(patsubst %, $(CLASSBINDIR)/%, $(AUTO_FILES_JAVA_DIRS)) 224 225 # 226 # Since the -C option to jar is used below, each directory entry must be 227 # preceded with the appropriate directory to "cd" into. 228 # 229 JAR_DIRS = $(patsubst %, -C $(CLASSDESTDIR) %, $(AUTO_FILES_JAVA_DIRS)) 230 231 build-jar: $(UNSIGNED_DIR)/jce.jar 232 233 # 234 # Build jce.jar, then replace the previously built JCE files in the 235 # classes directory with these. This ensures we have consistently built 236 # files throughout the workspaces. 237 # 238 $(UNSIGNED_DIR)/jce.jar: prebuild build $(JCE_MANIFEST_FILE) 239 $(prep-target) 240 $(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ $(JAR_DIRS) \ 241 $(BOOT_JAR_JFLAGS) 242 $(CP) -r $(CLASSDESTDIR)/* $(CLASSBINDIR) 243 @$(java-vm-cleanup) 244 245 build: prebuild 246 247 prebuild: 248 $(RM) -r $(DELETE_DIRS) 249 250 251 # ===================================================== 252 # Build the unsigned policy files. 253 # 254 # Given the current state of world export/import policies, 255 # these settings work for Sun's situation. This note is not 256 # legal guidance, you must still resolve any export/import issues 257 # applicable for your situation. Contact your export/import 258 # counsel for more information. 259 # 260 261 POLICY_DESTDIR = $(LIBDIR)/security 262 UNSIGNED_POLICY_BUILDDIR = $(UNSIGNED_DIR)/policy 263 264 build-policy: unlimited limited 265 266 # 267 # Build the unsigned unlimited policy files. 268 # 269 unlimited: \ 270 $(UNSIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar \ 271 $(UNSIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar 272 273 $(UNSIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar: \ 274 policy/unlimited/default_US_export.policy \ 275 policy/unlimited/UNLIMITED 276 $(prep-target) 277 $(BOOT_JAR_CMD) cmf policy/unlimited/UNLIMITED $@ \ 278 -C policy/unlimited default_US_export.policy \ 279 $(BOOT_JAR_JFLAGS) 280 @$(java-vm-cleanup) 281 282 $(UNSIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar: \ 283 policy/unlimited/default_local.policy \ 284 policy/unlimited/UNLIMITED 285 $(prep-target) 286 $(BOOT_JAR_CMD) cmf policy/unlimited/UNLIMITED $@ \ 287 -C policy/unlimited default_local.policy \ 288 $(BOOT_JAR_JFLAGS) 289 @$(java-vm-cleanup) 290 291 # 292 # Build the unsigned limited policy files. 293 # 294 # NOTE: We currently do not place restrictions on our limited export 295 # policy. This was not a typo. 296 # 297 limited: \ 298 $(UNSIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar \ 299 $(UNSIGNED_POLICY_BUILDDIR)/limited/local_policy.jar 300 301 $(UNSIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar: \ 302 $(UNSIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar 303 $(install-file) 304 305 $(UNSIGNED_POLICY_BUILDDIR)/limited/local_policy.jar: \ 306 policy/limited/default_local.policy \ 307 policy/limited/exempt_local.policy \ 308 policy/limited/LIMITED 309 $(prep-target) 310 $(BOOT_JAR_CMD) cmf policy/limited/LIMITED $@ \ 311 -C policy/limited default_local.policy \ 312 -C policy/limited exempt_local.policy \ 313 $(BOOT_JAR_JFLAGS) 314 @$(java-vm-cleanup) 315 316 UNSIGNED_POLICY_FILES = \ 317 $(UNSIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar \ 318 $(UNSIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar \ 319 $(UNSIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar \ 320 $(UNSIGNED_POLICY_BUILDDIR)/limited/local_policy.jar \ 321 322 323 ifndef OPENJDK 324 # ===================================================== 325 # Sign the various jar files. Not needed for OpenJDK. 326 # 327 328 SIGNED_DIR = $(JCE_BUILD_DIR)/signed 329 SIGNED_POLICY_BUILDDIR = $(SIGNED_DIR)/policy 330 331 SIGNED_POLICY_FILES = \ 332 $(patsubst $(UNSIGNED_POLICY_BUILDDIR)/%,$(SIGNED_POLICY_BUILDDIR)/%, \ 333 $(UNSIGNED_POLICY_FILES)) 334 335 sign: sign-jar sign-policy 336 337 sign-jar: $(SIGNED_DIR)/jce.jar 338 339 sign-policy: $(SIGNED_POLICY_FILES) 340 341 ifndef ALT_JCE_BUILD_DIR 342 $(SIGNED_DIR)/jce.jar: $(UNSIGNED_DIR)/jce.jar 343 else 344 # 345 # We have to remove the build dependency, otherwise, we'll try to rebuild it 346 # which we can't do on a read-only filesystem. 347 # 348 $(SIGNED_DIR)/jce.jar: 349 @if [ ! -r $(UNSIGNED_DIR)/jce.jar ] ; then \ 350 $(ECHO) "Couldn't find $(UNSIGNED_DIR)/jce.jar"; \ 351 exit 1; \ 352 fi 353 endif 354 $(call sign-file, $(UNSIGNED_DIR)/jce.jar) 355 356 $(SIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar: \ 357 $(UNSIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar 358 $(call sign-file, $<) 359 360 $(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar: \ 361 $(UNSIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar 362 $(call sign-file, $<) 363 364 $(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar: \ 365 $(UNSIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar 366 $(call sign-file, $<) 367 368 $(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar: \ 369 $(UNSIGNED_POLICY_BUILDDIR)/limited/local_policy.jar 370 $(call sign-file, $<) 371 372 373 # ===================================================== 374 # Create the Release Engineering files. Signed builds, 375 # unlimited policy file distribution, etc. 376 # 377 378 CLOSED_DIR = $(BUILDDIR)/closed/javax/crypto 379 380 release: $(SIGNED_DIR)/jce.jar sign-policy $(CLOSED_DIR)/doc/README.txt 381 $(RM) -r \ 382 $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy \ 383 $(JCE_BUILD_DIR)/release/jce.jar \ 384 $(JCE_BUILD_DIR)/release/US_export_policy.jar \ 385 $(JCE_BUILD_DIR)/release/local_policy.jar \ 386 $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy.zip 387 $(MKDIR) -p $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy 388 $(CP) $(SIGNED_DIR)/jce.jar $(JCE_BUILD_DIR)/release 389 $(CP) \ 390 $(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar \ 391 $(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar \ 392 $(JCE_BUILD_DIR)/release 393 $(CP) \ 394 $(SIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar \ 395 $(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar \ 396 $(CLOSED_DIR)/doc/README.txt \ 397 $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy 398 cd $(JCE_BUILD_DIR)/release ; \ 399 $(ZIPEXE) -qr UnlimitedJCEPolicy.zip UnlimitedJCEPolicy 400 $(release-warning) 401 402 endif # OPENJDK 403 404 405 # ===================================================== 406 # Install routines. 407 # 408 409 # 410 # Install jce.jar, depending on which type is requested. 411 # 412 install-jar jar: $(JAR_DESTFILE) 413 ifndef OPENJDK 414 $(release-warning) 415 endif 416 417 ifdef OPENJDK 418 $(JAR_DESTFILE): $(UNSIGNED_DIR)/jce.jar 419 else 420 $(JAR_DESTFILE): $(SIGNED_DIR)/jce.jar 421 endif 422 $(install-file) 423 424 # 425 # Install the appropriate policy file, depending on the type of build. 426 # 427 ifdef OPENJDK 428 INSTALL_POLICYDIR = $(UNSIGNED_POLICY_BUILDDIR) 429 else 430 INSTALL_POLICYDIR = $(SIGNED_POLICY_BUILDDIR) 431 endif 432 433 install-limited-jars: \ 434 $(INSTALL_POLICYDIR)/limited/US_export_policy.jar \ 435 $(INSTALL_POLICYDIR)/limited/local_policy.jar 436 $(MKDIR) -p $(POLICY_DESTDIR) 437 $(RM) \ 438 $(POLICY_DESTDIR)/US_export_policy.jar \ 439 $(POLICY_DESTDIR)/local_policy.jar 440 $(CP) $^ $(POLICY_DESTDIR) 441 442 install-limited: install-limited-jars 443 ifndef OPENJDK 444 $(release-warning) 445 endif 446 447 install-unlimited-jars: \ 448 $(INSTALL_POLICYDIR)/unlimited/US_export_policy.jar \ 449 $(INSTALL_POLICYDIR)/unlimited/local_policy.jar 450 $(MKDIR) -p $(POLICY_DESTDIR) 451 $(RM) \ 452 $(POLICY_DESTDIR)/US_export_policy.jar \ 453 $(POLICY_DESTDIR)/local_policy.jar 454 $(CP) $^ $(POLICY_DESTDIR) 455 456 install-unlimited: install-unlimited-jars 457 ifndef OPENJDK 458 $(release-warning) 459 endif 460 461 ifndef OPENJDK 462 install-prebuilt-jars: 463 @$(ECHO) "\n>>>Installing prebuilt JCE framework..." 464 $(RM) $(JAR_DESTFILE) \ 465 $(POLICY_DESTDIR)/US_export_policy.jar \ 466 $(POLICY_DESTDIR)/local_policy.jar 467 $(CP) $(PREBUILT_DIR)/jce/jce.jar $(JAR_DESTFILE) 468 $(CP) \ 469 $(PREBUILT_DIR)/jce/US_export_policy.jar \ 470 $(PREBUILT_DIR)/jce/local_policy.jar \ 471 $(POLICY_DESTDIR) 472 473 install-prebuilt: install-prebuilt-jars 474 endif 475 476 # ===================================================== 477 # Support routines. 478 # 479 480 clobber clean:: 481 $(RM) -r $(JAR_DESTFILE) $(POLICY_DESTDIR)/US_export_policy.jar \ 482 $(POLICY_DESTDIR)/local_policy.jar $(DELETE_DIRS) $(TEMPDIR) \ 483 $(JCE_BUILD_DIR) 484 485 .PHONY: build-jar jar build-policy unlimited limited install-jar \ 486 install-limited install-unlimited 487 ifndef OPENJDK 488 .PHONY: sign sign-jar sign-policy release install-prebuilt 489 endif