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