author | michaelm |
Tue, 06 Mar 2012 20:34:38 +0000 | |
changeset 12047 | 320a714614e9 |
parent 5506 | 202f599c92aa |
child 14342 | 8435a30053c1 |
permissions | -rw-r--r-- |
2 | 1 |
# |
5506 | 2 |
# Copyright (c) 1995, 2007, 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 |
# Native C/C++ Compile Rules |
|
28 |
# |
|
29 |
||
30 |
# |
|
31 |
# INCREMENTAL_BUILD: Record the #include file dependencies. |
|
32 |
# |
|
33 |
# NOTE: We build make include files with the suffix |
|
34 |
# $(DEPEND_SUFFIX) on every compilation. These are initially |
|
35 |
# created as temp files just in case a ^C kills it in the middle. |
|
36 |
# Compiler is smart enough to handle ^C and not create the .o file, or |
|
37 |
# is supposed to be that smart, but the .$(DEPEND_SUFFIX) file |
|
38 |
# creation here isn't. |
|
39 |
# These .$(DEPEND_SUFFIX) files are included by Library.gmk and |
|
40 |
# Program.gmk, when they exist (Search for 'make dependencies'). |
|
41 |
# |
|
42 |
||
43 |
ifeq ($(INCREMENTAL_BUILD),true) |
|
44 |
||
45 |
$(OBJDIR)/%.$(DEPEND_SUFFIX): %.c |
|
46 |
@$(prep-target) |
|
47 |
@$(ECHO) "Creating $@" |
|
48 |
@$(RM) $@.temp |
|
49 |
@$(CC) $(CC_DEPEND) $(CPPFLAGS) $< 2> $(DEV_NULL) | \ |
|
50 |
$(CC_DEPEND_FILTER) > $@.temp |
|
51 |
@$(MV) $@.temp $@ |
|
52 |
||
53 |
$(OBJDIR)/%.$(DEPEND_SUFFIX): %.cpp |
|
54 |
@$(prep-target) |
|
55 |
@$(ECHO) "Creating $@" |
|
56 |
@$(RM) $@.temp |
|
57 |
@$(CXX) $(CC_DEPEND) $(CPPFLAGS) $(CXXFLAGS) $< 2> $(DEV_NULL) | \ |
|
58 |
$(CC_DEPEND_FILTER) > $@.temp |
|
59 |
@$(MV) $@.temp $@ |
|
60 |
||
61 |
endif # INCREMENTAL_BUILD |
|
62 |
||
63 |
# |
|
64 |
# C, C++, asm files. |
|
65 |
# |
|
66 |
# Normal or parallel compile rule is the same, but batch compiles require |
|
67 |
# we save up the sources files that use the same compile line so that we |
|
68 |
# can do one compile line. |
|
69 |
# |
|
70 |
||
71 |
ifneq ($(COMPILE_APPROACH), batch) |
|
72 |
||
73 |
$(OBJDIR)/%.$(OBJECT_SUFFIX): %.c |
|
74 |
@$(prep-target) |
|
75 |
$(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $< |
|
76 |
@$(check-conventions) |
|
77 |
||
78 |
$(OBJDIR)/%.$(OBJECT_SUFFIX): %.cpp |
|
79 |
@$(prep-target) |
|
80 |
$(COMPILE.cc) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $< |
|
81 |
@$(check-conventions) |
|
82 |
||
83 |
else |
|
84 |
||
85 |
# |
|
86 |
# Batch compiling might be faster if the compiler was smart about recognizing |
|
87 |
# optimization opportunities available when all files are being compiled |
|
88 |
# the same way. Unfortunately this is rare. |
|
89 |
# Automatic pre-compiled headers (pch) might be a possibility so we |
|
90 |
# add any auto pch options here. |
|
91 |
# So we save all the source files that have the same compile line as the |
|
92 |
# first file. A normal compile pass is made after the batch compile |
|
93 |
# to catch anything missed. |
|
94 |
# If the compilers had a -o option that allowed us to direct where to |
|
95 |
# write the object files to, then we would not need to save the object |
|
96 |
# file list or move them from the make directory to the build directory. |
|
97 |
# |
|
98 |
||
99 |
# Source names |
|
100 |
COMPILE_LIST.c = $(OBJDIR)/.source_names_c |
|
101 |
COMPILE_LIST.cpp = $(OBJDIR)/.source_names_cpp |
|
102 |
||
103 |
# Object file list |
|
104 |
COMPILE_OBJ_LIST.c = $(OBJDIR)/.obj_names_c |
|
105 |
COMPILE_OBJ_LIST.cpp = $(OBJDIR)/.obj_names_cpp |
|
106 |
||
107 |
# The compile line |
|
108 |
COMPILE_BATCH.c = $(OBJDIR)/.compile_c |
|
109 |
COMPILE_BATCH.cpp = $(OBJDIR)/.compile_cpp |
|
110 |
||
111 |
# The compile line for the current target |
|
112 |
THIS_COMPILE_BATCH.c = $(COMPILE_BATCH.c)-$(@F) |
|
113 |
THIS_COMPILE_BATCH.cpp = $(COMPILE_BATCH.cpp)-$(@F) |
|
114 |
||
115 |
$(OBJDIR)/%.$(OBJECT_SUFFIX): %.c |
|
116 |
@$(prep-target) |
|
117 |
@$(ECHO) "$(COMPILE.c) $(CFLAGS_GPROF)" > $(THIS_COMPILE_BATCH.c) |
|
118 |
@if [ ! -s $(COMPILE_BATCH.c) ] ; then \ |
|
119 |
$(CP) $(THIS_COMPILE_BATCH.c) $(COMPILE_BATCH.c) ; \ |
|
120 |
$(ECHO) $< > $(COMPILE_LIST.c); \ |
|
121 |
$(ECHO) $(@F) > $(COMPILE_OBJ_LIST.c); \ |
|
122 |
elif [ "`$(DIFF) -w -b $(THIS_COMPILE_BATCH.c) $(COMPILE_BATCH.c)`" \ |
|
123 |
= "" ] ; then \ |
|
124 |
$(ECHO) $< >> $(COMPILE_LIST.c); \ |
|
125 |
$(ECHO) $(@F) >> $(COMPILE_OBJ_LIST.c); \ |
|
126 |
fi |
|
127 |
@$(RM) $(THIS_COMPILE_BATCH.c) |
|
128 |
@$(check-conventions) |
|
129 |
||
130 |
$(OBJDIR)/%.$(OBJECT_SUFFIX): %.cpp |
|
131 |
@$(prep-target) |
|
132 |
@$(ECHO) "$(COMPILE.cpp) $(CFLAGS_GPROF)" > $(THIS_COMPILE_BATCH.cpp) |
|
133 |
@if [ ! -s $(COMPILE_BATCH.cpp) ] ; then \ |
|
134 |
$(CP) $(THIS_COMPILE_BATCH.cpp) $(COMPILE_BATCH.cpp) ; \ |
|
135 |
$(ECHO) $< > $(COMPILE_LIST.cpp); \ |
|
136 |
$(ECHO) $(@F) > $(COMPILE_OBJ_LIST.cpp); \ |
|
137 |
elif [ "`$(DIFF) -w -b $(THIS_COMPILE_BATCH.cpp) $(COMPILE_BATCH.cpp)`"\ |
|
138 |
= "" ] ; then \ |
|
139 |
$(ECHO) $< >> $(COMPILE_LIST.cpp); \ |
|
140 |
$(ECHO) $(@F) >> $(COMPILE_OBJ_LIST.cpp); \ |
|
141 |
fi |
|
142 |
@$(RM) $(THIS_COMPILE_BATCH.cpp) |
|
143 |
@$(check-conventions) |
|
144 |
||
145 |
batch_compile: $(FILES_o) |
|
146 |
@$(ECHO) "Doing batch compilations" |
|
147 |
@if [ -s $(COMPILE_LIST.c) ] ; then \ |
|
148 |
$(ECHO) "$(COMPILE.c) $(CFLAGS_GPROF) $(AUTOMATIC_PCH_OPTION) \ |
|
149 |
`$(CAT) $(COMPILE_LIST.c)`" ; \ |
|
150 |
( $(COMPILE.c) $(CFLAGS_GPROF) $(AUTOMATIC_PCH_OPTION) \ |
|
151 |
`$(CAT) $(COMPILE_LIST.c)` && \ |
|
152 |
$(ECHO) "$(MV) `$(CAT) $(COMPILE_OBJ_LIST.c)` $(OBJDIR)" && \ |
|
153 |
$(MV) `$(CAT) $(COMPILE_OBJ_LIST.c)` $(OBJDIR) ) || exit 1 ; \ |
|
154 |
fi |
|
155 |
@if [ -s $(COMPILE_LIST.cpp) ] ; then \ |
|
156 |
$(ECHO) "$(COMPILE.cpp) $(CFLAGS_GPROF) $(AUTOMATIC_PCH_OPTION) \ |
|
157 |
`$(CAT) $(COMPILE_LIST.cpp)`" ; \ |
|
158 |
( $(COMPILE.cpp) $(CFLAGS_GPROF) $(AUTOMATIC_PCH_OPTION) \ |
|
159 |
`$(CAT) $(COMPILE_LIST.cpp)` && \ |
|
160 |
$(ECHO) "$(MV) `$(CAT) $(COMPILE_OBJ_LIST.cpp)` $(OBJDIR)" && \ |
|
161 |
$(MV) `$(CAT) $(COMPILE_OBJ_LIST.cpp)` $(OBJDIR) ) || exit 1 ; \ |
|
162 |
fi |
|
163 |
@$(RM) $(COMPILE_BATCH.c) $(COMPILE_LIST.c) $(COMPILE_OBJ_LIST.c) |
|
164 |
@$(RM) $(COMPILE_BATCH.cpp) $(COMPILE_LIST.cpp) $(COMPILE_OBJ_LIST.cpp) |
|
165 |
||
166 |
endif |
|
167 |
||
168 |
# newer as does not handle c++ style comments |
|
169 |
$(OBJDIR)/%.$(OBJECT_SUFFIX): %.s |
|
170 |
ifneq ($(CC_VERSION), gcc) |
|
171 |
@$(prep-target) |
|
172 |
$(COMPILE.s) $(CC_OBJECT_OUTPUT_FLAG)$@ $< |
|
173 |
else |
|
174 |
@$(prep-target) |
|
175 |
$(CPP) -x assembler-with-cpp $< | $(COMPILE.s) -o $@ |
|
176 |
endif |
|
177 |
@$(check-conventions) |
|
178 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
179 |
# Obj-C files (Mac OS X only). |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
180 |
ifeq ($(PLATFORM), macosx) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
181 |
$(OBJDIR)/%.$(OBJECT_SUFFIX): %.m |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
182 |
@$(prep-target) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
183 |
$(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $< |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
184 |
@$(check-conventions) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
185 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
186 |
$(OBJDIR)/%.$(OBJECT_SUFFIX): %.mm |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
187 |
@$(prep-target) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
188 |
$(COMPILE.cc) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $< |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
189 |
@$(check-conventions) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
190 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
191 |
$(OBJDIR)/%.$(OBJECT_SUFFIX): %.c |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
192 |
@$(prep-target) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
193 |
$(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $< |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
194 |
@$(check-conventions) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
195 |
endif # PLATFORM |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
196 |
|
2 | 197 |
# |
198 |
# Quick hack for making the compiler generate just the assembly file. |
|
199 |
# $ gnumake obj/sparc/myfile.s |
|
200 |
# |
|
201 |
$(OBJDIR)/%.s: %.c |
|
202 |
@$(prep-target) |
|
203 |
$(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ -S $< |
|
204 |
@$(check-conventions) |
|
205 |
||
206 |
# remove the intermediate files from the directories. |
|
207 |
# (If VARIANT=OPT, this removes all debug and fastdebug files too) |
|
208 |
clobber clean:: |
|
209 |
$(RM) -r $(OBJDIR) |
|
210 |
$(RM) -r $(OBJDIR)_* |
|
211 |
||
212 |
# |
|
213 |
# Lint support |
|
214 |
# (The 'lint' rule below is an older rule not using the .$(LINT_SUFFIX) files) |
|
215 |
# |
|
216 |
||
217 |
ifeq ($(PLATFORM), solaris) |
|
218 |
$(OBJDIR)/%.$(LINT_SUFFIX): %.c |
|
219 |
@$(prep-target) |
|
220 |
$(LINT.c) -dirout=$(OBJDIR) -c $< |
|
221 |
lint.clean: |
|
222 |
$(RM) $(OBJDIR)/*.$(LINT_SUFFIX) |
|
223 |
# Old rule |
|
224 |
lint: $(FILES_c) |
|
225 |
ifneq ($(FILES_c),) |
|
226 |
$(LINT.c) -Ncheck -Nlevel=3 $? $(LDLIBS) > lint.$(ARCH) 2>&1 |
|
227 |
endif |
|
228 |
endif |
|
229 |
||
230 |
.PHONY: batch_compile |
|
231 |
||
232 |