stxge/demo/Makefile

70 lines
1.7 KiB
Makefile

SHELL := /bin/sh
# tools
STE := ../bin/ste
STG := ../bin/stg
STS := ../bin/sts
STX := ../bin/stx
GUILE_FLAGS := "-L ../mod"
TITLE := "My cool site!"
# directories
SITE_DIR := site
TMPL_DIR := tmpl
EVAL_DIR := eval
GMI_DIR := dist/gmi
WWW_DIR := dist/www
ASST_DIR := asst
# style file
STYLE_SRC := $(ASST_DIR)/style.css
STYLE_DST := $(WWW_DIR)/style.css
# gather sources
TEMPLATE_FILES := $(shell find $(TMPL_DIR) -type f -name '*.scm')
SITE_FILES := $(shell find $(SITE_DIR) -type f -name '*.scm')
# map sources to targets
EVAL_FILES := $(patsubst $(SITE_DIR)/%.scm,$(EVAL_DIR)/%.sxp,$(SITE_FILES))
GMI_FILES := $(patsubst $(SITE_DIR)/%.scm,$(GMI_DIR)/%.gmi,$(SITE_FILES))
WWW_FILES := $(patsubst $(SITE_DIR)/%.scm,$(WWW_DIR)/%.xhtml,$(SITE_FILES))
# build both, just gmi, or just web
all: gmi web
gmi: $(GMI_FILES)
web: $(WWW_FILES)
# copy stylesheet
$(STYLE_DST): $(STYLE_SRC)
@mkdir -p $(dir $@)
cp $< $@
# build .sxp from .scm + templates
$(EVAL_DIR)/%.sxp: $(SITE_DIR)/%.scm $(TEMPLATE_FILES)
@mkdir -p $(dir $@)
GUILE_FLAGS=$(GUILE_FLAGS) $(STE) -I $(TMPL_DIR) $< > $@
# build .gmi from .sxp + templates
$(GMI_DIR)/%.gmi: $(EVAL_DIR)/%.sxp $(TEMPLATE_FILES)
@mkdir -p $(dir $@)
GUILE_FLAGS=$(GUILE_FLAGS) $(STG) $< > $@
# build .xhtml from .sxp + templates + style
$(WWW_DIR)/%.xhtml: $(EVAL_DIR)/%.sxp $(TEMPLATE_FILES) $(STYLE_DST)
@mkdir -p $(dir $@)
STYLE_REL=$$(realpath --relative-to=$(dir $@) $(STYLE_DST)); \
GUILE_FLAGS=$(GUILE_FLAGS) $(STS) --title $(TITLE) --style $$STYLE_REL $< | $(STX) > $@
# keep intermediates
.SECONDARY: $(EVAL_FILES)
# clean
clean:
rm -rf $(GMI_DIR) $(WWW_DIR)
distclean: clean
rm -rf $(EVAL_DIR)
.PHONY: all clean distclean