site.mk

This file has been replaced by generate.mk.

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.

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 $(@)

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 20250123.html 20250124.html 20250125.html 20250127.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

Produce tarball

The dist directory can be packaged up into a tarball, to avoid potential cycles the tarball will be created in another build directory.

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,$(@))

Publish

Publishing will be done using the hut CLI tool.

HUT := hut
publish: $(SITE_TAR)
    $(HUT) pages publish -d www.mattwhipple.com $(<)
.PHONY: publish