diff --git a/Makefile b/Makefile index 70c5913..8b9c05e 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,13 @@ API_BUILD_DIR = api API_DEVEL_BUILD_DIR = $(API_BUILD_DIR)/$(DEVEL_BUILD_DIR) API_PROD_BUILD_DIR = $(API_BUILD_DIR)/$(PROD_BUILD_DIR) -devel: frontend api devel-copy +TMPL_BUILD_DIR = templates +TMPL_DEVEL_BUILD_DIR = $(TMPL_BUILD_DIR)/$(DEVEL_BUILD_DIR) +TMPL_PROD_BUILD_DIR = $(TMPL_BUILD_DIR)/$(PROD_BUILD_DIR) -prod: frontend api prod-copy +devel: frontend api templates devel-copy + +prod: frontend api templates prod-copy # TODO: This can probably be written better: instead of explicitly defining # each target subdirectory, define them at the top and automatically do stuff. @@ -27,9 +31,13 @@ frontend: api: cd api && $(MAKE) $(MAKECMDGOALS) -devel-copy: devel-copy-frontend devel-copy-api +.PHONY: templates +templates: + cd templates && $(MAKE) $(MAKECDMGOALS) -prod-copy: prod-copy-frontend prod-copy-api +devel-copy: devel-copy-frontend devel-copy-api devel-copy-templates + +prod-copy: prod-copy-frontend prod-copy-api prod-copy-templates devel-copy-frontend: cp -r $(FRONTEND_DEVEL_BUILD_DIR)/* $(DEVEL_BUILD_DIR) @@ -37,12 +45,18 @@ devel-copy-frontend: devel-copy-api: cp -r $(API_DEVEL_BUILD_DIR)/* $(DEVEL_BUILD_DIR) +devel-copy-templates: + cp -r $(TMPL_DEVEL_BUILD_DIR)/* $(DEVEL_BUILD_DIR) + prod-copy-frontend: cp -r $(FRONTEND_PROD_BUILD_DIR)/* $(PROD_BUILD_DIR) prod-copy-api: cp -r $(API_PROD_BUILD_DIR)/* $(PROD_BUILD_DIR) +prod-copy-templates: + cp -r $(TMPL_PROD_BUILD_DIR)/* $(PROD_BUILD_DIR) + clean: clean-root clean-frontend clean-api clean-root: diff --git a/templates/Makefile b/templates/Makefile new file mode 100644 index 0000000..789a949 --- /dev/null +++ b/templates/Makefile @@ -0,0 +1,31 @@ +SHELL = bash + +BUILD_DIR = build +DEVEL_BUILD_DIR = $(BUILD_DIR)/devel +PROD_BUILD_DIR = $(BUILD_DIR)/prod + +TMPL_SRC_DIR = . +TMPL_SRC_FILES = $(wildcard $(TMPL_SRC_DIR)/*.tmpl) +TMPL_DEVEL_BUILD_DIR = $(DEVEL_BUILD_DIR) +TMPL_DEVEL_BUILD_FILES = $(patsubst $(TMPL_SRC_DIR)/%, $(TMPL_DEVEL_BUILD_DIR)/%, $(TMPL_SRC_FILES)) +TMPL_PROD_BUILD_DIR = $(PROD_BUILD_DIR) +TMPL_PROD_BUILD_FILES = $(patsubst $(TMPL_SRC_DIR)/%, $(TMPL_PROD_BUILD_DIR)/%, $(TMPL_SRC_FILES)) + +devel: devel-templates + +prod: prod-templates + +clean: + rm -rf $(BUILD_DIR) + +devel-templates: $(TMPL_DEVEL_BUILD_FILES) + +$(TMPL_DEVEL_BUILD_FILES): $(TMPL_DEVEL_BUILD_DIR)/%.tmpl: $(TMPL_SRC_DIR)/%.tmpl + cp $^ $@; + +prod-templates: $(TMPL_PROD_BUILD_FILES) + +$(TMPL_PROD_BUILD_FILES): $(TMPL_PROD_BUILD_DIR)/%.tmpl: $(TMPL_SRC_DIR)/%.tmpl + cp $^ $@; + +$(shell mkdir -p $(TMPL_DEVEL_BUILD_DIR) $(TMPL_PROD_BUILD_DIR))