experimenting with the build process...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-12-01 02:49:17 +03:00
parent de76c5f124
commit b064a99ddc

View File

@ -4,6 +4,8 @@
# #
# Main targets: # Main targets:
# doc - build class documentation # doc - build class documentation
#
# Distribution and install:
# dist - build a distributable zip # dist - build a distributable zip
# install - install to user home latex path # install - install to user home latex path
# uninstall - uninstall/remove from user home latex path # uninstall - uninstall/remove from user home latex path
@ -16,6 +18,7 @@
# sweep - cleanup auxiliary generated files # sweep - cleanup auxiliary generated files
# clean - cleanup repo # clean - cleanup repo
# #
#
# Variables: # Variables:
# CODE_INSTALL - set how we handle the installing code/source. # CODE_INSTALL - set how we handle the installing code/source.
# this can be: # this can be:
@ -33,6 +36,11 @@
# install to "./test" and do not strip docs. # install to "./test" and do not strip docs.
# #
# #
# XXX Q: shold dist: pack into a dir or into the archive root??
# ...have to make a decision here and stop asking the same question
# for every single project...
#
#
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# Config... # Config...
@ -45,16 +53,29 @@ SHELL := bash
MODULE := photobook MODULE := photobook
# metadata...
#
# NOTE: the code version is in the code...
VERSION = $(strip $(shell \
cat $(MODULE).cls \
| grep 'VERSION{' \
| sed 's/.*{\(.*\)}.*/\1/'))
DATE = $(strip $(shell date "+%Y%m%d%H%M"))
COMMIT = $(strip $(shell git rev-parse HEAD))
# installing code...
#
# this can be: # this can be:
# - strip # - strip
# - copy # - copy
# - link # - link
# #
# NOTE: we are doing things in different ways for different modes: # NOTE: we are doing things in different ways for different modes:
# copy vs. strip # - copy vs. strip
# - simply change the target name and let make figure it out... # - simply change the target name and let make figure it out...
# link vs. copy/strip # - link vs. copy/strip
# - either do $(LN) or $(CP) in the install target... # - $(LN) vs. $(CP) in the install target...
CODE_INSTALL ?= strip CODE_INSTALL ?= strip
ifeq ($(CODE_INSTALL),strip) ifeq ($(CODE_INSTALL),strip)
@ -64,22 +85,19 @@ else
endif endif
# metadata... # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# NOTE: the code version is in the code... # Paths and files...
VERSION = $(strip $(shell \
cat $(MODULE).cls \
| grep 'VERSION{' \
| sed 's/.*{\(.*\)}.*/\1/'))
DATE = $(strip $(shell date "+%Y%m%d%H%M"))
COMMIT = $(strip $(shell git rev-parse HEAD))
# LaTeX paths... # LaTeX...
TEX_LOCAL = $(shell kpsewhich --var-value TEXMFLOCAL) TEX_LOCAL = $(shell kpsewhich --var-value TEXMFLOCAL)
TEX_HOME = $(shell kpsewhich --var-value TEXMFHOME) TEX_HOME = $(shell kpsewhich --var-value TEXMFHOME)
# default install target... # default install target...
INSTALL_PATH ?= $(TEX_HOME) INSTALL_PATH ?= $(TEX_HOME)
# build...
BUILD_DIR := build
# distribution... # distribution...
#DIST_NAME := $(MODULE)-$(VERSION) #DIST_NAME := $(MODULE)-$(VERSION)
DIST_NAME := $(MODULE)-$(VERSION)-$(DATE) DIST_NAME := $(MODULE)-$(VERSION)-$(DATE)
@ -93,6 +111,7 @@ DIST_FILES = \
$(MODULE).pdf $(MODULE).pdf
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Software... # Software...
@ -106,6 +125,8 @@ DOC := ./scripts/cls2tex.sh
MD := mkdir -p MD := mkdir -p
CP := cp CP := cp
# copy preserving relative paths...
RCP := cp -r --parents
LN := cp -l LN := cp -l
@ -175,10 +196,17 @@ version:
doc: $(MODULE).pdf doc: $(MODULE).pdf
#.PHONY: build
#build: $(DIST_FILES)
# $(MD) $(BUILD_DIR)/$(DIST_NAME)
# $(RCP) $(DIST_FILES) $(BUILD_DIR)/$(DIST_NAME)
.PHONY: dist .PHONY: dist
dist: $(DIST_FILES) sweep dist: $(DIST_FILES) #build
$(MD) $(DIST_DIR) $(MD) $(DIST_DIR)
zip -Drq $(DIST_DIR)/$(DIST_NAME).zip $(DIST_FILES) zip -Drq $(DIST_DIR)/$(DIST_NAME).zip $(DIST_FILES)
# zip -Drq $(DIST_DIR)/$(DIST_NAME).zip $(BUILD_DIR)/$(DIST_NAME)
.PHONY: all .PHONY: all
@ -199,8 +227,8 @@ all: doc
.PHONY: install .PHONY: install
install: doc $(MODULE_CODE).cls install: doc $(MODULE_CODE).cls
$(MD) $(INSTALL_PATH)/{tex,source,doc}/latex/$(MODULE) $(MD) $(INSTALL_PATH)/{tex,source,doc}/latex/$(MODULE)
$(CP) $(MODULE).pdf $(INSTALL_PATH)/doc/latex/$(MODULE) $(CP) "$(MODULE).pdf" $(INSTALL_PATH)/doc/latex/$(MODULE)
$(CP) $(MODULE_CODE).cls $(INSTALL_PATH)/tex/latex/$(MODULE)/$(MODULE).cls $(CP) "$(MODULE_CODE).cls" $(INSTALL_PATH)/tex/latex/$(MODULE)/$(MODULE).cls
# # NOTE: we are printing only the stuff we are doing... # # NOTE: we are printing only the stuff we are doing...
@run(){ echo "$$@" ; "$$@" ; } ;\ @run(){ echo "$$@" ; "$$@" ; } ;\
if [[ $${CODE_INSTALL} == "link" ]] ; then \ if [[ $${CODE_INSTALL} == "link" ]] ; then \
@ -246,7 +274,7 @@ sweep:
.PHONY: clean .PHONY: clean
clean: sweep clean: sweep
rm -rf $(DIST_DIR) *.pdf rm -rf $(DIST_DIR) $(BUILD_DIR) *.pdf