annotate make/linux/makefiles/adlc.make @ 3660:45535ab90688

7200065: Cross-compilation changes to support the new-build Reviewed-by: dholmes, ohair Contributed-by: Fredrik Ohrstrom <fredrik.ohrstrom@oracle.com>
author dholmes
date Tue, 25 Sep 2012 07:58:42 -0400
parents 282abd0fd878
children 2cb5d5f6d5e5
rev   line source
duke@0 1 #
dcubed@3554 2 # Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
duke@0 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 #
duke@0 5 # This code is free software; you can redistribute it and/or modify it
duke@0 6 # under the terms of the GNU General Public License version 2 only, as
duke@0 7 # published by the Free Software Foundation.
duke@0 8 #
duke@0 9 # This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 # version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 # accompanied this code).
duke@0 14 #
duke@0 15 # You should have received a copy of the GNU General Public License version
duke@0 16 # 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 #
trims@1472 19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 # or visit www.oracle.com if you need additional information or have any
trims@1472 21 # questions.
duke@0 22 #
duke@0 23 #
duke@0 24
duke@0 25 # This makefile (adlc.make) is included from the adlc.make in the
duke@0 26 # build directories.
duke@0 27 # It knows how to compile, link, and run the adlc.
duke@0 28
kamg@91 29 include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make
duke@0 30
duke@0 31 # #########################################################################
duke@0 32
duke@0 33 # OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make:
duke@0 34 GENERATED = ../generated
duke@0 35 OUTDIR = $(GENERATED)/adfiles
duke@0 36
duke@0 37 ARCH = $(Platform_arch)
duke@0 38 OS = $(Platform_os_family)
duke@0 39
duke@0 40 SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad
duke@0 41
kvn@2955 42 ifeq ("${Platform_arch_model}", "${Platform_arch}")
kvn@2955 43 SOURCES.AD = \
kamg@2080 44 $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
kamg@2080 45 $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
kvn@2955 46 else
kvn@2955 47 SOURCES.AD = \
kvn@2955 48 $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
kvn@2955 49 $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) \
kvn@2955 50 $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
kvn@2955 51 endif
duke@0 52
duke@0 53 EXEC = $(OUTDIR)/adlc
duke@0 54
duke@0 55 # set VPATH so make knows where to look for source files
stefank@1879 56 Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc
stefank@1879 57 VPATH += $(Src_Dirs_V:%=%:)
duke@0 58
duke@0 59 # set INCLUDES for C preprocessor
stefank@1879 60 Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED)
duke@0 61 INCLUDES += $(Src_Dirs_I:%=-I%)
duke@0 62
jrose@475 63 # set flags for adlc compilation
erikj@3083 64 CXXFLAGS = $(SYSDEFS) $(INCLUDES)
jrose@475 65
duke@0 66 # Force assertions on.
erikj@3083 67 CXXFLAGS += -DASSERT
duke@0 68
duke@0 69 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
twisti@603 70 # Compiler warnings are treated as errors
twisti@603 71 CFLAGS_WARN = -Werror
duke@0 72 CFLAGS += $(CFLAGS_WARN)
duke@0 73
duke@0 74 OBJECTNAMES = \
duke@0 75 adlparse.o \
duke@0 76 archDesc.o \
duke@0 77 arena.o \
duke@0 78 dfa.o \
duke@0 79 dict2.o \
duke@0 80 filebuff.o \
duke@0 81 forms.o \
duke@0 82 formsopt.o \
duke@0 83 formssel.o \
duke@0 84 main.o \
duke@0 85 adlc-opcodes.o \
duke@0 86 output_c.o \
duke@0 87 output_h.o \
duke@0 88
duke@0 89 OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%)
duke@0 90
duke@0 91 GENERATEDNAMES = \
duke@0 92 ad_$(Platform_arch_model).cpp \
duke@0 93 ad_$(Platform_arch_model).hpp \
duke@0 94 ad_$(Platform_arch_model)_clone.cpp \
duke@0 95 ad_$(Platform_arch_model)_expand.cpp \
duke@0 96 ad_$(Platform_arch_model)_format.cpp \
duke@0 97 ad_$(Platform_arch_model)_gen.cpp \
duke@0 98 ad_$(Platform_arch_model)_misc.cpp \
duke@0 99 ad_$(Platform_arch_model)_peephole.cpp \
duke@0 100 ad_$(Platform_arch_model)_pipeline.cpp \
duke@0 101 adGlobals_$(Platform_arch_model).hpp \
duke@0 102 dfa_$(Platform_arch_model).cpp \
duke@0 103
duke@0 104 GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%)
duke@0 105
duke@0 106 # #########################################################################
duke@0 107
duke@0 108 all: $(EXEC)
duke@0 109
duke@0 110 $(EXEC) : $(OBJECTS)
duke@0 111 @echo Making adlc
dholmes@3660 112 $(QUIETLY) $(filter-out $(ARCHFLAG),$(HOST.LINK_NOPROF.CXX)) -o $(EXEC) $(OBJECTS)
duke@0 113
duke@0 114 # Random dependencies:
duke@0 115 $(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp
duke@0 116
duke@0 117 # The source files refer to ostream.h, which sparcworks calls iostream.h
duke@0 118 $(OBJECTS): ostream.h
duke@0 119
duke@0 120 ostream.h :
duke@0 121 @echo >$@ '#include <iostream.h>'
duke@0 122
duke@0 123 dump:
duke@0 124 : OUTDIR=$(OUTDIR)
duke@0 125 : OBJECTS=$(OBJECTS)
duke@0 126 : products = $(GENERATEDFILES)
duke@0 127
duke@0 128 all: $(GENERATEDFILES)
duke@0 129
duke@0 130 $(GENERATEDFILES): refresh_adfiles
duke@0 131
duke@0 132 # Get a unique temporary directory name, so multiple makes can run in parallel.
duke@0 133 # Note that product files are updated via "mv", which is atomic.
duke@0 134 TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$)
duke@0 135
dcubed@3554 136 ifneq ($(DEBUG_BINARIES), true)
dcubed@3554 137 # Debuggable by default (unless already done by DEBUG_BINARIES)
dcubed@3554 138 CFLAGS += -g
dcubed@3554 139 endif
never@1396 140
jrose@475 141 # Pass -D flags into ADLC.
jrose@475 142 ADLCFLAGS += $(SYSDEFS)
jrose@475 143
jrose@475 144 # Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO.
jrose@475 145 ADLCFLAGS += -q -T
jrose@475 146
jrose@475 147 # Normally, debugging is done directly on the ad_<arch>*.cpp files.
jrose@475 148 # But -g will put #line directives in those files pointing back to <arch>.ad.
never@1526 149 # Some builds of gcc 3.2 have a bug that gets tickled by the extra #line directives
never@1526 150 # so skip it for 3.2 and ealier.
never@1526 151 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
never@1396 152 ADLCFLAGS += -g
never@1526 153 endif
duke@0 154
duke@0 155 ifdef LP64
duke@0 156 ADLCFLAGS += -D_LP64
duke@0 157 else
duke@0 158 ADLCFLAGS += -U_LP64
duke@0 159 endif
duke@0 160
duke@0 161 #
duke@0 162 # adlc_updater is a simple sh script, under sccs control. It is
duke@0 163 # used to selectively update generated adlc files. This should
duke@0 164 # provide a nice compilation speed improvement.
duke@0 165 #
kamg@91 166 ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS)
duke@0 167 ADLC_UPDATER = adlc_updater
jrose@475 168 $(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER)
jrose@475 169 $(QUIETLY) cp $< $@; chmod +x $@
duke@0 170
duke@0 171 # This action refreshes all generated adlc files simultaneously.
duke@0 172 # The way it works is this:
duke@0 173 # 1) create a scratch directory to work in.
duke@0 174 # 2) if the current working directory does not have $(ADLC_UPDATER), copy it.
duke@0 175 # 3) run the compiled adlc executable. This will create new adlc files in the scratch directory.
duke@0 176 # 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files.
duke@0 177 # 5) If we actually updated any files, echo a notice.
duke@0 178 #
jrose@475 179 refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER)
duke@0 180 @rm -rf $(TEMPDIR); mkdir $(TEMPDIR)
duke@0 181 $(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \
duke@0 182 -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \
duke@0 183 || { rm -rf $(TEMPDIR); exit 1; }
duke@0 184 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
duke@0 185 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
duke@0 186 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR)
duke@0 187 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR)
duke@0 188 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR)
duke@0 189 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR)
duke@0 190 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR)
duke@0 191 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR)
duke@0 192 $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR)
duke@0 193 $(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
duke@0 194 $(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
duke@0 195 $(QUIETLY) [ -f $(TEMPDIR)/made-change ] \
duke@0 196 || echo "Rescanned $(SOURCE.AD) but encountered no changes."
duke@0 197 $(QUIETLY) rm -rf $(TEMPDIR)
duke@0 198
duke@0 199
duke@0 200 # #########################################################################
duke@0 201
duke@0 202 $(SOURCE.AD): $(SOURCES.AD)
jrose@475 203 $(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD)
jrose@475 204
jrose@475 205 #PROCESS_AD_FILES = cat
jrose@475 206 # Pass through #line directives, in case user enables -g option above:
jrose@475 207 PROCESS_AD_FILES = awk '{ \
jrose@475 208 if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \
jrose@475 209 if (need_lineno && $$0 !~ /\/\//) \
jrose@475 210 { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \
jrose@475 211 print }'
duke@0 212
duke@0 213 $(OUTDIR)/%.o: %.cpp
duke@0 214 @echo Compiling $<
duke@0 215 $(QUIETLY) $(REMOVE_TARGET)
dholmes@3660 216 $(QUIETLY) $(filter-out $(ARCHFLAG),$(HOST.COMPILE.CXX)) -o $@ $< $(COMPILE_DONE)
duke@0 217
duke@0 218 # Some object files are given a prefix, to disambiguate
duke@0 219 # them from objects of the same name built for the VM.
duke@0 220 $(OUTDIR)/adlc-%.o: %.cpp
duke@0 221 @echo Compiling $<
duke@0 222 $(QUIETLY) $(REMOVE_TARGET)
dholmes@3660 223 $(QUIETLY) $(filter-out $(ARCHFLAG),$(HOST.COMPILE.CXX)) -o $@ $< $(COMPILE_DONE)
duke@0 224
duke@0 225 # #########################################################################
duke@0 226
duke@0 227 clean :
duke@0 228 rm $(OBJECTS)
duke@0 229
duke@0 230 cleanall :
duke@0 231 rm $(OBJECTS) $(EXEC)
duke@0 232
duke@0 233 # #########################################################################
duke@0 234
duke@0 235 .PHONY: all dump refresh_adfiles clean cleanall