| 
									
										
										
										
											2021-08-08 01:54:37 +03:00
										 |  |  | #----------------------------------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2021-11-15 18:27:46 +03:00
										 |  |  | #
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Main targets:
 | 
					
						
							| 
									
										
										
										
											2021-12-13 00:57:15 +03:00
										 |  |  | # 	pdf				- build class pdf documentation...
 | 
					
						
							|  |  |  | # 	md				- build class markdown documentation (XXX EXPERIMENTAL)...
 | 
					
						
							| 
									
										
										
										
											2021-12-01 02:49:17 +03:00
										 |  |  | #
 | 
					
						
							|  |  |  | # Distribution and install:
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | # 	dist			- build a distributable zip
 | 
					
						
							|  |  |  | # 	install			- install to user home latex path
 | 
					
						
							|  |  |  | #	uninstall		- uninstall/remove from user home latex path
 | 
					
						
							|  |  |  | # 	install-local	- install to local latex path 
 | 
					
						
							|  |  |  | # 						(may require elevated privileges)
 | 
					
						
							|  |  |  | # 	uninstall-local	- uninstall/remove from local latex path
 | 
					
						
							|  |  |  | # 						(may require elevated privileges)
 | 
					
						
							| 
									
										
										
										
											2021-12-05 03:38:25 +03:00
										 |  |  | # 	install-devel	- XXX
 | 
					
						
							|  |  |  | # 	uninstall-devel	- XXX
 | 
					
						
							| 
									
										
										
										
											2021-11-15 18:27:46 +03:00
										 |  |  | #
 | 
					
						
							|  |  |  | # Other targets:
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | # 	sweep			- cleanup auxiliary generated files
 | 
					
						
							|  |  |  | # 	clean			- cleanup repo
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-12-01 02:49:17 +03:00
										 |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | # Variables:
 | 
					
						
							| 
									
										
										
										
											2021-11-29 18:27:19 +03:00
										 |  |  | # 	CODE_INSTALL	- set how we handle the installing code/source.
 | 
					
						
							|  |  |  | # 						this can be:
 | 
					
						
							| 
									
										
										
										
											2021-11-30 02:04:53 +03:00
										 |  |  | # 							strip		- strip the docs from code (default)
 | 
					
						
							| 
									
										
										
										
											2021-11-29 18:27:19 +03:00
										 |  |  | # 							copy		- copy the code/doc file
 | 
					
						
							|  |  |  | # 							link		- link the code/doc files
 | 
					
						
							| 
									
										
										
										
											2021-11-30 02:04:53 +03:00
										 |  |  | # 						(affects install and install-local targets)
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | # 	INSTALL_PATH	- install path
 | 
					
						
							| 
									
										
										
										
											2021-11-30 02:04:53 +03:00
										 |  |  | # 						(only affects install target)
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | #
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # Examples:
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-11-29 18:27:19 +03:00
										 |  |  | # 	$ INSTALL_PATH=./test CODE_INSTALL=link make install
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | # 		install to "./test" and do not strip docs.
 | 
					
						
							| 
									
										
										
										
											2021-11-15 18:27:46 +03:00
										 |  |  | #
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-12-01 02:49:17 +03:00
										 |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-11-15 18:27:46 +03:00
										 |  |  | #----------------------------------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | # Config...
 | 
					
						
							| 
									
										
										
										
											2021-08-08 01:54:37 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 13:42:06 +03:00
										 |  |  | # NOTE: this makes things run consistently on different systems including 
 | 
					
						
							|  |  |  | # 		things like Android...
 | 
					
						
							|  |  |  | SHELL := bash | 
					
						
							| 
									
										
										
										
											2021-08-08 01:54:37 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | MODULE := photobook | 
					
						
							| 
									
										
										
										
											2021-11-14 13:42:06 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-01 02:49:17 +03:00
										 |  |  | # metadata...
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # NOTE: the code version is in the code...
 | 
					
						
							|  |  |  | VERSION = $(strip $(shell \
 | 
					
						
							|  |  |  | 	cat $(MODULE).cls \
 | 
					
						
							|  |  |  | 		| grep 'VERSION{' \
 | 
					
						
							| 
									
										
										
										
											2023-03-13 16:35:18 +03:00
										 |  |  | 	 	| sed \
 | 
					
						
							|  |  |  | 			-e 's/.*{\(.*\)}.*/\1/' \
 | 
					
						
							|  |  |  | 			-e 's/v//')) | 
					
						
							| 
									
										
										
										
											2021-12-01 02:49:17 +03:00
										 |  |  | DATE = $(strip $(shell date "+%Y%m%d%H%M")) | 
					
						
							|  |  |  | COMMIT = $(strip $(shell git rev-parse HEAD)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # installing code...
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-11-29 18:27:19 +03:00
										 |  |  | # this can be:
 | 
					
						
							|  |  |  | # 	- strip
 | 
					
						
							|  |  |  | # 	- copy
 | 
					
						
							|  |  |  | # 	- link
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # NOTE: we are doing things in different ways for different modes:
 | 
					
						
							| 
									
										
										
										
											2021-12-01 02:49:17 +03:00
										 |  |  | # 		- copy vs. strip
 | 
					
						
							| 
									
										
										
										
											2021-11-29 18:27:19 +03:00
										 |  |  | # 			- simply change the target name and let make figure it out...
 | 
					
						
							| 
									
										
										
										
											2021-12-01 02:49:17 +03:00
										 |  |  | # 		- link vs. copy/strip
 | 
					
						
							| 
									
										
										
										
											2021-12-12 22:54:37 +03:00
										 |  |  | # 			- $(LN) vs. $(INSTALL) in the install target...
 | 
					
						
							| 
									
										
										
										
											2021-11-29 18:27:19 +03:00
										 |  |  | CODE_INSTALL ?= strip | 
					
						
							|  |  |  | ifeq ($(CODE_INSTALL),strip) | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | 	MODULE_CODE := $(MODULE)-stripped | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  | 	MODULE_CODE := $(MODULE) | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-13 00:57:15 +03:00
										 |  |  | # markdown dialect...
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # XXX still needs some tweaking...
 | 
					
						
							|  |  |  | MD_FORMAT ?= markdown_github | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # debug output...
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # $DEBUG can either be empty or anything else...
 | 
					
						
							|  |  |  | ifeq ($(DEBUG),) | 
					
						
							|  |  |  | 	STDERR := > /dev/null | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-01 02:49:17 +03:00
										 |  |  | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					
						
							|  |  |  | # Paths and files...
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-01 02:49:17 +03:00
										 |  |  | # LaTeX...
 | 
					
						
							| 
									
										
										
										
											2021-11-26 18:02:11 +03:00
										 |  |  | TEX_LOCAL = $(shell kpsewhich --var-value TEXMFLOCAL) | 
					
						
							|  |  |  | TEX_HOME = $(shell kpsewhich --var-value TEXMFHOME) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | # default install target...
 | 
					
						
							|  |  |  | INSTALL_PATH ?= $(TEX_HOME) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-01 02:49:17 +03:00
										 |  |  | # build...
 | 
					
						
							|  |  |  | BUILD_DIR := build | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | # distribution...
 | 
					
						
							| 
									
										
										
										
											2021-11-30 02:04:53 +03:00
										 |  |  | #DIST_NAME := $(MODULE)-$(VERSION)
 | 
					
						
							|  |  |  | DIST_NAME := $(MODULE)-$(VERSION)-$(DATE) | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | DIST_DIR := dist | 
					
						
							| 
									
										
										
										
											2022-11-14 02:05:16 +03:00
										 |  |  | DIST_SCRIPTS = \
 | 
					
						
							|  |  |  | 	$(wildcard scripts/*) | 
					
						
							| 
									
										
										
										
											2022-11-14 03:40:13 +03:00
										 |  |  | # NOTE: these are separate to unset the x bit...
 | 
					
						
							|  |  |  | DIST_NORMAL_FILES = \
 | 
					
						
							| 
									
										
										
										
											2022-09-15 02:00:47 +03:00
										 |  |  | 	README.md \
 | 
					
						
							| 
									
										
										
										
											2022-09-15 18:50:12 +03:00
										 |  |  | 	LICENSE \
 | 
					
						
							| 
									
										
										
										
											2022-09-14 11:48:47 +03:00
										 |  |  | 	Makefile \
 | 
					
						
							| 
									
										
										
										
											2023-03-18 21:38:31 +03:00
										 |  |  | 	DEPENDS.txt \
 | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | 	$(MODULE).cls \
 | 
					
						
							|  |  |  | 	$(MODULE).pdf | 
					
						
							| 
									
										
										
										
											2022-11-14 03:40:13 +03:00
										 |  |  | DIST_FILES = \
 | 
					
						
							|  |  |  | 	$(DIST_SCRIPTS) \
 | 
					
						
							|  |  |  | 	$(DIST_NORMAL_FILES) \
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-14 16:02:55 +03:00
										 |  |  | # Add these when ready...
 | 
					
						
							|  |  |  | #	$(wildcard examples/*) \
 | 
					
						
							|  |  |  | #	$(wildcard manual/*) \
 | 
					
						
							|  |  |  | #	$(wildcard workflow/*) \
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-01 02:49:17 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					
						
							|  |  |  | # Software...
 | 
					
						
							| 
									
										
										
										
											2021-08-12 11:24:18 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-16 00:58:45 +03:00
										 |  |  | # NOTE: need to run latex two+ times to build index, the simpler way to 
 | 
					
						
							| 
									
										
										
										
											2021-09-03 05:18:18 +03:00
										 |  |  | # 		go is to use latexmk...
 | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | #TEX := lualatex
 | 
					
						
							|  |  |  | TEX := latexmk -lualatex | 
					
						
							| 
									
										
										
										
											2021-08-08 01:54:37 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-14 13:42:06 +03:00
										 |  |  | # Doc generator...
 | 
					
						
							|  |  |  | DOC := ./scripts/cls2tex.sh | 
					
						
							| 
									
										
										
										
											2021-08-11 20:37:16 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-26 18:02:11 +03:00
										 |  |  | MD := mkdir -p | 
					
						
							| 
									
										
										
										
											2021-12-12 22:54:37 +03:00
										 |  |  | # XXX cp/install, technically this is only used in install* targets so 
 | 
					
						
							|  |  |  | # 		renaming CP -> INSTALL would seem logical...
 | 
					
						
							|  |  |  | #INSTALL := cp
 | 
					
						
							|  |  |  | INSTALL := install | 
					
						
							| 
									
										
										
										
											2021-12-01 02:49:17 +03:00
										 |  |  | # copy preserving relative paths...
 | 
					
						
							|  |  |  | RCP := cp -r --parents | 
					
						
							| 
									
										
										
										
											2021-11-29 18:27:19 +03:00
										 |  |  | LN := cp -l | 
					
						
							| 
									
										
										
										
											2021-11-26 18:02:11 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-11 20:37:16 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-22 14:52:34 +03:00
										 |  |  | #----------------------------------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | # Rules...
 | 
					
						
							| 
									
										
										
										
											2021-08-11 20:37:16 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-13 00:57:15 +03:00
										 |  |  | # docs (pdf)...
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-08-11 20:37:16 +03:00
										 |  |  | %.pdf: %.tex | 
					
						
							| 
									
										
										
										
											2021-12-13 00:57:15 +03:00
										 |  |  | 	$(TEX) $< $(STDERR) | 
					
						
							| 
									
										
										
										
											2021-08-11 20:37:16 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-13 00:57:15 +03:00
										 |  |  | # docs (markdown)...
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # XXX this still needs some tweaking...
 | 
					
						
							| 
									
										
										
										
											2021-12-18 23:04:21 +03:00
										 |  |  | # 			- |..|	- verbatim does not work...
 | 
					
						
							|  |  |  | # 			- ||	- parts of doc omitted...
 | 
					
						
							|  |  |  | #			- verbatim blocks get merged sometimes...
 | 
					
						
							|  |  |  | #			- ...
 | 
					
						
							|  |  |  | #		...not sure if this can be tweaked...
 | 
					
						
							| 
									
										
										
										
											2021-12-13 00:57:15 +03:00
										 |  |  | #%.md: %.tex
 | 
					
						
							|  |  |  | #	pandoc -t $(MD_FORMAT) -s $< -o $@
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-15 20:28:02 +03:00
										 |  |  | # XXX EXPERIMENTAL...
 | 
					
						
							| 
									
										
										
										
											2021-12-13 00:57:15 +03:00
										 |  |  | # XXX revise:
 | 
					
						
							|  |  |  | #		...for this to work we need to replace:
 | 
					
						
							|  |  |  | #			\documentclass{ltxdoc}
 | 
					
						
							|  |  |  | #		to:
 | 
					
						
							|  |  |  | #			\documentclass[markdownextra]{internet}
 | 
					
						
							| 
									
										
										
										
											2021-12-15 20:28:02 +03:00
										 |  |  | # XXX install the internet class...
 | 
					
						
							|  |  |  | #			https://github.com/loopspace/latex-to-internet
 | 
					
						
							| 
									
										
										
										
											2021-12-17 22:12:23 +03:00
										 |  |  | #		...needs testing...
 | 
					
						
							| 
									
										
										
										
											2021-12-13 00:57:15 +03:00
										 |  |  | %.md: %.tex | 
					
						
							|  |  |  | 	cat $< \
 | 
					
						
							|  |  |  | 		| sed 's/documentclass{ltxdoc}/documentclass[markdownextra]{internet}/' \
 | 
					
						
							|  |  |  | 		> $<.tmp | 
					
						
							|  |  |  | 	mv $<{.tmp,} | 
					
						
							|  |  |  | 	$(TEX) $< $(STDERR) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # meta-section...
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-08-12 11:24:18 +03:00
										 |  |  | # NOTE: .sty and .cls are essentially the same in terms of documentation 
 | 
					
						
							|  |  |  | # 		generation...
 | 
					
						
							| 
									
										
										
										
											2022-02-27 12:29:15 +03:00
										 |  |  | # XXX might be a good idea to place a link/footnote where metadocs were 
 | 
					
						
							|  |  |  | #		originally located...
 | 
					
						
							|  |  |  | #		...not sure yet manually or automatically...
 | 
					
						
							| 
									
										
										
										
											2021-09-03 03:28:04 +03:00
										 |  |  | %.tex: %.sty %-meta.tex | 
					
						
							| 
									
										
										
										
											2021-11-22 22:14:52 +03:00
										 |  |  | 	$(DOC) $< > $@ | 
					
						
							| 
									
										
										
										
											2021-08-11 20:37:16 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-03 03:28:04 +03:00
										 |  |  | %.tex: %.cls %-meta.tex | 
					
						
							| 
									
										
										
										
											2021-11-22 22:14:52 +03:00
										 |  |  | 	$(DOC) $< > $@ | 
					
						
							| 
									
										
										
										
											2021-09-03 03:28:04 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | # meta docs...
 | 
					
						
							|  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2021-09-03 03:28:04 +03:00
										 |  |  | # NOTE: this is a bit ugly, but allot less so than trying to push \verb
 | 
					
						
							|  |  |  | # 		into a LaTeX macro/env and then getting it out again in one pice...
 | 
					
						
							|  |  |  | %-meta.tex: %.sty | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | 	$(DOC) --prefix M $< > $@ | 
					
						
							| 
									
										
										
										
											2021-09-03 03:28:04 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | %-meta.tex: %.cls | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | 	$(DOC) --prefix M $< > $@ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # strip docs out...
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | # XXX can we unify these???
 | 
					
						
							| 
									
										
										
										
											2023-03-20 12:50:02 +03:00
										 |  |  | # 		....not sure how...
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | %-stripped.tex: %.tex | 
					
						
							|  |  |  | 	$(DOC) --strip $< \
 | 
					
						
							|  |  |  | 		$(DOC) --prefix M --strip \
 | 
					
						
							|  |  |  | 		> $@ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | %-stripped.sty: %.sty | 
					
						
							|  |  |  | 	$(DOC) --strip $< \
 | 
					
						
							|  |  |  | 		| $(DOC) --prefix M --strip \
 | 
					
						
							|  |  |  | 		> $@ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | %-stripped.cls: %.cls | 
					
						
							|  |  |  | 	$(DOC) --strip $< \
 | 
					
						
							|  |  |  | 		| $(DOC) --prefix M --strip \
 | 
					
						
							|  |  |  | 		> $@ | 
					
						
							| 
									
										
										
										
											2021-08-11 20:37:16 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-18 21:38:31 +03:00
										 |  |  | # list of dependencies...
 | 
					
						
							|  |  |  | #
 | 
					
						
							|  |  |  | DEPENDS.txt: $(MODULE).cls | 
					
						
							| 
									
										
										
										
											2023-04-27 01:46:04 +03:00
										 |  |  | 	make depends \
 | 
					
						
							| 
									
										
										
										
											2023-04-28 02:50:29 +03:00
										 |  |  | 		| grep -v make \
 | 
					
						
							|  |  |  | 		| sed -e 's/^/hard /' \
 | 
					
						
							| 
									
										
										
										
											2023-03-18 21:38:31 +03:00
										 |  |  | 		> $@ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-08 01:54:37 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-08 14:07:52 +03:00
										 |  |  | #----------------------------------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | # Info targets...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .PHONY: version | 
					
						
							|  |  |  | version: | 
					
						
							|  |  |  | 	@echo $(VERSION) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-28 02:50:29 +03:00
										 |  |  | # NOTE: grep's -z flag generates a bunch if nulls that we need to clean 
 | 
					
						
							|  |  |  | # 		out via tr.
 | 
					
						
							|  |  |  | # XXX this is a bit ugly -- adding/removing "hard" and then adding it 
 | 
					
						
							|  |  |  | # 		again for DEPENDS.txt...
 | 
					
						
							| 
									
										
										
										
											2023-04-27 01:46:04 +03:00
										 |  |  | .PHONY: depends | 
					
						
							|  |  |  | depends: $(MODULE).cls | 
					
						
							|  |  |  | 	@cat $< \
 | 
					
						
							|  |  |  | 		| grep -Ezo '\s*\\RequirePackage(\[[^]]*\])?\{[^}]*\}' \
 | 
					
						
							|  |  |  | 		| sed -e 's/.*{\(.*\)}/hard \1\n/' \
 | 
					
						
							|  |  |  | 		| grep -a hard \
 | 
					
						
							| 
									
										
										
										
											2023-04-28 02:50:29 +03:00
										 |  |  | 		| tr -d '\000' \
 | 
					
						
							|  |  |  | 		| cut -d " " -f 2 | 
					
						
							| 
									
										
										
										
											2023-04-27 01:46:04 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | #----------------------------------------------------------------------
 | 
					
						
							|  |  |  | # Main targets...
 | 
					
						
							| 
									
										
										
										
											2021-08-22 14:52:34 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-25 11:58:14 +03:00
										 |  |  | .PHONY: dep | 
					
						
							|  |  |  | dep: DEPENDS.txt | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-13 00:57:15 +03:00
										 |  |  | .PHONY: pdf | 
					
						
							|  |  |  | pdf: $(MODULE).pdf | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .PHONY: md | 
					
						
							|  |  |  | md: $(MODULE).md | 
					
						
							| 
									
										
										
										
											2021-08-22 14:52:34 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-10 17:18:52 +03:00
										 |  |  | # XXX STUB -- not sure how to approach this yet...
 | 
					
						
							|  |  |  | # 		on one hand the manual should be a self-contained example in 
 | 
					
						
							|  |  |  | # 		itself on the other hand we already have a working Makefile 
 | 
					
						
							|  |  |  | # 		building the docs...
 | 
					
						
							| 
									
										
										
										
											2021-12-09 19:46:07 +03:00
										 |  |  | .PHONY: manual | 
					
						
							|  |  |  | manual: | 
					
						
							| 
									
										
										
										
											2021-12-10 17:18:52 +03:00
										 |  |  | 	$(MAKE) -C manual all | 
					
						
							| 
									
										
										
										
											2021-12-10 20:46:30 +03:00
										 |  |  | 	mv manual/*.pdf . | 
					
						
							| 
									
										
										
										
											2021-12-08 00:15:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-22 14:52:34 +03:00
										 |  |  | .PHONY: dist | 
					
						
							| 
									
										
										
										
											2022-11-14 03:40:13 +03:00
										 |  |  | dist: $(DIST_FILES) | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | 	$(MD) $(DIST_DIR) | 
					
						
							| 
									
										
										
										
											2022-11-14 03:40:13 +03:00
										 |  |  | 	chmod 644 $(DIST_NORMAL_FILES) | 
					
						
							|  |  |  | 	zip -Drq $(DIST_DIR)/$(DIST_NAME).zip $(DIST_FILES) | 
					
						
							| 
									
										
										
										
											2022-09-15 01:52:52 +03:00
										 |  |  | 	# Place everything in the module dir as per CTAN spec... | 
					
						
							|  |  |  | 	zipnote $(DIST_DIR)/$(DIST_NAME).zip \
 | 
					
						
							|  |  |  | 		| sed 's/^\@ \([^(].*\)$$/@ \1\n@=$(MODULE)\/\1/' \
 | 
					
						
							|  |  |  | 		| zipnote -w $(DIST_DIR)/$(DIST_NAME).zip | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-15 22:30:17 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-16 00:22:15 +03:00
										 |  |  | # this is used to create a CTAN-compatible dist archive...
 | 
					
						
							|  |  |  | .PHONY: ctan-dist | 
					
						
							|  |  |  | ctan-dist: dist | 
					
						
							| 
									
										
										
										
											2022-09-16 00:15:01 +03:00
										 |  |  | 	cp -f $(DIST_DIR)/$(DIST_NAME).zip $(DIST_DIR)/$(MODULE).zip | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-15 22:30:17 +03:00
										 |  |  | .PHONY: tag | 
					
						
							|  |  |  | tag: | 
					
						
							|  |  |  | 	@echo "Will create and publish git tag:" | 
					
						
							| 
									
										
										
										
											2022-11-14 01:21:11 +03:00
										 |  |  | 	@echo "    v$(VERSION)" | 
					
						
							| 
									
										
										
										
											2022-09-15 22:30:17 +03:00
										 |  |  | 	@echo "Last 5 tags:" | 
					
						
							| 
									
										
										
										
											2022-11-14 01:21:11 +03:00
										 |  |  | 	@git tag -l 'v[0-9]*'\
 | 
					
						
							| 
									
										
										
										
											2023-03-13 14:40:28 +03:00
										 |  |  | 		| sort -V \
 | 
					
						
							| 
									
										
										
										
											2022-09-15 22:30:17 +03:00
										 |  |  | 		| tail -n 5 \
 | 
					
						
							| 
									
										
										
										
											2023-02-27 17:12:30 +03:00
										 |  |  | 		| sed 's/^/    /' \
 | 
					
						
							|  |  |  | 		| tac | 
					
						
							| 
									
										
										
										
											2023-03-13 14:14:39 +03:00
										 |  |  | #	# check if we need to bug the user about committing and/or pushing stuff...
 | 
					
						
							|  |  |  | 	@\
 | 
					
						
							|  |  |  | 		UNCOMITTED=$$(git status --porcelain=v1 2> /dev/null | grep -v '??' | wc -l) ;\
 | 
					
						
							|  |  |  | 		UNPUSHED=$$(git log origin..HEAD | wc -l) ;\
 | 
					
						
							|  |  |  | 		if ! [ $$UNCOMITTED = 0 ] ; then \
 | 
					
						
							|  |  |  | 			echo ;\
 | 
					
						
							|  |  |  | 			echo "WARNING: Uncommited changes found!" ;\
 | 
					
						
							|  |  |  | 		fi ;\
 | 
					
						
							|  |  |  | 		if ! [ $$UNPUSHED = 0 ] ; then \
 | 
					
						
							|  |  |  | 			[ $$UNCOMITTED = 0 ] \
 | 
					
						
							|  |  |  | 				&& echo ;\
 | 
					
						
							|  |  |  | 			echo "WARNING: Unpushed commits found!" ;\
 | 
					
						
							|  |  |  | 		fi ;\
 | 
					
						
							|  |  |  | 		if ! [ $$UNCOMITTED = 0 ] || ! [ $$UNPUSHED = 0 ] ; then \
 | 
					
						
							|  |  |  | 			echo ;\
 | 
					
						
							|  |  |  | 			echo "Note that this must be done after a commit and a push." ;\
 | 
					
						
							|  |  |  | 			echo "(press any key to continue or ctrl-c to cancel)" ;\
 | 
					
						
							|  |  |  | 			read ;\
 | 
					
						
							|  |  |  | 		fi ;\
 | 
					
						
							| 
									
										
										
										
											2022-11-14 01:21:11 +03:00
										 |  |  | 	git tag "v$(VERSION)" | 
					
						
							|  |  |  | 	git push origin "v$(VERSION)" | 
					
						
							| 
									
										
										
										
											2022-09-15 22:30:17 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #.PHONY: publish
 | 
					
						
							|  |  |  | #publish: dist
 | 
					
						
							| 
									
										
										
										
											2021-11-26 18:02:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-22 14:52:34 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | .PHONY: all | 
					
						
							| 
									
										
										
										
											2023-03-25 11:58:14 +03:00
										 |  |  | all: pdf dep  | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					
						
							|  |  |  | # Install/uninstall targets...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # NOTE: keep the dir clean unless this is explicitly built...
 | 
					
						
							|  |  |  | .INTERMEDIATE: \ | 
					
						
							|  |  |  | 		$(MODULE)-stripped.cls \
 | 
					
						
							|  |  |  | 		$(MODULE)-stripped.sty \
 | 
					
						
							|  |  |  | 		$(MODULE)-stripped.tex | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-29 18:27:19 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | # user install...
 | 
					
						
							| 
									
										
										
										
											2021-08-22 14:52:34 +03:00
										 |  |  | .PHONY: install | 
					
						
							| 
									
										
										
										
											2021-12-13 00:57:15 +03:00
										 |  |  | install: pdf $(MODULE_CODE).cls | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | 	$(MD) $(INSTALL_PATH)/{tex,source,doc}/latex/$(MODULE) | 
					
						
							| 
									
										
										
										
											2021-12-12 22:54:37 +03:00
										 |  |  | 	$(INSTALL) "$(MODULE).pdf" $(INSTALL_PATH)/doc/latex/$(MODULE) | 
					
						
							|  |  |  | 	$(INSTALL) "$(MODULE_CODE).cls" $(INSTALL_PATH)/tex/latex/$(MODULE)/$(MODULE).cls | 
					
						
							| 
									
										
										
										
											2021-11-29 18:27:19 +03:00
										 |  |  | #	# NOTE: we are printing only the stuff we are doing...
 | 
					
						
							|  |  |  | 	@run(){ echo "$$@" ;  "$$@" ; } ;\
 | 
					
						
							|  |  |  | 	if [[ $${CODE_INSTALL} == "link" ]] ; then \
 | 
					
						
							|  |  |  | 		run $(LN) \
 | 
					
						
							|  |  |  | 			"$(INSTALL_PATH)/tex/latex/$(MODULE)/$(MODULE).cls" \
 | 
					
						
							|  |  |  | 			"$(INSTALL_PATH)/source/latex/$(MODULE)/" ;\
 | 
					
						
							|  |  |  | 	else \
 | 
					
						
							| 
									
										
										
										
											2021-12-12 22:54:37 +03:00
										 |  |  | 		run $(INSTALL) "$(MODULE).cls" "$(INSTALL_PATH)/source/latex/$(MODULE)" ;\
 | 
					
						
							| 
									
										
										
										
											2021-11-29 18:27:19 +03:00
										 |  |  | 	fi | 
					
						
							| 
									
										
										
										
											2021-11-26 18:02:11 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | .PHONY: uninstall | 
					
						
							|  |  |  | uninstall: | 
					
						
							|  |  |  | 	rm -rf $(INSTALL_PATH)/{tex,source,doc}/latex/$(MODULE) | 
					
						
							|  |  |  | 	@echo "###" | 
					
						
							|  |  |  | 	@echo "### NOTE: this can leave the following dirs empty:" | 
					
						
							|  |  |  | 	@echo "###         $(INSTALL_PATH)/{tex,source,doc}/latex/" | 
					
						
							|  |  |  | 	@echo "###" | 
					
						
							| 
									
										
										
										
											2021-08-22 14:52:34 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-08 14:07:52 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | # local/system install...
 | 
					
						
							|  |  |  | # NOTE: this should be run with sudo, i.e.:
 | 
					
						
							|  |  |  | # 			$ sudo make install-local
 | 
					
						
							|  |  |  | .PHONY: install-local | 
					
						
							|  |  |  | install-local: INSTALL_PATH := $(TEX_LOCAL) | 
					
						
							|  |  |  | install-local: install | 
					
						
							| 
									
										
										
										
											2021-11-15 18:27:46 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | .PHONY: uninstall-local | 
					
						
							|  |  |  | uninstall-local: INSTALL_PATH := $(TEX_LOCAL) | 
					
						
							|  |  |  | uninstall-local: uninstall | 
					
						
							| 
									
										
										
										
											2021-11-15 18:27:46 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-08 14:07:52 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-04 02:06:07 +03:00
										 |  |  | # XXX need to make this work for windows...
 | 
					
						
							|  |  |  | # 		...this must depend not on the OS but rather on in what context 
 | 
					
						
							|  |  |  | # 		(cygwin/wsl/windows), latex is running...
 | 
					
						
							|  |  |  | # 		...this seems to work:
 | 
					
						
							|  |  |  | # 			> mkling TO FROM
 | 
					
						
							|  |  |  | # 		but like ln, it's args are in the wrong order...
 | 
					
						
							|  |  |  | # 		...cp -s creates links usable from cygwin but not usable from 
 | 
					
						
							|  |  |  | # 		windows...
 | 
					
						
							|  |  |  | .PHONY: install-devel | 
					
						
							|  |  |  | install-devel: CODE_INSTALL := copy | 
					
						
							| 
									
										
										
										
											2021-12-12 22:54:37 +03:00
										 |  |  | install-devel: INSTALL := cp -s | 
					
						
							| 
									
										
										
										
											2021-12-04 02:06:07 +03:00
										 |  |  | install-devel: install | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .PHONY: uninstall-devel | 
					
						
							|  |  |  | uninstall-devel: uninstall | 
					
						
							| 
									
										
										
										
											2021-12-03 11:38:44 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-05 03:38:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 | 
					
						
							| 
									
										
										
										
											2021-11-27 13:18:11 +03:00
										 |  |  | # Cleanup targets...
 | 
					
						
							| 
									
										
										
										
											2021-08-08 01:54:37 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | .PHONY: sweep | 
					
						
							|  |  |  | sweep: | 
					
						
							| 
									
										
										
										
											2021-11-28 00:29:09 +03:00
										 |  |  | 	rm -f \
 | 
					
						
							|  |  |  | 		*.{aux,fls,glo,gls,hd,idx,ilg,ind,ins,log,out,toc,fdb_latexmk} \
 | 
					
						
							|  |  |  | 		*-stripped.{tex,sty,cls} \
 | 
					
						
							|  |  |  | 		*-meta.{tex,sty,cls} \
 | 
					
						
							|  |  |  | 		${MODULE}.tex | 
					
						
							| 
									
										
										
										
											2021-08-08 01:54:37 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .PHONY: clean | 
					
						
							|  |  |  | clean: sweep | 
					
						
							| 
									
										
										
										
											2023-03-18 21:38:31 +03:00
										 |  |  | 	rm -rf $(DIST_DIR) $(BUILD_DIR) $(MODULE).md DEPENDS.txt *.pdf | 
					
						
							| 
									
										
										
										
											2021-08-08 01:54:37 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-22 14:52:34 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-08 01:54:37 +03:00
										 |  |  | #----------------------------------------------------------------------
 | 
					
						
							|  |  |  | #                                                   vim:set ts=4 sw=4 :
 |