1 #
   2 # Copyright 1999-2008 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.
   8 #
   9 # This code is distributed in the hope that it will be useful, but WITHOUT
  10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12 # version 2 for more details (a copy is included in the LICENSE file that
  13 # accompanied this code).
  14 #
  15 # You should have received a copy of the GNU General Public License version
  16 # 2 along with this work; if not, write to the Free Software Foundation,
  17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 #
  19 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20 # CA 95054 USA or visit www.sun.com if you need additional information or
  21 # have any questions.
  22 #  
  23 #
  24 
  25 # top.make is included in the Makefile in the build directories.
  26 # It DOES NOT include the vm dependency info in order to be faster.
  27 # It's main job is to implement the incremental form of make lists.
  28 # It also:
  29 #   -builds and runs adlc via adlc.make
  30 #   -generates JVMTI source and docs via jvmti.make (JSR-163)
  31 #   -generate sa-jdi.jar (JDI binding to core files)
  32 
  33 # It assumes the following flags are set:
  34 # CFLAGS Platform_file, Src_Dirs, SYSDEFS, AOUT, Obj_Files
  35 
  36 # -- D. Ungar (5/97) from a file by Bill Bush
  37 
  38 # Don't override the built-in $(MAKE).
  39 # Instead, use "gmake" (or "gnumake") from the command line.  --Rose
  40 #MAKE = gmake
  41 
  42 TOPDIR      = $(shell echo `pwd`)
  43 GENERATED   = $(TOPDIR)/../generated
  44 VM          = $(GAMMADIR)/src/share/vm
  45 Plat_File   = $(Platform_file)
  46 CDG         = cd $(GENERATED); 
  47 
  48 # Pick up MakeDeps' sources and definitions
  49 include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/makedeps.make
  50 MakeDepsClass = MakeDeps.class
  51 
  52 ifdef USE_PRECOMPILED_HEADER
  53 PrecompiledOption = -DUSE_PRECOMPILED_HEADER
  54 UpdatePCH         = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS) 
  55 else
  56 UpdatePCH         = \# precompiled header is not used
  57 PrecompiledOption = 
  58 endif
  59 
  60 MakeDeps    = $(RUN.JAVA) $(PrecompiledOption) -classpath $(GENERATED) MakeDeps
  61 
  62 Include_DBs/GC          = $(VM)/includeDB_gc \
  63                           $(VM)/includeDB_gc_parallel \
  64                           $(VM)/gc_implementation/includeDB_gc_parallelScavenge \
  65                           $(VM)/gc_implementation/includeDB_gc_concurrentMarkSweep \
  66                           $(VM)/gc_implementation/includeDB_gc_parNew \
  67                           $(VM)/gc_implementation/includeDB_gc_g1     \
  68                           $(VM)/gc_implementation/includeDB_gc_serial \
  69                           $(VM)/gc_implementation/includeDB_gc_shared
  70 
  71 Include_DBs/CORE        = $(VM)/includeDB_core   $(Include_DBs/GC) \
  72                           $(VM)/includeDB_jvmti \
  73                           $(VM)/includeDB_features
  74 Include_DBs/COMPILER1   = $(Include_DBs/CORE) $(VM)/includeDB_compiler1
  75 Include_DBs/COMPILER2   = $(Include_DBs/CORE) $(VM)/includeDB_compiler2
  76 Include_DBs/TIERED      = $(Include_DBs/CORE) $(VM)/includeDB_compiler1 $(VM)/includeDB_compiler2
  77 Include_DBs = $(Include_DBs/$(TYPE))
  78 
  79 Cached_plat = $(GENERATED)/platform.current
  80 Cached_db   = $(GENERATED)/includeDB.current
  81 
  82 Incremental_Lists = $(Cached_db)
  83 # list generation also creates $(GENERATED)/$(Cached_plat)
  84 
  85 
  86 AD_Dir   = $(GENERATED)/adfiles
  87 ADLC     = $(AD_Dir)/adlc
  88 AD_Spec  = $(GAMMADIR)/src/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad
  89 AD_Src   = $(GAMMADIR)/src/share/vm/adlc
  90 AD_Names = ad_$(Platform_arch_model).hpp ad_$(Platform_arch_model).cpp
  91 AD_Files = $(AD_Names:%=$(AD_Dir)/%)
  92 
  93 # AD_Files_If_Required/COMPILER1 = ad_stuff
  94 AD_Files_If_Required/COMPILER2 = ad_stuff
  95 AD_Files_If_Required/TIERED = ad_stuff
  96 AD_Files_If_Required = $(AD_Files_If_Required/$(TYPE))
  97 
  98 # Wierd argument adjustment for "gnumake -j..."
  99 adjust-mflags   = $(GENERATED)/adjust-mflags
 100 MFLAGS-adjusted = -r `$(adjust-mflags) "$(MFLAGS)" "$(HOTSPOT_BUILD_JOBS)"`
 101 
 102 
 103 # default target: make makeDeps, update lists, make vm
 104 # done in stages to force sequential order with parallel make
 105 #
 106 
 107 default: vm_build_preliminaries the_vm
 108         @echo All done.
 109 
 110 # This is an explicit dependency for the sake of parallel makes.
 111 vm_build_preliminaries:  checks $(Incremental_Lists) $(AD_Files_If_Required) jvmti_stuff sa_stuff
 112         @# We need a null action here, so implicit rules don't get consulted.
 113 
 114 # make makeDeps: (and zap the cached db files to force a nonincremental run)
 115 
 116 $(GENERATED)/$(MakeDepsClass): $(MakeDepsSources)
 117         @$(REMOTE) $(COMPILE.JAVAC) -classpath $(GAMMADIR)/src/share/tools/MakeDeps -g -d $(GENERATED) $(MakeDepsSources)
 118         @echo Removing $(Incremental_Lists) to force regeneration.
 119         @rm -f $(Incremental_Lists)
 120         @$(CDG) echo >$(Cached_plat)
 121 
 122 # make incremental_lists, if cached files out of date, run makeDeps
 123 
 124 $(Incremental_Lists): $(Include_DBs) $(Plat_File) $(GENERATED)/$(MakeDepsClass)
 125         $(CDG) cat $(Include_DBs) > $(GENERATED)/includeDB
 126         $(CDG) if [ ! -r incls ] ; then \
 127         mkdir incls ; \
 128         fi
 129         $(CDG) (echo $(CDG) echo $(MakeDeps) diffs UnixPlatform $(Cached_plat) $(Cached_db) $(Plat_File) $(GENERATED)/includeDB $(MakeDepsOptions)) > makeDeps.sh
 130         $(CDG) $(REMOTE) sh $(GENERATED)/makeDeps.sh
 131         $(CDG) cp includeDB    $(Cached_db)
 132         $(CDG) cp $(Plat_File) $(Cached_plat)
 133 
 134 # symbolic target for command lines
 135 lists: $(Incremental_Lists)
 136         @: lists are now up to date
 137 
 138 # make AD files as necessary
 139 ad_stuff: $(Incremental_Lists) $(adjust-mflags)
 140         @$(MAKE) -f adlc.make $(MFLAGS-adjusted)
 141 
 142 # generate JVMTI files from the spec
 143 jvmti_stuff: $(Incremental_Lists) $(adjust-mflags)
 144         @$(MAKE) -f jvmti.make $(MFLAGS-adjusted)
 145 
 146 # generate SA jar files and native header
 147 sa_stuff:
 148         @$(MAKE) -f sa.make $(MFLAGS-adjusted)
 149 
 150 # and the VM: must use other makefile with dependencies included
 151 
 152 # We have to go to great lengths to get control over the -jN argument
 153 # to the recursive invocation of vm.make.  The problem is that gnumake
 154 # resets -jN to -j1 for recursive runs.  (How helpful.)
 155 # Note that the user must specify the desired parallelism level via a
 156 # command-line or environment variable name HOTSPOT_BUILD_JOBS.
 157 $(adjust-mflags): $(GAMMADIR)/make/$(Platform_os_family)/makefiles/adjust-mflags.sh
 158         @+rm -f $@ $@+
 159         @+cat $< > $@+
 160         @+chmod +x $@+
 161         @+mv $@+ $@
 162 
 163 the_vm: vm_build_preliminaries $(adjust-mflags)
 164         @$(UpdatePCH)
 165         @$(MAKE) -f vm.make $(MFLAGS-adjusted)
 166 
 167 install: the_vm
 168         @$(MAKE) -f vm.make install
 169 
 170 # next rules support "make foo.[oi]"
 171 
 172 %.o %.i %.s:
 173         $(UpdatePCH) 
 174         $(MAKE) -f vm.make $(MFLAGS) $@
 175         #$(MAKE) -f vm.make $@
 176 
 177 # this should force everything to be rebuilt
 178 clean: 
 179         rm -f $(GENERATED)/*.class
 180         $(MAKE) $(MFLAGS) $(GENERATED)/$(MakeDepsClass)
 181         $(MAKE) -f vm.make $(MFLAGS) clean
 182 
 183 # just in case it doesn't, this should do it
 184 realclean:
 185         $(MAKE) -f vm.make $(MFLAGS) clean
 186         rm -fr $(GENERATED)
 187 
 188 .PHONY: default vm_build_preliminaries
 189 .PHONY: lists ad_stuff jvmti_stuff sa_stuff the_vm clean realclean
 190 .PHONY: checks check_os_version install