-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
198 lines (161 loc) · 7.22 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# Makefile for suse-xsl-stylesheets
#
# Copyright (C) 2011-2022 SUSE Linux GmbH
#
# Author:
# Frank Sundermeyer <fsundermeyer at opensuse dot org>
#
ifndef PREFIX
PREFIX := /usr/share
endif
SHELL := /bin/bash
PACKAGE := suse-xsl-stylesheets
VERSION := 2.94.8
CDIR := $(shell pwd)
SUSE_XML_PATH := $(PREFIX)/xml/suse
DB_XML_PATH := $(PREFIX)/xml/docbook
SUSE_STYLES_PATH := $(DB_XML_PATH)/stylesheet
XSL_INST_PATH := /usr/share/xml/docbook/stylesheet/
#--------------------------------------------------------------
# stylesheet directory names
DIR2005 := suse
DIR2013_DAPS := daps2013
DIR2013_OPENSUSE := opensuse2013
DIR2013_SUSE := suse2013
# SUSE2021 and beyond are only available in a namespaced version
DIR2021_SUSE := suse2021-ns
DIR2022_SUSE := suse2022-ns
DIRSBP := sbp
DIRTRD := trd
#--------------------------------------------------------------
# Directories and files that will be created
BUILD_DIR := $(CDIR)/build
DEV_CATALOG_DIR := $(BUILD_DIR)/catalog.d
DEV_STYLE_DIR := $(BUILD_DIR)/stylesheet
# Catalog stuff
SUSEXSL_CATALOG := catalog.d/$(PACKAGE).xml
DEV_SUSEXSL_CATALOG := $(DEV_CATALOG_DIR)/$(PACKAGE).xml
#-------
# Local Stylesheets Directories
DEV_DIR2005 := $(DEV_STYLE_DIR)/$(DIR2005)-ns
DEV_DIR2013_DAPS := $(DEV_STYLE_DIR)/$(DIR2013_DAPS)-ns
DEV_DIR2013_OPENSUSE := $(DEV_STYLE_DIR)/$(DIR2013_OPENSUSE)-ns
DEV_DIR2013_SUSE := $(DEV_STYLE_DIR)/$(DIR2013_SUSE)-ns
DEV_DIRECTORIES := $(DEV_CATALOG_DIR) \
$(DEV_DIR2005) \
$(DEV_DIR2013_DAPS) $(DEV_DIR2013_OPENSUSE) $(DEV_DIR2013_SUSE)
LOCAL_STYLEDIRS := $(DIR2005) $(DEV_DIR2005) \
$(DIR2013_DAPS) $(DEV_DIR2013_DAPS) \
$(DIR2013_OPENSUSE) $(DEV_DIR2013_OPENSUSE) \
$(DIR2013_SUSE) $(DEV_DIR2013_SUSE) \
$(DIR2021_SUSE) $(DIR2022_SUSE)
#-------------------------------------------------------
# Directories for installation
INST_STYLE_ROOT := $(DESTDIR)$(SUSE_STYLES_PATH)
STYLEDIR2005 := $(INST_STYLE_ROOT)/$(DIR2005)
STYLEDIR2005-NS := $(INST_STYLE_ROOT)/$(DIR2005)-ns
DAPSSTYLEDIR2013 := $(INST_STYLE_ROOT)/$(DIR2013_DAPS)
DAPSSTYLEDIR2013-NS := $(INST_STYLE_ROOT)/$(DIR2013_DAPS)-ns
OPENSUSESTYLEDIR2013 := $(INST_STYLE_ROOT)/$(DIR2013_OPENSUSE)
OPENSUSESTYLEDIR2013-NS := $(INST_STYLE_ROOT)/$(DIR2013_OPENSUSE)-ns
SUSESTYLEDIR2013 := $(INST_STYLE_ROOT)/$(DIR2013_SUSE)
SUSESTYLEDIR2013-NS := $(INST_STYLE_ROOT)/$(DIR2013_SUSE)-ns
SUSESTYLEDIR2021-NS := $(INST_STYLE_ROOT)/$(DIR2021_SUSE)
SUSESTYLEDIR2022-NS := $(INST_STYLE_ROOT)/$(DIR2022_SUSE)
SBPDIR := $(INST_STYLE_ROOT)/$(DIRSBP)
TRDDIR := $(INST_STYLE_ROOT)/$(DIRTRD)
DOCDIR := $(DESTDIR)$(PREFIX)/doc/packages/suse-xsl-stylesheets
TTF_FONT_DIR := $(DESTDIR)$(PREFIX)/fonts/truetype
CATALOG_DIR := $(DESTDIR)/etc/xml/catalog.d
INST_STYLEDIRS := $(STYLEDIR2005) $(STYLEDIR2005-NS) \
$(DAPSSTYLEDIR2013) $(DAPSSTYLEDIR2013-NS) \
$(OPENSUSESTYLEDIR2013) $(OPENSUSESTYLEDIR2013-NS) \
$(SUSESTYLEDIR2013) $(SUSESTYLEDIR2013-NS) \
$(SUSESTYLEDIR2021-NS) $(SUSESTYLEDIR2022-NS) $(SBPDIR) $(TRDDIR)
INST_DIRECTORIES := $(INST_STYLEDIRS) $(DOCDIR) \
$(TTF_FONT_DIR) $(CATALOG_DIR)
#-------------------------------------------------------
# Variables for SASS->CSS conversion and other web stuff
styles2021_sass = $(sort $(wildcard source-assets/styles2021/sass/*.sass))
styles2022_sass_main = source-assets/styles2022/sass/style.sass
styles2022_sass_custom = $(wildcard source-assets/styles2022/sass/custom/*.sass)
styles2022_sass_bulma = $(wildcard source-assets/styles2022/sass/bulma-0.9.3/bulma/sass/*/*.sass)
#############################################################
all: $(DEV_SUSEXSL_CATALOG) generate_xslns sass-css
@echo "Ready to install..."
#-----------------------------
install: | $(INST_DIRECTORIES)
install -m644 $(DEV_CATALOG_DIR)/*.xml $(CATALOG_DIR)
install -m644 COPYING* $(DOCDIR)
install -m644 fonts/*.ttf $(TTF_FONT_DIR)
tar c --mode=u+w,go+r-w,a-s -C $(DIR2005) . | (cd $(STYLEDIR2005); tar xp)
tar c --mode=u+w,go+r-w,a-s -C $(DEV_DIR2005) . | (cd $(STYLEDIR2005-NS); tar xp)
tar c --mode=u+w,go+r-w,a-s -C $(DIR2013_DAPS) . | (cd $(DAPSSTYLEDIR2013); tar xp)
tar c --mode=u+w,go+r-w,a-s -C $(DEV_DIR2013_DAPS) . | (cd $(DAPSSTYLEDIR2013-NS); tar xp)
tar c --mode=u+w,go+r-w,a-s -C $(DIR2013_OPENSUSE) . | (cd $(OPENSUSESTYLEDIR2013); tar xp)
tar c --mode=u+w,go+r-w,a-s -C $(DEV_DIR2013_OPENSUSE) . | (cd $(OPENSUSESTYLEDIR2013-NS); tar xp)
tar c --mode=u+w,go+r-w,a-s -C $(DIR2013_SUSE) . | (cd $(SUSESTYLEDIR2013); tar xp)
tar c --mode=u+w,go+r-w,a-s -C $(DEV_DIR2013_SUSE) . | (cd $(SUSESTYLEDIR2013-NS); tar xp)
tar c --mode=u+w,go+r-w,a-s -C $(DIR2021_SUSE) . | (cd $(SUSESTYLEDIR2021-NS); tar xp)
tar c --mode=u+w,go+r-w,a-s -C $(DIR2022_SUSE) . | (cd $(SUSESTYLEDIR2022-NS); tar xp)
tar c --mode=u+w,go+r-w,a-s -C $(DIRSBP) . | (cd $(SBPDIR); tar xp)
tar c --mode=u+w,go+r-w,a-s -C $(DIRTRD) . | (cd $(TRDDIR); tar xp)
for SDIR in $(INST_STYLEDIRS); do \
sed "s/@@#version@@/$(VERSION)/" $$SDIR/VERSION.xsl > $$SDIR/VERSION.xsl.0; \
mv $$SDIR/VERSION.xsl.0 $$SDIR/VERSION.xsl; \
cp $$SDIR/VERSION.xsl $$SDIR/VERSION; \
done
#-----------------------------
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
#-----------------------------
# auto-generate the DocBook5 (xsl-ns) stylesheets
# Let's be super lazy and generate them every time make is called by
# making this target PHONY
#
.PHONY: generate_xslns
generate_xslns: | $(LOCAL_STYLEDIRS)
bin/xslns-build $(DIR2005) $(DEV_DIR2005)
bin/xslns-build $(DIR2013_DAPS) $(DEV_DIR2013_DAPS)
bin/xslns-build $(DIR2013_OPENSUSE) $(DEV_DIR2013_OPENSUSE)
bin/xslns-build $(DIR2013_SUSE) $(DEV_DIR2013_SUSE)
# Generate XML catalog file:
# * replace xml:base attribute
# * replace "build/stylesheet/" directory part
$(DEV_SUSEXSL_CATALOG): $(SUSEXSL_CATALOG) | $(DEV_CATALOG_DIR)
@echo "Creating XML catalog $@..."
@sed 's_xml:base=".."_xml:base="file://$(XSL_INST_PATH)"_g;s_"build/stylesheet/_"_g' $< > $@
# create needed directories
#
$(INST_DIRECTORIES) $(DEV_DIRECTORIES) $(BUILD_DIR):
@mkdir -p $@
#-----------------------------
# create tarball
#
# minor disadvantages of using Git here:
# * you need to commit before things are packaged (combined with a reminder,
# may actually be positive)
# * it does not work outside of a Git repo (should be inconsequential)
.PHONY: dist
dist: | $(BUILD_DIR)
@if [[ -n $$(git status -s | sed -n '/^\?\?/!p') ]]; then \
echo "There appear to be uncommitted files in this repo. Commit or stash before building a package."; \
exit 1; \
fi
git archive --format=tar.gz -o $(BUILD_DIR)/$(PACKAGE)-$(VERSION).tar.gz --prefix=$(PACKAGE)-$(VERSION)/ HEAD
@echo "Successfully created $(BUILD_DIR)/$(PACKAGE)-$(VERSION).tar.gz"
PHONY: dist-clean
dist-clean:
rm -f $(BUILD_DIR)/$(PACKAGE)-$(VERSION).tar.gz
rmdir $(BUILD_DIR) 2>/dev/null || true
PHONY: sass-css
sass-css: suse2021-ns/static/css/style.css suse2022-ns/static/css/style.css
suse2021-ns/static/css/style.css: $(styles2021_sass)
sassc $< $@
suse2022-ns/static/css/style.css: $(styles2022_sass_main) $(styles2022_sass_custom) $(styles2022_sass_bulma)
sassc $< $@
PHONY: sass-clean
sass-clean:
rm suse2021-ns/static/css/style.css
rm suse2022-ns/static/css/style.css