aboutsummaryrefslogblamecommitdiff
path: root/v2/dynamic.mk
blob: 238e6e960c33b2d7e7e54be8267b4156ead4f6e1 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
       

                       








                    
                                       


             

                                             


                                          





                                                  


                                             
 


                            
 



                                         


                                         
                                         
 
 
                                                              
                           
 
           
 
                                        
 


                                                                 

 
                                                                                   
 


                       
 

                                                                       
 

                                                                 
 





















                                                                                              
                                                     
                
 

                                             
 

                                                                                                

 


                                  
                                  
 
                                           




                     

        








                                                       

       
.POSIX:
DOMAIN = euandre.org
EMAIL  = eu@euandre.org


default: all

include generated.mk



.SUFFIXES:
.SUFFIXES: .in .md .conf .content .html

.in:
	sed \
		-e 's|@DOMAIN@|$(DOMAIN)|g' \
		-e 's|@EMAIL@|$(EMAIL)|g' \
		< $< > $@
	if [ -x $< ]; then chmod +x $@; fi

.md.conf:
	sh src/development/getconf.sh $< > $@

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

.md.html:
	sh src/development/genhtml.sh $< > $@


favicons = \
	public/favicon.png \
	public/favicon.ico \

sed.in-files = \
	src/lib/base-conf               \
	src/development/security-txt.sh \

derived-assets = \
	$(all-generated)                \
	$(favicons)                     \
	$(sed.in-files)                 \


$(all-generated.conf) $(all-generated.content): $(non-content)
$(sed.in-files): dynamic.mk

all: public

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

clean:
	rm -rf \
		public/ $(derived-assets) *.sentinel generated.mk


public: $(favicons) public-copy-content.sentinel public-copy-code-snippets.sentinel

public-mkdir.sentinel:
	mkdir -p public
	touch $@

public/favicon.png: public-mkdir.sentinel src/content/favicon.svg
	inkscape -o $@ -w 2048 -h 2048 -b white src/content/favicon.svg

public/favicon.ico: public-mkdir.sentinel src/content/favicon.svg
	convert src/content/favicon.svg $@

content = \
	$(all-generated.html)                \
	$(static-content)                    \
	src/content/public.asc.txt           \
	src/content/.well-known/security.txt \

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

public-copy-code-snippets.sentinel: $(all-generated.snippets) public-content-mkdir.sentinel
	echo $? | tr ' ' '\n' | grep '^src/content/' | sed 's|^src/content/||' | \
		awk '{ printf "cp `cat src/content/%s` public/`dirname %s`\n", $$0, $$0 }' | \
		sh
	touch $@

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

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

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



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

aux/checks/shellcheck.sh: src/lib/base-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: