-SRC_DIR := src
+ASSETS_DIR := assets
BUILD_DIR := build
+SRC_DIR := src
BUILD_LIST := $(shell find -L . -path './$(SRC_DIR)/**/*.md' | sed 's:./$(SRC_DIR):$(BUILD_DIR):g' | sed 's:\.md:\.html:g')
-.PHONY: clean help index
+.PHONY: all clean help
help:
@echo "Builds HTML files from MD files. Targets include:"
@echo
+ @echo "all Builds the .buildlist and an index. (Top-level)"
@echo "clean Removes build artifacts."
@echo "help Prints this help message."
- @echo "index Builds an index of all the files in the $(BUILD_DIR) directory. (Top-level)"
- @echo "$(BUILD_DIR) Builds all the files defined in .buildlist."
@echo ".buildlist Defines a list of all files to build. Paths may be relative."
@echo " to this Makefile's directory. Paths should be on their own lines. You"
@echo " may create this file manually or override the BUILD_LIST variable when"
@echo " you invoke the make command. The default BUILD_LIST is created from MD files"
@echo " found anywhere under the $(SRC_DIR) directory."
-index: $(BUILD_DIR)
- scripts/index.sh > build/index.html
+all: build/index.html
-$(BUILD_DIR): .buildlist
+build/index.html: .buildlist
xargs -n 1 make --no-print-directory < .buildlist
+ scripts/index.sh > build/index.html
.buildlist:
@echo $(BUILD_LIST) | tr ' ' '\n' > .buildlist
-$(BUILD_DIR)/%.html: $(SRC_DIR)/%.md
+$(BUILD_DIR)/$(ASSETS_DIR): $(SRC_DIR)/$(ASSETS_DIR)
+ mkdir -p $(BUILD_DIR)/$(ASSETS_DIR)
+ cp -rL $(SRC_DIR)/$(ASSETS_DIR)/* $(BUILD_DIR)/$(ASSETS_DIR)
+
+$(BUILD_DIR)/%.html: $(SRC_DIR)/%.md $(BUILD_DIR)/$(ASSETS_DIR)
@mkdir -p $(dir $@)
@pandoc \
--to=html5 \
--standalone \
+ --toc=true \
--defaults=./defaults.yml \
--output=$@ $< \
--lua-filter=scripts/links-to-html.lua
@echo "Building $@ from $<..."
clean:
- rm .buildlist
+ -rm .buildlist
rm -rf $(BUILD_DIR)
\ No newline at end of file
from: markdown+wikilinks_title_before_pipe
css:
# ${.} is robust on build, but probably not for deployment
- - ${.}/assets/css/normalize.css
- - ${.}/assets/css/space-sakura.css
+ - ../assets/css/normalize.css
+ - ../assets/css/space-sakura.css