Improve makefile
This commit is contained in:
parent
e4c3a308e5
commit
983b3c8def
1 changed files with 22 additions and 15 deletions
37
Makefile
37
Makefile
|
@ -11,34 +11,42 @@ CACHE_DIR ?= .cache
|
||||||
|
|
||||||
# we don't want to publish files in drafts
|
# we don't want to publish files in drafts
|
||||||
NO_DRAFT := -not -path '$(SRC_DIR)/drafts/*'
|
NO_DRAFT := -not -path '$(SRC_DIR)/drafts/*'
|
||||||
# we don't copy source files, nor images, they are transformed
|
# we don't copy source files
|
||||||
NO_SRC_FILE := ! -name '*.org' ! -name '*.jpg' ! -name '*.png' ! -name '*.jpeg' ! -name '*.gif'
|
NO_SRC_FILE := ! -name '*.org'
|
||||||
|
|
||||||
|
|
||||||
# ASSETS
|
# ASSETS
|
||||||
SRC_RAW_FILES := $(shell find $(SRC_DIR) -type f $(NO_DRAFT) $(NO_SRC_FILE))
|
SRC_RAW_FILES := $(shell find $(SRC_DIR) -type f $(NO_DRAFT) $(NO_SRC_FILE))
|
||||||
DST_RAW_FILES := $(patsubst $(SRC_DIR)/%,$(DST_DIR)/%,$(SRC_RAW_FILES))
|
DST_RAW_FILES := $(patsubst $(SRC_DIR)/%,$(DST_DIR)/%,$(SRC_RAW_FILES))
|
||||||
|
ALL += $(DST_RAW_FILES)
|
||||||
$(DST_DIR)/% : $(SRC_DIR)/%
|
$(DST_DIR)/% : $(SRC_DIR)/%
|
||||||
@mkdir -p "$(dir $@)"
|
@mkdir -p "$(dir $@)"
|
||||||
cp "$<" "$@"
|
cp "$<" "$@"
|
||||||
ALL += $(DST_RAW_FILES)
|
assets: $(DST_RAW_FILES)
|
||||||
|
|
||||||
|
# CSS
|
||||||
|
SRC_CSS_FILES := $(shell find $(SRC_DIR) -type f -name '*.css')
|
||||||
|
DST_CSS_FILES := $(patsubst $(SRC_DIR)/%,$(DST_DIR)/%,$(SRC_RAW_FILES))
|
||||||
|
ALL += $(DST_CSS_FILES)
|
||||||
|
$(DST_DIR)/%.css : $(SRC_DIR)/%.css
|
||||||
|
@mkdir -p "$(dir $@)"
|
||||||
|
minify "$<" > "$@"
|
||||||
|
css: $(DST_CSS_FILES)
|
||||||
|
|
||||||
# ORG -> HTML
|
# ORG -> HTML
|
||||||
EXT := .org
|
EXT ?= .org
|
||||||
SRC_PANDOC_FILES ?= $(shell find $(SRC_DIR) -type f -name "*$(EXT)" $(NO_DRAFT))
|
SRC_PANDOC_FILES ?= $(shell find $(SRC_DIR) -type f -name "*$(EXT)" $(NO_DRAFT))
|
||||||
DST_PANDOC_FILES ?= $(subst $(EXT),.html, \
|
DST_PANDOC_FILES ?= $(subst $(EXT),.html, \
|
||||||
$(patsubst $(SRC_DIR)/%,$(DST_DIR)/%, \
|
$(patsubst $(SRC_DIR)/%,$(DST_DIR)/%, \
|
||||||
$(SRC_PANDOC_FILES)))
|
$(SRC_PANDOC_FILES)))
|
||||||
TEMPLATE ?= templates/post.html
|
PANDOC_TEMPLATE ?= templates/post.html
|
||||||
CSS = /css/y.css
|
PANDOC_CSS ?= /css/y.css
|
||||||
MK_HTML := engine/mk-html.sh
|
MK_HTML := engine/mk-html.sh
|
||||||
PANDOC := $(MK_HTML) $(CSS) $(TEMPLATE)
|
PANDOC := $(MK_HTML) $(PANDOC_CSS) $(PANDOC_TEMPLATE)
|
||||||
$(DST_DIR)/%.html: $(SRC_DIR)/%.org $(TEMPLATE) $(MK_HTML)
|
$(DST_DIR)/%.html: $(SRC_DIR)/%.org $(PANDOC_TEMPLATE) $(MK_HTML)
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p "$(dir $@)"
|
||||||
$(PANDOC) $< $@.tmp
|
$(PANDOC) "$<" "$@.tmp"
|
||||||
minify --mime text/html $@.tmp > $@
|
minify --mime text/html "$@.tmp" > "$@"
|
||||||
@rm $@.tmp
|
@rm "$@.tmp"
|
||||||
ALL += $(DST_PANDOC_FILES)
|
ALL += $(DST_PANDOC_FILES)
|
||||||
html: $(DST_PANDOC_FILES)
|
html: $(DST_PANDOC_FILES)
|
||||||
|
|
||||||
|
@ -54,6 +62,7 @@ ALL += $(DST_XML_FILES)
|
||||||
$(RSS_CACHE_DIR)/%.xml: $(DST_POSTS_DIR)/%.html
|
$(RSS_CACHE_DIR)/%.xml: $(DST_POSTS_DIR)/%.html
|
||||||
@mkdir -p "$(dir $@)"
|
@mkdir -p "$(dir $@)"
|
||||||
hxclean "$<" > "$@"
|
hxclean "$<" > "$@"
|
||||||
|
indexcache: $(DST_XML_FILES)
|
||||||
|
|
||||||
# HTML INDEX
|
# HTML INDEX
|
||||||
HTML_INDEX := $(DST_DIR)/index.html
|
HTML_INDEX := $(DST_DIR)/index.html
|
||||||
|
@ -62,7 +71,6 @@ $(HTML_INDEX): $(DST_XML_FILES) $(MKINDEX) $(TEMPLATE)
|
||||||
@mkdir -p $(DST_DIR)
|
@mkdir -p $(DST_DIR)
|
||||||
$(MKINDEX)
|
$(MKINDEX)
|
||||||
ALL += $(HTML_INDEX)
|
ALL += $(HTML_INDEX)
|
||||||
|
|
||||||
index: $(HTML_INDEX)
|
index: $(HTML_INDEX)
|
||||||
|
|
||||||
# RSS
|
# RSS
|
||||||
|
@ -79,7 +87,6 @@ MKRSS := engine/mkrss.sh
|
||||||
$(RSS): $(DST_RSS_FILES) $(MKRSS)
|
$(RSS): $(DST_RSS_FILES) $(MKRSS)
|
||||||
$(MKRSS)
|
$(MKRSS)
|
||||||
ALL += $(RSS)
|
ALL += $(RSS)
|
||||||
|
|
||||||
rss: $(DST_RSS_FILES) $(RSS)
|
rss: $(DST_RSS_FILES) $(RSS)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue