From f20c8a6621e682c5700084c62f3a7a52e5e2b49f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 21 Oct 2015 10:35:31 -0400 Subject: maker.org make setting debug flags more straightforward --- makefile | 36 +++++++++++++++++++++------------- maker.org | 67 +++++++++++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 68 insertions(+), 35 deletions(-) diff --git a/makefile b/makefile index 250f1fb..d8bee00 100644 --- a/makefile +++ b/makefile @@ -1,35 +1,43 @@ -#DMD=dmd DMD=dmd DMD_FLAGS=-de -w -DMD_FLAGS_DEBUG=-unittest -debug=checkdoc -debug=summary DMD_FLAGS_RELEASE=-release DMD_FLAG_BINOF=-of -#LDC=ldc2 LDC=ldc2 LDC_FLAGS=-w -LDC_FLAGS_DEBUG=-unittest -d-debug=checkdoc -d-debug=summary LDC_FLAGS_RELEASE=-release LDC_FLAG_BINOF=-of= -#GDC=gdc GDC=gdc #GDC=gdc-5 GDC_FLAGS= -GDC_FLAGS_DEBUG=-fdebug=checkdoc -fdebug=summary GDC_FLAGS_RELEASE=-frelease GDC_FLAG_BINOF=-o -## D_COMPILER=DMD -## D_COMPILER=LDC -## D_COMPILER=GDC +# set D_COMPILER one of DMD LDC or GDC: D_COMPILER=LDC + +SET_DC_FLAGS_DEBUG=-unittest -debug=checkdoc -debug=summary +SET_DC_FLAGS_DEBUG_EXTRA=-debug=headings -debug=bookindex + DC=$($(D_COMPILER)) DC_FLAGS=$($(shell echo $(D_COMPILER)_FLAGS)) -DC_FLAGS_DEBUG=$($(shell echo $(D_COMPILER)_FLAGS_DEBUG)) DC_FLAGS_RELEASE=$($(shell echo $(D_COMPILER)_FLAGS_RELEASE)) DC_FLAG_BINOF=$($(shell echo $(D_COMPILER)_FLAG_BINOF)) +ifeq ($(DC), $(DMD)) + DC_FLAGS_DEBUG :=$(shell echo $(SET_DC_FLAGS_DEBUG)) + DC_FLAGS_DEBUG_EXTRA :=$(shell echo $(SET_DC_FLAGS_DEBUG_EXTRA)) +endif +ifeq ($(DC) ,$(LDC)) + DC_FLAGS_DEBUG :=$(shell echo $(SET_DC_FLAGS_DEBUG)| sed -e "s/-debug=/-d-debug=/g") + DC_FLAGS_DEBUG_EXTRA :=$(shell echo $(SET_DC_FLAGS_DEBUG_EXTRA)| sed -e "s/-debug=/-d-debug=/g") +endif +ifeq ($(DC), $(GDC)) + DC_FLAGS_DEBUG :=$(shell echo $(SET_DC_FLAGS_DEBUG)| sed -e "s/-debug/-fdebug/g") + DC_FLAGS_DEBUG_EXTRA :=$(shell echo $(SET_DC_FLAGS_DEBUG_EXTRA)| sed -e "s/-debug/-fdebug/g") +endif + PRG_NAME=sdp PRG_SRC=$(PRG_NAME).d PRG_SRCDIR=./lib/$(PRG_NAME) @@ -54,22 +62,22 @@ build: $(PRG_SRCDIR)/$(PRG_SRC) rebuild: $(PRG_SRCDIR)/$(PRG_SRC) $(PRG_BINDIR)/$(PRG_BIN).o clean build debug: $(PRG_SRCDIR)/$(PRG_SRC) - $(DC) $(DC_FLAGS) $(DC_FLAGS_DEBUG) \ + $(DC) $(DC_FLAGS) $(DC_FLAGS_DEBUG) $(DC_FLAGS_DEBUG_EXTRA) \ $(DC_FLAG_BINOF)$(PRG_BINDIR)/$(PRG_BIN) \ $(PRG_SRCDIR)/$(PRG_SRC) debug_dmd: $(PRG_SRCDIR)/$(PRG_SRC) - $(DMD) $(DMD_FLAGS) $(DMD_FLAGS_DEBUG) \ + $(DMD) $(DMD_FLAGS) $(DMD_FLAGS_DEBUG) $(DC_FLAGS_DEBUG_EXTRA) \ $(DMD_FLAG_BINOF)$(PRG_BINDIR)/$(PRG_BIN) \ $(PRG_SRCDIR)/$(PRG_SRC) debug_ldc: $(PRG_SRCDIR)/$(PRG_SRC) - $(LDC) $(LDC_FLAGS) $(LDC_FLAGS_DEBUG) \ + $(LDC) $(LDC_FLAGS) $(LDC_FLAGS_DEBUG) $(DC_FLAGS_DEBUG_EXTRA) \ $(LDC_FLAG_BINOF)$(PRG_BINDIR)/$(PRG_BIN) \ $(PRG_SRCDIR)/$(PRG_SRC) debug_gdc: $(PRG_SRCDIR)/$(PRG_SRC) - $(GDC) $(GDC_FLAGS) $(GDC_FLAGS_DEBUG) \ + $(GDC) $(GDC_FLAGS) $(GDC_FLAGS_DEBUG) $(DC_FLAGS_DEBUG_EXTRA) \ $(GDC_FLAG_BINOF)$(PRG_BINDIR)/$(PRG_BIN) \ $(PRG_SRCDIR)/$(PRG_SRC) diff --git a/maker.org b/maker.org index dc42a45..2af2133 100644 --- a/maker.org +++ b/maker.org @@ -13,54 +13,72 @@ * makefile :makefile: ** settings -*** alternative compilers +*** alternative compilers [+1] **** dmd #+BEGIN_SRC makefile :tangle makefile -#DMD=dmd DMD=dmd DMD_FLAGS=-de -w -DMD_FLAGS_DEBUG=-unittest -debug=checkdoc -debug=summary DMD_FLAGS_RELEASE=-release DMD_FLAG_BINOF=-of #+end_src -**** ldc +**** ldc2 #+BEGIN_SRC makefile :tangle makefile -#LDC=ldc2 LDC=ldc2 LDC_FLAGS=-w -LDC_FLAGS_DEBUG=-unittest -d-debug=checkdoc -d-debug=summary LDC_FLAGS_RELEASE=-release LDC_FLAG_BINOF=-of= #+end_src **** gdc #+BEGIN_SRC makefile :tangle makefile -#GDC=gdc GDC=gdc #GDC=gdc-5 GDC_FLAGS= -GDC_FLAGS_DEBUG=-fdebug=checkdoc -fdebug=summary GDC_FLAGS_RELEASE=-frelease GDC_FLAG_BINOF=-o #+end_src -*** set compiler -one line to edit +*** set/select: compiler settings [+1] +**** compiler is: +Set D_COMPILER one of DMD LDC or GDC D_COMPILER=DMD - D_COMPILER=LDC - D_COMPILER=GDC #+BEGIN_SRC makefile :tangle makefile -## D_COMPILER=DMD -## D_COMPILER=LDC -## D_COMPILER=GDC +# set D_COMPILER one of DMD LDC or GDC: D_COMPILER=LDC + +#+end_src +**** debug flags are: +Set debug flags using DMD standard flag -debug= +#+BEGIN_SRC makefile :tangle makefile +SET_DC_FLAGS_DEBUG=-unittest -debug=checkdoc -debug=summary +SET_DC_FLAGS_DEBUG_EXTRA=-debug=headings -debug=bookindex + +#+end_src +*** compiler settings [+1] +**** compiler settings +#+BEGIN_SRC makefile :tangle makefile DC=$($(D_COMPILER)) DC_FLAGS=$($(shell echo $(D_COMPILER)_FLAGS)) -DC_FLAGS_DEBUG=$($(shell echo $(D_COMPILER)_FLAGS_DEBUG)) DC_FLAGS_RELEASE=$($(shell echo $(D_COMPILER)_FLAGS_RELEASE)) DC_FLAG_BINOF=$($(shell echo $(D_COMPILER)_FLAG_BINOF)) +#+end_src +**** compiler conditional settings +#+BEGIN_SRC makefile :tangle makefile +ifeq ($(DC), $(DMD)) + DC_FLAGS_DEBUG :=$(shell echo $(SET_DC_FLAGS_DEBUG)) + DC_FLAGS_DEBUG_EXTRA :=$(shell echo $(SET_DC_FLAGS_DEBUG_EXTRA)) +endif +ifeq ($(DC) ,$(LDC)) + DC_FLAGS_DEBUG :=$(shell echo $(SET_DC_FLAGS_DEBUG)| sed -e "s/-debug=/-d-debug=/g") + DC_FLAGS_DEBUG_EXTRA :=$(shell echo $(SET_DC_FLAGS_DEBUG_EXTRA)| sed -e "s/-debug=/-d-debug=/g") +endif +ifeq ($(DC), $(GDC)) + DC_FLAGS_DEBUG :=$(shell echo $(SET_DC_FLAGS_DEBUG)| sed -e "s/-debug/-fdebug/g") + DC_FLAGS_DEBUG_EXTRA :=$(shell echo $(SET_DC_FLAGS_DEBUG_EXTRA)| sed -e "s/-debug/-fdebug/g") +endif + #+end_src *** program name #+BEGIN_SRC makefile :tangle makefile @@ -83,7 +101,8 @@ ORGDIR=$(shell echo `pwd`) #+end_src ** make commands -*** build commands +*** build commands [+1] +**** build rebuild #+BEGIN_SRC makefile :tangle makefile all: build @@ -93,26 +112,32 @@ build: $(PRG_SRCDIR)/$(PRG_SRC) $(PRG_SRCDIR)/$(PRG_SRC) rebuild: $(PRG_SRCDIR)/$(PRG_SRC) $(PRG_BINDIR)/$(PRG_BIN).o clean build +#+end_src +**** debug +#+BEGIN_SRC makefile :tangle makefile debug: $(PRG_SRCDIR)/$(PRG_SRC) - $(DC) $(DC_FLAGS) $(DC_FLAGS_DEBUG) \ + $(DC) $(DC_FLAGS) $(DC_FLAGS_DEBUG) $(DC_FLAGS_DEBUG_EXTRA) \ $(DC_FLAG_BINOF)$(PRG_BINDIR)/$(PRG_BIN) \ $(PRG_SRCDIR)/$(PRG_SRC) debug_dmd: $(PRG_SRCDIR)/$(PRG_SRC) - $(DMD) $(DMD_FLAGS) $(DMD_FLAGS_DEBUG) \ + $(DMD) $(DMD_FLAGS) $(DMD_FLAGS_DEBUG) $(DC_FLAGS_DEBUG_EXTRA) \ $(DMD_FLAG_BINOF)$(PRG_BINDIR)/$(PRG_BIN) \ $(PRG_SRCDIR)/$(PRG_SRC) debug_ldc: $(PRG_SRCDIR)/$(PRG_SRC) - $(LDC) $(LDC_FLAGS) $(LDC_FLAGS_DEBUG) \ + $(LDC) $(LDC_FLAGS) $(LDC_FLAGS_DEBUG) $(DC_FLAGS_DEBUG_EXTRA) \ $(LDC_FLAG_BINOF)$(PRG_BINDIR)/$(PRG_BIN) \ $(PRG_SRCDIR)/$(PRG_SRC) debug_gdc: $(PRG_SRCDIR)/$(PRG_SRC) - $(GDC) $(GDC_FLAGS) $(GDC_FLAGS_DEBUG) \ + $(GDC) $(GDC_FLAGS) $(GDC_FLAGS_DEBUG) $(DC_FLAGS_DEBUG_EXTRA) \ $(GDC_FLAG_BINOF)$(PRG_BINDIR)/$(PRG_BIN) \ $(PRG_SRCDIR)/$(PRG_SRC) +#+end_src +**** release +#+BEGIN_SRC makefile :tangle makefile release: distclean_and_init tangle $(PRG_SRCDIR)/$(PRG_SRC) $(DC) $(DC_FLAGS) $(DC_FLAGS_RELEASE) \ -- cgit v1.2.3