# Sample Makefile for building user compiler models. # Requirements: # - A C++ compiler. Known to work with gcc and cl. # - Boost, including the Boost Regex Library. Available at http://boost.org # Obtain those libraries, then set the variables below. # This sample makefile will build the sample c++ compiler model, # samplecm.cpp, and create the shared object file. The name of this # model is "samplecm", so CodeSonar will attempt to load # csurf/lib/libsamplecm.so. ### Set these variables ### # Root CodeSonar or CodeSurfer installation directory. CSURF_INST = ../@MANUAL_ROOT@../../.. # Source files for compiler models. See samplecm.cpp for an example. TUTORIAL_SRC = samplecm.cpp # Name of compiler model. TUTORIAL_NAME = samplecm # Location of Boost. You have some options on how you want to build # and link with Boost. The easiest way is to download the source from # boost.org, then set BOOST_INST. The build system will then build and # link the regex source .cpp files with the library and link them # together. You could instead build it yourself manually, or install # it with a package manager, and link it by setting BOOST_LIBRARY_PATH # and BOOST_REGEX_LIB_FLAG. BOOST_INST = $(CSURF_INST)/third-party/boost # Boost regex .cpp files. Set this to nothing if you have a prebuilt # Boost library. BOOST_REGEX_SRC_FILES = $(BOOST_INST)/libs/regex/src/*.cpp # Location of Boost regex library. You shouldn't need to set this if # in a system lib path like /usr/lib. BOOST_LIBRARY_PATH = -L /some/path/to/boost/regex/lib # Link flag for the Boost regex library. Normally -lboost_regex BOOST_REGEX_LIB_FLAG = ### Stop here. ### CXX = g++ CFLAGS = -pthread INCLUDEFLAGS = -I $(CSURF_INST)/csurf/include -I $(CSURF_INST) -I $(BOOST_INST) LIBS = -L $(CSURF_INST)/csurf/lib $(BOOST_LIBRARY_PATH) LDFLAGS = -lcompmodel_util $(BOOST_REGEX_LIB_FLAG) -static-libgcc $(LIBS) # Set the shared library suffix SOSUFFIX=so all: tutorial build-so: $(CXX) -shared -fPIC $(BOOST_REGEX_SRC_FILES) $(TUTORIAL_SRC) -o lib$(TUTORIAL_NAME).$(SOSUFFIX) $(LDFLAGS) $(INCLUDEFLAGS) $(CFLAGS) tutorial: FORCE build-so install: tutorial cp lib$(TUTORIAL_NAME).$(SOSUFFIX) $(CSURF_INST)/csurf/lib test: tutorial install touch empty.c $(CSURF_INST)/codesonar/bin/codesonar compile -TCMT -CCMT -invoke-compiler no -transparent yes -compiler-location $(CSURF_INST)/codesonar/bin/null-cc $(TUTORIAL_NAME) -c empty.c clean: rm -f empty.c rm -R -f CMT* rm -f libtutorial_example.$(SOSUFFIX) rm -f $(CSURF_INST)/csurf/lib/lib$(TUTORIAL_NAME).$(SOSUFFIX) .PHONY: FORCE FORCE: