aboutsummaryrefslogblamecommitdiff
path: root/v2/dynamic.mk
blob: e4f349d1f90b7a1ffa920a0278d82d46215757be (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 .uncolored


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

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

.md.conf:
	conf $< > $@

.md.html:
	html $< > $@

.md.categoryentry:
	category $< > $@

.md.indexentry:
	indexentry $< > $@

.md.xmlentry:
	xmlentry $< > $@

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



all: public


$(all-generated.conf) $(all-generated.content): $(non-content)
$(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 $@

clean:
	rm -rf \
		$(all-generated) $(pages-mds) $(svgs) public/ *.sentinel       \
		generated.mk po/po4a.cfg      src/content/.gitignore           \
		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/*/*.sortdata      src/content/*/*/*.sortdata       \
		src/content/*/feed.*.xml      src/content/*/*/feed.*.xml       \
		src/lib/generated.conf src/lib/generated.*.conf po/*.mo        \


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

content = \
	$(all-generated.html)                \
	$(all-generated.index)               \
	$(all-generated.xml)                 \
	$(static-content)                    \
	$(svgs)                              \

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


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: