Files

97 lines
3.2 KiB
Makefile
Raw Permalink Normal View History

SHELL := bash
2025-08-08 11:28:20 +02:00
# we need an override so that this variable is cleanly set in this makefile
# else it might come from somewhere else
override HUGO := $(CURDIR)/hugo
override HDIR := $(HUGO)/.git
2025-08-08 11:28:20 +02:00
# if the directory exists, print that we do not need to prepare
hugo-exists:
@if [ -d $(HDIR) ]; then \
echo; \
echo 'Build environment for hugo exists, nothing to setup, continuing.'; \
fi
2021-02-24 15:07:39 +01:00
2025-08-08 11:28:20 +02:00
# if the directory does not extist, initialize the framework and create the theme
$(HDIR):
@echo 'Initialize the hugo framework and build the theme, no docs get built.'
@mkdir -p $(HUGO)/content/
@mkdir -p $(HUGO)/extensions/
@mkdir -p $(HUGO)/public/
@cd $(HUGO) && git init
@cd $(HUGO) && git config advice.detachedHead false
@cd $(HUGO) && git remote rm origin || true
@cd $(HUGO) && git remote add origin https://github.com/owncloud/owncloud.github.io
@cd $(HUGO) && git fetch --depth=1
@cd $(HUGO) && git checkout origin/main -f
@$(MAKE) -C $(HUGO) --no-print-directory theme
# print available make targets
.PHONY: help
2025-08-08 11:28:20 +02:00
.DEFAULT_GOAL := help
help:
2025-08-08 11:28:20 +02:00
@echo -e 'Available .PHONY targets: \n'
@grep -P -o '(?<=^\.PHONY: )(.*)' Makefile | sort -u
@echo
# alternative target because we also use it in the root's makefile
.PHONY:list
list: help
2026-05-13 12:14:45 +02:00
# Creates a symlink ../hugo → hugo/ required by the Hugo Docker image
# (hugomods/hugo:base-0.129.0), which expects the hugo folder at the repo root.
2025-08-08 11:28:20 +02:00
# CURDIR will work for make only but not when running manually in the shell
.PHONY: docs-hugo-drone-prep
docs-hugo-drone-prep:
@echo
@echo 'Linking directory hugo for drone.'
@rm -f ../hugo
@ln -s $(HUGO) ../hugo
# generate data from sources such as services
.PHONY: docs-run-helpers
docs-run-helpers:
@echo
@echo 'Generate envvar adoc and md tables for all oCIS services used for dev and admin docs'
@pushd helpers && go run .; popd
2021-02-23 12:38:18 +01:00
2025-08-08 11:28:20 +02:00
# create the docs build environment
2021-02-25 14:37:34 +01:00
.PHONY: docs-init
2025-08-08 11:28:20 +02:00
docs-init: hugo-exists $(HDIR)
# if there is nothing to do, stop printing that
# another way would be https://stackoverflow.com/questions/58039810/makefiles-what-is-an-order-only-prerequisite
@:
2020-11-24 08:46:04 +01:00
2025-08-08 11:28:20 +02:00
# the docs-build|serve commands require that docs-init was run first for the required data to exists
# create a docs build
.PHONY: docs-build
docs-build:
@echo
@echo 'Building ocis for owncloud.dev'
@$(MAKE) -C $(HUGO) --no-print-directory hugo-build
@echo 'To view the rendered docs in the browser, run: make docs-serve'
2021-02-26 12:02:27 +01:00
2025-08-08 11:28:20 +02:00
# serve built docs with hugo
.PHONY: docs-serve
docs-serve:
@$(MAKE) -C $(HUGO) --no-print-directory hugo-server
2021-02-25 14:37:34 +01:00
2025-08-08 11:28:20 +02:00
# copy required resources into hugo
2021-02-25 14:37:34 +01:00
.PHONY: docs-copy
2025-08-08 11:28:20 +02:00
docs-copy:
@echo
@echo 'Syncing required doc files and directories for the build process.'
# brace expansion not with sh
@rsync --delete -ax --exclude={hugo,templates,Makefile,.gitignore,README.md} ./ $(HUGO)/content/
# clean up docs build artifacts (removing the hugo folder)
.PHONY: docs-clean
docs-clean:
# NOTE: the whitespace at the beginning of the ifeq/else/endif statements is intentional.
@echo
ifneq ($(shell id -u), 0)
@echo "You must run the clean command using sudo or as root because some doc files are created by root"
else
@echo 'Clean up docs build artifacts'
@rm -rf $(HUGO)
@echo "Removed folder: $(HUGO)"
endif