# -------------------------------------------------- # # Makefile for building a standalone, statically linked Bluesim executable # # Usage: # # make [options] # # Example: # # make TOPMOD=mkTb SIMDIR=simdir # # The following variables must be set, either in the environment or on the # command line: # # TOPMOD - The top module of the design # # Optional variables: # # SIMDIR - The location of the generated Bluesim C++ source files # (default: directory where 'make' is run) # # OTHEROBJS - Any additional files needed for linking (.o, .a) # # OTHERLIBS - Any additional dynamic libraries needed for linking # # LIBDIRS - Any additional search directories for finding dynamic libraries # # EXE - The name of the output executable (default: model.exe) # # -------------------------------------------------- ifndef TOPMOD $(error Variable TOPMOD is not set) else $(info >>> TOPMOD "$(TOPMOD)") endif BLUESPECDIR=$(shell echo 'puts $$env(BLUESPECDIR)' | bluetcl) ifeq ($(BLUESPECDIR),) $(error Failure to find BLUESPECDIR) else $(info >>> BLUESPECDIR "$(BLUESPECDIR)") endif SIMDIR ?= . EXE ?= model.exe #EXE ?= $(TOPMOD).exe # --------------- BSIM_INCDIR=$(BLUESPECDIR)/Bluesim BSIM_LIBDIR=$(BLUESPECDIR)/Bluesim default: $(EXE) $(EXE): main_$(TOPMOD).cxx $(SIMDIR)/*.o c++ -O3 \ -g \ -D BLUESIM_TOP_MODULE=$(TOPMOD) \ -o $@ \ -I. \ -I$(BSIM_INCDIR) \ -I$(SIMDIR) \ $(addprefix -L, $(LIBDIRS)) \ $(OTHEROBJS) \ $^ \ $(BSIM_LIBDIR)/libbskernel.a \ $(BSIM_LIBDIR)/libbsprim.a \ -lpthread \ $(OTHERLIBS) \ main_$(TOPMOD).cxx: main.cxx.template sed 's/BLUESIM_TOP_MODULE/$(TOPMOD)/g' main.cxx.template > $@ .PHONY: clean clean: .PHONY: realclean realclean: clean rm -rf main_*.cxx rm -rf $(EXE)