2
|
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 |
|
|
26 |
#
|
|
27 |
# Generic makefile for building shared libraries.
|
|
28 |
#
|
|
29 |
|
|
30 |
# WARNING: This file is shared with other workspaces.
|
|
31 |
# So when it includes other files, it must use JDK_TOPDIR.
|
|
32 |
#
|
|
33 |
|
|
34 |
include $(JDK_TOPDIR)/make/common/Classes.gmk
|
|
35 |
|
|
36 |
#
|
|
37 |
# It is important to define these *after* including Classes.gmk
|
|
38 |
# in order to override the values defined inthat makefile.
|
|
39 |
#
|
|
40 |
|
|
41 |
ifeq ($(LIBRARY), fdlibm)
|
|
42 |
ifeq ($(PLATFORM),windows)
|
|
43 |
ACTUAL_LIBRARY_NAME = $(LIB_PREFIX)$(LIBRARY).$(FDDLIBM_SUFFIX)
|
|
44 |
ACTUAL_LIBRARY_DIR = $(OBJDIR)
|
|
45 |
else # PLATFORM
|
|
46 |
ACTUAL_LIBRARY_NAME = $(LIB_PREFIX)$(LIBRARY).$(ARCH).$(FDDLIBM_SUFFIX)
|
|
47 |
ACTUAL_LIBRARY_DIR = $(OBJDIR)
|
|
48 |
endif #PLATFORM
|
|
49 |
else # LIBRARY
|
|
50 |
ACTUAL_LIBRARY_NAME = $(LIB_PREFIX)$(LIBRARY).$(LIBRARY_SUFFIX)
|
|
51 |
ACTUAL_LIBRARY_DIR = $(LIB_LOCATION)
|
|
52 |
endif
|
|
53 |
ACTUAL_LIBRARY = $(ACTUAL_LIBRARY_DIR)/$(ACTUAL_LIBRARY_NAME)
|
|
54 |
|
|
55 |
library:: $(ACTUAL_LIBRARY)
|
|
56 |
|
|
57 |
FILES_o = $(patsubst %.c, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c))))
|
|
58 |
FILES_o += $(patsubst %.s, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_s))))
|
|
59 |
FILES_o += $(patsubst %.cpp, %.$(OBJECT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_cpp))))
|
|
60 |
|
|
61 |
ifeq ($(INCREMENTAL_BUILD),true)
|
|
62 |
FILES_d = $(patsubst %.c, %.$(DEPEND_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c))))
|
|
63 |
FILES_d += $(patsubst %.cpp, %.$(DEPEND_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_cpp))))
|
|
64 |
endif # INCREMENTAL_BUILD
|
|
65 |
|
|
66 |
ifeq ($(PLATFORM),solaris)
|
|
67 |
# List of all lint files, one for each .c file (only for C)
|
|
68 |
FILES_ln = $(patsubst %.c, %.$(LINT_SUFFIX), $(addprefix $(OBJDIR)/, $(notdir $(FILES_c))))
|
|
69 |
endif
|
|
70 |
|
|
71 |
#
|
|
72 |
# C++ libraries must be linked with CC.
|
|
73 |
#
|
|
74 |
ifdef CPLUSPLUSLIBRARY
|
|
75 |
LINKER=$(LINK.cc)
|
|
76 |
else
|
|
77 |
LINKER=$(LINK.c)
|
|
78 |
endif
|
|
79 |
|
|
80 |
# FIXUP: unpack needs the zip .o files. So we must build zip?
|
|
81 |
# or fix unpack makefile so it uses Program.gmk.
|
|
82 |
ifneq ($(IMPORT_NATIVE_BINARIES),true)
|
|
83 |
COMPILE_IT=true
|
|
84 |
else
|
|
85 |
ifeq ($(LIBRARY),zip)
|
|
86 |
COMPILE_IT=true
|
|
87 |
else
|
|
88 |
COMPILE_IT=false
|
|
89 |
endif
|
|
90 |
endif
|
|
91 |
|
|
92 |
# If a Makefile has specified a pre-compiled closed src lib, just copy it.
|
|
93 |
ifdef USE_BINARY_PLUG_LIBRARY
|
|
94 |
COMPILE_IT=false
|
|
95 |
endif
|
|
96 |
|
|
97 |
# We either need to import (copy) libraries in, or build them
|
|
98 |
ifeq ($(COMPILE_IT),true)
|
|
99 |
|
|
100 |
$(ACTUAL_LIBRARY):: $(INIT) $(TEMPDIR) $(LIBDIR) $(BINDIR) $(EXTDIR) classheaders
|
|
101 |
|
|
102 |
#
|
|
103 |
# COMPILE_APPROACH: Different approaches to compile up the native object
|
|
104 |
# files as quickly as possible.
|
|
105 |
# The setting of parallel works best on Unix, batch on Windows.
|
|
106 |
#
|
|
107 |
|
|
108 |
COMPILE_FILES_o = $(OBJDIR)/.files_compiled
|
|
109 |
$(COMPILE_FILES_o): $(FILES_d) $(FILES_o)
|
|
110 |
@$(ECHO) "$<" >> $@
|
|
111 |
clean::
|
|
112 |
$(RM) $(COMPILE_FILES_o)
|
|
113 |
|
|
114 |
#
|
|
115 |
# COMPILE_APPROACH=parallel: Will trigger compilations (just compilations) to
|
|
116 |
# happen in parallel. Greatly decreases Unix build time, even on single CPU
|
|
117 |
# machines, more so on multiple CPU machines. Default is 2 compiles
|
|
118 |
# at a time, but can be adjusted with ALT_PARALLEL_COMPILE_JOBS.
|
|
119 |
# Note that each .d file will also be dependent on it's .o file, see
|
|
120 |
# Rules.gmk.
|
|
121 |
# Note this does not depend on Rules.gmk to work like batch (below)
|
|
122 |
# and this technique doesn't seem to help Windows build time nor does
|
|
123 |
# it work very well, it's possible the Windows Visual Studio compilers
|
|
124 |
# don't work well in a parallel situation, this needs investigation.
|
|
125 |
#
|
|
126 |
|
|
127 |
ifeq ($(COMPILE_APPROACH),parallel)
|
|
128 |
|
|
129 |
.PHONY: library_parallel_compile
|
|
130 |
|
|
131 |
library_parallel_compile:
|
|
132 |
@$(ECHO) "Begin parallel compiles: $(shell $(PWD))"
|
|
133 |
@$(MAKE) -j $(PARALLEL_COMPILE_JOBS) $(COMPILE_FILES_o)
|
|
134 |
@$(ECHO) "Done with parallel compiles: $(shell $(PWD))"
|
|
135 |
|
|
136 |
$(ACTUAL_LIBRARY):: library_parallel_compile
|
|
137 |
|
|
138 |
endif
|
|
139 |
|
|
140 |
#
|
|
141 |
# COMPILE_APPROACH=batch: Will trigger compilations (just compilations) to
|
|
142 |
# happen in batch mode. Greatly decreases Windows build time.
|
|
143 |
# See logic in Rules.gmk for how compiles happen, the $(MAKE) in
|
|
144 |
# library_batch_compile below triggers the actions in Rules.gmk.
|
|
145 |
# Note that each .d file will also be dependent on it's .o file, see
|
|
146 |
# Rules.gmk.
|
|
147 |
#
|
|
148 |
ifeq ($(COMPILE_APPROACH),batch)
|
|
149 |
|
|
150 |
.PHONY: library_batch_compile
|
|
151 |
|
|
152 |
library_batch_compile:
|
|
153 |
@$(ECHO) "Begin BATCH compiles: $(shell $(PWD))"
|
|
154 |
$(MAKE) $(COMPILE_FILES_o)
|
|
155 |
$(MAKE) batch_compile
|
|
156 |
@$(ECHO) "Done with BATCH compiles: $(shell $(PWD))"
|
|
157 |
$(MAKE) COMPILE_APPROACH=normal $(COMPILE_FILES_o)
|
|
158 |
|
|
159 |
$(ACTUAL_LIBRARY):: library_batch_compile
|
|
160 |
|
|
161 |
endif
|
|
162 |
|
|
163 |
ifeq ($(PLATFORM), windows)
|
|
164 |
|
|
165 |
#
|
|
166 |
# Library building rules.
|
|
167 |
#
|
|
168 |
|
|
169 |
$(LIBRARY).lib:: $(OBJDIR)
|
|
170 |
|
|
171 |
ifeq ($(LIBRARY), fdlibm)
|
|
172 |
$(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lib
|
|
173 |
|
|
174 |
$(OBJDIR)/$(LIBRARY).lib:: $(OBJDIR)/$(LIBRARY).lcf
|
|
175 |
@$(prep-target)
|
|
176 |
$(LIBEXE) -NODEFAULTLIB:MSVCRT -out:$@ -nologo \
|
|
177 |
@$(OBJDIR)/$(LIBRARY).lcf $(OTHER_LCF) $(LDLIBS_COMMON)
|
|
178 |
else # LIBRARY
|
|
179 |
# build it into $(OBJDIR) so that the other generated files get put
|
|
180 |
# there, then copy just the DLL (and MAP file) to the requested directory.
|
|
181 |
#
|
|
182 |
$(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf
|
|
183 |
@$(prep-target)
|
|
184 |
@$(MKDIR) -p $(OBJDIR)
|
|
185 |
$(LINK) -dll -out:$(OBJDIR)/$(@F) \
|
|
186 |
-map:$(OBJDIR)/$(LIBRARY).map \
|
|
187 |
$(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \
|
|
188 |
$(OTHER_LCF) $(JAVALIB) $(LDLIBS)
|
|
189 |
$(CP) $(OBJDIR)/$(@F) $@
|
|
190 |
$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
|
|
191 |
$(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
|
|
192 |
|
|
193 |
endif # LIBRARY
|
|
194 |
|
|
195 |
$(OBJDIR)/$(LIBRARY).lcf: $(OBJDIR)/$(LIBRARY).res $(COMPILE_FILES_o) $(FILES_m)
|
|
196 |
@$(prep-target)
|
|
197 |
@$(MKDIR) -p $(TEMPDIR)
|
|
198 |
@$(ECHO) $(FILES_o) > $@
|
|
199 |
ifndef LOCAL_RESOURCE_FILE
|
|
200 |
@$(ECHO) $(OBJDIR)/$(LIBRARY).res >> $@
|
|
201 |
endif
|
|
202 |
@$(ECHO) Created $@
|
|
203 |
|
|
204 |
# J2SE name required here
|
|
205 |
RC_FLAGS += /D "J2SE_FNAME=$(LIBRARY).dll" \
|
|
206 |
/D "J2SE_INTERNAL_NAME=$(LIBRARY)" \
|
|
207 |
/D "J2SE_FTYPE=0x2L"
|
|
208 |
|
|
209 |
$(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE)
|
|
210 |
ifndef LOCAL_RESOURCE_FILE
|
|
211 |
@$(prep-target)
|
|
212 |
$(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE)
|
|
213 |
endif
|
|
214 |
|
|
215 |
#
|
|
216 |
# Install a .lib file if required.
|
|
217 |
#
|
|
218 |
ifeq ($(INSTALL_DOT_LIB), true)
|
|
219 |
$(ACTUAL_LIBRARY):: $(LIBDIR)/$(LIBRARY).lib
|
|
220 |
|
|
221 |
clean::
|
|
222 |
-$(RM) $(LIBDIR)/$(LIBRARY).lib
|
|
223 |
|
|
224 |
$(LIBDIR)/$(LIBRARY).lib:: $(OBJDIR)/$(LIBRARY).lib
|
|
225 |
$(install-file)
|
|
226 |
|
|
227 |
$(LIBDIR)/$(LIBRARY).dll:: $(OBJDIR)/$(LIBRARY).dll
|
|
228 |
$(install-file)
|
|
229 |
|
|
230 |
endif # INSTALL_DOT_LIB
|
|
231 |
|
|
232 |
else # PLATFORM
|
|
233 |
|
|
234 |
#
|
|
235 |
# On Solaris, use mcs to write the version into the comment section of
|
|
236 |
# the shared library. On other platforms set this to false at the
|
|
237 |
# make command line.
|
|
238 |
#
|
|
239 |
$(ACTUAL_LIBRARY):: $(COMPILE_FILES_o) $(FILES_m) $(FILES_reorder)
|
|
240 |
@$(prep-target)
|
|
241 |
@$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), _OPT=$(_OPT)"
|
|
242 |
@$(ECHO) "Rebuilding $@ because of $?"
|
|
243 |
ifeq ($(LIBRARY), fdlibm)
|
|
244 |
$(AR) -r $@ $(FILES_o)
|
|
245 |
else # LIBRARY
|
|
246 |
$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
|
|
247 |
ifeq ($(WRITE_LIBVERSION),true)
|
|
248 |
$(MCS) -d -a "$(FULL_VERSION)" $@
|
|
249 |
endif # WRITE_LIBVERSION
|
|
250 |
endif # LIBRARY
|
|
251 |
|
|
252 |
endif # PLATFORM
|
|
253 |
|
|
254 |
#
|
|
255 |
# Cross check all linted files against each other
|
|
256 |
#
|
|
257 |
ifeq ($(PLATFORM),solaris)
|
|
258 |
lint.errors : $(FILES_ln)
|
|
259 |
$(LINT.c) $(FILES_ln) $(LDLIBS)
|
|
260 |
endif
|
|
261 |
|
|
262 |
else # COMPILE_IT
|
|
263 |
|
|
264 |
# OpenJDK rule is first so any lib is preferentially copied from that location.
|
|
265 |
ifndef USE_BINARY_PLUG_LIBRARY
|
|
266 |
|
|
267 |
# In this case we are just copying the file.
|
|
268 |
ifneq ($(LIBRARY), fdlibm)
|
|
269 |
# Copies in the file from the JDK_IMPORT_PATH area
|
|
270 |
$(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/%
|
|
271 |
$(install-import-file)
|
|
272 |
$(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/native_threads/%
|
|
273 |
$(install-import-file)
|
|
274 |
$(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/headless/%
|
|
275 |
$(install-import-file)
|
|
276 |
$(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/xawt/%
|
|
277 |
$(install-import-file)
|
|
278 |
else # fdlibm
|
|
279 |
$(ACTUAL_LIBRARY_DIR)/%:
|
|
280 |
$(prep-target)
|
|
281 |
endif # fdlibm
|
|
282 |
|
|
283 |
endif # USE_BINARY_PLUG_LIBRARY
|
|
284 |
|
|
285 |
endif # COMPILE_IT
|
|
286 |
|
|
287 |
#
|
|
288 |
# Class libraries with JNI native methods get a include to the package.
|
|
289 |
#
|
|
290 |
ifdef PACKAGE
|
|
291 |
vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)
|
|
292 |
vpath %.c $(SHARE_SRC)/native/$(PKGDIR)
|
|
293 |
OTHER_INCLUDES += -I$(SHARE_SRC)/native/common -I$(PLATFORM_SRC)/native/common
|
|
294 |
OTHER_INCLUDES += -I$(SHARE_SRC)/native/$(PKGDIR) \
|
|
295 |
-I$(PLATFORM_SRC)/native/$(PKGDIR)
|
|
296 |
endif
|
|
297 |
|
|
298 |
#
|
|
299 |
# Clean/clobber rules
|
|
300 |
#
|
|
301 |
clean::
|
|
302 |
$(RM) -r $(ACTUAL_LIBRARY)
|
|
303 |
|
|
304 |
clobber:: clean
|
|
305 |
|
|
306 |
#
|
|
307 |
# INCREMENTAL_BUILD means that this workspace will be built over and over
|
|
308 |
# possibly incrementally. This means tracking the object file dependencies
|
|
309 |
# on include files so that sources get re-compiled when the include files
|
|
310 |
# change. When building from scratch and doing a one time build (like
|
|
311 |
# release engineering or nightly builds) set INCREMENTAL_BUILD=false.
|
|
312 |
#
|
|
313 |
|
|
314 |
ifeq ($(INCREMENTAL_BUILD),true)
|
|
315 |
|
|
316 |
#
|
|
317 |
# Workaround: gnumake sometimes says files is empty when it shouldn't
|
|
318 |
# was: files := $(foreach file, $(wildcard $(OBJDIR)/*.$(DEPEND_SUFFIX)), $(file))
|
|
319 |
#
|
|
320 |
files := $(shell $(LS) $(OBJDIR)/*.$(DEPEND_SUFFIX) 2>/dev/null)
|
|
321 |
|
|
322 |
#
|
|
323 |
# Only include these files if we have any.
|
|
324 |
#
|
|
325 |
ifneq ($(strip $(files)),)
|
|
326 |
|
|
327 |
include $(files)
|
|
328 |
|
|
329 |
endif # files
|
|
330 |
|
|
331 |
endif # INCREMENTAL_BUILD
|
|
332 |
|
|
333 |
#
|
|
334 |
# Default dependencies
|
|
335 |
#
|
|
336 |
|
|
337 |
all: build
|
|
338 |
|
|
339 |
build: library
|
|
340 |
|
|
341 |
debug:
|
|
342 |
$(MAKE) VARIANT=DBG build
|
|
343 |
|
|
344 |
fastdebug:
|
|
345 |
$(MAKE) VARIANT=DBG FASTDEBUG=true build
|
|
346 |
|
|
347 |
openjdk:
|
|
348 |
$(MAKE) OPENJDK=true build
|
|
349 |
|
|
350 |
.PHONY: all build debug fastdebug
|
|
351 |
|