summaryrefslogtreecommitdiffstats
path: root/src/build/mkrules/beam.rules.mk
blob: b109c58d307341da96c6b6738bb8955f51c03b05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: src/build/mkrules/beam.rules.mk $
#
# OpenPOWER HostBoot Project
#
# COPYRIGHT International Business Machines Corp. 2013,2014
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# IBM_PROLOG_END_TAG

# File: beam.rules.mk
# Description:
#     Rules for running BEAM on C/C++/ASM files.
##
##  NOTE,   export BUILD_VERBOSE=1 to expose the BEAM invocation for debug.
##          (export -n BUILD_VERBOSE to turn it back off)
##
##  collect "real" BEAM errors into the *.beam files
##  push parser errors to the *.parser files
##  push stats (for debug) to *.stats files.

BEAMOBJS = $(addprefix $(BEAMDIR)/, $(OBJS:.o=.beam))

$(BEAMDIR)/%.beam : %.C
	$(C2) "    BEAM       $(notdir $<)"
	@rm -f  $@ $@.parser $@.stats
	$(C1)$(BEAMCMD) $(INCFLAGS) -I . $(CXXFLAGS) $(BEAMFLAGS)   \
    --beam::complaint_file=$@        \
    --beam::parser_file=$@.parser    \
    --beam::stats_file=$@.stats      \
    $<

$(BEAMDIR)/%.beam : %.cc
	$(C2) "    BEAM       $(notdir $<)"
	@rm -f  $@ $@.parser $@.stats
	$(C1)$(BEAMCMD) $(INCFLAGS) -I . $(CXXFLAGS) $(BEAMFLAGS)   \
    --beam::complaint_file=$@        \
    --beam::parser_file=$@.parser    \
    --beam::stats_file=$@.stats      \
    $<

$(BEAMDIR)/%.beam : %.c
	$(C2) "    BEAM       $(notdir $<)"
	@rm -f  $@ $@.parser $@.stats
	$(C1)$(BEAMCMD) $(INCFLAGS) -I . $(CFLAGS) $(BEAMFLAGS)   \
    --beam::complaint_file=$@        \
    --beam::parser_file=$@.parser    \
    --beam::stats_file=$@.stats      \
    $<

$(BEAMDIR)/%.beam : %.S
	@echo Skipping ASM file: $<

beam: BEAM_PASS

##  Run beam_configure for the C++ and C compilers.
##  This outputs the config files to ./obj/beam, you have to copy them
##  to the correct location.
##  This only needs to be done when something in the build environment changes.
##  See https://w3.eda.ibm.com/beam/beam_configure.html for documentation.
beamgen:
	$(BEAMPATH)/bin/beam_configure $(firstword $(CXX_RAW))  \
    --cpp   \
    --force \
    -o $(ROOTPATH)/src/build/beam/compiler_cpp_config.tcl \
    --compile_flag="$(wordlist 2, $(words $(CXX_RAW)), $(CXX_RAW)) $(CXXFLAGS)"\
    --verbose
	$(BEAMPATH)/bin/beam_configure  $(firstword $(CC_RAW))  \
    --c   \
    --force \
    -o $(ROOTPATH)/src/build/beam/compiler_c_config.tcl \
    --compile_flag="$(wordlist 2, $(words $(CC_RAW)), $(CC_RAW)) $(CFLAGS)" \
    --verbose

.PHONY: make_beamdir
make_beamdir:
	@mkdir -p $(BEAMDIR)


BEAM_PASS_PRE   += make_beamdir
BEAM_PASS_BODY  += $(BEAMOBJS)

CLEAN_TARGETS += $(BEAMOBJS) $(BEAMOBJS:.beam=.beam.parser) \
                 $(BEAMOBJS:.beam=.beam.stats)
OpenPOWER on IntegriCloud