Mon, 23 Mar 2009 17:58:32 -0700
Merge
duke@1 | 1 | # |
duke@1 | 2 | # Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved. |
duke@1 | 3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | # |
duke@1 | 5 | # This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | # under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | # published by the Free Software Foundation. Sun designates this |
duke@1 | 8 | # particular file as subject to the "Classpath" exception as provided |
duke@1 | 9 | # by Sun in the LICENSE file that accompanied this code. |
duke@1 | 10 | # |
duke@1 | 11 | # This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | # version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | # accompanied this code). |
duke@1 | 16 | # |
duke@1 | 17 | # You should have received a copy of the GNU General Public License version |
duke@1 | 18 | # 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | # |
duke@1 | 21 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 22 | # CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 23 | # have any questions. |
duke@1 | 24 | # |
duke@1 | 25 | |
duke@1 | 26 | # |
duke@1 | 27 | # Generic makefile for building shared libraries. |
duke@1 | 28 | # |
duke@1 | 29 | |
duke@1 | 30 | include $(TOPDIR)/make/common/Classes.gmk |
duke@1 | 31 | |
duke@1 | 32 | # |
duke@1 | 33 | # It is important to define these *after* including Classes.gmk |
duke@1 | 34 | # in order to override the values defined inthat makefile. |
duke@1 | 35 | # |
duke@1 | 36 | |
duke@1 | 37 | ACTUAL_LIBRARY_NAME = $(LIB_PREFIX)$(LIBRARY).$(LIBRARY_SUFFIX) |
duke@1 | 38 | ACTUAL_LIBRARY_DIR = $(LIB_LOCATION) |
duke@1 | 39 | ACTUAL_LIBRARY = $(ACTUAL_LIBRARY_DIR)/$(ACTUAL_LIBRARY_NAME) |
duke@1 | 40 | |
duke@1 | 41 | library:: $(ACTUAL_LIBRARY) |
duke@1 | 42 | |
duke@1 | 43 | FILES_o = $(patsubst %.c, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c)))) |
duke@1 | 44 | FILES_o += $(patsubst %.s, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_s)))) |
duke@1 | 45 | FILES_o += $(patsubst %.cpp, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_cpp)))) |
duke@1 | 46 | |
duke@1 | 47 | ifeq ($(INCREMENTAL_BUILD),true) |
duke@1 | 48 | FILES_d = $(patsubst %.c, %.$(DEPEND_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c)))) |
duke@1 | 49 | FILES_d += $(patsubst %.cpp, %.$(DEPEND_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_cpp)))) |
duke@1 | 50 | endif # INCREMENTAL_BUILD |
duke@1 | 51 | |
duke@1 | 52 | ifeq ($(PLATFORM),solaris) |
duke@1 | 53 | # List of all lint files, one for each .c file (only for C) |
duke@1 | 54 | FILES_ln = $(patsubst %.c, %.$(LINT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c)))) |
duke@1 | 55 | endif |
duke@1 | 56 | |
duke@1 | 57 | # |
duke@1 | 58 | # C++ libraries must be linked with CC. |
duke@1 | 59 | # |
duke@1 | 60 | ifdef CPLUSPLUSLIBRARY |
duke@1 | 61 | LINKER=$(LINK.cc) |
duke@1 | 62 | else |
duke@1 | 63 | LINKER=$(LINK.c) |
duke@1 | 64 | endif |
duke@1 | 65 | |
duke@1 | 66 | # We either need to import (copy) libraries in, or build them |
duke@1 | 67 | $(ACTUAL_LIBRARY):: $(INIT) $(TEMPDIR) $(LIBDIR) $(BINDIR) $(EXTDIR) classheaders |
duke@1 | 68 | |
duke@1 | 69 | # |
duke@1 | 70 | # COMPILE_APPROACH: Different approaches to compile up the native object |
duke@1 | 71 | # files as quickly as possible. |
duke@1 | 72 | # The setting of parallel works best on Unix, batch on Windows. |
duke@1 | 73 | # |
duke@1 | 74 | |
duke@1 | 75 | COMPILE_FILES_o = $(OBJDIR)/.files_compiled |
duke@1 | 76 | $(COMPILE_FILES_o): $(FILES_d) $(FILES_o) |
duke@1 | 77 | @$(ECHO) "$<" >> $@ |
duke@1 | 78 | clean:: |
duke@1 | 79 | $(RM) $(COMPILE_FILES_o) |
duke@1 | 80 | |
duke@1 | 81 | # |
duke@1 | 82 | # COMPILE_APPROACH=parallel: Will trigger compilations (just compilations) to |
duke@1 | 83 | # happen in parallel. Greatly decreases Unix build time, even on single CPU |
duke@1 | 84 | # machines, more so on multiple CPU machines. Default is 2 compiles |
duke@1 | 85 | # at a time, but can be adjusted with ALT_PARALLEL_COMPILE_JOBS. |
duke@1 | 86 | # Note that each .d file will also be dependent on it's .o file, see |
duke@1 | 87 | # Rules.gmk. |
duke@1 | 88 | # Note this does not depend on Rules.gmk to work like batch (below) |
duke@1 | 89 | # and this technique doesn't seem to help Windows build time nor does |
duke@1 | 90 | # it work very well, it's possible the Windows Visual Studio compilers |
duke@1 | 91 | # don't work well in a parallel situation, this needs investigation. |
duke@1 | 92 | # |
duke@1 | 93 | |
duke@1 | 94 | ifeq ($(COMPILE_APPROACH),parallel) |
duke@1 | 95 | |
duke@1 | 96 | .PHONY: library_parallel_compile |
duke@1 | 97 | |
duke@1 | 98 | library_parallel_compile: |
duke@1 | 99 | @$(ECHO) "Begin parallel compiles: $(shell $(PWD))" |
duke@1 | 100 | @$(MAKE) -j $(PARALLEL_COMPILE_JOBS) $(COMPILE_FILES_o) |
duke@1 | 101 | @$(ECHO) "Done with parallel compiles: $(shell $(PWD))" |
duke@1 | 102 | |
duke@1 | 103 | $(ACTUAL_LIBRARY):: library_parallel_compile |
duke@1 | 104 | |
duke@1 | 105 | endif |
duke@1 | 106 | |
duke@1 | 107 | # |
duke@1 | 108 | # COMPILE_APPROACH=batch: Will trigger compilations (just compilations) to |
duke@1 | 109 | # happen in batch mode. Greatly decreases Windows build time. |
duke@1 | 110 | # See logic in Rules.gmk for how compiles happen, the $(MAKE) in |
duke@1 | 111 | # library_batch_compile below triggers the actions in Rules.gmk. |
duke@1 | 112 | # Note that each .d file will also be dependent on it's .o file, see |
duke@1 | 113 | # Rules.gmk. |
duke@1 | 114 | # |
duke@1 | 115 | ifeq ($(COMPILE_APPROACH),batch) |
duke@1 | 116 | |
duke@1 | 117 | .PHONY: library_batch_compile |
duke@1 | 118 | |
duke@1 | 119 | library_batch_compile: |
duke@1 | 120 | @$(ECHO) "Begin BATCH compiles: $(shell $(PWD))" |
duke@1 | 121 | $(MAKE) $(COMPILE_FILES_o) |
duke@1 | 122 | $(MAKE) batch_compile |
duke@1 | 123 | @$(ECHO) "Done with BATCH compiles: $(shell $(PWD))" |
duke@1 | 124 | $(MAKE) COMPILE_APPROACH=normal $(COMPILE_FILES_o) |
duke@1 | 125 | |
duke@1 | 126 | $(ACTUAL_LIBRARY):: library_batch_compile |
duke@1 | 127 | |
duke@1 | 128 | endif |
duke@1 | 129 | |
duke@1 | 130 | ifeq ($(PLATFORM), windows) |
duke@1 | 131 | |
duke@1 | 132 | # |
duke@1 | 133 | # Library building rules. |
duke@1 | 134 | # |
duke@1 | 135 | |
duke@1 | 136 | $(LIBRARY).lib:: $(OBJDIR) |
duke@1 | 137 | |
duke@1 | 138 | # build it into $(OBJDIR) so that the other generated files get put |
duke@1 | 139 | # there, then copy just the DLL (and MAP file) to the requested directory. |
duke@1 | 140 | # |
duke@1 | 141 | $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf |
duke@1 | 142 | @$(prep-target) |
duke@1 | 143 | @$(MKDIR) -p $(OBJDIR) |
duke@1 | 144 | $(LINK) -dll -out:$(OBJDIR)/$(@F) \ |
duke@1 | 145 | -map:$(OBJDIR)/$(LIBRARY).map \ |
duke@1 | 146 | $(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \ |
duke@1 | 147 | $(OTHER_LCF) $(JAVALIB) $(LDLIBS) |
duke@1 | 148 | $(CP) $(OBJDIR)/$(@F) $@ |
duke@1 | 149 | $(CP) $(OBJDIR)/$(LIBRARY).map $(@D) |
duke@1 | 150 | $(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D) |
duke@1 | 151 | |
duke@1 | 152 | $(OBJDIR)/$(LIBRARY).lcf: $(OBJDIR)/$(LIBRARY).res $(COMPILE_FILES_o) $(FILES_m) |
duke@1 | 153 | @$(prep-target) |
duke@1 | 154 | @$(MKDIR) -p $(TEMPDIR) |
duke@1 | 155 | @$(ECHO) $(FILES_o) > $@ |
duke@1 | 156 | ifndef LOCAL_RESOURCE_FILE |
duke@1 | 157 | @$(ECHO) $(OBJDIR)/$(LIBRARY).res >> $@ |
duke@1 | 158 | endif |
duke@1 | 159 | @$(ECHO) Created $@ |
duke@1 | 160 | |
duke@1 | 161 | RC_FLAGS += /D "J2SE_FNAME=$(LIBRARY).dll" \ |
duke@1 | 162 | /D "J2SE_INTERNAL_NAME=$(LIBRARY)" \ |
duke@1 | 163 | /D "J2SE_FTYPE=0x2L" |
duke@1 | 164 | |
duke@1 | 165 | $(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE) |
duke@1 | 166 | ifndef LOCAL_RESOURCE_FILE |
duke@1 | 167 | @$(prep-target) |
duke@1 | 168 | $(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE) |
duke@1 | 169 | endif |
duke@1 | 170 | |
duke@1 | 171 | # |
duke@1 | 172 | # Install a .lib file if required. |
duke@1 | 173 | # |
duke@1 | 174 | ifeq ($(INSTALL_DOT_LIB), true) |
duke@1 | 175 | $(ACTUAL_LIBRARY):: $(LIBDIR)/$(LIBRARY).lib |
duke@1 | 176 | |
duke@1 | 177 | clean:: |
duke@1 | 178 | -$(RM) $(LIBDIR)/$(LIBRARY).lib |
duke@1 | 179 | |
duke@1 | 180 | $(LIBDIR)/$(LIBRARY).lib:: $(OBJDIR)/$(LIBRARY).lib |
duke@1 | 181 | $(install-file) |
duke@1 | 182 | |
duke@1 | 183 | $(LIBDIR)/$(LIBRARY).dll:: $(OBJDIR)/$(LIBRARY).dll |
duke@1 | 184 | $(install-file) |
duke@1 | 185 | |
duke@1 | 186 | endif # INSTALL_DOT_LIB |
duke@1 | 187 | |
duke@1 | 188 | else # PLATFORM |
duke@1 | 189 | |
duke@1 | 190 | # |
duke@1 | 191 | # On Solaris, use mcs to write the version into the comment section of |
duke@1 | 192 | # the shared library. On other platforms set this to false at the |
duke@1 | 193 | # make command line. |
duke@1 | 194 | # |
duke@1 | 195 | $(ACTUAL_LIBRARY):: $(COMPILE_FILES_o) $(FILES_m) $(FILES_reorder) |
duke@1 | 196 | @$(prep-target) |
duke@1 | 197 | @$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), _OPT=$(_OPT)" |
duke@1 | 198 | @$(ECHO) "Rebuilding $@ because of $?" |
duke@1 | 199 | $(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS) |
duke@1 | 200 | ifeq ($(WRITE_LIBVERSION),true) |
duke@1 | 201 | $(MCS) -d -a "$(FULL_VERSION)" $@ |
duke@1 | 202 | endif # WRITE_LIBVERSION |
duke@1 | 203 | |
duke@1 | 204 | endif # PLATFORM |
duke@1 | 205 | |
duke@1 | 206 | # |
duke@1 | 207 | # Cross check all linted files against each other |
duke@1 | 208 | # |
duke@1 | 209 | ifeq ($(PLATFORM),solaris) |
duke@1 | 210 | lint.errors : $(FILES_ln) |
duke@1 | 211 | $(LINT.c) $(FILES_ln) $(LDLIBS) |
duke@1 | 212 | endif |
duke@1 | 213 | |
duke@1 | 214 | # |
duke@1 | 215 | # Class libraries with JNI native methods get a include to the package. |
duke@1 | 216 | # |
duke@1 | 217 | ifdef PACKAGE |
duke@1 | 218 | vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR) |
duke@1 | 219 | vpath %.c $(SHARE_SRC)/native/$(PKGDIR) |
duke@1 | 220 | OTHER_INCLUDES += -I$(SHARE_SRC)/native/common -I$(PLATFORM_SRC)/native/common |
duke@1 | 221 | OTHER_INCLUDES += -I$(SHARE_SRC)/native/$(PKGDIR) \ |
duke@1 | 222 | -I$(PLATFORM_SRC)/native/$(PKGDIR) |
duke@1 | 223 | endif |
duke@1 | 224 | |
duke@1 | 225 | # |
duke@1 | 226 | # Clean/clobber rules |
duke@1 | 227 | # |
duke@1 | 228 | clean:: |
duke@1 | 229 | $(RM) -r $(ACTUAL_LIBRARY) |
duke@1 | 230 | |
duke@1 | 231 | clobber:: clean |
duke@1 | 232 | |
duke@1 | 233 | # |
duke@1 | 234 | # INCREMENTAL_BUILD means that this workspace will be built over and over |
duke@1 | 235 | # possibly incrementally. This means tracking the object file dependencies |
duke@1 | 236 | # on include files so that sources get re-compiled when the include files |
duke@1 | 237 | # change. When building from scratch and doing a one time build (like |
duke@1 | 238 | # release engineering or nightly builds) set INCREMENTAL_BUILD=false. |
duke@1 | 239 | # |
duke@1 | 240 | |
duke@1 | 241 | ifeq ($(INCREMENTAL_BUILD),true) |
duke@1 | 242 | |
duke@1 | 243 | # |
duke@1 | 244 | # Workaround: gnumake sometimes says files is empty when it shouldn't |
duke@1 | 245 | # was: files := $(foreach file, $(wildcard $(OBJDIR)/*.$(DEPEND_SUFFIX)), $(file)) |
duke@1 | 246 | # |
duke@1 | 247 | files := $(shell $(LS) $(OBJDIR)/*.$(DEPEND_SUFFIX) 2>/dev/null) |
duke@1 | 248 | |
duke@1 | 249 | # |
duke@1 | 250 | # Only include these files if we have any. |
duke@1 | 251 | # |
duke@1 | 252 | ifneq ($(strip $(files)),) |
duke@1 | 253 | |
duke@1 | 254 | include $(files) |
duke@1 | 255 | |
duke@1 | 256 | endif # files |
duke@1 | 257 | |
duke@1 | 258 | endif # INCREMENTAL_BUILD |
duke@1 | 259 | |
duke@1 | 260 | # |
duke@1 | 261 | # Default dependencies |
duke@1 | 262 | # |
duke@1 | 263 | |
duke@1 | 264 | all: build |
duke@1 | 265 | |
duke@1 | 266 | build: library |
duke@1 | 267 | |
duke@1 | 268 | debug: |
duke@1 | 269 | $(MAKE) VARIANT=DBG build |
duke@1 | 270 | |
duke@1 | 271 | fastdebug: |
duke@1 | 272 | $(MAKE) VARIANT=DBG FASTDEBUG=true build |
duke@1 | 273 | |
duke@1 | 274 | .PHONY: all build debug fastdebug |
duke@1 | 275 |