[Documentation] [TitleIndex] [WordIndex

/!\ NOTE: when using rospack to find the mk-package, the ROS_PACKAGE_PATH needs to be set accordingly. Thus, you should have a dependency to roslib in your package.xml, as this provides the respective environment hooks that set this.

CMake-driven builds

Most packages, and all stacks, use CMake to build. But every package must provide a Makefile if it does any building. The following files are provided to simplify the Makefile in most packages, and all stacks:

Use these files by including them, as explained in the rosbuild documentation and stack-building documentation.

3rdparty code, from tarball

For a 3rdparty package that pulls code from an tarball (or equivalent downloadable file), you should use download_unpack_build.mk, like so:

all: paramiko

TARBALL = build/paramiko-1.7.5.tar.gz
TARBALL_URL = http://pr.willowgarage.com/downloads/paramiko-1.7.5.tar.gz
SOURCE_DIR = build/paramiko-1.7.5
MD5SUM_FILE = paramiko-1.7.5.tar.gz.md5sum
UNPACK_CMD = tar xzf
include $(shell rospack find mk)/download_unpack_build.mk

paramiko: $(SOURCE_DIR)/unpacked
        mkdir -p src
        cd $(SOURCE_DIR) && python setup.py build 
        rm -rf src
        mv `python find_pylib.py paramiko $(SOURCE_DIR)/build/` src
        touch paramiko
clean:
        -rm -rf src $(SOURCE_DIR) paramiko
wipe: clean
        -rm -rf build

The following variables should be defined prior to including download_unpack_build.mk:

After including download_unpack_build.mk, you can make targets depend on the $(SOURCE_DIR)/unpacked file; it will be created (and updated) after the tarball has been downloaded, unpacked, and (optionally) patched.

Examples

Some packages that use download_unpack_build.mk:

3rdparty code, from SVN

For a 3rdparty package that pulls code from an SVN repository, you should use svn_checkout.mk, like so:

all: installed

SVN_DIR = build/stage-svn
SVN_URL = https://playerstage.svn.sourceforge.net/svnroot/playerstage/code/stage/branches/stage-ros
SVN_REVISION = -r 8262
include $(shell rospack find mk)/svn_checkout.mk

installed: $(SVN_DIR) patched Makefile.stage
        cd $(SVN_DIR) && autoreconf -i -s
        cd $(SVN_DIR) && ./configure --prefix=`pwd`/../..
        cd $(SVN_DIR) && make install
        touch installed

clean:
        -cd $(SVN_DIR) && make clean
        rm -rf stage installed patched

wipe: clean
        rm -rf $(SVN_DIR)

The following variables should be defined prior to including svn_checkout.mk:

After including svn_checkout.mk, you can make your targets depend on the patched file; it will be created after the working copy is checked out and (optionally) patched.

Examples

Some packages that use svn_checkout.mk:

3rdparty code, from Git, Mercurial, Bazaar

Similar to svn_checkout.mk, there are also:

These are based on svn_checkout.mk, so you can generally use them by substituting the appropriate three-letter abbreviation for SVN.

Optimizing SVN

svn checkouts are both slow and more prone to downtime. A hybrid approach using the tarball for distribution, and a fancy makefile can be done with a script like the bullet package https://code.ros.org/svn/ros-pkg/stacks/geometry/tags/geometry-1.0.0/bullet/Makefile.bullet This uses the svn_checkout script to build the tarball when developing, but most users simply use the tarball.


2024-06-15 12:58