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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
## ****************************************************************************
##
## Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
## more contributor license agreements. See the NOTICE file distributed
## with this work for additional information regarding copyright ownership.
## Accellera licenses this file to you 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.
##
## ****************************************************************************
##
## Makefile.rules -- simple generic SystemC example build rules
##
## Include this file from your own Makefile to obtain a simple build
## environment. You need to set at least the variables
## PROJECT - name of the application
## OBJS - list of required object files
## to make things work.
##
## The environment is assumed to be set up from Makefile.config file and
## the main example Makefile.
##
## Original Author: Philipp A. Hartmann, OFFIS
##
## ***************************************************************************
##
## MODIFICATION LOG - modifiers, enter your name, affiliation, date and
## changes you are making here.
##
## Name, Affiliation, Date:
## Description of Modification:
##
## ***************************************************************************
## complete config, if not set from Makefile.config
## Variable that points to SystemC installation path
## needs to be set, fallback to SYSTEMC otherwise
SYSTEMC_HOME?=$(SYSTEMC)
## Select the TARGET_ARCH needs to be set
# TARGET_ARCH ?= linux
## default values for additional setup variables
ifneq (,$(strip $(TARGET_ARCH)))
ARCH_SUFFIX ?= -$(TARGET_ARCH)
endif
LDFLAG_RPATH ?= -Wl,-rpath=
SYSTEMC_INC_DIR ?= $(SYSTEMC_HOME)/include
SYSTEMC_LIB_DIR ?= $(SYSTEMC_HOME)/lib$(ARCH_SUFFIX)
SYSTEMC_DEFINES ?=
SYSTEMC_CXXFLAGS ?= $(FLAGS_COMMON) $(FLAGS_STRICT) $(FLAGS_WERROR)
SYSTEMC_LDFLAGS ?= -L $(SYSTEMC_LIB_DIR) \
$(LDFLAG_RPATH)$(SYSTEMC_LIB_DIR)
SYSTEMC_LIBS ?= -lsystemc -lm
## Add 'PTHREADS=1' to command line for a pthreads build
## (should not be needed in most cases)
ifdef PTHREADS
SYSTEMC_CXXFLAGS += -pthread
SYSTEMC_LIBS += -lpthread
endif
## ***************************************************************************
## example defaults
## - basic configuration should be set from Makefile.config
FILTER ?= cat
INCDIR += -I. -I.. -I$(SYSTEMC_INC_DIR)
LIBDIR += -L. -L..
CXXFLAGS += $(CFLAGS) $(SYSTEMC_CXXFLAGS) $(INCDIR) $(SYSTEMC_DEFINES)
LDFLAGS += $(CFLAGS) $(SYSTEMC_CXXFLAGS) $(LIBDIR) $(SYSTEMC_LDFLAGS)
LIBS += $(SYSTEMC_LIBS) $(EXTRA_LIBS)
# "real" Makefile needs to set PROJECT
ifeq (,$(strip $(PROJECT)))
$(error PROJECT not set. Cannot build.)
endif
# basic check for SystemC directory
ifeq (,$(wildcard $(SYSTEMC_HOME)/.))
$(error SYSTEMC_HOME [$(SYSTEMC_HOME)] is not present. \
Please update Makefile.config)
endif
ifeq (,$(wildcard $(SYSTEMC_INC_DIR)/systemc.h))
$(error systemc.h [$(SYSTEMC_INC_DIR)] not found. \
Please update Makefile.config)
endif
ifeq (,$(wildcard $(SYSTEMC_LIB_DIR)/libsystemc*))
$(error SystemC library [$(SYSTEMC_LIB_DIR)] not found. \
Please update Makefile.config)
endif
## ***************************************************************************
## build rules
.SUFFIXES: .cc .cpp .o .x
GOLDEN?=$(firstword $(wildcard ../results/expected.log golden.log))
EXEEXT?=.x
EXE := $(PROJECT)$(EXEEXT)
all: announce build
announce:
@if test x1 = x$(FLAG_BATCH) ; then \
echo; echo "*** $(PROJECT):"; echo; \
fi
check: announce all
@if test -f "$(INPUT)" ; then INPUT="< $(INPUT)" ; fi ; \
eval "$(VALGRIND) ./$(EXE) $(ARGS) $${INPUT} > run.log"
@cat run.log | grep -v "stopped by user" | \
$(FILTER) | awk '{if($$0!="") print $$0}' > run_trimmed.log
@if test -f "$(GOLDEN)" ; then \
cat "$(GOLDEN)" | grep -v "stopped by user" | \
awk '{if($$0!="") print $$0}' > ./expected_trimmed.log ; \
diff ./run_trimmed.log ./expected_trimmed.log > diff.log 2>&1 ; \
if [ -s diff.log ]; then \
echo "***ERROR:"; cat diff.log; \
else echo "OK"; fi \
fi
run: announce all
@if test -f "$(INPUT)" ; then INPUT="< $(INPUT)" ; fi ; \
eval "./$(EXE) $(ARGS) $${INPUT}"
build: announce $(EXE)
$(EXE): $(OBJS) $(SYSTEMC_LIB_DIR)/libsystemc.a
$(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 2>&1 | c++filt
@test -x $@
.cpp.o:
$(CXX) $(CXXFLAGS) -c $< -o $@
.cc.o:
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:: announce
rm -f $(OBJS) $(EXE) core $(EXTRA_CLEAN) \
run.log run_trimmed.log expected_trimmed.log diff.log
ultraclean: announce clean
rm -f Makefile.deps *~
Makefile.deps:
# $(CXX) $(CXXFLAGS) -M $(SRCS) >> Makefile.deps
#include Makefile.deps
|