site.mk
Table of Contents
1. File Name
While the name of this file is site.mk
, I'm going to start with
producing a Makefile so I don't have to continually specify the file
(and forget to do so). Later on I'll likely create a main Makefile
that includes the other files.
2. Define dist directory.
The directory that will be packaged up to be published should be defined and created as needed.
DIST_DIR := dist $(DIST_DIR): ; mkdir -p $(@)
3. Define output files and copy to dist.
These will be explicitly defined in line with my build preferences. Journals and pages will be listed separately to handle the directory conventions and allow for pages to be published without a sub-directory (there's no particular reason to need one for journals either).
JOURNALS_DIR := journals JOURNALS_DST_DIR := $(DIST_DIR)/journals $(JOURNALS_DST_DIR): ; mkdir -p $(@) PAGE_SRCS = index.html site.mk.html JOURNAL_FILES = 20250122.html JOURNAL_SRCS = $(call addprefix,$(JOURNALS_DIR)/,$(JOURNAL_FILES)) $(DIST_DIR)/%: % | $(DIST_DIR) $(JOURNALS_DST_DIR) cp $(<) $(@) DST_FILES := $(call addprefix,$(DIST_DIR)/,$(PAGE_SRCS) $(JOURNAL_SRCS)) export: $(DST_FILES) .PHONY: export
4. Produce tarball
The dist dir can be packaged up into a tarball, to avoid potential
cycles the tarball will be created in another build
dir.
BUILD_DIR := build $(BUILD_DIR): ; mkdir -p $(@) SITE_TAR := $(BUILD_DIR)/site.tar.gz $(SITE_TAR): $(DST_FILES) | $(BUILD_DIR) cd $(DIST_DIR) && tar --create --gzip . > $(call abspath,$(@))
5. Publish
Publishing will be done using the hut
CLI tool.
HUT := hut publish: $(SITE_TAR) $(HUT) pages publish -d mwhipple.srht.site $(<) .PHONY: publish