ROSE 0.11.145.192

Using a build system to build tools.

Once the ROSE library has been configured, built, and installed it can be used. Any program that uses ROSE will likely need to be compiled with the same switches and software components as ROSE itself. The easiest way to get this information is by running "rose-config --help".

Here's an example makefile:

1# Sample makefile for programs that use the ROSE library.
2#
3# ROSE has a number of configuration details that must be present when
4# compiling and linking a user program with ROSE, and some of these
5# details are difficult to get right. The most foolproof way to get
6# these details into your own makefile is to use the "rose-config"
7# tool.
8#
9#
10# This makefile assumes:
11# 1. The ROSE library has been properly installed (refer to the
12# documentation for configuring, building, and installing ROSE).
13#
14# 2. The top of the installation directory is $(ROSE_HOME). This
15# is the same directory you specified for the "--prefix" argument
16# of the "configure" script, or the "CMAKE_INSTALL_PREFIX" if using
17# cmake. E.g., "/usr/local".
18#
19# The "rose-config" tool currently only works for ROSE configured with
20# GNU auto tools (e.g., you ran "configure" when you built and
21# installed ROSE). The "cmake" configuration is not currently
22# supported by "rose-config" [September 2015].
23##############################################################################
24
25#If the ROSE bin directory is in your path, rose-config can be found automatically
26ifndef ROSE_HOME
27ROSE_HOME = $(shell rose-config prefix)
28endif
29
30include $(ROSE_HOME)/lib/rose-config.cfg
31
32# Standard C++ compiler stuff (see rose-config --help)
33ROSE_CXX = $(shell $(ROSE_HOME)/bin/rose-config ROSE_CXX)
34ROSE_CPPFLAGS = $(shell $(ROSE_HOME)/bin/rose-config ROSE_CPPFLAGS)
35ROSE_CXXFLAGS = $(shell $(ROSE_HOME)/bin/rose-config ROSE_CXXFLAGS)
36ROSE_LDFLAGS = $(shell $(ROSE_HOME)/bin/rose-config ROSE_LDFLAGS)
37ROSE_LIBDIRS = $(shell $(ROSE_HOME)/bin/rose-config ROSE_LIBDIRS)
38ROSE_RPATHS = $(shell $(ROSE_HOME)/bin/rose-config ROSE_RPATHS)
39ROSE_LINK_RPATHS = $(shell $(ROSE_HOME)/bin/rose-config ROSE_LINK_RPATHS)
40
41MOSTLYCLEANFILES =
42
43##############################################################################
44# Assuming your source code is "demo.C" to build an executable named "demo".
45
46all: demo
47
48demo.o: demo.C
49 $(ROSE_CXX) $(ROSE_CPPFLAGS) $(ROSE_CXXFLAGS) -o $@ -c $^
50
51demo: demo.o
52 $(ROSE_CXX) $(ROSE_CXXFLAGS) -o $@ $^ $(ROSE_LDFLAGS) $(ROSE_LINK_RPATHS) -Wl,-rpath=$(ROSE_HOME)/lib
53
54MOSTLYCLEANFILES += demo demo.o
55
56##############################################################################
57# Standard boilerplate
58
59.PHONY: clean
60clean:
61 rm -f $(MOSTLYCLEANFILES)
Collaboration diagram for Build systems: