From 5622a463a9a9d2b949f4de3a667ab57e7286d324 Mon Sep 17 00:00:00 2001 From: heck Date: Sat, 21 Sep 2024 09:08:54 +0200 Subject: [PATCH] Build: fix build conf concept A build variable is evaluated like: 1.) if the var is already defined in the shell env, use that. 2.) if the var is defined in the the build.conf, use that. 3. fallback to using the var default in Makefile.conf --- Makefile.conf | 20 ++++++-------------- build.conf.example | 10 +++++----- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Makefile.conf b/Makefile.conf index 54b9d68..52733ff 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -1,4 +1,5 @@ HERE:=$(dir $(lastword $(MAKEFILE_LIST))) +-include $(HERE)build.conf # Project Name TARGET?=blink @@ -7,29 +8,20 @@ TARGET?=blink # common configurations: # use DEBUG = 1 and OPT = -Og for debugging # or DEBUG = 0 and OPT = -O3 for performance -DEBUG=0 -OPT=-O3 +DEBUG?=0 +OPT?=-O3 # (optional) Includes FatFS source files within project. #USE_FATFS = 1 # Relative to dir 'src' -LIBDAISY_DIR=../../heck_libDaisy -DAISYSP_DIR=../../heck_DaisySP - - CXXFLAGS+=-Wall -Wno-unused -Wno-reorder-ctor -Wno-switch +LIBDAISY_DIR?=../../heck_libDaisy +DAISYSP_DIR?=../../heck_DaisySP -######### Overrides from build.conf ######### --include $(HERE)build.conf +CXXFLAGS+=-Wall -Wno-unused -Wno-reorder-ctor -Wno-switch ifneq (,$(findstring g++,$(CXX))) CXXFLAGS+=-fdiagnostics-color=always else ifneq (,$(findstring clang,$(CXX))) CXXFLAGS+=-fcolor-diagnostics endif - -ifeq ($(DEBUG),1) - CXXFLAGS+=-g -O0 -else - CXXFLAGS+=-DNDEBUG=1 -O3 -endif diff --git a/build.conf.example b/build.conf.example index 2c71c04..6f077aa 100644 --- a/build.conf.example +++ b/build.conf.example @@ -3,11 +3,11 @@ # TARGET sets the program to compile and flash # the name of the main cxx file without the prefix 'main_' -TARGET=blink -#TARGET=testtone +TARGET?=blink +#TARGET?=testtone -DEBUG=0 +DEBUG?=0 # Daisy dependencies relative to dir 'src' -LIBDAISY_DIR=../../heck_libDaisy -DAISYSP_DIR=../../heck_DaisySP +LIBDAISY_DIR?=../../heck_libDaisy +DAISYSP_DIR?=../../heck_DaisySP