From 54fe9d52dadea42e15123dea5f68703f56acf76a Mon Sep 17 00:00:00 2001
From: Thomas Juerges <203795-tjuerges@users.noreply.gitlab.com>
Date: Wed, 30 Jun 2021 07:48:12 +0200
Subject: [PATCH] L2SS-290 Add a check for the LOFAR20_dir environment variable

If the LOFAR20_DIR environment variable is not set, then bail out
with an error message. This reminds the user to source the
lofar20rc.sh file.  It also avoids weird error messages when
trying to run Docker containers without the necessary mount options
set up in our environment variables.
---
 docker-compose/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/docker-compose/Makefile b/docker-compose/Makefile
index a5cf4ec00..307e7c0e6 100644
--- a/docker-compose/Makefile
+++ b/docker-compose/Makefile
@@ -1,3 +1,11 @@
+# Before doing anything, make 100% certain that all necessary environment
+# variables are set.
+ifndef LOFAR20_DIR
+    # Generate the full path to the lofar20rc.sh file
+    # for exactly this repository.
+    LOFAR20RC = $(subst docker-compose,bootstrap/etc/lofar20rc.sh,$(abspath .))
+    $(error There are essential LOFAR2.0 environment variables missing. You must source the lofar20rc.sh file of this repo first. You can do it like this (paste without quotes): ". $(LOFAR20RC)")
+endif
 # Set dir of Makefile to a variable to use later
 MAKEPATH := $(abspath $(lastword $(MAKEFILE_LIST)))
 BASEDIR := $(notdir $(patsubst %/,%,$(dir $(MAKEPATH))))
-- 
GitLab