From 2a44517842531c64135d4a11daf6b072fc4f2c5d Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Fri, 15 Feb 2019 11:43:00 -0600 Subject: [PATCH] Update BSDmakefile formatting and add documentation --- BSDmakefile | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/BSDmakefile b/BSDmakefile index 25c23e754..5298a7866 100644 --- a/BSDmakefile +++ b/BSDmakefile @@ -1,15 +1,21 @@ -# by default bmake will cd into ./obj first +# This is a very basic `make` wrapper around the CMake build toolchain. +# +# Supported arguments: +# PREFIX: sets the installation prefix +# GENERATOR: explicitly specifies the CMake generator to use + +# By default, bmake will try to cd into ./obj before anything else. Don't do that. .OBJDIR: ./ +# Before anything else, test for CMake, which is the only requirement to be able to run +# this Makefile CMake will perform the remaining dependency tests on its own. .BEGIN: - # test for cmake, which is the only requirement to be able to run this Makefile - # cmake will perform the remaining dependency tests on its own - @which cmake >/dev/null 2>/dev/null || (echo 'Please install cmake and then re-run the `make` command!' 1>&2 && false) + @which cmake >/dev/null 2>/dev/null || \ + (echo 'Please install CMake and then re-run the `make` command!' 1>&2 && false) -# Use ninja, if it is installed -_GENERATOR!=which ninja 2>/dev/null >/dev/null && echo Ninja || echo "'Unix Makefiles'" +# Prefer to use ninja, if it is installed +_GENERATOR!=which ninja 2>/dev/null >/dev/null && echo Ninja || echo "Unix Makefiles" GENERATOR?=$(_GENERATOR) -PREFIX?=/usr/local .if $(GENERATOR) == "Ninja" BUILDFILE=build/build.ninja @@ -17,7 +23,8 @@ BUILDFILE=build/build.ninja BUILDFILE=build/Makefile .endif -.DEFAULT: build/fish +PREFIX?=/usr/local + build/fish: build/$(BUILDFILE) cmake --build build @@ -25,7 +32,7 @@ build: mkdir -p build build/$(BUILDFILE): build - cd build; cmake .. -G $(GENERATOR) -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_EXPORT_COMPILE_COMMANDS=1 + cd build; cmake .. -G "$(GENERATOR)" -DCMAKE_INSTALL_PREFIX="$(PREFIX)" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .PHONY: install install: build/fish