From aeaf2f93e2fcc5cc0d91e9802d51317c438e3baf Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 18 Dec 2019 21:26:51 -0600 Subject: [PATCH] Revert "Remove Makefile(s)" This reverts commit 326f5586deb33cc8d711d51b36a400c85d44185e. See discussion in #6264. --- BSDmakefile | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 BSDmakefile create mode 100644 Makefile diff --git a/BSDmakefile b/BSDmakefile new file mode 100644 index 000000000..85f5ee162 --- /dev/null +++ b/BSDmakefile @@ -0,0 +1,53 @@ +# 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: ./ + +CMAKE?=cmake + +# 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: + @which $(CMAKE) >/dev/null 2>/dev/null || \ + (echo 'Please install CMake and then re-run the `make` command!' 1>&2 && false) + +# Prefer to use ninja, if it is installed +_GENERATOR!=which ninja 2>/dev/null >/dev/null && echo Ninja || echo "Unix Makefiles" +GENERATOR?=$(_GENERATOR) + +.if $(GENERATOR) == "Ninja" +BUILDFILE=build/build.ninja +.else +BUILDFILE=build/Makefile +.endif + +PREFIX?=/usr/local + +build/fish: build/$(BUILDFILE) + $(CMAKE) --build build + +build: + mkdir -p build + +build/$(BUILDFILE): build + cd build; $(CMAKE) .. -G "$(GENERATOR)" -DCMAKE_INSTALL_PREFIX="$(PREFIX)" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 + +.PHONY: install +install: build/fish + $(CMAKE) --build build --target install + +.PHONY: clean +clean: + rm -rf build + +.PHONY: test +test: build/fish + $(CMAKE) --build build --target test + +.PHONY: run +run: build/fish + build/fish diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..dedfec76c --- /dev/null +++ b/Makefile @@ -0,0 +1,54 @@ +# 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 + +CMAKE ?= cmake + +GENERATOR ?= $(shell (which ninja > /dev/null 2> /dev/null && echo Ninja) || \ + echo 'Unix Makefiles') +prefix ?= /usr/local +PREFIX ?= $(prefix) + +ifeq ($(GENERATOR), Ninja) +BUILDFILE = build.ninja +else +BUILDFILE = Makefile +endif + +all: .begin build/fish + +PHONY: .begin +.begin: + @which $(CMAKE) > /dev/null 2> /dev/null || \ + (echo 'Please install CMake and then re-run the `make` command!' 1>&2 && false) + +build/fish: build/$(BUILDFILE) + $(CMAKE) --build build + +build/$(BUILDFILE): build + cd build; $(CMAKE) .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -G "$(GENERATOR)" -DCMAKE_INSTALL_PREFIX="$(PREFIX)" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 + +build: + mkdir -p build + +.PHONY: clean +clean: + rm -rf build + +.PHONY: test +test: build/fish + $(CMAKE) --build build --target test + +.PHONY: install +install: build/fish + $(CMAKE) --build build --target install + +.PHONY: run +run: build/fish + ./build/fish || true + +.PHONY: exec +exec: build/fish + exec ./build/fish