source: trunk/openjdk/jdk/make/common/internal/NativeCompileRules.gmk

Last change on this file was 278, checked in by dmik, 14 years ago

trunk: Merged in openjdk6 b22 from branches/vendor/oracle.

File size: 7.1 KB
Line 
1#
2# Copyright (c) 1995, 2007, 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# 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
43ifeq ($(INCREMENTAL_BUILD),true)
44
45$(OBJDIR)/%.$(DEPEND_SUFFIX): %.c
46 @$(prep-target)
47 @$(ECHO) "Creating $@"
48 @$(RM) $@.temp
49 @$(CC) $(CC_DEPEND) $(CPPFLAGS) $< \
50 $(if $(CC_DEPEND_FILTER), | $(CC_DEPEND_FILTER)) \
51 > $@.temp
52 @$(MV) $@.temp $@
53
54$(OBJDIR)/%.$(DEPEND_SUFFIX): %.cpp
55 @$(prep-target)
56 @$(ECHO) "Creating $@"
57 @$(RM) $@.temp
58 @$(CXX) $(CC_DEPEND) $(CPPFLAGS) $(CXXFLAGS) $< \
59 $(if $(CC_DEPEND_FILTER), | $(CC_DEPEND_FILTER)) \
60 > $@.temp
61 @$(MV) $@.temp $@
62
63endif # INCREMENTAL_BUILD
64
65#
66# C, C++, asm files.
67#
68# Normal or parallel compile rule is the same, but batch compiles require
69# we save up the sources files that use the same compile line so that we
70# can do one compile line.
71#
72
73ifneq ($(COMPILE_APPROACH), batch)
74
75$(OBJDIR)/%.$(OBJECT_SUFFIX): %.c
76 @$(prep-target)
77 $(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $<
78 @$(check-conventions)
79
80$(OBJDIR)/%.$(OBJECT_SUFFIX): %.cpp
81 @$(prep-target)
82 $(COMPILE.cc) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $<
83 @$(check-conventions)
84
85else
86
87 #
88 # Batch compiling might be faster if the compiler was smart about recognizing
89 # optimization opportunities available when all files are being compiled
90 # the same way. Unfortunately this is rare.
91 # Automatic pre-compiled headers (pch) might be a possibility so we
92 # add any auto pch options here.
93 # So we save all the source files that have the same compile line as the
94 # first file. A normal compile pass is made after the batch compile
95 # to catch anything missed.
96 # If the compilers had a -o option that allowed us to direct where to
97 # write the object files to, then we would not need to save the object
98 # file list or move them from the make directory to the build directory.
99 #
100
101 # Source names
102 COMPILE_LIST.c = $(OBJDIR)/.source_names_c
103 COMPILE_LIST.cpp = $(OBJDIR)/.source_names_cpp
104
105 # Object file list
106 COMPILE_OBJ_LIST.c = $(OBJDIR)/.obj_names_c
107 COMPILE_OBJ_LIST.cpp = $(OBJDIR)/.obj_names_cpp
108
109 # The compile line
110 COMPILE_BATCH.c = $(OBJDIR)/.compile_c
111 COMPILE_BATCH.cpp = $(OBJDIR)/.compile_cpp
112
113 # The compile line for the current target
114 THIS_COMPILE_BATCH.c = $(COMPILE_BATCH.c)-$(@F)
115 THIS_COMPILE_BATCH.cpp = $(COMPILE_BATCH.cpp)-$(@F)
116
117$(OBJDIR)/%.$(OBJECT_SUFFIX): %.c
118 @$(prep-target)
119 @$(ECHO) "$(COMPILE.c) $(CFLAGS_GPROF)" > $(THIS_COMPILE_BATCH.c)
120 @if [ ! -s $(COMPILE_BATCH.c) ] ; then \
121 $(CP) $(THIS_COMPILE_BATCH.c) $(COMPILE_BATCH.c) ; \
122 $(ECHO) $< > $(COMPILE_LIST.c); \
123 $(ECHO) $(@F) > $(COMPILE_OBJ_LIST.c); \
124 elif [ "`$(DIFF) -w -b $(THIS_COMPILE_BATCH.c) $(COMPILE_BATCH.c)`" \
125 = "" ] ; then \
126 $(ECHO) $< >> $(COMPILE_LIST.c); \
127 $(ECHO) $(@F) >> $(COMPILE_OBJ_LIST.c); \
128 fi
129 @$(RM) $(THIS_COMPILE_BATCH.c)
130 @$(check-conventions)
131
132$(OBJDIR)/%.$(OBJECT_SUFFIX): %.cpp
133 @$(prep-target)
134 @$(ECHO) "$(COMPILE.cpp) $(CFLAGS_GPROF)" > $(THIS_COMPILE_BATCH.cpp)
135 @if [ ! -s $(COMPILE_BATCH.cpp) ] ; then \
136 $(CP) $(THIS_COMPILE_BATCH.cpp) $(COMPILE_BATCH.cpp) ; \
137 $(ECHO) $< > $(COMPILE_LIST.cpp); \
138 $(ECHO) $(@F) > $(COMPILE_OBJ_LIST.cpp); \
139 elif [ "`$(DIFF) -w -b $(THIS_COMPILE_BATCH.cpp) $(COMPILE_BATCH.cpp)`"\
140 = "" ] ; then \
141 $(ECHO) $< >> $(COMPILE_LIST.cpp); \
142 $(ECHO) $(@F) >> $(COMPILE_OBJ_LIST.cpp); \
143 fi
144 @$(RM) $(THIS_COMPILE_BATCH.cpp)
145 @$(check-conventions)
146
147batch_compile: $(FILES_o)
148 @$(ECHO) "Doing batch compilations"
149 @if [ -s $(COMPILE_LIST.c) ] ; then \
150 $(ECHO) "$(COMPILE.c) $(CFLAGS_GPROF) $(AUTOMATIC_PCH_OPTION) \
151 `$(CAT) $(COMPILE_LIST.c)`" ; \
152 ( $(COMPILE.c) $(CFLAGS_GPROF) $(AUTOMATIC_PCH_OPTION) \
153 `$(CAT) $(COMPILE_LIST.c)` && \
154 $(ECHO) "$(MV) `$(CAT) $(COMPILE_OBJ_LIST.c)` $(OBJDIR)" && \
155 $(MV) `$(CAT) $(COMPILE_OBJ_LIST.c)` $(OBJDIR) ) || exit 1 ; \
156 fi
157 @if [ -s $(COMPILE_LIST.cpp) ] ; then \
158 $(ECHO) "$(COMPILE.cpp) $(CFLAGS_GPROF) $(AUTOMATIC_PCH_OPTION) \
159 `$(CAT) $(COMPILE_LIST.cpp)`" ; \
160 ( $(COMPILE.cpp) $(CFLAGS_GPROF) $(AUTOMATIC_PCH_OPTION) \
161 `$(CAT) $(COMPILE_LIST.cpp)` && \
162 $(ECHO) "$(MV) `$(CAT) $(COMPILE_OBJ_LIST.cpp)` $(OBJDIR)" && \
163 $(MV) `$(CAT) $(COMPILE_OBJ_LIST.cpp)` $(OBJDIR) ) || exit 1 ; \
164 fi
165 @$(RM) $(COMPILE_BATCH.c) $(COMPILE_LIST.c) $(COMPILE_OBJ_LIST.c)
166 @$(RM) $(COMPILE_BATCH.cpp) $(COMPILE_LIST.cpp) $(COMPILE_OBJ_LIST.cpp)
167
168endif
169
170# newer as does not handle c++ style comments
171$(OBJDIR)/%.$(OBJECT_SUFFIX): %.s
172 ifneq ($(CC_VERSION), gcc)
173 @$(prep-target)
174 $(COMPILE.s) $(CC_OBJECT_OUTPUT_FLAG)$@ $<
175 else
176 @$(prep-target)
177 $(CPP) -x assembler-with-cpp $< | $(COMPILE.s) -o $@
178 endif
179 @$(check-conventions)
180
181#
182# Quick hack for making the compiler generate just the assembly file.
183# $ gnumake obj/sparc/myfile.s
184#
185$(OBJDIR)/%.s: %.c
186 @$(prep-target)
187 $(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ -S $<
188 @$(check-conventions)
189
190# remove the intermediate files from the directories.
191# (If VARIANT=OPT, this removes all debug and fastdebug files too)
192clobber clean::
193 $(RM) -r $(OBJDIR)
194 $(RM) -r $(OBJDIR)_*
195
196#
197# Lint support
198# (The 'lint' rule below is an older rule not using the .$(LINT_SUFFIX) files)
199#
200
201ifeq ($(PLATFORM), solaris)
202$(OBJDIR)/%.$(LINT_SUFFIX): %.c
203 @$(prep-target)
204 $(LINT.c) -dirout=$(OBJDIR) -c $<
205lint.clean:
206 $(RM) $(OBJDIR)/*.$(LINT_SUFFIX)
207# Old rule
208lint: $(FILES_c)
209 ifneq ($(FILES_c),)
210 $(LINT.c) -Ncheck -Nlevel=3 $? $(LDLIBS) > lint.$(ARCH) 2>&1
211 endif
212endif
213
214.PHONY: batch_compile
215
216
Note: See TracBrowser for help on using the repository browser.