From 2f3146441b48fe7441e38410742344512814bb3a Mon Sep 17 00:00:00 2001 From: "John J. Camilleri" Date: Fri, 27 Nov 2020 00:47:09 +0100 Subject: [PATCH] Makefile now works with: global runghc, stack-only runghc, and falls back to shell script. --- Makefile | 30 +++++++++++++++++++++++++----- README.md | 17 +++++++++-------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index aaaaf711a..50c3b4939 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,32 @@ -# A simple wrapper over the Haskell-based RGL build script +# A wrapper over the Haskell and Bash build scripts +# Will try and fallback in order: +# - runghc Setup.hs +# - stack runghc Setup.hs +# - ./Setup.sh -RUNMAKE=runghc Setup.hs +ifneq (, $(shell which runghc)) +RUNGHC=runghc Setup.hs +else ifneq (, $(shell which stack)) +RUNGHC=stack runghc Setup.hs +else +RUNGHC= +endif .PHONY: build copy install doc clean default: build copy build: src/*/*.gf - $(RUNMAKE) build +ifneq (, $(RUNGHC)) + $(RUNGHC) build +else + ./Setup.sh +endif copy: - $(RUNMAKE) copy +ifneq (, $(RUNGHC)) + $(RUNGHC) copy +endif install: build copy @@ -18,4 +34,8 @@ doc: build make -C doc GF_LIB_PATH=../dist clean: - $(RUNMAKE) clean +ifneq (, $(RUNGHC)) + $(RUNGHC) clean +else + rm -r dist +endif diff --git a/README.md b/README.md index 09a215b84..0f25dc3c6 100644 --- a/README.md +++ b/README.md @@ -47,12 +47,7 @@ This file should be kept up-to-date and all build methods should read this confi If default is `y` then anything other than `n`, including the empty string, is treated as true (and vice versa when default is `n`). -## Haskell script: `Setup.hs` - -This build method gives you most options. -You will need Haskell installed on your system. - -### Basic +## Using Make If you have `Make` installed and don't care about advanced settings, you can compile the RGL and install it to the default location with: @@ -64,9 +59,15 @@ make install This is the same as `make build` followed by `make copy`. There is also `make clean` available. -### Advanced +The Makefile will try to use the Haskell install script, +falling back to the shell script if you do not have Haskell installed. -For more fine-grained control over the build process, you can run the build script directly: +## Haskell script: `Setup.hs` + +This build method gives you most options. +You will need Haskell installed on your system. + +Run the build script with: ``` runghc Setup.hs ...