author | alanb |
Tue, 07 Sep 2010 08:36:10 +0100 | |
changeset 6532 | 46e43203603e |
parent 5506 | 202f599c92aa |
child 7666 | 7b994e3dd41d |
permissions | -rw-r--r-- |
2 | 1 |
# |
5506 | 2 |
# Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
# published by the Free Software Foundation. Oracle designates this |
2 | 8 |
# particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
# by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
# |
|
5506 | 21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
# or visit www.oracle.com if you need additional information or have any |
|
23 |
# questions. |
|
2 | 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 |
# |
|
1776
33e9405ab91b
6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents:
1247
diff
changeset
|
182 |
# In VS2005 or VS2008 the link command creates a .manifest file that we want |
33e9405ab91b
6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents:
1247
diff
changeset
|
183 |
# to insert into the linked artifact so we do not need to track it separately. |
33e9405ab91b
6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents:
1247
diff
changeset
|
184 |
# Use ";#2" for .dll and ";#1" for .exe in the MT command below: |
2 | 185 |
$(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf |
186 |
@$(prep-target) |
|
187 |
@$(MKDIR) -p $(OBJDIR) |
|
188 |
$(LINK) -dll -out:$(OBJDIR)/$(@F) \ |
|
189 |
-map:$(OBJDIR)/$(LIBRARY).map \ |
|
190 |
$(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \ |
|
191 |
$(OTHER_LCF) $(JAVALIB) $(LDLIBS) |
|
1776
33e9405ab91b
6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents:
1247
diff
changeset
|
192 |
ifdef MT |
33e9405ab91b
6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents:
1247
diff
changeset
|
193 |
$(MT) /manifest $(OBJDIR)/$(@F).manifest /outputresource:$(OBJDIR)/$(@F);#2 |
33e9405ab91b
6754862: jdk/src/windows/bin/java_md.c: hardcoded reference to msvcr71.dll
tbell
parents:
1247
diff
changeset
|
194 |
endif |
2 | 195 |
$(CP) $(OBJDIR)/$(@F) $@ |
4665
d14dc3d9e1fa
6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents:
3111
diff
changeset
|
196 |
$(install-module-file) |
2 | 197 |
$(CP) $(OBJDIR)/$(LIBRARY).map $(@D) |
198 |
$(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D) |
|
199 |
||
4665
d14dc3d9e1fa
6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents:
3111
diff
changeset
|
200 |
$(ACTUAL_LIBRARY):: $(ACTUAL_LIBRARY_DIR)/$(LIBRARY).map $(ACTUAL_LIBRARY_DIR)/$(LIBRARY).pdb |
d14dc3d9e1fa
6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents:
3111
diff
changeset
|
201 |
|
d14dc3d9e1fa
6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents:
3111
diff
changeset
|
202 |
$(ACTUAL_LIBRARY_DIR)/%.map: FORCE |
d14dc3d9e1fa
6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents:
3111
diff
changeset
|
203 |
$(install-module-file) |
d14dc3d9e1fa
6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents:
3111
diff
changeset
|
204 |
|
d14dc3d9e1fa
6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents:
3111
diff
changeset
|
205 |
$(ACTUAL_LIBRARY_DIR)/%.pdb: FORCE |
d14dc3d9e1fa
6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents:
3111
diff
changeset
|
206 |
$(install-module-file) |
d14dc3d9e1fa
6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents:
3111
diff
changeset
|
207 |
|
2 | 208 |
endif # LIBRARY |
209 |
||
210 |
$(OBJDIR)/$(LIBRARY).lcf: $(OBJDIR)/$(LIBRARY).res $(COMPILE_FILES_o) $(FILES_m) |
|
211 |
@$(prep-target) |
|
212 |
@$(MKDIR) -p $(TEMPDIR) |
|
213 |
@$(ECHO) $(FILES_o) > $@ |
|
214 |
ifndef LOCAL_RESOURCE_FILE |
|
215 |
@$(ECHO) $(OBJDIR)/$(LIBRARY).res >> $@ |
|
216 |
endif |
|
217 |
@$(ECHO) Created $@ |
|
218 |
||
3111
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
219 |
# JDK name required here |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
220 |
RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \ |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
221 |
/D "JDK_INTERNAL_NAME=$(LIBRARY)" \ |
fefdeafb7ab9
6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7
herrick
parents:
1776
diff
changeset
|
222 |
/D "JDK_FTYPE=0x2L" |
2 | 223 |
|
224 |
$(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE) |
|
225 |
ifndef LOCAL_RESOURCE_FILE |
|
226 |
@$(prep-target) |
|
227 |
$(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE) |
|
228 |
endif |
|
229 |
||
230 |
# |
|
231 |
# Install a .lib file if required. |
|
232 |
# |
|
233 |
ifeq ($(INSTALL_DOT_LIB), true) |
|
234 |
$(ACTUAL_LIBRARY):: $(LIBDIR)/$(LIBRARY).lib |
|
235 |
||
236 |
clean:: |
|
237 |
-$(RM) $(LIBDIR)/$(LIBRARY).lib |
|
238 |
||
239 |
$(LIBDIR)/$(LIBRARY).lib:: $(OBJDIR)/$(LIBRARY).lib |
|
240 |
$(install-file) |
|
241 |
||
242 |
$(LIBDIR)/$(LIBRARY).dll:: $(OBJDIR)/$(LIBRARY).dll |
|
243 |
$(install-file) |
|
244 |
||
245 |
endif # INSTALL_DOT_LIB |
|
246 |
||
247 |
else # PLATFORM |
|
248 |
||
249 |
# |
|
250 |
# On Solaris, use mcs to write the version into the comment section of |
|
251 |
# the shared library. On other platforms set this to false at the |
|
252 |
# make command line. |
|
253 |
# |
|
254 |
$(ACTUAL_LIBRARY):: $(COMPILE_FILES_o) $(FILES_m) $(FILES_reorder) |
|
255 |
@$(prep-target) |
|
917
75261da60fff
6729772: 64-bit build with SS12 compiler: SIGSEGV (0xb) at pc=0x0000000000000048, pid=14826, tid=2
ohair
parents:
2
diff
changeset
|
256 |
@$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), OPTIMIZATION_LEVEL=$(OPTIMIZATION_LEVEL)" |
2 | 257 |
@$(ECHO) "Rebuilding $@ because of $?" |
258 |
ifeq ($(LIBRARY), fdlibm) |
|
259 |
$(AR) -r $@ $(FILES_o) |
|
260 |
else # LIBRARY |
|
261 |
$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS) |
|
4665
d14dc3d9e1fa
6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents:
3111
diff
changeset
|
262 |
$(install-module-file) |
2 | 263 |
ifeq ($(WRITE_LIBVERSION),true) |
264 |
$(MCS) -d -a "$(FULL_VERSION)" $@ |
|
265 |
endif # WRITE_LIBVERSION |
|
266 |
endif # LIBRARY |
|
267 |
||
268 |
endif # PLATFORM |
|
269 |
||
270 |
# |
|
271 |
# Cross check all linted files against each other |
|
272 |
# |
|
273 |
ifeq ($(PLATFORM),solaris) |
|
274 |
lint.errors : $(FILES_ln) |
|
275 |
$(LINT.c) $(FILES_ln) $(LDLIBS) |
|
276 |
endif |
|
277 |
||
278 |
else # COMPILE_IT |
|
279 |
||
280 |
# OpenJDK rule is first so any lib is preferentially copied from that location. |
|
281 |
ifndef USE_BINARY_PLUG_LIBRARY |
|
282 |
||
283 |
# In this case we are just copying the file. |
|
284 |
ifneq ($(LIBRARY), fdlibm) |
|
285 |
# Copies in the file from the JDK_IMPORT_PATH area |
|
286 |
$(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/% |
|
287 |
$(install-import-file) |
|
288 |
$(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/native_threads/% |
|
289 |
$(install-import-file) |
|
290 |
$(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/headless/% |
|
291 |
$(install-import-file) |
|
292 |
$(ACTUAL_LIBRARY_DIR)/%: $(JDK_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/xawt/% |
|
293 |
$(install-import-file) |
|
294 |
else # fdlibm |
|
295 |
$(ACTUAL_LIBRARY_DIR)/%: |
|
296 |
$(prep-target) |
|
297 |
endif # fdlibm |
|
298 |
||
299 |
endif # USE_BINARY_PLUG_LIBRARY |
|
300 |
||
301 |
endif # COMPILE_IT |
|
302 |
||
303 |
# |
|
304 |
# Class libraries with JNI native methods get a include to the package. |
|
305 |
# |
|
306 |
ifdef PACKAGE |
|
307 |
vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR) |
|
308 |
vpath %.c $(SHARE_SRC)/native/$(PKGDIR) |
|
309 |
OTHER_INCLUDES += -I$(SHARE_SRC)/native/common -I$(PLATFORM_SRC)/native/common |
|
310 |
OTHER_INCLUDES += -I$(SHARE_SRC)/native/$(PKGDIR) \ |
|
311 |
-I$(PLATFORM_SRC)/native/$(PKGDIR) |
|
312 |
endif |
|
313 |
||
314 |
# |
|
315 |
# Clean/clobber rules |
|
316 |
# |
|
317 |
clean:: |
|
318 |
$(RM) -r $(ACTUAL_LIBRARY) |
|
319 |
||
320 |
clobber:: clean |
|
321 |
||
322 |
# |
|
323 |
# INCREMENTAL_BUILD means that this workspace will be built over and over |
|
324 |
# possibly incrementally. This means tracking the object file dependencies |
|
325 |
# on include files so that sources get re-compiled when the include files |
|
326 |
# change. When building from scratch and doing a one time build (like |
|
327 |
# release engineering or nightly builds) set INCREMENTAL_BUILD=false. |
|
328 |
# |
|
329 |
||
330 |
ifeq ($(INCREMENTAL_BUILD),true) |
|
331 |
||
332 |
# |
|
333 |
# Workaround: gnumake sometimes says files is empty when it shouldn't |
|
334 |
# was: files := $(foreach file, $(wildcard $(OBJDIR)/*.$(DEPEND_SUFFIX)), $(file)) |
|
335 |
# |
|
336 |
files := $(shell $(LS) $(OBJDIR)/*.$(DEPEND_SUFFIX) 2>/dev/null) |
|
337 |
||
338 |
# |
|
339 |
# Only include these files if we have any. |
|
340 |
# |
|
341 |
ifneq ($(strip $(files)),) |
|
342 |
||
343 |
include $(files) |
|
344 |
||
345 |
endif # files |
|
346 |
||
347 |
endif # INCREMENTAL_BUILD |
|
348 |
||
349 |
# |
|
350 |
# Default dependencies |
|
351 |
# |
|
352 |
||
353 |
all: build |
|
354 |
||
355 |
build: library |
|
356 |
||
357 |
debug: |
|
358 |
$(MAKE) VARIANT=DBG build |
|
359 |
||
360 |
fastdebug: |
|
361 |
$(MAKE) VARIANT=DBG FASTDEBUG=true build |
|
362 |
||
363 |
openjdk: |
|
364 |
$(MAKE) OPENJDK=true build |
|
365 |
||
4665
d14dc3d9e1fa
6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents:
3111
diff
changeset
|
366 |
FORCE: |
d14dc3d9e1fa
6911737: Module build: generate modules with native libraries and any other files not in jar
mchung
parents:
3111
diff
changeset
|
367 |
|
2 | 368 |
.PHONY: all build debug fastdebug |
369 |