From 724e0fdd5ce6ec295487b7ec1a3d3fc26ce08d4a Mon Sep 17 00:00:00 2001 From: heck Date: Mon, 28 Aug 2023 19:15:10 +0200 Subject: [PATCH] Build: add propper build configuration concept --- Makefile.conf | 22 ++++++++++++++++++---- README.md | 4 +++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Makefile.conf b/Makefile.conf index 02df81a..60768c1 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -3,7 +3,24 @@ # This file may be used under the terms of the GNU General Public License version 3 # see LICENSE.txt -HERE:=$(dir $(lastword $(MAKEFILE_LIST))) +# BUILD_CONF must be specified relative to the repo root or must be an absolute path +# BUILD_CONF defaults to ./build.conf +REPO_ROOT_REL:=$(dir $(lastword $(MAKEFILE_LIST))) +ifndef BUILD_CONF + BUILD_CONF=$(REPO_ROOT_REL)/build.conf + -include $(BUILD_CONF) +else + BUILD_CONF_EFF=$(BUILD_CONF) + ifeq ($(dir $(BUILD_CONF)),./) + BUILD_CONF_EFF=$(REPO_ROOT_REL)/$(BUILD_CONF) + endif + ifeq ($(wildcard $(BUILD_CONF_EFF)),) + $(info BUILD_CONF must be specified relative to the repo root or must be an absolute path) + $(error file specified using BUILD_CONF ($(BUILD_CONF)) not found) + endif + include $(BUILD_CONF_EFF) +endif + TARGET=libpEpAdapter.a @@ -12,9 +29,6 @@ TARGET=libpEpAdapter.a DEBUG=1 PREFIX?=$(HOME) -# Overrides --include $(HERE)build.conf - # Constants CXXFLAGS+=-std=c++11 -fPIC CXXFLAGS+=-Wall -pedantic-errors -Wno-unused-parameter -Wno-reorder-ctor diff --git a/README.md b/README.md index 2b92f06..f7d0476 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ ## Build Configuration -The build configuration file is called `build.conf`. +The build configuration file is called `build.conf` or can be specified (relative to repo root) using +the env var `BUILD_CONF`. + Use the file `build.conf.example` as a template. ```bash