source: trunk/openjdk/jdk/make/javax/crypto/Makefile

Last change on this file was 278, checked in by dmik, 14 years ago

trunk: Merged in openjdk6 b22 from branches/vendor/oracle.

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