braincoded.software

braincoded.software website static files
git clone git://bsandro.tech/braincoded.software
Log | Files | Refs

Makefile (2923B)


      1 # Content
      2 
      3 AUTHOR_NAME = "bsandro"
      4 AUTHOR_EMAIL = "email@bsandro.tech"
      5 SITE_TITLE = "braincoded.software"
      6 SITE_TAGLINE = "For those who still likes coding"
      7 LOCALE = "en_US.utf-8"
      8 
      9 POSTS_PER_PAGE = 32
     10 
     11 BLOGC ?= $(shell which blogc)
     12 MKDIR ?= $(shell which mkdir)
     13 CP ?= $(shell which cp)
     14 LS ?= $(shell which ls)
     15 AWK ?= $(shell which awk)
     16 CUT ?= $(shell which cut)
     17 SORT ?= $(shell which sort)
     18 GREP ?= $(shell which grep)
     19 POSTS_LIST = $(shell $(GREP) 'DATE:.*$$' content/posts/*.txt | $(CUT) -d: -f1,3 | $(AWK) '{print $$2 " " $$1}' | $(SORT) -r | $(CUT) -d: -f1 | $(CUT) -d' ' -f2)
     20 PAGES_LIST = $(wildcard content/*.txt)
     21 POSTS = $(patsubst content/posts/%.txt,%,$(POSTS_LIST))
     22 PAGES = $(patsubst content/%.txt,%,$(PAGES_LIST))
     23 ASSETS = $(wildcard assets/*)
     24 
     25 # Arguments
     26 
     27 OUTPUT_DIR ?= public
     28 BASE_DOMAIN ?= https://braincoded.software
     29 BASE_URL ?=
     30 
     31 DATE_FORMAT = "%b %d, %Y"
     32 
     33 BLOGC_COMMAND = \
     34 	LC_ALL=$(LOCALE) \
     35 	$(BLOGC) \
     36 		-D AUTHOR_NAME=$(AUTHOR_NAME) \
     37 		-D AUTHOR_EMAIL=$(AUTHOR_EMAIL) \
     38 		-D SITE_TITLE=$(SITE_TITLE) \
     39 		-D SITE_TAGLINE=$(SITE_TAGLINE) \
     40 		-D BASE_DOMAIN=$(BASE_DOMAIN) \
     41 		-D BASE_URL=$(BASE_URL) \
     42 	$(NULL)
     43 
     44 
     45 # Rules
     46 
     47 LAST_PAGE = $(shell $(BLOGC_COMMAND) \
     48 	-D FILTER_PAGE=1 \
     49 	-D FILTER_PER_PAGE=$(POSTS_PER_PAGE) \
     50 	-p LAST_PAGE \
     51 	-l \
     52 	$(POSTS_LIST))
     53 
     54 ALL_LIST = \
     55 	$(POSTS_LIST) \
     56 	$(PAGES_LIST) \
     57 	$(ASSETS) \
     58 	templates/main.tmpl \
     59 	Makefile \
     60 	$(NULL)
     61 
     62 all: \
     63 	$(OUTPUT_DIR)/index.html \
     64 	$(addprefix $(OUTPUT_DIR)/, $(ASSETS)) \
     65 	$(addprefix $(OUTPUT_DIR)/posts/, $(addsuffix /index.html, $(POSTS))) \
     66 	$(addprefix $(OUTPUT_DIR)/, $(addsuffix /index.html, $(PAGES))) \
     67 	$(addprefix $(OUTPUT_DIR)/page/, $(addsuffix /index.html, \
     68 		$(shell for i in $(shell seq 1 $(LAST_PAGE)); do echo $$i; done)))
     69 
     70 $(OUTPUT_DIR)/index.html: $(POSTS_LIST) templates/main.tmpl Makefile
     71 	$(BLOGC_COMMAND) \
     72 		-D DATE_FORMAT=$(DATE_FORMAT) \
     73 		-D FILTER_PAGE=1 \
     74 		-D FILTER_PER_PAGE=$(POSTS_PER_PAGE) \
     75 		-D MENU=blog \
     76 		-l \
     77 		-o $@ \
     78 		-t templates/main.tmpl \
     79 		$(POSTS_LIST)
     80 
     81 $(OUTPUT_DIR)/page/%/index.html: $(POSTS_LIST) templates/main.tmpl Makefile
     82 	$(BLOGC_COMMAND) \
     83 		-D DATE_FORMAT=$(DATE_FORMAT) \
     84 		-D FILTER_PAGE=$(shell echo $@ | sed -e 's,^$(OUTPUT_DIR)/page/,,' -e 's,/index\.html$$,,')\
     85 		-D FILTER_PER_PAGE=$(POSTS_PER_PAGE) \
     86 		-D MENU=blog \
     87 		-l \
     88 		-o $@ \
     89 		-t templates/main.tmpl \
     90 		$(POSTS_LIST)
     91 
     92 IS_POST = 0
     93 
     94 $(OUTPUT_DIR)/about/index.html: MENU = about
     95 
     96 $(OUTPUT_DIR)/humans/index.html: MENU = humans
     97 
     98 $(OUTPUT_DIR)/posts/%/index.html: MENU = blog
     99 $(OUTPUT_DIR)/posts/%/index.html: IS_POST = 1
    100 
    101 $(OUTPUT_DIR)/%/index.html: content/%.txt templates/main.tmpl Makefile
    102 	$(BLOGC_COMMAND) \
    103 		-D DATE_FORMAT=$(DATE_FORMAT) \
    104 		-D MENU=$(MENU) \
    105 		$(shell test "$(IS_POST)" -eq 1 && echo -D IS_POST=1) \
    106 		-o $@ \
    107 		-t templates/main.tmpl \
    108 		$<
    109 
    110 $(OUTPUT_DIR)/assets/%: assets/% Makefile
    111 	$(MKDIR) -p $(dir $@) && \
    112 		$(CP) -r $< $@
    113 
    114 clean:
    115 	rm -rf "$(OUTPUT_DIR)"
    116 
    117 .PHONY: all clean