Skip to content

Commit

Permalink
Add a build.sh helper to allow for a one-stop build
Browse files Browse the repository at this point in the history
This allows for a quick build instead of typing the whole mkdir, cd,
cmake and ninja sequence.

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
Signed-off-by: Leon Romanovsky <[email protected]>
  • Loading branch information
jgunthorpe authored and rleon committed Oct 12, 2016
1 parent 32205ae commit 9bf2db7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ Additional service daemons are provided for:
This project uses a cmake based build system. Quick start:

```sh
$ mkdir build
$ cd build
$ cmake -GNinja ..
$ ninja
$ bash build.sh
```

*build/bin* will contain the sample programs and *build/lib* will contain the
Expand Down Expand Up @@ -76,16 +73,6 @@ Install required packages:
$ yum install cmake gcc libnl3-devel make pkgconfig valgrind-devel
```

For end users, the package can be built using GNU Make and the old cmake
included with the distro:

```sh
$ mkdir build
$ cd build
$ cmake ..
$ make
```

Developers are suggested to install more modern tooling for the best experience.

```sh
Expand All @@ -96,8 +83,6 @@ $ unzip ninja-linux.zip
$ install -m755 ninja /usr/local/bin/ninja
```

Use the 'cmake3' program in place of `cmake` in the above instructions.

# Reporting bugs

Bugs should be reported to the <[email protected]> mailing list
Expand Down
31 changes: 31 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
set -e

SRCDIR=`dirname $0`
BUILDDIR="$SRCDIR/build"

mkdir -p "$BUILDDIR"

if hash cmake3 2>/dev/null; then
# CentOS users are encouraged to install cmake3 from EPEL
CMAKE=cmake3
else
CMAKE=cmake
fi

if hash ninja-build 2>/dev/null; then
# Fedora uses this name
NINJA=ninja-build
elif hash ninja 2>/dev/null; then
NINJA=ninja
fi

cd "$BUILDDIR"

if [ "x$NINJA" == "x" ]; then
cmake ..
make
else
cmake -GNinja ..
$NINJA
fi

0 comments on commit 9bf2db7

Please sign in to comment.