Makefile revision 4:d83470fdf495
1#
2# Copyright 1995-2007 Sun Microsystems, Inc.  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.  Sun designates this
8# particular file as subject to the "Classpath" exception as provided
9# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22# CA 95054 USA or visit www.sun.com if you need additional information or
23# have any questions.
24#
25
26ifndef TOPDIR
27  TOPDIR:=$(shell \
28    if [ -r ./j2se/make/Makefile -o -r ./jdk/make/Makefile ]; then \
29      echo "."; \
30    else \
31      echo "../.."; \
32    fi)
33endif
34
35ifndef CONTROL_TOPDIR
36  CONTROL_TOPDIR=$(TOPDIR)/control
37  CONTROL_TOPDIR:=$(shell \
38    if [ -r $(TOPDIR)/control/make/Makefile ]; then \
39      echo "$(TOPDIR)/control"; \
40    else \
41      echo "$(TOPDIR)"; \
42    fi)
43endif
44
45# Openjdk sources (only used if SKIP_OPENJDK_BUILD!=true)
46OPENJDK_SOURCETREE=$(TOPDIR)/openjdk
47OPENJDK_BUILDDIR:=$(shell \
48  if [ -r $(OPENJDK_SOURCETREE)/control/make/Makefile ]; then \
49    echo "$(OPENJDK_SOURCETREE)/control/make"; \
50  elif [ -r $(OPENJDK_SOURCETREE)/Makefile ]; then \
51    echo "$(OPENJDK_SOURCETREE)"; \
52  else \
53    echo "."; \
54  fi)
55
56ifndef JDK_TOPDIR
57  JDK_TOPDIR=$(TOPDIR)/jdk
58endif
59ifndef JDK_MAKE_SHARED_DIR
60  JDK_MAKE_SHARED_DIR=$(JDK_TOPDIR)/make/common/shared
61endif
62
63include $(JDK_MAKE_SHARED_DIR)/Defs-control.gmk
64
65include ./make/Defs-internal.gmk
66
67all::
68	@$(ECHO) $(PLATFORM) $(ARCH) $(RELEASE) build started: `$(DATE) '+%y-%m-%d %H:%M'`
69
70# Rules for sanity checks
71include ./make/sanity-rules.gmk
72
73dev : dev-build
74
75dev-build:
76	$(MAKE) DEV_ONLY=true all
77dev-sanity:
78	$(MAKE) DEV_ONLY=true sanity
79dev-clobber:
80	$(MAKE) DEV_ONLY=true clobber
81
82# Rules for various components
83include ./make/hotspot-rules.gmk
84include ./make/langtools-rules.gmk
85include ./make/corba-rules.gmk
86include ./make/jaxp-rules.gmk
87include ./make/jaxws-rules.gmk
88include ./make/jdk-rules.gmk
89include ./make/install-rules.gmk
90include ./make/sponsors-rules.gmk
91include ./make/deploy-rules.gmk
92
93all:: setup build
94
95setup: openjdk_check
96	$(MKDIR) -p $(OUTPUTDIR)/j2sdk-image
97	$(MKDIR) -p $(ABS_OUTPUTDIR)/j2sdk-image
98	$(MKDIR) -p $(OUTPUTDIR)-fastdebug/j2sdk-image
99	$(MKDIR) -p $(ABS_OUTPUTDIR)-fastdebug/j2sdk-image
100
101# Check on whether we really can build the openjdk, need source etc.
102openjdk_check:
103ifneq ($(SKIP_OPENJDK_BUILD), true)
104	@$(ECHO) " "
105	@$(ECHO) "================================================="
106	@if [ ! -r $(OPENJDK_BUILDDIR)/Makefile ] ; then \
107	    $(ECHO) "ERROR: No openjdk source tree available at: $(OPENJDK_BUILDDIR)"; \
108	    exit 1; \
109	else \
110	    $(ECHO) "OpenJDK will be built after JDK is built"; \
111	    $(ECHO) "  OPENJDK_BUILDDIR=$(OPENJDK_BUILDDIR)"; \
112	fi
113	@$(ECHO) "================================================="
114	@$(ECHO) " "
115endif
116
117build:: sanity 
118
119clobber::
120
121ifeq ($(BUILD_LANGTOOLS), true)
122  build:: langtools
123  clobber:: langtools-clobber
124endif
125
126ifeq ($(BUILD_CORBA), true)
127  build:: corba
128  clobber:: corba-clobber
129endif
130
131ifeq ($(BUILD_JAXP), true)
132  build:: jaxp
133  clobber:: jaxp-clobber
134endif
135
136ifeq ($(BUILD_JAXWS), true)
137  build:: jaxws
138  clobber:: jaxws-clobber
139endif
140
141ifeq ($(BUILD_HOTSPOT), true)
142  build:: $(HOTSPOT) 
143  clobber:: hotspot-clobber
144endif
145
146ifeq ($(BUILD_JDK), true)
147  build:: $(JDK_JAVA_EXE)
148  clobber:: jdk-clobber
149endif
150
151ifeq ($(BUILD_DEPLOY), true)
152  build:: $(DEPLOY)
153  clobber:: deploy-clobber
154endif
155
156#
157# Generic debug build, fastdebug or debug. Needs special handling.
158#  Note that debug builds do NOT do INSTALL steps, but must be done
159#  after the product build and before the INSTALL step of the product build.
160#
161#   DEBUG_NAME is fastdebug or debug
162#   ALT_OUTPUTDIR is changed to have -debug or -fastdebug suffix
163#   The resulting j2sdk-image is used by the install makefiles to create a
164#     debug install bundle jdk-*-debug-** bundle (tar or zip) 
165#     which will install in the debug or fastdebug subdirectory of the
166#     normal product install area.
167#     The install process needs to know what the DEBUG_NAME is, so
168#     look for INSTALL_DEBUG_NAME in the install rules.
169#
170
171COMMON_DEBUG_FLAGS= \
172	DEBUG_NAME=$(DEBUG_NAME) \
173	ALT_OUTPUTDIR=$(_OUTPUTDIR)-$(DEBUG_NAME) \
174	NO_DOCS=true
175
176product_build: setup
177	@$(ECHO) $@ build started: `$(DATE) '+%y-%m-%d %H:%M'`
178	$(MAKE) SKIP_FASTDEBUG_BUILD=true SKIP_DEBUG_BUILD=true all
179	@$(ECHO) $@ build finished: `$(DATE) '+%y-%m-%d %H:%M'`
180
181generic_debug_build:
182	@$(ECHO) $@ build started: `$(DATE) '+%y-%m-%d %H:%M'`
183	$(MAKE) $(COMMON_DEBUG_FLAGS) setup build
184	@$(ECHO) $@ build finished: `$(DATE) '+%y-%m-%d %H:%M'`
185
186debug_build: setup
187	$(MAKE) DEBUG_NAME=debug generic_debug_build
188
189fastdebug_build: setup
190	$(MAKE) DEBUG_NAME=fastdebug generic_debug_build
191
192ifeq ($(SKIP_FASTDEBUG_BUILD), false)
193  all:: fastdebug_build
194endif
195
196ifeq ($(SKIP_DEBUG_BUILD), false)
197  all:: debug_build
198endif
199
200ifeq ($(BUILD_JDK), true)
201  ifeq ($(BUNDLE_RULES_AVAILABLE), true)
202    all:: openjdk-binary-plugs-bundles
203  endif
204endif
205
206ifeq ($(BUILD_INSTALL), true)
207  all :: $(INSTALL)
208  clobber:: install-clobber
209endif
210
211ifeq ($(BUILD_SPONSORS), true)
212  all :: $(SPONSORS)
213  clobber:: sponsors-clobber
214endif
215
216ifneq ($(SKIP_COMPARE_IMAGES), true)
217  all :: compare-image
218endif
219
220ifneq ($(SKIP_OPENJDK_BUILD), true)
221  all :: openjdk_build
222endif
223
224# If we have bundle rules, we have a chance here to do a complete cycle
225#   build, of production and open build.
226# FIXUP: We should create the openjdk source bundle and build that?
227#   But how do we reliable create or get at a formal openjdk source tree?
228#   The one we have needs to be trimmed of built bits and closed dirs.
229#   The repositories might not be available.
230#   The openjdk source bundle is probably not available.
231
232ifneq ($(SKIP_OPENJDK_BUILD), true)
233  ifeq ($(BUILD_JDK), true)
234    ifeq ($(BUNDLE_RULES_AVAILABLE), true)
235
236OPENJDK_PLUGS=$(ABS_OUTPUTDIR)/$(OPENJDK_BINARY_PLUGS_INAME)
237OPENJDK_OUTPUTDIR=$(ABS_OUTPUTDIR)/open-output
238OPENJDK_BUILD_NAME \
239  = openjdk-$(JDK_MINOR_VERSION)-$(BUILD_NUMBER)-$(PLATFORM)-$(ARCH)-$(BUNDLE_DATE)
240OPENJDK_BUILD_BINARY_ZIP=$(ABS_BIN_BUNDLEDIR)/$(OPENJDK_BUILD_NAME).zip
241BUILT_IMAGE=$(ABS_OUTPUTDIR)/j2sdk-image
242ifeq ($(PLATFORM)$(ARCH_DATA_MODEL),solaris64)
243  OPENJDK_BOOTDIR=$(BOOTDIR)
244  OPENJDK_IMPORTJDK=$(JDK_IMPORT_PATH)
245else
246  OPENJDK_BOOTDIR=$(BUILT_IMAGE)
247  OPENJDK_IMPORTJDK=$(BUILT_IMAGE)
248endif
249
250openjdk_build:
251	@$(ECHO) " "
252	@$(ECHO) "================================================="
253	@$(ECHO) "Starting openjdk build"
254	@$(ECHO) " Using: ALT_JDK_DEVTOOLS_DIR=$(JDK_DEVTOOLS_DIR)"
255	@$(ECHO) "================================================="
256	@$(ECHO) " "
257	$(RM) -r $(OPENJDK_OUTPUTDIR)
258	$(MKDIR) -p $(OPENJDK_OUTPUTDIR)
259	($(CD) $(OPENJDK_BUILDDIR) && $(MAKE) \
260	  OPENJDK=true \
261	  ALT_JDK_DEVTOOLS_DIR=$(JDK_DEVTOOLS_DIR) \
262	  ALT_OUTPUTDIR=$(OPENJDK_OUTPUTDIR) \
263	  ALT_BINARY_PLUGS_PATH=$(OPENJDK_PLUGS) \
264	  ALT_BOOTDIR=$(OPENJDK_BOOTDIR) \
265	  ALT_JDK_IMPORT_PATH=$(OPENJDK_IMPORTJDK) \
266		product_build )
267	$(RM) $(OPENJDK_BUILD_BINARY_ZIP)
268	( $(CD) $(OPENJDK_OUTPUTDIR)/j2sdk-image && \
269	  $(ZIPEXE) -q -r $(OPENJDK_BUILD_BINARY_ZIP) .)
270	$(RM) -r $(OPENJDK_OUTPUTDIR)
271	@$(ECHO) " "
272	@$(ECHO) "================================================="
273	@$(ECHO) "Finished openjdk build"
274	@$(ECHO) " Binary Bundle: $(OPENJDK_BUILD_BINARY_ZIP)"
275	@$(ECHO) "================================================="
276	@$(ECHO) " "
277    
278    endif
279  endif
280endif
281
282clobber::
283	$(RM) -r $(OUTPUTDIR)/*
284	$(RM) -r $(OUTPUTDIR)-debug/*
285	$(RM) -r $(OUTPUTDIR)-fastdebug/*
286	-($(RMDIR) -p $(OUTPUTDIR) > $(DEV_NULL) 2>&1; $(TRUE))
287
288clean: clobber
289
290all:: 
291	@$(ECHO) Control build finished: `$(DATE) '+%y-%m-%d %H:%M'`
292
293#
294# Quick jdk verification build
295#
296jdk_only:
297	$(MAKE) SKIP_FASTDEBUG_BUILD=true BUILD_HOTSPOT=false all
298
299
300#
301# Quick jdk verification fastdebug build
302#
303jdk_fastdebug_only:
304	$(MAKE) DEBUG_NAME=fastdebug BUILD_HOTSPOT=false BUILD_DEPLOY=false \
305	    BUILD_INSTALL=false BUILD_SPONSORS=false generic_debug_build
306
307#
308# Quick deploy verification fastdebug build
309#
310deploy_fastdebug_only:
311	$(MAKE) \
312	    DEBUG_NAME=fastdebug \
313	    BUILD_HOTSPOT=false \
314	    BUILD_JDK=false \
315	    BUILD_LANGTOOLS=false \
316	    BUILD_CORBA=false \
317	    BUILD_JAXP=false \
318	    BUILD_JAXWS=false \
319	    BUILD_INSTALL=false \
320	    BUILD_SPONSORS=false \
321	    generic_debug_build
322
323#
324# Product build (skip debug builds)
325#
326product_only:
327	$(MAKE) SKIP_FASTDEBUG_BUILD=true all
328
329#
330# Check target
331#
332
333check: variable_check
334
335#
336# Help target
337#
338help: intro_help target_help variable_help notes_help examples_help
339
340# Intro help message
341intro_help:
342	@$(ECHO) "\
343Makefile for the JDK builds (all the JDK). \n\
344"
345
346# Target help
347target_help:
348	@$(ECHO) "\
349--- Common Targets ---  \n\
350all               -- build the core JDK (default target) \n\
351help              -- Print out help information \n\
352check             -- Check make variable values for correctness \n\
353sanity            -- Perform detailed sanity checks on system and settings \n\
354fastdebug_build   -- build the core JDK in 'fastdebug' mode (-g -O) \n\
355debug_build       -- build the core JDK in 'debug' mode (-g) \n\
356clean             -- remove all built and imported files \n\
357clobber           -- same as clean \n\
358"
359
360# Variable help (only common ones used by this Makefile)
361variable_help: variable_help_intro variable_list variable_help_end
362variable_help_intro:
363	@$(ECHO) "--- Common Variables ---"
364variable_help_end:
365	@$(ECHO) " "
366
367# One line descriptions for the variables
368OUTPUTDIR.desc             = Output directory
369PARALLEL_COMPILE_JOBS.desc = Solaris/Linux parallel compile run count
370SLASH_JAVA.desc            = Root of all build tools, e.g. /java or J:
371BOOTDIR.desc               = JDK used to boot the build
372JDK_IMPORT_PATH.desc       = JDK used to import components of the build
373COMPILER_PATH.desc         = Compiler install directory
374CACERTS_FILE.desc          = Location of certificates file
375DEVTOOLS_PATH.desc         = Directory containing zip and gnumake
376CUPS_HEADERS_PATH.desc     = Include directory location for CUPS header files
377DXSDK_PATH.desc            = Root directory of DirectX SDK
378MSDEVTOOLS_PATH.desc       = Root directory of VC++ tools (e.g. rc.exe)
379MSVCRT_DLL_PATH.desc       = Directory containing mscvrt.dll
380
381# Make variables to print out (description and value)
382VARIABLE_PRINTVAL_LIST +=       \
383    OUTPUTDIR                   \
384    PARALLEL_COMPILE_JOBS       \
385    SLASH_JAVA                  \
386    BOOTDIR                     \
387    JDK_IMPORT_PATH             \
388    COMPILER_PATH               \
389    CACERTS_FILE                \
390    DEVTOOLS_PATH
391
392# Make variables that should refer to directories that exist
393VARIABLE_CHECKDIR_LIST +=       \
394    SLASH_JAVA                  \
395    BOOTDIR                     \
396    JDK_IMPORT_PATH             \
397    COMPILER_PATH               \
398    DEVTOOLS_PATH 
399
400# Make variables that should refer to files that exist
401VARIABLE_CHECKFIL_LIST +=       \
402    CACERTS_FILE
403
404# Some are windows specific
405ifeq ($(PLATFORM), windows)
406
407VARIABLE_PRINTVAL_LIST +=       \
408    DXSDK_PATH                  \
409    MSDEVTOOLS_PATH             \
410    MSVCRT_DLL_PATH
411
412VARIABLE_CHECKDIR_LIST +=       \
413    DXSDK_PATH                  \
414    MSDEVTOOLS_PATH             \
415    MSVCRT_DLL_PATH
416
417endif
418
419# For pattern rules below, so all are treated the same
420DO_PRINTVAL_LIST=$(VARIABLE_PRINTVAL_LIST:%=%.printval)
421DO_CHECKDIR_LIST=$(VARIABLE_CHECKDIR_LIST:%=%.checkdir)
422DO_CHECKFIL_LIST=$(VARIABLE_CHECKFIL_LIST:%=%.checkfil)
423
424# Complete variable check
425variable_check: $(DO_CHECKDIR_LIST) $(DO_CHECKFIL_LIST)
426variable_list: $(DO_PRINTVAL_LIST) variable_check
427
428# Pattern rule for printing out a variable
429%.printval:
430	@$(ECHO) "  ALT_$* - $($*.desc)"
431	@$(ECHO) "  \t $*=$($*)"
432
433# Pattern rule for checking to see if a variable with a directory exists
434%.checkdir:
435	@if [ ! -d $($*) ] ; then \
436	    $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \
437	fi
438
439# Pattern rule for checking to see if a variable with a file exists
440%.checkfil:
441	@if [ ! -f $($*) ] ; then \
442	    $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \
443	fi
444
445# Misc notes on help
446notes_help:
447	@$(ECHO) "\
448--- Notes --- \n\
449- All builds use same output directory unless overridden with \n\
450 \t ALT_OUTPUTDIR=<dir>, changing from product to fastdebug you may want \n\
451 \t to use the clean target first. \n\
452- JDK_IMPORT_PATH must refer to a compatible build, not all past promoted \n\
453 \t builds or previous release JDK builds will work. \n\
454- The fastest builds have been when the sources and the BOOTDIR are on \n\
455 \t local disk. \n\
456"
457
458examples_help:
459	@$(ECHO) "\
460--- Examples --- \n\
461  $(MAKE) fastdebug_build \n\
462  $(MAKE) ALT_OUTPUTDIR=/tmp/foobar all \n\
463  $(MAKE) ALT_OUTPUTDIR=/tmp/foobar fastdebug_build \n\
464  $(MAKE) ALT_OUTPUTDIR=/tmp/foobar all \n\
465  $(MAKE) ALT_BOOTDIR=/opt/java/jdk1.5.0 \n\
466  $(MAKE) ALT_JDK_IMPORT_PATH=/opt/java/jdk1.6.0 \n\
467"
468
469################################################################
470# Source and binary plug bundling
471################################################################
472ifeq ($(BUNDLE_RULES_AVAILABLE), true)
473  include $(BUNDLE_RULES)
474endif
475
476################################################################
477# Cycle build. Build the jdk, use it to build the jdk again.
478################################################################
479  
480ABS_BOOTDIR_OUTPUTDIR=$(ABS_OUTPUTDIR)/bootjdk
481  
482boot_cycle:
483	$(MAKE) ALT_OUTPUTDIR=$(ABS_BOOTDIR_OUTPUTDIR) product_build
484	$(MAKE) ALT_BOOTDIR=$(ABS_BOOTDIR_OUTPUTDIR)/j2sdk-image product_build
485
486################################################################
487# JPRT rule to build
488################################################################
489
490include ./make/jprt.gmk
491
492################################################################
493#  PHONY
494################################################################
495
496.PHONY: all build what clobber insane \
497	fastdebug_build debug_build product_build setup \
498        dev dev-build dev-sanity dev-clobber
499
500# FIXUP: Old j2se targets
501j2se_fastdebug_only: jdk_fastdebug_only
502j2se_only: jdk_only
503
504