-*- mode: org -*-
#+TITLE:       spine (doc_reform) (project) makefile
#+DESCRIPTION: makefile for spine
#+FILETAGS:    :spine:build:tools:
#+AUTHOR:      Ralph Amissah
#+EMAIL:       [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]]
#+COPYRIGHT:   Copyright (C) 2015 - 2021 Ralph Amissah
#+LANGUAGE:    en
#+STARTUP:     content hideblocks hidestars noindent entitiespretty
#+OPTIONS:     H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t
#+PROPERTY:    header-args  :exports code
#+PROPERTY:    header-args+ :noweb yes
#+PROPERTY:    header-args+ :eval no
#+PROPERTY:    header-args+ :results no
#+PROPERTY:    header-args+ :cache no
#+PROPERTY:    header-args+ :padline no
#+PROPERTY:    header-args+ :mkdirp yes

[[./spine.org][spine.org]] VERSION
[[./spine_info.org][spine_info.org]]  [[../org/][org/]]

* spine
** version info SET VERSION :version:set:project:
*** project SET VERSION

#+NAME: spine_version_set
#+BEGIN_SRC sh
0.11.3
#+END_SRC

*** build tools if specified

- meson

#+NAME: meson_version_set
#+BEGIN_SRC sh
0.46
#+END_SRC

- soversion

#+NAME: soversion_version_set
#+BEGIN_SRC sh
0
#+END_SRC

** makefile :makefile:
*** tangle

#+HEADER: :tangle ../makefile
#+BEGIN_SRC makefile
<<make_set_var_0_git_version>>
<<make_set_var_1_dub>>
<<make_set_var_2_project_details>>
<<make_set_var_3_emacs_org>>
<<make_set_var_4_markup_samples_pods>>
<<make_set_var_5_markup_samples_search_dirs>>
<<make_find_markup_samples_0_pod_and_dir>>
<<make_find_markup_samples_1_pod>>
<<make_find_markup_samples_2_dir>>
<<make_version_tag>>
<<make_changelog>>
<<make_project_zip_archive>>
<<make_get_project_dependencies_github>>
<<make_dub_upgrade>>
<<make_compile_0_compiler_default>>
<<make_compile_1_compiler_all>>
<<make_compile_2_compiler_all_versioned>>
<<make_compile_3_compiler_all_debug>>
<<make_meson_build>>
<<make_clean_tangle_compile_0_all_clean>>
<<make_clean_tangle_compile_1_all_clean_versioned>>
<<make_clean_tangle_compile_2_all_clean_debug>>
<<make_dub_compile_dmd_0_default>>
<<make_dub_compile_dmd_1_debug>>
<<make_dub_compile_dmd_2_versioned>>
<<make_dub_compile_dmd_3_release>>
<<make_dub_compile_gdc_0_default>>
<<make_dub_compile_gdc_1_debug>>
<<make_dub_compile_gdc_2_versioned>>
<<make_dub_compile_gdc_3_release>>
<<make_dub_compile_ldc_0_default>>
<<make_dub_compile_ldc_1_debug>>
<<make_dub_compile_ldc_2_versioned>>
<<make_dub_compile_ldc_3_release>>
<<make_initialization_operations_0_parts>>
<<make_initialization_operations_1_git_version>>
<<make_initialization_operations_2_assemble>>
<<make_project_testrun_0_find_pods>>
<<make_project_testrun_1>>
<<make_project_testrun_2>>
<<make_project_testrun_3>>
<<make_project_testrun_4>>
<<make_project_testrun_5>>
<<make_project_testrun_6>>
<<make_project_testrun_7>>
<<make_project_testrun_8>>
<<make_project_testrun_9>>
<<make_project_testrun_10>>
<<make_project_testrun_11>>
<<make_project_testrun_12>>
<<make_tangle_0>>
<<make_tangle_1>>
<<make_nix_project>>
<<make_git_snapshot>>
<<make_phony>>
#+END_SRC

*** settings [+2] :settings:
**** git version stamp :git:version:

#+NAME: make_set_var_0_git_version
#+BEGIN_SRC makefile
PROG_VER_GIT :=$(shell echo `git describe --long --tags | sed -e "s/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g"`)
PROG_VER_DECLARED :=$(shell echo `cat ./views/version.txt | grep --color=never "enum" | sed 's/.\+(\([0-9]\+\),[ \t]\+\([0-9]\+\),[ \t]\+\([0-9]\+\)[ \t]*).\+/\1.\2.\3/g'`)
#+END_SRC

**** dub (build tool) :dub:

#+NAME: make_set_var_1_dub
#+BEGIN_SRC makefile
DUB=dub
DUB_FLAGS=-v --force --compiler=
#+END_SRC

**** Project Details :project:spine:

#+NAME: make_set_var_2_project_details
#+BEGIN_SRC makefile
PRG_NAME=doc-reform
PRG_NICKAME=spine
PRG_NAME_DIR=$(shell echo `echo $(PRG_NAME) | sed -e "s/-/_/g"`)
PRG_SRC=$(PRG_NAME).d
PRG_SRCDIR=./src
PRG_BIN=$(PRG_NAME)
PRG_BINDIR=./bin
PRG_DOCDIR=./docs
#+END_SRC

**** Emacs Org settings :settings:emacs:org:tangle:

#+NAME: make_set_var_3_emacs_org
#+BEGIN_SRC makefile
EMACSLISP=/usr/share/emacs/site-lisp
ORG_VER_AVAILABLE=$(shell echo `ls -d ~/.emacs.d/elpa/org-???????? | cut -d '-' -f2`)
EMACSLISP_ORG=~/.emacs.d/elpa/org-$($(shell echo $(ORG_VER_AVAILABLE)))
ORG_CONTRIB_VER_AVAILABLE=$(shell echo `ls -d ~/.emacs.d/elpa/org-plus-contrib-???????? | cut -d '-' -f2`)
EMACSLISP_ORG_CONTRIB=~/.emacs.d/elpa/org-plus-contrib-$($(shell echo $(ORG_CONTRIB_VER_AVAILABLE)))
ORGFILELIST=$(shell echo `ls -1 org/*.org`)
ORGFILES=""
ORGDIR :=$(shell echo `pwd`)
#+END_SRC

**** Markup Samples
***** pods

#+NAME: make_set_var_4_markup_samples_pods
#+BEGIN_SRC makefile
SiSU_MARKUP_SAMPLES_FIND_PODS= \
find data/pod -maxdepth 2 -name pod.manifest | cut -f 1-3 -d / | sort

SiSU_MARKUP_SAMPLES_PODS_FOUND= \
$(SiSU_MARKUP_SAMPLES_FIND_PODS) | xargs

SiSU_MARKUP_SAMPLES_POD = \
data/pod/accelerando.charles_stross \
data/pod/alices_adventures_in_wonderland.lewis_carroll \
data/pod/content.cory_doctorow \
data/pod/democratizing_innovation.eric_von_hippel \
data/pod/down_and_out_in_the_magic_kingdom.cory_doctorow \
data/pod/for_the_win.cory_doctorow \
data/pod/free_as_in_freedom_2.richard_stallman_and_the_free_software_revolution.sam_williams.richard_stallman \
data/pod/free_culture.lawrence_lessig \
data/pod/free_for_all.peter_wayner \
data/pod/gpl2.fsf \
data/pod/gpl3.fsf \
data/pod/gullivers_travels.jonathan_swift \
data/pod/little_brother.cory_doctorow \
data/pod/live-manual \
data/pod/sisu-manual \
data/pod/the_autonomous_contract.ralph_amissah \
data/pod/the_cathedral_and_the_bazaar.eric_s_raymond \
data/pod/the_public_domain.james_boyle \
data/pod/the_wealth_of_networks.yochai_benkler \
data/pod/through_the_looking_glass.lewis_carroll \
data/pod/two_bits.christopher_kelty \
data/pod/un_contracts_international_sale_of_goods_convention_1980 \
data/pod/viral_spiral.david_bollier
#+END_SRC

***** dir

#+NAME: make_set_var_5_markup_samples_search_dirs
#+BEGIN_SRC makefile
SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND = \
find data/sisudir/media/text -name *.ss[tm] | sort | xargs

SiSU_MARKUP_SAMPLES_DIR = \
data/sisudir/media/text/accelerando.charles_stross.sst \
data/sisudir/media/text/alices_adventures_in_wonderland.lewis_carroll.sst \
data/sisudir/media/text/content.cory_doctorow.sst \
data/sisudir/media/text/democratizing_innovation.eric_von_hippel.sst \
data/sisudir/media/text/down_and_out_in_the_magic_kingdom.cory_doctorow.sst \
data/sisudir/media/text/ffa_tmp.sst \
data/sisudir/media/text/for_the_win.cory_doctorow.sst \
data/sisudir/media/text/free_as_in_freedom_2.richard_stallman_and_the_free_software_revolution.sam_williams.richard_stallman.sst \
data/sisudir/media/text/free_culture.lawrence_lessig.sst \
data/sisudir/media/text/free_for_all.peter_wayner.sst \
data/sisudir/media/text/gpl2.fsf.sst \
data/sisudir/media/text/gpl3.fsf.sst \
data/sisudir/media/text/gullivers_travels.jonathan_swift.sst \
data/sisudir/media/text/little_brother.cory_doctorow.sst \
data/sisudir/media/text/sisu_markup.sst \
data/sisudir/media/text/sisu_markup_stress_test.sst \
data/sisudir/media/text/sisu_markup_test.sst \
data/sisudir/media/text/table_special_markup.sst \
data/sisudir/media/text/the_autonomous_contract.ralph_amissah.sst \
data/sisudir/media/text/the_cathedral_and_the_bazaar.eric_s_raymond.sst \
data/sisudir/media/text/the_public_domain.james_boyle.sst \
data/sisudir/media/text/the_wealth_of_networks.yochai_benkler.sst \
data/sisudir/media/text/through_the_looking_glass.lewis_carroll.sst \
data/sisudir/media/text/two_bits.christopher_kelty.sst \
data/sisudir/media/text/un_contracts_international_sale_of_goods_convention_1980.sst \
data/sisudir/media/text/viral_spiral.david_bollier.sst
#+END_SRC

****** sample markup file list

#+NAME: make_find_markup_samples_0_pod_and_dir
#+BEGIN_SRC makefile
markup_samples:
	find data/pod -name pod.manifest | cut -f 1-3 -d / | sort; \
find data/sisudir/media/text -name *.ss[tm] | sort
#+END_SRC

#+NAME: make_find_markup_samples_1_pod
#+BEGIN_SRC makefile
markup_pod_samples:
	find data/pod -name pod.manifest | cut -f 1-3 -d / | sort
#+END_SRC

#+NAME: make_find_markup_samples_2_dir
#+BEGIN_SRC makefile
markup_dir_samples:
	find data/sisudir/media/text -name *.ss[tm] | sort
#+END_SRC

*** make archive

#+NAME: make_project_zip_archive
#+BEGIN_SRC makefile
gitZip:
	git archive -v --format=tar --prefix=`echo spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)`/ HEAD | gzip > ../spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz && \
	echo "to unzip: tar -xzf spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz"
gitArchive:
	git archive -v --format=tar --prefix=spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)/ HEAD | gzip > ../spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz && \
	echo "to unzip: tar -xzf spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT).tar.gz"
#+END_SRC

*** _make_ commands [+2] :make:commands:

- build commands
  - build
  - debug
  - release
- init, clean, distclean etc.
  - init
  - clean
  - expunge
  - distclean
  - distclean_and_init
- org babel tangle
  - tangle
- git snapshot
  - gitsnapshot

**** version tag, stamp

#+NAME: make_version_tag
#+BEGIN_SRC makefile
version_tag:
	echo "DRV=<<spine_version_set>>; git tag -f doc-reform_v$$\{DRV} -m\"doc-reform $$\{DRV}\" HEAD" && \
	echo "git tag -f doc-reform_v<<spine_version_set>> -m\"doc-reform spine-<<spine_version_set>>\" HEAD"
#+END_SRC

**** changelog

#+NAME: make_changelog
#+BEGIN_SRC makefile
changelog:
	git log --pretty=format:'---%+s %+as %ae%+h%d%+b' --no-merges | sed "/^\\s*$$/d" | sed "s/^---$$//" | sed "s/^\(\*\)\+/-/" | sed "s/ \+$$//" > CHANGELOG_
#+END_SRC

**** build commands [+1] :build:compile:
***** _dub_ build rebuild :dub:
****** all compiler builds :all:dmd:gdc:ldc:
******* all builds
******** default

#+NAME: make_dub_upgrade
#+BEGIN_SRC makefile
dub_upgrade:
	$(DUB) upgrade
#+END_SRC

#+NAME: make_compile_0_compiler_default
#+BEGIN_SRC makefile
default: ldc
#+END_SRC

******** quick :quick:
********* default :default:

#+NAME: make_compile_1_compiler_all
#+BEGIN_SRC makefile
all: dmd ldc gdc
#+END_SRC

********* version :version:

#+NAME: make_compile_2_compiler_all_versioned
#+BEGIN_SRC makefile
all_ver: dmd_ver ldc_ver gdc_ver
#+END_SRC

********* get project dependencies

#+NAME: make_get_project_dependencies_github
#+BEGIN_SRC makefile
get_depends:
	hwd=$$(echo `pwd`) && \
	gwd="$${hwd}/src/ext_depends" && \
	dirs=$$(echo `ls -gx $${gwd}`) && \
	license_bsl="Boost Software License 1.0 (BSL-1.0)" && \
	echo $${hwd} && \
	echo $${gwd} && \
	echo $${dirs} && \
	dub upgrade; \
	cd $${gwd} && \
	for dir in $${dirs}; do \
	  if [ -d $${dir} ]; then \
	    echo $${dir} && \
	    if [ "imageformats" == $${dir} ]; then \
	      echo $${dir} && \
	      rm -rf $${dir} && \
	      git clone --depth=1 https://github.com/tjhann/$${dir} && \
	      cd $${dir} && \
	      echo $$PWD && \
	      echo "$${dir} `git rev-parse HEAD | cut -c 1-8`"   > ../$${dir}.meta && \
	      echo "https://github.com/tjhann/$${dir}"          >> ../$${dir}.meta && \
	      echo "$${license_bsl}"                            >> ../$${dir}.meta && \
	      cd $${gwd} && \
	      rm -rf $${dir}/.git; \
	    elif [[ "d2sqlite3" == $${dir}  || "D-YAML" == $${dir} || "tinyendian" == $${dir} ]]; then \
	      echo $${dir} && \
	      rm -rf $${dir} && \
	      git clone --depth=1 https://github.com/dlang-community/$${dir} && \
	      cd $${dir} && \
	      echo "$${dir} `git rev-parse HEAD | cut -c 1-8`"   > ../$${dir}.meta && \
	      echo "https://github.com/dlang-community/$${dir}" >> ../$${dir}.meta && \
	      echo "$${license_bsl}"                            >> ../$${dir}.meta && \
	      cd $${gwd} && \
	      rm -rf $${dir}/.git; \
	    fi; \
	  fi; \
	done; \
	cd $${hwd}
set_depends: get_depends
	dub describe | sed 's~$(shell echo `pwd | sed 's_/_\\/_g'`)~.~g'  > dub_describe.json
rm_flakelock:
	git reset HEAD flake.lock && \
	touch flake.lock \
	git rm -f flake.lock
flake_update:
	git add .; \
	nix flake update && \
	git reset HEAD flake.lock; \
	cp flake.lock flake.lock_
flake_update_move_lock: flake_update
	touch flake.lock \
	git rm -f flake.lock
set_latest: set_depends flake_update rm_flakelock
#+END_SRC

gitDir=dub2nix; git clone --depth=1 https://github.com/lionello/${gitDir} | rm -rf ${gitDir}/.git

********* debug :debug:

#+NAME: make_compile_3_compiler_all_debug
#+BEGIN_SRC makefile
all_debug: dmd_debug gdc_debug ldc_debug
#+END_SRC

********* _meson_ build :meson:

meson using dub
- works & looks pretty clean
- but subprojects built externally & not suitable for debian packaging

#+NAME: make_meson_build
#+BEGIN_SRC makefile
meson_clean_build_dir:
	rm -r build; mkdir build
meson_build: meson_clean_build_dir
	meson --buildtype=debugoptimized build
	ninja -C build
	notify-send -t 0 'D meson build ldc compiled test release executable ready' 'spine'
meson_redo: meson_clean_build_dir meson_build
meson_project_build_clean: clean skel tangle dub_upgrade meson_build
meson: meson_clean_build_dir dub_upgrade meson_build
#+END_SRC

******** clean & tangle :clean:tangle:
********* default :default:

#+NAME: make_clean_tangle_compile_0_all_clean
#+BEGIN_SRC makefile
all_clean: clean tangle dmd ldc gdc
#+END_SRC

********* version :version:

#+NAME: make_clean_tangle_compile_1_all_clean_versioned
#+BEGIN_SRC makefile
all_ver_clean: clean tangle dmd_ver ldc_ver gdc_ver
#+END_SRC

********* debug :debug:

#+NAME: make_clean_tangle_compile_2_all_clean_debug
#+BEGIN_SRC makefile
all_debug_ver: dmd_debug_ver gdc_debug_ver ldc_debug_ver
all_debug_clean_ver: clean tangle dmd_debug_ver gdc_debug_ver ldc_debug_ver
#+END_SRC

****** individual compiler builds :each:
******* dmd :dmd:
******** quick :quick:
********* default :default:

#+NAME: make_dub_compile_dmd_0_default
#+BEGIN_SRC makefile
dmd: dub_upgrade
	$(DUB) --compiler=dmd --config=dmd --build=release-nobounds
	notify-send -t 0 'D dmd compiled test release executable ready' 'spine-dmd'
#+END_SRC

********* debug :debug:

#+NAME: make_dub_compile_dmd_1_debug
#+BEGIN_SRC makefile
dmd_debug:
	$(DUB) --compiler=dmd --config=dmd --build=debug
#+END_SRC

********* version :version:

- assumes git tags with program version

#+NAME: make_dub_compile_dmd_2_versioned
#+BEGIN_SRC makefile
dmd_ver: dub_upgrade
	$(DUB) --compiler=dmd --config=dmd-version
	mv bin/spine-dmd-ver bin-archive/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-dmd
	notify-send -t 0 'D dmd compiled test release executable ready' 'spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-dmd'
dmd_clean_ver: clean tangle dmd_ver
#+END_SRC

******** clean & tangle :clean:tangle:

#+NAME: make_dub_compile_dmd_3_release
#+BEGIN_SRC makefile
dmd_rel: expunge skel tangle
	$(DUB) --compiler=dmd --config=spine-release
dmd_rel_tangle: tangle
	$(DUB) --compiler=dmd --config=spine-dmd
dmd_rel_expunge_tangle: expunge skel tangle dmd_rel_tangle
dmd_debug_tangle: tangle
	$(DUB) --compiler=dmd --config=spine-dmd-debug
#+END_SRC

******* gdc :gdc:
******** quick :quick:
********* default :default:

#+NAME: make_dub_compile_gdc_0_default
#+BEGIN_SRC makefile
gdc: dub_upgrade
	$(DUB) --compiler=gdc --config=gdc
	notify-send -t 0 'D gdc compiled test release executable ready' 'spine-gdc'
#+END_SRC

********* debug :debug:

#+NAME: make_dub_compile_gdc_1_debug
#+BEGIN_SRC makefile
gdc_debug:
	$(DUB) --compiler=gdc --config=gdc --build=debug
#+END_SRC

********* version :version:

- assumes git tags with program version

#+NAME: make_dub_compile_gdc_2_versioned
#+BEGIN_SRC makefile
gdc_ver: dub_upgrade
	$(DUB) --compiler=gdc --config=gdc-version
	mv bin/spine-gdc-ver bin-archive/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-gdc
	notify-send -t 0 'D gdc compiled test release executable ready' 'spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-gdc'
gdc_clean_ver: clean tangle gdc_ver
#+END_SRC

******** clean & tangle :clean:tangle:

#+NAME: make_dub_compile_gdc_3_release
#+BEGIN_SRC makefile
gdc_rel: expunge skel tangle
	$(DUB) --compiler=gdc --config=spine-release
gdc_rel_tangle: tangle
	$(DUB) --compiler=gdc --config=spine-gdc
gdc_rel_expunge_tangle: expunge skel tangle gdc_rel_tangle
gdc_debug_tangle: tangle
	$(DUB) --compiler=gdc --config=spine-gdc-debug
#+END_SRC

******* ldc :ldc:
******** quick :quick:
********* default :default:

#+NAME: make_dub_compile_ldc_0_default
#+BEGIN_SRC makefile
ldc: dub_upgrade
	$(DUB) --compiler=ldc2 --config=ldc --build=release
	notify-send -t 0 'D ldc compiled test release executable ready' 'spine-ldc'
#+END_SRC

********* debug :debug:

#+NAME: make_dub_compile_ldc_1_debug
#+BEGIN_SRC makefile
ldc_debug:
	$(DUB) --compiler=ldc2 --config=ldc --build=debug
#+END_SRC

********* version :version:

- assumes git tags with program version

#+NAME: make_dub_compile_ldc_2_versioned
#+BEGIN_SRC makefile
ldc_ver: dub_upgrade
	$(DUB) --compiler=ldc2 --config=ldc-version
	mv bin/spine-ldc-ver bin-archive/spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-ldc
	notify-send -t 0 'D ldc2 compiled test release executable ready' 'spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)-ldc'
ldc_clean_ver: clean tangle ldc_ver
#+END_SRC

******** clean & tangle :clean:tangle:

#+NAME: make_dub_compile_ldc_3_release
#+BEGIN_SRC makefile
ldc_rel: expunge skel tangle
	$(DUB) --compiler=ldc2 --config=spine-release
ldc_rel_tangle: tangle
	$(DUB) --compiler=ldc2 --config=spine-ldc
ldc_rel_expunge_tangle: expunge skel tangle ldc_rel_tangle
ldc_debug_tangle: tangle
	$(DUB) --compiler=ldc2 --config=spine-ldc-debug
#+END_SRC

****** generic
******* init clean distclean etc. :clean:

#+NAME: make_initialization_operations_0_parts
#+BEGIN_SRC makefile
reinit: clean skel tangle
skel:
	mkdir -p $(PRG_BINDIR); \
	mkdir -p $(PRG_BINDIR)-archive; \
	mkdir -p build; \
	mkdir -p views; \
	mkdir -p data; \
	mkdir -p sundry/util/d/cgi/search/cgi-bin/src; \
	mkdir -p sundry/util/d/tools/markup_conversion; \
	mkdir -p sundry/editor-syntax-etc/emacs; \
	mkdir -p sundry/editor-syntax-etc/vim/syntax; \
	mkdir -p sundry/editor-syntax-etc/vim/colors; \
	mkdir -p sundry/editor-syntax-etc/vim/ftplugin; \
	mkdir -p sundry/editor-syntax-etc/vim/rc; \
	mkdir -p sundry/editor-syntax-etc/vim/templates; \
	mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/conf; \
	mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/io_in; \
	mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/io_out; \
	mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/meta; \
	mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR)/share; \
	mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR); \
	mkdir -p $(PRG_BINDIR);
init: skel
clean:
	rm -rf build; \
	rm -rf $(PRG_SRCDIR); \
	rm -rf $(PRG_DOCDIR);
clean_bin:
	rm $(PRG_BINDIR)/*
clean_src:
	rm -rf $(PRG_SRCDIR);
clean_docs:
	rm -rf $(PRG_DOCDIR)
expunge:
	rm -f dub.selections.json; \
	rm -rf build; \
	rm -rf $(PRG_SRCDIR); \
	rm -rf $(PRG_BINDIR); \
	rm -rf $(PRG_DOCDIR);
distclean: expunge
distclean_and_init: expunge
	mkdir -p views; \
	mkdir -p sundry/util/d/cgi/search/cgi-bin/src; \
	mkdir -p sundry/util/d/tools/markup_conversion; \
	mkdir -p sundry/editor-syntax-etc/emacs; \
	mkdir -p sundry/editor-syntax-etc/vim/syntax; \
	mkdir -p sundry/editor-syntax-etc/vim/colors; \
	mkdir -p sundry/editor-syntax-etc/vim/ftplugin; \
	mkdir -p sundry/editor-syntax-etc/vim/rc; \
	mkdir -p sundry/editor-syntax-etc/vim/templates; \
	mkdir -p $(PRG_SRCDIR)/$(PRG_NAME_DIR); \
	mkdir -p $(PRG_BINDIR);
#+END_SRC

******* version :version:

#+NAME: make_initialization_operations_1_git_version
#+BEGIN_SRC makefile
ver:
	echo spine-$(PROG_VER_DECLARED)-tag-$(PROG_VER_GIT)
#+END_SRC

******* tangle build rebuild :clean:tangle:build:

#+NAME: make_initialization_operations_2_assemble
#+BEGIN_SRC makefile
clean_tangle_build: clean tangle build
tangle_build: tangle build
build: $(PRG_SRCDIR)/$(PRG_SRC)
	$(DC) $(DC_FLAGS) \
	$(DC_FLAG_BINOF)$(PRG_BINDIR)/$(PRG_BIN) \
	$(PRG_SRCDIR)/$(PRG_SRC)
rebuild: $(PRG_SRCDIR)/$(PRG_SRC) $(PRG_BINDIR)/$(PRG_BIN).o clean build
makefile_new:
	make -k tangle_maker
restart: clean tangle
#+END_SRC

**** testrun (program against document markup) :markup:sample:
***** pods :pod:
******* find files

#+NAME: make_project_testrun_0_find_pods
#+BEGIN_SRC makefile
find_pods:
	$(SiSU_MARKUP_SAMPLES_FIND_PODS)
#+END_SRC

****** dmd
******* find files

#+NAME: make_project_testrun_1
#+BEGIN_SRC makefile
dmd_testrun_find:
	./bin/spine-dmd -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_pod \
data/pod/sisu-manual
dmd_testrun_find_pod_source:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
./bin/spine-ldc -v --source --html --epub \
--output-dir=tmp/program_output_pod
dmd_testrun_find_pod_pod:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
./bin/spine-dmd -v --pod \
--output-dir=tmp/program_output_pod
dmd_testrun_find_pod_html:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
./bin/spine-dmd -v --html \
--output-dir=tmp/program_output_pod
dmd_testrun_find_pod_epub:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
./bin/spine-dmd -v --epub \
--output-dir=tmp/program_output_pod
dmd_testrun_find_pod_all:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
./bin/spine-dmd -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_pod
#+END_SRC

******* path list

#+NAME: make_project_testrun_2
#+BEGIN_SRC makefile
dmd_testrun_paths_pod_source:
	./bin/spine-dmd -v --source \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
dmd_testrun_paths_pod_pod:
	./bin/spine-dmd -v --pod \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
dmd_testrun_paths_pod_html:
	./bin/spine-dmd -v --html \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
dmd_testrun_paths_pod_epub:
	./bin/spine-dmd -v --epub \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
dmd_testrun_paths_pod_all:
	./bin/spine-dmd -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
#+END_SRC

****** gdc
******* find files

#+NAME: make_project_testrun_3
#+BEGIN_SRC makefile
gdc_testrun_find:
	./bin/spine-gdc -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_pod \
data/pod/sisu-manual
gdc_testrun_find_pod_source:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
./bin/spine-gdc -v --source \
--output-dir=tmp/program_output_pod
gdc_testrun_find_pod_pod:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
./bin/spine-gdc -v --pod \
--output-dir=tmp/program_output_pod
gdc_testrun_find_pod_html:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
./bin/spine-gdc -v --html \
--output-dir=tmp/program_output_pod
gdc_testrun_find_pod_epub:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
./bin/spine-gdc -v --epub \
--output-dir=tmp/program_output_pod
gdc_testrun_find_pod_all:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
./bin/spine-gdc -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_pod
#+END_SRC

******* path list

#+NAME: make_project_testrun_4
#+BEGIN_SRC makefile
gdc_testrun_paths:
	./bin/spine-gdc -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_pod \
data/pod/sisu-manual
gdc_testrun_paths_pod_source:
	./bin/spine-gdc -v --source \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
gdc_testrun_paths_pod_pod:
	./bin/spine-gdc -v --pod \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
gdc_testrun_paths_pod_html:
	./bin/spine-gdc -v --html \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
gdc_testrun_paths_pod_epub:
	./bin/spine-gdc -v --epub \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
gdc_testrun_paths_pod_all:
	./bin/spine-gdc -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
#+END_SRC

****** ldc
******* find files

#+NAME: make_project_testrun_5
#+BEGIN_SRC makefile
ldc_testrun_find:
	./bin/spine-ldc -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_pod \
data/pod/sisu-manual
ldc_testrun_find_pod_source:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
	./bin/spine-ldc -v --source \
--output-dir=tmp/program_output_pod
ldc_testrun_find_pod_pod:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
	./bin/spine-ldc -v --pod \
--output-dir=tmp/program_output_pod
ldc_testrun_find_pod_html:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
	./bin/spine-ldc -v --html \
--output-dir=tmp/program_output_pod
ldc_testrun_find_pod_epub:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
	./bin/spine-ldc -v --epub \
--output-dir=tmp/program_output_pod
ldc_testrun_find_pod_all:
	$(SiSU_MARKUP_SAMPLES_PODS_FOUND) \
	./bin/spine-ldc -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_pod
#+END_SRC

******* path list

#+NAME: make_project_testrun_6
#+BEGIN_SRC makefile
ldc_testrun_paths:
	./bin/spine-ldc -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_pod \
data/pod/sisu-manual
ldc_testrun_paths_pod_source:
	./bin/spine-ldc -v --source \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
ldc_testrun_paths_pod_pod:
	./bin/spine-ldc -v --pod \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
ldc_testrun_paths_pod_html:
	./bin/spine-ldc -v --html \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
ldc_testrun_paths_pod_epub:
	./bin/spine-ldc -v --epub \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
ldc_testrun_paths_pod_all:
	./bin/spine-ldc -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_pod \
$(SiSU_MARKUP_SAMPLES_POD)
#+END_SRC

***** dir :dir:
****** dmd
******* find files

#+NAME: make_project_testrun_7
#+BEGIN_SRC makefile
dmd_testrun_find_dir_source:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-dmd -v --source \
--output-dir=tmp/program_output_dir
dmd_testrun_find_dir_pod:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-dmd -v --pod \
--output-dir=tmp/program_output_dir
dmd_testrun_find_dir_html:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-dmd -v --html \
--output-dir=tmp/program_output_dir
dmd_testrun_find_dir_epub:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-dmd -v --epub \
--output-dir=tmp/program_output_dir
dmd_testrun_find_dir_all:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-dmd -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_dir
#+END_SRC

******* file list

#+NAME: make_project_testrun_8
#+BEGIN_SRC makefile
dmd_testrun_filelist_dir_source:
	./bin/spine-dmd -v --source \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
dmd_testrun_filelist_dir_pod:
	./bin/spine-dmd -v --pod \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
dmd_testrun_filelist_dir_html:
	./bin/spine-dmd -v --html \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
dmd_testrun_filelist_dir_epub:
	./bin/spine-dmd -v --epub \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
dmd_testrun_filelist_dir_all:
	./bin/spine-dmd -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
#+END_SRC

****** gdc
******* find files

#+NAME: make_project_testrun_9
#+BEGIN_SRC makefile
gdc_testrun_find_dir_source:
	./bin/spine-gdc -v --source \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
gdc_testrun_find_dir_pod:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-gdc -v --pod \
--output-dir=tmp/program_output_dir
gdc_testrun_find_dir_html:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-gdc -v --html \
--output-dir=tmp/program_output_dir
gdc_testrun_find_dir_epub:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-gdc -v --epub \
--output-dir=tmp/program_output_dir
gdc_testrun_find_dir_all:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-gdc -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_dir
#+END_SRC

******* file list

#+NAME: make_project_testrun_10
#+BEGIN_SRC makefile
gdc_testrun_filelist_dir_source:
	./bin/spine-gdc -v --source \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
gdc_testrun_filelist_dir_pod:
	./bin/spine-gdc -v --pod \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
gdc_testrun_filelist_dir_html:
	./bin/spine-gdc -v --html \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
gdc_testrun_filelist_dir_epub:
	./bin/spine-gdc -v --epub \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
gdc_testrun_filelist_dir_all:
	./bin/spine-gdc -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
#+END_SRC

****** ldc
******* find files

#+NAME: make_project_testrun_11
#+BEGIN_SRC makefile
ldc_testrun_find_dir_source:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-ldc -v --source \
--output-dir=tmp/program_output_dir
ldc_testrun_find_dir_pod:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-ldc -v --pod \
--output-dir=tmp/program_output_dir
ldc_testrun_find_dir_html:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-ldc -v --html \
--output-dir=tmp/program_output_dir
ldc_testrun_find_dir_epub:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-ldc -v --epub \
--output-dir=tmp/program_output_dir
ldc_testrun_find_dir_all:
	$(SiSU_MARKUP_SAMPLES_DIR_FILES_FOUND) \
./bin/spine-ldc -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_dir
#+END_SRC

******* file list

#+NAME: make_project_testrun_12
#+BEGIN_SRC makefile
ldc_testrun_filelist_dir_source:
	./bin/spine-ldc -v --source \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
ldc_testrun_filelist_dir_pod:
	./bin/spine-ldc -v --pod \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
ldc_testrun_filelist_dir_html:
	./bin/spine-ldc -v --html \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
ldc_testrun_filelist_dir_epub:
	./bin/spine-ldc -v --epub \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
ldc_testrun_filelist_dir_all:
	./bin/spine-ldc -v --source --html --epub --sqlite-discrete \
--sqlite-create --sqlite-update \
--output-dir=tmp/program_output_dir \
$(SiSU_MARKUP_SAMPLES_DIR)
#+END_SRC

**** org babel tangle batch process command :tangle:
***** tangle: org babel tangle *.org

#+NAME: make_tangle_0
#+BEGIN_SRC makefile
tangle: skel
	for f in $(ORGFILELIST); do \
		ORGFILES="$$ORGFILES \"$$f\""; \
	done; \
	emacs --batch -Q -q \
	--eval "(progn \
		(add-to-list 'load-path \
			(expand-file-name \"$(EMACSLISP)\")) \
		(add-to-list 'load-path \
			(expand-file-name \"$(EMACSLISP_ORG)\" t)) \
		(add-to-list 'load-path \
			(expand-file-name \"$(EMACSLISP_ORG_CONTRIB)\" t)) \
		(require 'org)(require 'ob)(require 'ob-tangle) \
		(mapc (lambda (file) \
			(find-file (expand-file-name file \"$(ORGDIR)\")) \
				(setq-local org-src-preserve-indentation t) \
			(org-babel-tangle) \
			(kill-buffer)) '($$ORGFILES)))" 2>&1
#+END_SRC

***** tangle maker: org babel tangle makefile new

#+NAME: make_tangle_1
#+BEGIN_SRC makefile
tangle_maker:
	for f in $(ORGFILELIST); do \
		ORGFILES="\"org/dr_build_scaffold.org\""; \
	done; \
	emacs --batch -Q -q \
	--eval "(progn \
		(add-to-list 'load-path \
			(expand-file-name \"$(EMACSLISP)\")) \
		(add-to-list 'load-path \
			(expand-file-name \"$(EMACSLISP_ORG)\" t)) \
		(add-to-list 'load-path \
			(expand-file-name \"$(EMACSLISP_ORG_CONTRIB)\" t)) \
		(require 'org)(require 'ob)(require 'ob-tangle) \
		(mapc (lambda (file) \
			(find-file (expand-file-name file \".\")) \
				(setq-local org-src-preserve-indentation t) \
			(org-babel-tangle) \
			(kill-buffer)) '($$ORGFILES)))" 2>&1
#+END_SRC

***** tangle nix project

#+NAME: make_nix_project
#+BEGIN_SRC makefile
lorri_shell:
	lorri shell
nix_shell:
	nix-shell
nix_build_default:
	nix build -f default.nix && ./result/bin/spine -v
nix_build_project:
	nix build -f project.nix && ./result/bin/spine -v
nix_build_spine:
	nix build -f spine.nix && ./result/bin/spine -v
nix-build_default:
	nix-build default.nix
#+END_SRC

**** git snapshot

#+NAME: make_git_snapshot
#+BEGIN_SRC makefile
gitsnapshot: distclean tangle
	git commit -a
#+END_SRC

*** phony :phony:

#+NAME: make_phony
#+BEGIN_SRC makefile
.PHONY : all build rebuild debug release \
	distclean init \
	tangle gitsnapshot
#+END_SRC