Browse Source

:wrench: Make the dist dir customizable

DricomDragon 1 year ago
parent
commit
ecc7395f17
2 changed files with 20 additions and 9 deletions
  1. 3 1
      README.md
  2. 17 8
      makefile

+ 3 - 1
README.md

@@ -18,7 +18,9 @@ Can be used to test the deployement script like updating the version number.
 
 You may need to manually start apache first with `service apache2 start`.
 
-Run `undeployed/scripts/deploy-local-httpd.sh`
+```sh
+DIST_DIR=/var/www/html make -e dist
+```
 
 Check your work [on local apache server](http://localhost).
 

+ 17 - 8
makefile

@@ -1,3 +1,7 @@
+# Environment vars
+DIST_DIR := dist
+
+# Computed vars
 SRC_HTMLS := $(shell find src -name '*.src.html')
 SRC_MDS := $(shell find src -name '*.src.md')
 
@@ -8,14 +12,14 @@ GEN_FILES := $(GEN_HTMLS) $(GEN_MDS)
 INCLUDED_FILES := $(shell find src/include -type f)
 DOWNLOAD_FILES := $(shell find src/download -type f)
 
-DIST_GEN_FILES := $(GEN_FILES:src/%.gen.html=dist/%.html)
-DIST_INC_FILES := $(INCLUDED_FILES:src/%=dist/%)
-DIST_DWN_FILES := $(DOWNLOAD_FILES:src/%=dist/%)
+DIST_GEN_FILES := $(GEN_FILES:src/%.gen.html=$(DIST_DIR)/%.html)
+DIST_INC_FILES := $(INCLUDED_FILES:src/%=$(DIST_DIR)/%)
+DIST_DWN_FILES := $(DOWNLOAD_FILES:src/%=$(DIST_DIR)/%)
 DIST_FILES := $(DIST_GEN_FILES) $(DIST_INC_FILES) $(DIST_DWN_FILES)
 
 PANDOC_GEN := pandoc --standalone --wrap=none --template src/templates/main.html --metadata-file src/meta.yml
 
-.PHONY: build
+.PHONY: build dist
 build: $(GEN_FILES)
 	$(info HTML generated)
 
@@ -25,18 +29,20 @@ build: $(GEN_FILES)
 %.gen.html: %.src.md
 	$(PANDOC_GEN) --output $@ $<
 
-dist: $(DIST_FILES)
+dist: $(DIST_DIR)
 	$(info Distributed folder generated)
 
-dist/include/%: src/include/%
+$(DIST_DIR): $(DIST_FILES)
+
+$(DIST_DIR)/include/%: src/include/%
 	mkdir --parents $(dir $@)
 	cp $< $@
 
-dist/download/%: src/download/%
+$(DIST_DIR)/download/%: src/download/%
 	mkdir --parents $(dir $@)
 	cp $< $@
 
-dist/%.html: src/%.gen.html
+$(DIST_DIR)/%.html: src/%.gen.html
 	mkdir --parents $(dir $@)
 	cp $< $@
 
@@ -44,6 +50,9 @@ dist/%.html: src/%.gen.html
 clean:
 	rm -f $(GEN_FILES)
 
+clean-dist:
+	rm -f $(DIST_FILES)
+
 .PHONY: debug
 debug:
 	$(info SRC_HTMLS $(SRC_HTMLS))