Thu, 23 Sep 2010 17:33:23 -0700
Added tag jdk7-b111 for changeset 640fa4d4e2ad
duke@1 | 1 | # |
ohair@158 | 2 | # Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | # |
duke@1 | 5 | # This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | # under the terms of the GNU General Public License version 2 only, as |
ohair@158 | 7 | # published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | # particular file as subject to the "Classpath" exception as provided |
ohair@158 | 9 | # by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | # |
duke@1 | 11 | # This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | # version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | # accompanied this code). |
duke@1 | 16 | # |
duke@1 | 17 | # You should have received a copy of the GNU General Public License version |
duke@1 | 18 | # 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | # |
ohair@158 | 21 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@158 | 22 | # or visit www.oracle.com if you need additional information or have any |
ohair@158 | 23 | # questions. |
duke@1 | 24 | # |
duke@1 | 25 | |
duke@1 | 26 | # |
duke@1 | 27 | # Native C/C++ Compile Rules |
duke@1 | 28 | # |
duke@1 | 29 | |
duke@1 | 30 | # |
duke@1 | 31 | # INCREMENTAL_BUILD: Record the #include file dependencies. |
duke@1 | 32 | # |
duke@1 | 33 | # NOTE: We build make include files with the suffix |
duke@1 | 34 | # $(DEPEND_SUFFIX) on every compilation. These are initially |
duke@1 | 35 | # created as temp files just in case a ^C kills it in the middle. |
duke@1 | 36 | # Compiler is smart enough to handle ^C and not create the .o file, or |
duke@1 | 37 | # is supposed to be that smart, but the .$(DEPEND_SUFFIX) file |
duke@1 | 38 | # creation here isn't. |
duke@1 | 39 | # These .$(DEPEND_SUFFIX) files are included by Library.gmk and |
duke@1 | 40 | # Program.gmk, when they exist (Search for 'make dependencies'). |
duke@1 | 41 | # |
duke@1 | 42 | |
duke@1 | 43 | ifeq ($(INCREMENTAL_BUILD),true) |
duke@1 | 44 | |
duke@1 | 45 | $(OBJDIR)/%.$(DEPEND_SUFFIX): %.c |
duke@1 | 46 | @$(prep-target) |
duke@1 | 47 | @$(ECHO) "Creating $@" |
duke@1 | 48 | @$(RM) $@.temp |
duke@1 | 49 | @$(CC) $(CC_DEPEND) $(CPPFLAGS) $< 2> $(DEV_NULL) | \ |
duke@1 | 50 | $(CC_DEPEND_FILTER) > $@.temp |
duke@1 | 51 | @$(MV) $@.temp $@ |
duke@1 | 52 | |
duke@1 | 53 | $(OBJDIR)/%.$(DEPEND_SUFFIX): %.cpp |
duke@1 | 54 | @$(prep-target) |
duke@1 | 55 | @$(ECHO) "Creating $@" |
duke@1 | 56 | @$(RM) $@.temp |
duke@1 | 57 | @$(CXX) $(CC_DEPEND) $(CPPFLAGS) $(CXXFLAGS) $< 2> $(DEV_NULL) | \ |
duke@1 | 58 | $(CC_DEPEND_FILTER) > $@.temp |
duke@1 | 59 | @$(MV) $@.temp $@ |
duke@1 | 60 | |
duke@1 | 61 | endif # INCREMENTAL_BUILD |
duke@1 | 62 | |
duke@1 | 63 | # |
duke@1 | 64 | # C, C++, asm files. |
duke@1 | 65 | # |
duke@1 | 66 | # Normal or parallel compile rule is the same, but batch compiles require |
duke@1 | 67 | # we save up the sources files that use the same compile line so that we |
duke@1 | 68 | # can do one compile line. |
duke@1 | 69 | # |
duke@1 | 70 | |
duke@1 | 71 | ifneq ($(COMPILE_APPROACH), batch) |
duke@1 | 72 | |
duke@1 | 73 | $(OBJDIR)/%.$(OBJECT_SUFFIX): %.c |
duke@1 | 74 | @$(prep-target) |
duke@1 | 75 | $(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $< |
duke@1 | 76 | @$(check-conventions) |
duke@1 | 77 | |
duke@1 | 78 | $(OBJDIR)/%.$(OBJECT_SUFFIX): %.cpp |
duke@1 | 79 | @$(prep-target) |
duke@1 | 80 | $(COMPILE.cc) $(CC_OBJECT_OUTPUT_FLAG)$@ $(CFLAGS_GPROF) $< |
duke@1 | 81 | @$(check-conventions) |
duke@1 | 82 | |
duke@1 | 83 | else |
duke@1 | 84 | |
duke@1 | 85 | # |
duke@1 | 86 | # Batch compiling might be faster if the compiler was smart about recognizing |
duke@1 | 87 | # optimization opportunities available when all files are being compiled |
duke@1 | 88 | # the same way. Unfortunately this is rare. |
duke@1 | 89 | # Automatic pre-compiled headers (pch) might be a possibility so we |
duke@1 | 90 | # add any auto pch options here. |
duke@1 | 91 | # So we save all the source files that have the same compile line as the |
duke@1 | 92 | # first file. A normal compile pass is made after the batch compile |
duke@1 | 93 | # to catch anything missed. |
duke@1 | 94 | # If the compilers had a -o option that allowed us to direct where to |
duke@1 | 95 | # write the object files to, then we would not need to save the object |
duke@1 | 96 | # file list or move them from the make directory to the build directory. |
duke@1 | 97 | # |
duke@1 | 98 | |
duke@1 | 99 | # Source names |
duke@1 | 100 | COMPILE_LIST.c = $(OBJDIR)/.source_names_c |
duke@1 | 101 | COMPILE_LIST.cpp = $(OBJDIR)/.source_names_cpp |
duke@1 | 102 | |
duke@1 | 103 | # Object file list |
duke@1 | 104 | COMPILE_OBJ_LIST.c = $(OBJDIR)/.obj_names_c |
duke@1 | 105 | COMPILE_OBJ_LIST.cpp = $(OBJDIR)/.obj_names_cpp |
duke@1 | 106 | |
duke@1 | 107 | # The compile line |
duke@1 | 108 | COMPILE_BATCH.c = $(OBJDIR)/.compile_c |
duke@1 | 109 | COMPILE_BATCH.cpp = $(OBJDIR)/.compile_cpp |
duke@1 | 110 | |
duke@1 | 111 | # The compile line for the current target |
duke@1 | 112 | THIS_COMPILE_BATCH.c = $(COMPILE_BATCH.c)-$(@F) |
duke@1 | 113 | THIS_COMPILE_BATCH.cpp = $(COMPILE_BATCH.cpp)-$(@F) |
duke@1 | 114 | |
duke@1 | 115 | $(OBJDIR)/%.$(OBJECT_SUFFIX): %.c |
duke@1 | 116 | @$(prep-target) |
duke@1 | 117 | @$(ECHO) "$(COMPILE.c) $(CFLAGS_GPROF)" > $(THIS_COMPILE_BATCH.c) |
duke@1 | 118 | @if [ ! -s $(COMPILE_BATCH.c) ] ; then \ |
duke@1 | 119 | $(CP) $(THIS_COMPILE_BATCH.c) $(COMPILE_BATCH.c) ; \ |
duke@1 | 120 | $(ECHO) $< > $(COMPILE_LIST.c); \ |
duke@1 | 121 | $(ECHO) $(@F) > $(COMPILE_OBJ_LIST.c); \ |
duke@1 | 122 | elif [ "`$(DIFF) -w -b $(THIS_COMPILE_BATCH.c) $(COMPILE_BATCH.c)`" \ |
duke@1 | 123 | = "" ] ; then \ |
duke@1 | 124 | $(ECHO) $< >> $(COMPILE_LIST.c); \ |
duke@1 | 125 | $(ECHO) $(@F) >> $(COMPILE_OBJ_LIST.c); \ |
duke@1 | 126 | fi |
duke@1 | 127 | @$(RM) $(THIS_COMPILE_BATCH.c) |
duke@1 | 128 | @$(check-conventions) |
duke@1 | 129 | |
duke@1 | 130 | $(OBJDIR)/%.$(OBJECT_SUFFIX): %.cpp |
duke@1 | 131 | @$(prep-target) |
duke@1 | 132 | @$(ECHO) "$(COMPILE.cpp) $(CFLAGS_GPROF)" > $(THIS_COMPILE_BATCH.cpp) |
duke@1 | 133 | @if [ ! -s $(COMPILE_BATCH.cpp) ] ; then \ |
duke@1 | 134 | $(CP) $(THIS_COMPILE_BATCH.cpp) $(COMPILE_BATCH.cpp) ; \ |
duke@1 | 135 | $(ECHO) $< > $(COMPILE_LIST.cpp); \ |
duke@1 | 136 | $(ECHO) $(@F) > $(COMPILE_OBJ_LIST.cpp); \ |
duke@1 | 137 | elif [ "`$(DIFF) -w -b $(THIS_COMPILE_BATCH.cpp) $(COMPILE_BATCH.cpp)`"\ |
duke@1 | 138 | = "" ] ; then \ |
duke@1 | 139 | $(ECHO) $< >> $(COMPILE_LIST.cpp); \ |
duke@1 | 140 | $(ECHO) $(@F) >> $(COMPILE_OBJ_LIST.cpp); \ |
duke@1 | 141 | fi |
duke@1 | 142 | @$(RM) $(THIS_COMPILE_BATCH.cpp) |
duke@1 | 143 | @$(check-conventions) |
duke@1 | 144 | |
duke@1 | 145 | batch_compile: $(FILES_o) |
duke@1 | 146 | @$(ECHO) "Doing batch compilations" |
duke@1 | 147 | @if [ -s $(COMPILE_LIST.c) ] ; then \ |
duke@1 | 148 | $(ECHO) "$(COMPILE.c) $(CFLAGS_GPROF) $(AUTOMATIC_PCH_OPTION) \ |
duke@1 | 149 | `$(CAT) $(COMPILE_LIST.c)`" ; \ |
duke@1 | 150 | ( $(COMPILE.c) $(CFLAGS_GPROF) $(AUTOMATIC_PCH_OPTION) \ |
duke@1 | 151 | `$(CAT) $(COMPILE_LIST.c)` && \ |
duke@1 | 152 | $(ECHO) "$(MV) `$(CAT) $(COMPILE_OBJ_LIST.c)` $(OBJDIR)" && \ |
duke@1 | 153 | $(MV) `$(CAT) $(COMPILE_OBJ_LIST.c)` $(OBJDIR) ) || exit 1 ; \ |
duke@1 | 154 | fi |
duke@1 | 155 | @if [ -s $(COMPILE_LIST.cpp) ] ; then \ |
duke@1 | 156 | $(ECHO) "$(COMPILE.cpp) $(CFLAGS_GPROF) $(AUTOMATIC_PCH_OPTION) \ |
duke@1 | 157 | `$(CAT) $(COMPILE_LIST.cpp)`" ; \ |
duke@1 | 158 | ( $(COMPILE.cpp) $(CFLAGS_GPROF) $(AUTOMATIC_PCH_OPTION) \ |
duke@1 | 159 | `$(CAT) $(COMPILE_LIST.cpp)` && \ |
duke@1 | 160 | $(ECHO) "$(MV) `$(CAT) $(COMPILE_OBJ_LIST.cpp)` $(OBJDIR)" && \ |
duke@1 | 161 | $(MV) `$(CAT) $(COMPILE_OBJ_LIST.cpp)` $(OBJDIR) ) || exit 1 ; \ |
duke@1 | 162 | fi |
duke@1 | 163 | @$(RM) $(COMPILE_BATCH.c) $(COMPILE_LIST.c) $(COMPILE_OBJ_LIST.c) |
duke@1 | 164 | @$(RM) $(COMPILE_BATCH.cpp) $(COMPILE_LIST.cpp) $(COMPILE_OBJ_LIST.cpp) |
duke@1 | 165 | |
duke@1 | 166 | endif |
duke@1 | 167 | |
duke@1 | 168 | # newer as does not handle c++ style comments |
duke@1 | 169 | $(OBJDIR)/%.$(OBJECT_SUFFIX): %.s |
duke@1 | 170 | ifneq ($(CC_VERSION), gcc) |
duke@1 | 171 | @$(prep-target) |
duke@1 | 172 | $(COMPILE.s) $(CC_OBJECT_OUTPUT_FLAG)$@ $< |
duke@1 | 173 | else |
duke@1 | 174 | @$(prep-target) |
duke@1 | 175 | $(CPP) -x assembler-with-cpp $< | $(COMPILE.s) -o $@ |
duke@1 | 176 | endif |
duke@1 | 177 | @$(check-conventions) |
duke@1 | 178 | |
duke@1 | 179 | # |
duke@1 | 180 | # Quick hack for making the compiler generate just the assembly file. |
duke@1 | 181 | # $ gnumake obj/sparc/myfile.s |
duke@1 | 182 | # |
duke@1 | 183 | $(OBJDIR)/%.s: %.c |
duke@1 | 184 | @$(prep-target) |
duke@1 | 185 | $(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$@ -S $< |
duke@1 | 186 | @$(check-conventions) |
duke@1 | 187 | |
duke@1 | 188 | # remove the intermediate files from the directories. |
duke@1 | 189 | # (If VARIANT=OPT, this removes all debug and fastdebug files too) |
duke@1 | 190 | clobber clean:: |
duke@1 | 191 | $(RM) -r $(OBJDIR) |
duke@1 | 192 | $(RM) -r $(OBJDIR)_* |
duke@1 | 193 | |
duke@1 | 194 | # |
duke@1 | 195 | # Lint support |
duke@1 | 196 | # (The 'lint' rule below is an older rule not using the .$(LINT_SUFFIX) files) |
duke@1 | 197 | # |
duke@1 | 198 | |
duke@1 | 199 | ifeq ($(PLATFORM), solaris) |
duke@1 | 200 | $(OBJDIR)/%.$(LINT_SUFFIX): %.c |
duke@1 | 201 | @$(prep-target) |
duke@1 | 202 | $(LINT.c) -dirout=$(OBJDIR) -c $< |
duke@1 | 203 | lint.clean: |
duke@1 | 204 | $(RM) $(OBJDIR)/*.$(LINT_SUFFIX) |
duke@1 | 205 | # Old rule |
duke@1 | 206 | lint: $(FILES_c) |
duke@1 | 207 | ifneq ($(FILES_c),) |
duke@1 | 208 | $(LINT.c) -Ncheck -Nlevel=3 $? $(LDLIBS) > lint.$(ARCH) 2>&1 |
duke@1 | 209 | endif |
duke@1 | 210 | endif |
duke@1 | 211 | |
duke@1 | 212 | .PHONY: batch_compile |
duke@1 | 213 | |
duke@1 | 214 |