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






                    
          
                                                                        
 



                                                  


                    
         
                    
 





                          

                        
 
 
 
           
 

                                                              









                                                               


                     
 

                









                                                                                

 
                                                                                
 

                                              
                                              
                                              
                                              
 











                                                     




                                                                              
                                                        
                                                                                  
                                                                

                
                                                              

                                                        
                                                                

                
                                                



                                                                                  
                                                     
                
 
 

                                                    
 

                                             
 

                                                                                     

 


                                  
                                  





                     

        








                                                       

       
.POSIX:


default: all

include generated.mk


.SUFFIXES:
.SUFFIXES: .md .content .conf .html .categoryentry .indexentry .xmlentry


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

.md.conf:
	conf $< > $@

.md.html:
	html $< > $@

.md.categoryentry:
	category $< > $@

.md.indexentry:
	indexentry $< > $@

.md.xmlentry:
	xmlentry $< > $@



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
	conf > $@

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

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

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

clean:
	rm -rf \
		public/ $(all-generated) *.sentinel generated.mk po/po4a.cfg   \
		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)                    \

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      \

$(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: