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