aboutsummaryrefslogblamecommitdiff
path: root/v2/dynamic.mk
blob: 77c7e77658bddf9341a73e8591725d390f80f720 (plain) (tree)
1
2
3
4
5
6
7
8
9
       






                    
          
                                                                                                   
                           
 
 
         
                             
                   
                        
 


                                                  


                    
         
                    
 





                          

                        
 


                        






                                                       




                    
 
 
           
 

                                                              
                                                       

                                                               
                                            






                                              


                     
 


                        



                                     

                
                                                                                


                                                                                





                                                                                
                                                                                

                                                                                

                                                                                

 
                                                                                
 

                                              
                                              
                                              
                                              
                                              
                                              
                                              
 





                                              


                                                  





                                                     




                                                                              
                                                        
                                                                                  
                                                                

                
                                                              

                                                        
                                                                

                
                                                



                                                                                  
                                                     
                
 
 

                                                    
 

                                             
 

                                                                                     

 


                                  
                                  
 

                                                




                     

        








                                                       

       
.POSIX:


default: all

include generated.mk


.SUFFIXES:
.SUFFIXES: .page .md .content .conf .html .categoryentry .indexentry .xmlentry .mapentry .uncolored
.SUFFIXES: .slides .ps .pdf


.page.md:
	ln -f $<.i18n $@.i18n
	ln -f $< $@
	touch $@ $@.i18n

.md.content:
	awk 'sep >= 2; /^---$$/ {sep++}' < $< > $@

.md.conf:
	conf $< > $@

.md.html:
	html $< > $@

.md.categoryentry:
	category $< > $@

.md.indexentry:
	indexentry $< > $@

.md.xmlentry:
	xmlentry $< > $@

.md.mapentry:
	mapentry $< > $@

.uncolored:
	printf '%s\n%s\n%s\n' \
		"`head -n2 $<`" \
		"`cat src/content/img/dark-mode.xml`" \
		"`tail -n +3 $<`" \
		> $@

.slides.ps:
	exit 88

.ps.pdf:
	ps2pdf $< $@


all: public


$(all-generated.conf) $(all-generated.content): $(non-content)
$(all-generated.conf) $(pages-mds): i18n-index.sentinel
$(all-generated.conf): src/lib/base.conf src/lib/generated.conf

src/lib/generated.conf: src/bin/conf $(svgs)
	conf > $@

$(all-generated.categories):
	categories $@

$(all-generated.index): src/lib/generated.conf
	index $@

$(all-generated.xml):
	feed $@

$(all-generated.series):
	series $@

i18n-index.sentinel: po/i18n.mappings
	i18n < po/i18n.mappings
	touch $@

clean:
	rm -rf \
		$(all-generated) $(pages-mds) $(svgs) public/ *.sentinel       \
		generated.mk po/po4a.cfg po/*.mo                               \
		src/lib/generated.conf        src/lib/generated.*.conf         \
		src/content/.gitignore        src/content/sitemap.xml          \
		src/content/*/*.category      src/content/*/*/*.category       \
		src/content/*/*.categorysort  src/content/*/*/*.categorysort   \
		src/content/*/*.html          src/content/*/*/*.html           \
		src/content/*/*.extrahtml     src/content/*/*/*.extrahtml      \
		src/content/*/*.extrafeeds    src/content/*/*/*.extrafeeds     \
		src/content/*/*.html.*.txt    src/content/*/*/*.html.*.txt     \
		src/content/*/*.i18n          src/content/*/*/*.i18n           \
		src/content/*/*.sortdata      src/content/*/*/*.sortdata       \
		src/content/*/feed.*.xml      src/content/*/*/feed.*.xml       \
		src/content/*/*.md.next       src/content/*/*/*.md.next        \
		src/content/*/*.md.prev       src/content/*/*/*.md.prev        \


public: symlink-mappings.sentinel copy-content.sentinel copy-containers.sentinel

content = \
	$(all-generated.html)                \
	$(all-generated.index)               \
	$(all-generated.xml)                 \
	$(all-generated.pdf)                 \
	$(static-content)                    \
	$(svgs)                              \
	src/content/sitemap.xml              \

containers = \
	$(all-generated.snippets)            \
	$(all-generated.extrahtml)           \
	$(all-generated.extrafeeds)          \


src/content/sitemap.xml: $(all-generated.mapentry)
	sitemap > $@

symlink-mappings.sentinel: src/redirect.mappings
	awk '{print $$2}' src/redirect.mappings | \
		xargs dirname | \
		sort |          \
		uniq |          \
		xargs -P`nproc` -I% mkdir -p public/%
	< src/redirect.mappings \
		awk '{ printf "ln -rfs public/%s public/%s\n", $$2, $$1 }' | \
		sh
	touch $@

copy-content.sentinel: $(content) content-mkdir.sentinel
	echo $? | tr ' ' '\n' | grep '^src/content/' | sed 's|^src/content/||' | \
		xargs -P`nproc` -I% ln -f src/content/% public/%
	touch $@

copy-containers.sentinel: $(containers) content-mkdir.sentinel
	echo $? | tr ' ' '\n' | grep '^src/content/' | \
		xargs sed 's|^src/content/||' | \
		xargs -P`nproc` -I% ln -f src/content/% public/%
	touch $@

content-mkdir.sentinel: $(content) $(containers)
	echo $? | tr ' ' '\n' | grep '^src/content/' | sed 's|^src/content/||' | \
		xargs dirname | \
		sort |          \
		uniq |          \
		xargs -P`nproc` -I% mkdir -p public/%
	touch $@


src/content/favicon.ico: src/content/img/favicon.svg
	convert src/content/img/favicon.svg $@

src/content/public.asc.txt:
	gpg --armour --export '$(EMAIL)' > $@

src/content/.well-known/security.txt: src/content/public.asc.txt src/bin/security-txt
	security-txt > $@



test-files = \
	aux/checks/shellcheck.sh \
	aux/checks/todos.sh      \

aux/checks/shellcheck.sh: src/lib/generated.conf

$(test-files): ALWAYS
	sh $@

check: $(test-files)
dev: all check

run: all
	serve -d public/

upload: public
	rsync \
		--rsync-path='sudo -u deployer rsync' \
		-avzP \
		--delete \
		--exclude 's/*' \
		public/ $(DOMAIN):/srv/www/

ALWAYS: