Makefile revision 8:cbc8ad9dd0e0
1176434Skaiw#
2176434Skaiw# Copyright 1995-2007 Sun Microsystems, Inc.  All Rights Reserved.
3176434Skaiw# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4176434Skaiw#
5176434Skaiw# This code is free software; you can redistribute it and/or modify it
6176434Skaiw# under the terms of the GNU General Public License version 2 only, as
7176434Skaiw# published by the Free Software Foundation.  Sun designates this
8176434Skaiw# particular file as subject to the "Classpath" exception as provided
9176434Skaiw# by Sun in the LICENSE file that accompanied this code.
10176434Skaiw#
11176434Skaiw# This code is distributed in the hope that it will be useful, but WITHOUT
12176434Skaiw# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13176434Skaiw# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14176434Skaiw# version 2 for more details (a copy is included in the LICENSE file that
15176434Skaiw# accompanied this code).
16176434Skaiw#
17176434Skaiw# You should have received a copy of the GNU General Public License version
18176434Skaiw# 2 along with this work; if not, write to the Free Software Foundation,
19176434Skaiw# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20176434Skaiw#
21176434Skaiw# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22176434Skaiw# CA 95054 USA or visit www.sun.com if you need additional information or
23176434Skaiw# have any questions.
24176434Skaiw#
25176434Skaiw
26176434SkaiwBUILD_PARENT_DIRECTORY=.
27176434Skaiw
28176434Skaiwifndef TOPDIR
29176434Skaiw  TOPDIR:=.
30176434Skaiwendif
31176434Skaiw
32176434Skaiwifndef CONTROL_TOPDIR
33176434Skaiw  CONTROL_TOPDIR=$(TOPDIR)
34176434Skaiwendif
35176434Skaiw
36176434Skaiw# Openjdk sources (only used if SKIP_OPENJDK_BUILD!=true)
37176434SkaiwOPENJDK_SOURCETREE=$(TOPDIR)/openjdk
38176434SkaiwOPENJDK_BUILDDIR:=$(shell \
39176434Skaiw  if [ -r $(OPENJDK_SOURCETREE)/Makefile ]; then \
40176434Skaiw    echo "$(OPENJDK_SOURCETREE)"; \
41176434Skaiw  else \
42176434Skaiw    echo "."; \
43176434Skaiw  fi)
44176434Skaiw
45176434Skaiwifndef JDK_TOPDIR
46176434Skaiw  JDK_TOPDIR=$(TOPDIR)/jdk
47176434Skaiwendif
48176434Skaiwifndef JDK_MAKE_SHARED_DIR
49176434Skaiw  JDK_MAKE_SHARED_DIR=$(JDK_TOPDIR)/make/common/shared
50176434Skaiwendif
51176434Skaiw
52176434Skaiwinclude $(JDK_MAKE_SHARED_DIR)/Defs-control.gmk
53176434Skaiw
54176434Skaiwinclude ./make/Defs-internal.gmk
55176434Skaiw
56176434Skaiwall::
57176434Skaiw	@$(ECHO) $(PLATFORM) $(ARCH) $(RELEASE) build started: `$(DATE) '+%y-%m-%d %H:%M'`
58176434Skaiw	$(MKDIR) -p $(OUTPUTDIR)
59176434Skaiw
60176434Skaiw# Rules for sanity checks
61176434Skaiwinclude ./make/sanity-rules.gmk
62176434Skaiw
63176434Skaiwdev : dev-build
64176434Skaiw
65176434Skaiwdev-build:
66176434Skaiw	$(MAKE) DEV_ONLY=true all
67176434Skaiwdev-sanity:
68176434Skaiw	$(MAKE) DEV_ONLY=true sanity
69176434Skaiwdev-clobber:
70176434Skaiw	$(MAKE) DEV_ONLY=true clobber
71176434Skaiw
72176434Skaiw# Rules for various components
73176434Skaiwinclude ./make/hotspot-rules.gmk
74176434Skaiwinclude ./make/langtools-rules.gmk
75176434Skaiwinclude ./make/corba-rules.gmk
76176434Skaiwinclude ./make/jaxp-rules.gmk
77176434Skaiwinclude ./make/jaxws-rules.gmk
78176434Skaiwinclude ./make/jdk-rules.gmk
79176434Skaiwinclude ./make/install-rules.gmk
80176434Skaiwinclude ./make/sponsors-rules.gmk
81176434Skaiwinclude ./make/deploy-rules.gmk
82176434Skaiw
83176434Skaiwall:: setup build
84176434Skaiw
85176434Skaiwsetup: openjdk_check
86176434Skaiw	$(MKDIR) -p $(OUTPUTDIR)/j2sdk-image
87176434Skaiw
88176434Skaiw# Check on whether we really can build the openjdk, need source etc.
89176434Skaiwopenjdk_check: FRC
90201166Skientzleifneq ($(SKIP_OPENJDK_BUILD), true)
91248612Smm	@$(ECHO) " "
92176434Skaiw	@$(ECHO) "================================================="
93176434Skaiw	@if [ ! -r $(OPENJDK_BUILDDIR)/Makefile ] ; then \
94176434Skaiw	    $(ECHO) "ERROR: No openjdk source tree available at: $(OPENJDK_BUILDDIR)"; \
95176434Skaiw	    exit 1; \
96176434Skaiw	else \
97176434Skaiw	    $(ECHO) "OpenJDK will be built after JDK is built"; \
98176434Skaiw	    $(ECHO) "  OPENJDK_BUILDDIR=$(OPENJDK_BUILDDIR)"; \
99176434Skaiw	fi
100176434Skaiw	@$(ECHO) "================================================="
101176434Skaiw	@$(ECHO) " "
102176434Skaiwendif
103176434Skaiw
104176434Skaiwbuild:: sanity 
105176434Skaiw
106176434Skaiwclobber::
107176434Skaiw
108176434Skaiwifeq ($(BUILD_LANGTOOLS), true)
109176434Skaiw  build:: langtools
110176434Skaiw  clobber:: langtools-clobber
111176434Skaiwendif
112176434Skaiw
113176434Skaiwifeq ($(BUILD_CORBA), true)
114176434Skaiw  build:: corba
115176434Skaiw  clobber:: corba-clobber
116176434Skaiwendif
117176434Skaiw
118176434Skaiwifeq ($(BUILD_JAXP), true)
119176434Skaiw  build:: jaxp
120176434Skaiw  clobber:: jaxp-clobber
121176434Skaiwendif
122176434Skaiw
123176434Skaiwifeq ($(BUILD_JAXWS), true)
124176434Skaiw  build:: jaxws
125176434Skaiw  clobber:: jaxws-clobber
126176434Skaiwendif
127176434Skaiw
128176434Skaiwifeq ($(BUILD_HOTSPOT), true)
129176434Skaiw  build:: $(HOTSPOT) 
130176434Skaiw  clobber:: hotspot-clobber
131176434Skaiwendif
132176434Skaiw
133176434Skaiwifeq ($(BUILD_JDK), true)
134176434Skaiw  build:: $(JDK_JAVA_EXE)
135176434Skaiw  clobber:: jdk-clobber
136176434Skaiwendif
137176434Skaiw
138176434Skaiwifeq ($(BUILD_DEPLOY), true)
139176434Skaiw  build:: $(DEPLOY)
140176434Skaiw  clobber:: deploy-clobber
141176434Skaiwendif
142176434Skaiw
143176434Skaiw#
144176434Skaiw# Generic debug build, fastdebug or debug. Needs special handling.
145176434Skaiw#  Note that debug builds do NOT do INSTALL steps, but must be done
146176434Skaiw#  after the product build and before the INSTALL step of the product build.
147176434Skaiw#
148176434Skaiw#   DEBUG_NAME is fastdebug or debug
149176434Skaiw#   ALT_OUTPUTDIR is changed to have -debug or -fastdebug suffix
150176434Skaiw#   The resulting j2sdk-image is used by the install makefiles to create a
151176434Skaiw#     debug install bundle jdk-*-debug-** bundle (tar or zip) 
152176434Skaiw#     which will install in the debug or fastdebug subdirectory of the
153176434Skaiw#     normal product install area.
154176434Skaiw#     The install process needs to know what the DEBUG_NAME is, so
155176434Skaiw#     look for INSTALL_DEBUG_NAME in the install rules.
156176434Skaiw#
157176434Skaiw
158176434SkaiwCOMMON_DEBUG_FLAGS= \
159176434Skaiw	DEBUG_NAME=$(DEBUG_NAME) \
160176434Skaiw	ALT_OUTPUTDIR=$(ABS_OUTPUTDIR)-$(DEBUG_NAME) \
161176434Skaiw	NO_DOCS=true
162176434Skaiw
163176434Skaiwproduct_build: setup
164176434Skaiw	@$(ECHO) $@ build started: `$(DATE) '+%y-%m-%d %H:%M'`
165176434Skaiw	$(MAKE) SKIP_FASTDEBUG_BUILD=true SKIP_DEBUG_BUILD=true all
166176434Skaiw	@$(ECHO) $@ build finished: `$(DATE) '+%y-%m-%d %H:%M'`
167176434Skaiw
168176434Skaiwgeneric_debug_build:
169176434Skaiw	@$(ECHO) $@ build started: `$(DATE) '+%y-%m-%d %H:%M'`
170176434Skaiw	$(MAKE) $(COMMON_DEBUG_FLAGS) setup build
171176434Skaiw	@$(ECHO) $@ build finished: `$(DATE) '+%y-%m-%d %H:%M'`
172176434Skaiw
173176434Skaiwdebug_build: setup
174176434Skaiw	$(MAKE) DEBUG_NAME=debug generic_debug_build
175176434Skaiw
176176434Skaiwfastdebug_build: setup
177176434Skaiw	$(MAKE) DEBUG_NAME=fastdebug generic_debug_build
178176434Skaiw
179176434Skaiwifeq ($(SKIP_FASTDEBUG_BUILD), false)
180176434Skaiw  all:: fastdebug_build
181176434Skaiwendif
182176434Skaiw
183176434Skaiwifeq ($(SKIP_DEBUG_BUILD), false)
184176434Skaiw  all:: debug_build
185176434Skaiwendif
186176434Skaiw
187176434Skaiwifeq ($(BUILD_JDK), true)
188176434Skaiw  ifeq ($(BUNDLE_RULES_AVAILABLE), true)
189176434Skaiw    all:: openjdk-binary-plugs-bundles
190176434Skaiw  endif
191176434Skaiwendif
192176434Skaiw
193176434Skaiwifeq ($(BUILD_INSTALL), true)
194176434Skaiw  all :: $(INSTALL)
195176434Skaiw  clobber:: install-clobber
196176434Skaiwendif
197176434Skaiw
198176434Skaiwifeq ($(BUILD_SPONSORS), true)
199176434Skaiw  all :: $(SPONSORS)
200176434Skaiw  clobber:: sponsors-clobber
201176434Skaiwendif
202248612Smm
203176434Skaiwifneq ($(SKIP_COMPARE_IMAGES), true)
204  all :: compare-image
205endif
206
207ifneq ($(SKIP_OPENJDK_BUILD), true)
208  all :: openjdk_build
209endif
210
211# If we have bundle rules, we have a chance here to do a complete cycle
212#   build, of production and open build.
213# FIXUP: We should create the openjdk source bundle and build that?
214#   But how do we reliable create or get at a formal openjdk source tree?
215#   The one we have needs to be trimmed of built bits and closed dirs.
216#   The repositories might not be available.
217#   The openjdk source bundle is probably not available.
218
219ifneq ($(SKIP_OPENJDK_BUILD), true)
220  ifeq ($(BUILD_JDK), true)
221    ifeq ($(BUNDLE_RULES_AVAILABLE), true)
222
223OPENJDK_PLUGS=$(ABS_OUTPUTDIR)/$(OPENJDK_BINARY_PLUGS_INAME)
224OPENJDK_OUTPUTDIR=$(ABS_OUTPUTDIR)/open-output
225OPENJDK_BUILD_NAME \
226  = openjdk-$(JDK_MINOR_VERSION)-$(BUILD_NUMBER)-$(PLATFORM)-$(ARCH)-$(BUNDLE_DATE)
227OPENJDK_BUILD_BINARY_ZIP=$(ABS_BIN_BUNDLEDIR)/$(OPENJDK_BUILD_NAME).zip
228BUILT_IMAGE=$(ABS_OUTPUTDIR)/j2sdk-image
229ifeq ($(PLATFORM)$(ARCH_DATA_MODEL),solaris64)
230  OPENJDK_BOOTDIR=$(BOOTDIR)
231  OPENJDK_IMPORTJDK=$(JDK_IMPORT_PATH)
232else
233  OPENJDK_BOOTDIR=$(BUILT_IMAGE)
234  OPENJDK_IMPORTJDK=$(BUILT_IMAGE)
235endif
236
237openjdk_build:
238	@$(ECHO) " "
239	@$(ECHO) "================================================="
240	@$(ECHO) "Starting openjdk build"
241	@$(ECHO) " Using: ALT_JDK_DEVTOOLS_DIR=$(JDK_DEVTOOLS_DIR)"
242	@$(ECHO) "================================================="
243	@$(ECHO) " "
244	$(RM) -r $(OPENJDK_OUTPUTDIR)
245	$(MKDIR) -p $(OPENJDK_OUTPUTDIR)
246	($(CD) $(OPENJDK_BUILDDIR) && $(MAKE) \
247	  OPENJDK=true \
248	  ALT_JDK_DEVTOOLS_DIR=$(JDK_DEVTOOLS_DIR) \
249	  ALT_OUTPUTDIR=$(OPENJDK_OUTPUTDIR) \
250	  ALT_BINARY_PLUGS_PATH=$(OPENJDK_PLUGS) \
251	  ALT_BOOTDIR=$(OPENJDK_BOOTDIR) \
252	  ALT_JDK_IMPORT_PATH=$(OPENJDK_IMPORTJDK) \
253		product_build )
254	$(RM) $(OPENJDK_BUILD_BINARY_ZIP)
255	( $(CD) $(OPENJDK_OUTPUTDIR)/j2sdk-image && \
256	  $(ZIPEXE) -q -r $(OPENJDK_BUILD_BINARY_ZIP) .)
257	$(RM) -r $(OPENJDK_OUTPUTDIR)
258	@$(ECHO) " "
259	@$(ECHO) "================================================="
260	@$(ECHO) "Finished openjdk build"
261	@$(ECHO) " Binary Bundle: $(OPENJDK_BUILD_BINARY_ZIP)"
262	@$(ECHO) "================================================="
263	@$(ECHO) " "
264    
265    endif
266  endif
267endif
268
269clobber::
270	$(RM) -r $(OUTPUTDIR)/*
271	$(RM) -r $(OUTPUTDIR)-debug/*
272	$(RM) -r $(OUTPUTDIR)-fastdebug/*
273	-($(RMDIR) -p $(OUTPUTDIR) > $(DEV_NULL) 2>&1; $(TRUE))
274
275clean: clobber
276
277all:: 
278	@$(ECHO) Control build finished: `$(DATE) '+%y-%m-%d %H:%M'`
279
280#
281# Quick jdk verification build
282#
283jdk_only:
284	$(MAKE) SKIP_FASTDEBUG_BUILD=true BUILD_HOTSPOT=false all
285
286
287#
288# Quick jdk verification fastdebug build
289#
290jdk_fastdebug_only:
291	$(MAKE) DEBUG_NAME=fastdebug BUILD_HOTSPOT=false BUILD_DEPLOY=false \
292	    BUILD_INSTALL=false BUILD_SPONSORS=false generic_debug_build
293
294#
295# Quick deploy verification fastdebug build
296#
297deploy_fastdebug_only:
298	$(MAKE) \
299	    DEBUG_NAME=fastdebug \
300	    BUILD_HOTSPOT=false \
301	    BUILD_JDK=false \
302	    BUILD_LANGTOOLS=false \
303	    BUILD_CORBA=false \
304	    BUILD_JAXP=false \
305	    BUILD_JAXWS=false \
306	    BUILD_INSTALL=false \
307	    BUILD_SPONSORS=false \
308	    generic_debug_build
309
310#
311# Product build (skip debug builds)
312#
313product_only:
314	$(MAKE) SKIP_FASTDEBUG_BUILD=true all
315
316#
317# Check target
318#
319
320check: variable_check
321
322#
323# Help target
324#
325help: intro_help target_help variable_help notes_help examples_help
326
327# Intro help message
328intro_help:
329	@$(ECHO) "\
330Makefile for the JDK builds (all the JDK). \n\
331"
332
333# Target help
334target_help:
335	@$(ECHO) "\
336--- Common Targets ---  \n\
337all               -- build the core JDK (default target) \n\
338help              -- Print out help information \n\
339check             -- Check make variable values for correctness \n\
340sanity            -- Perform detailed sanity checks on system and settings \n\
341fastdebug_build   -- build the core JDK in 'fastdebug' mode (-g -O) \n\
342debug_build       -- build the core JDK in 'debug' mode (-g) \n\
343clean             -- remove all built and imported files \n\
344clobber           -- same as clean \n\
345"
346
347# Variable help (only common ones used by this Makefile)
348variable_help: variable_help_intro variable_list variable_help_end
349variable_help_intro:
350	@$(ECHO) "--- Common Variables ---"
351variable_help_end:
352	@$(ECHO) " "
353
354# One line descriptions for the variables
355OUTPUTDIR.desc             = Output directory
356PARALLEL_COMPILE_JOBS.desc = Solaris/Linux parallel compile run count
357SLASH_JAVA.desc            = Root of all build tools, e.g. /java or J:
358BOOTDIR.desc               = JDK used to boot the build
359JDK_IMPORT_PATH.desc       = JDK used to import components of the build
360COMPILER_PATH.desc         = Compiler install directory
361CACERTS_FILE.desc          = Location of certificates file
362DEVTOOLS_PATH.desc         = Directory containing zip and gnumake
363CUPS_HEADERS_PATH.desc     = Include directory location for CUPS header files
364DXSDK_PATH.desc            = Root directory of DirectX SDK
365MSDEVTOOLS_PATH.desc       = Root directory of VC++ tools (e.g. rc.exe)
366MSVCRT_DLL_PATH.desc       = Directory containing mscvrt.dll
367
368# Make variables to print out (description and value)
369VARIABLE_PRINTVAL_LIST +=       \
370    OUTPUTDIR                   \
371    PARALLEL_COMPILE_JOBS       \
372    SLASH_JAVA                  \
373    BOOTDIR                     \
374    JDK_IMPORT_PATH             \
375    COMPILER_PATH               \
376    CACERTS_FILE                \
377    DEVTOOLS_PATH
378
379# Make variables that should refer to directories that exist
380VARIABLE_CHECKDIR_LIST +=       \
381    SLASH_JAVA                  \
382    BOOTDIR                     \
383    JDK_IMPORT_PATH             \
384    COMPILER_PATH               \
385    DEVTOOLS_PATH 
386
387# Make variables that should refer to files that exist
388VARIABLE_CHECKFIL_LIST +=       \
389    CACERTS_FILE
390
391# Some are windows specific
392ifeq ($(PLATFORM), windows)
393
394VARIABLE_PRINTVAL_LIST +=       \
395    DXSDK_PATH                  \
396    MSDEVTOOLS_PATH             \
397    MSVCRT_DLL_PATH
398
399VARIABLE_CHECKDIR_LIST +=       \
400    DXSDK_PATH                  \
401    MSDEVTOOLS_PATH             \
402    MSVCRT_DLL_PATH
403
404endif
405
406# For pattern rules below, so all are treated the same
407DO_PRINTVAL_LIST=$(VARIABLE_PRINTVAL_LIST:%=%.printval)
408DO_CHECKDIR_LIST=$(VARIABLE_CHECKDIR_LIST:%=%.checkdir)
409DO_CHECKFIL_LIST=$(VARIABLE_CHECKFIL_LIST:%=%.checkfil)
410
411# Complete variable check
412variable_check: $(DO_CHECKDIR_LIST) $(DO_CHECKFIL_LIST)
413variable_list: $(DO_PRINTVAL_LIST) variable_check
414
415# Pattern rule for printing out a variable
416%.printval:
417	@$(ECHO) "  ALT_$* - $($*.desc)"
418	@$(ECHO) "  \t $*=$($*)"
419
420# Pattern rule for checking to see if a variable with a directory exists
421%.checkdir:
422	@if [ ! -d $($*) ] ; then \
423	    $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \
424	fi
425
426# Pattern rule for checking to see if a variable with a file exists
427%.checkfil:
428	@if [ ! -f $($*) ] ; then \
429	    $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \
430	fi
431
432# Misc notes on help
433notes_help:
434	@$(ECHO) "\
435--- Notes --- \n\
436- All builds use same output directory unless overridden with \n\
437 \t ALT_OUTPUTDIR=<dir>, changing from product to fastdebug you may want \n\
438 \t to use the clean target first. \n\
439- JDK_IMPORT_PATH must refer to a compatible build, not all past promoted \n\
440 \t builds or previous release JDK builds will work. \n\
441- The fastest builds have been when the sources and the BOOTDIR are on \n\
442 \t local disk. \n\
443"
444
445examples_help:
446	@$(ECHO) "\
447--- Examples --- \n\
448  $(MAKE) fastdebug_build \n\
449  $(MAKE) ALT_OUTPUTDIR=/tmp/foobar all \n\
450  $(MAKE) ALT_OUTPUTDIR=/tmp/foobar fastdebug_build \n\
451  $(MAKE) ALT_OUTPUTDIR=/tmp/foobar all \n\
452  $(MAKE) ALT_BOOTDIR=/opt/java/jdk1.5.0 \n\
453  $(MAKE) ALT_JDK_IMPORT_PATH=/opt/java/jdk1.6.0 \n\
454"
455
456################################################################
457# Source and binary plug bundling
458################################################################
459ifeq ($(BUNDLE_RULES_AVAILABLE), true)
460  include $(BUNDLE_RULES)
461endif
462
463################################################################
464# Cycle build. Build the jdk, use it to build the jdk again.
465################################################################
466  
467ABS_BOOTDIR_OUTPUTDIR=$(ABS_OUTPUTDIR)/bootjdk
468  
469boot_cycle:
470	$(MAKE) ALT_OUTPUTDIR=$(ABS_BOOTDIR_OUTPUTDIR) product_build
471	$(MAKE) ALT_BOOTDIR=$(ABS_BOOTDIR_OUTPUTDIR)/j2sdk-image product_build
472
473################################################################
474# JPRT rule to build
475################################################################
476
477include ./make/jprt.gmk
478
479################################################################
480#  PHONY
481################################################################
482
483.PHONY: all build what clobber insane \
484	fastdebug_build debug_build product_build setup \
485        dev dev-build dev-sanity dev-clobber
486
487# Force target
488FRC:
489
490