summaryrefslogtreecommitdiffstats
path: root/doc/init.mk
diff options
context:
space:
mode:
Diffstat (limited to 'doc/init.mk')
-rw-r--r--doc/init.mk100
1 files changed, 100 insertions, 0 deletions
diff --git a/doc/init.mk b/doc/init.mk
new file mode 100644
index 0000000..7dc5efd
--- /dev/null
+++ b/doc/init.mk
@@ -0,0 +1,100 @@
1# Makefile including this should first set nondefault BRANCH_DOCENEACOMMON before including it
2# and should have targets init: s_docbuild and optional initcommon: s_doceneacommon
3# Typically let doc: depend on init and initcommon inside Makefile
4# Manually optionally set GLOBALTMPCLONEROOT to yes or to a parent dir for tmpcommon
5# This init.mk file ver
6# R1.00/2016-04-29
7# R2.00/2017-03-30 changed linux/documentation.git and it's old branch to linux/el_releases-common.git and it's new branch
8
9ifeq ($(VERBOSE),yes)
10VERB :=
11else
12VERB := @
13endif
14
15#Git repositories to be cloned
16REPO_DOCBUILD := build/docbuild.git
17NAME_DOCBUILD := docbuild
18REPO_DOCENEACOMMON := linux/el_releases-common.git
19NAME_DOCENEACOMMON := doceneacommon
20
21# Set nondefault BRANCH_DOCENEACOMMON in Makefile
22BRANCH_DOCENEACOMMON ?= master
23# Separate clones of el_releases-common.git with different branches, needed if cloned globally with risk that different distros can be at same place
24ifneq ($(BRANCH_DOCENEACOMMON),master)
25NAME_DOCENEACOMMON := doceneacommon_$(BRANCH_DOCENEACOMMON)
26endif
27
28GLOBALTMPCLONEROOT = ../../tmpcommon
29ifeq ($(BOOK_GLOBALCLONEROOT),)
30 TMPCLONEROOT := tmpcommon
31else
32 ifeq ($(BOOK_GLOBALCLONEROOT),yes)
33 TMPCLONEROOT := $(GLOBALTMPCLONEROOT)
34 else
35 TMPCLONEROOT := $(BOOK_GLOBALCLONEROOT)/tmpcommon
36 endif
37endif
38DIR_TMPCLONEROOT := $(dir $(TMPCLONEROOT))
39ifeq ($(wildcard $(DIR_TMPCLONEROOT)),)
40$(error Parent of selected clone root does not exist ($(DIR_TMPCLONEROOT)))
41endif
42
43.PHONY: initbuild initcommon usageinit cleaninit
44# Keep usageinit as default target here to avoid init by mistake
45
46usageinit: docusage
47 @echo 'make initbuild Create s_docbuild and if not exists, clone docbuild.git'
48 @echo 'make initcommon Create s_doceneacommon and if not exists, clone el_releases-common.git'
49 @echo ' Default clone in tmpcommon'
50 @echo ' BOOK_GLOBALCLONEROOT=yes Clone in $(GLOBALTMPCLONEROOT)'
51 @echo ' BOOK_GLOBALCLONEROOT=parentdir Clone in parentdir/tmpcommon'
52 @echo ' Default branch for el_releases-common.git is master'
53 @echo ' BRANCH_DOCENEACOMMON=... If another branch, Makefile should set this'
54 @echo 'make pullbuild git pull in s_docbuild'
55 @echo 'make pullcommon git pull in s_doceneacommon'
56 @echo 'make cleaninit Delete all s_* symlinks and local tmpcommon/'
57
58
59# MOVE these to Makefile and set also non-default BRANCH_DOCENEACOMMON in Makefile
60initbuild: s_docbuild
61initcommon: s_doceneacommon
62pullbuild:
63 $(VERB)if [ ! -d s_docbuild ]; then echo "ERROR: No s_docbuild exists?" ; exit 10 ; fi
64 $(VERB)cd s_docbuild ; git pull
65pullcommon:
66 $(VERB)if [ ! -d s_doceneacommon ]; then echo "ERROR: No s_doceneacommon exists?" ; exit 10 ; fi
67 $(VERB)cd s_doceneacommon ; git pull
68
69s_docbuild: $(TMPCLONEROOT)/$(NAME_DOCBUILD)
70 $(VERB)rm s_docbuild 2>/dev/null; ln -s $(TMPCLONEROOT)/$(NAME_DOCBUILD) s_docbuild
71
72s_doceneacommon: $(TMPCLONEROOT)/$(NAME_DOCENEACOMMON)
73 $(VERB)rm s_doceneacommon 2>/dev/null; ln -s $(TMPCLONEROOT)/$(NAME_DOCENEACOMMON) s_doceneacommon
74
75$(TMPCLONEROOT)/$(NAME_DOCBUILD):
76 $(VERB)if [ ! -d "$(TMPCLONEROOT)" ] ; then mkdir -p "$(TMPCLONEROOT)" ; fi
77 $(VERB)if [ -d "$(TMPCLONEROOT)/$(NAME_DOCBUILD)" ] ; then \
78 echo "Already exists $(TMPCLONEROOT)/$(NAME_DOCBUILD)" ; \
79 echo "Doing git pull instead"; cd $(TMPCLONEROOT)/$(NAME_DOCBUILD) ; git pull ; \
80 else \
81 echo "Cloning $(REPO_DOCBUILD) in $(TMPCLONEROOT)" ; \
82 cd "$(TMPCLONEROOT)" ; \
83 git clone -b master git@git.enea.se:$(REPO_DOCBUILD) $(NAME_DOCBUILD) ; \
84 fi
85
86$(TMPCLONEROOT)/$(NAME_DOCENEACOMMON):
87 $(VERB)if [ ! -d "$(TMPCLONEROOT)" ] ; then mkdir -p "$(TMPCLONEROOT)" ; fi
88 $(VERB)if [ -d "$(TMPCLONEROOT)/$(NAME_DOCENEACOMMON)" ] ; then \
89 echo "Already exists $(TMPCLONEROOT)/$(NAME_DOCENEACOMMON)" ; \
90 echo "Doing git pull instead"; cd $(TMPCLONEROOT)/$(NAME_DOCENEACOMMON) ; git pull ; \
91 else \
92 echo "Cloning $(REPO_DOCENEACOMMON) in $(TMPCLONEROOT) as $(NAME_DOCENEACOMMON)" ; \
93 cd "$(TMPCLONEROOT)"; \
94 git clone -b $(BRANCH_DOCENEACOMMON) git@git.enea.se:$(REPO_DOCENEACOMMON) $(NAME_DOCENEACOMMON) ; \
95 fi
96
97cleaninit:
98 @echo "Clean only local tmpcommon/ and all local temporary symlinks s_docbuild s_targets etc."
99 $(VERB)rm -rf tmpcommon 2>/dev/null ; true
100 $(VERB)rm s_* 2>/dev/null ; true