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