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
|
# Copyright (C) 2012-2020 SUSE Software Solutions Germany GmbH
#
# Author:
# Frank Sundermeyer <fsundermeyer at opensuse dot org>
#
# Profiling stuff for DAPS
#
# Please submit feedback or patches to
# <fsundermeyer at opensuse dot org>
#
# includes are set in selector.mk
# include $(DAPSROOT)/make/setfiles.mk
#
# Set $(PROFILES) and the profiling stylesheets.
# AsciiDoc:
#
# If ADOC_POST is set to yes, we use ADOC_POST_STYLE, otherwise a noprofile
# stylesheet
#
# XML:
#
# If PROFILE_URN is set, we resolve it, otherwise we use a nonprofiling
# stylesheet
ifeq "$(strip $(SRC_FORMAT))" "adoc"
PROFILES := $(subst $(ADOC_DIR)/,$(PROFILEDIR)/,$(MAIN))
ifeq "$(strip $(ADOC_POST))" "yes"
PROFILE_STYLESHEET := $(ADOC_POST_STYLE)
endif
else
PROFILES := $(sort $(subst $(DOC_DIR)/xml/,$(PROFILEDIR)/,$(SRCFILES)))
ifdef PROFILE_URN
# Resolve profile urn because saxon does not accept urns
ifeq "$(shell expr substr $(PROFILE_URN) 1 4 2>/dev/null)" "urn:"
PROFILE_STYLESHEET := $(shell $(DAPSROOT)/libexec/xml_cat_resolver $(PROFILE_URN) 2>/dev/null)
else
PROFILE_STYLESHEET := $(PROFILE_URN)
endif
#
# depending on the distribution, xmlcatalog returns file://... or file:...
# make sure both cases are matched
#
PROFILE_STYLESHEET := $(patsubst //%,%,$(subst file:%,%,$(PROFILE_STYLESHEET)))
ifeq "$(strip $(PROFILE_STYLESHEET))" ""
$(error $(shell ccecho "error" "Could not resolve URN \"$(PROFILE_URN)\" with xmlcatalog via catalog file \"$(XML_MAIN_CATALOG)\""))
endif
endif
endif
#
# If not profiling stylesheet has been set by now, we need to use a
# noprofiling stylesheet
#
ifeq "$(strip $(PROFILE_STYLESHEET))" ""
ifeq "$(DOCBOOK_VERSION)" "5"
PROFILE_STYLESHEET := $(DAPSROOT)/daps-xslt/profiling/noprofile5.xsl
else
PROFILE_STYLESHEET := $(DAPSROOT)/daps-xslt/profiling/noprofile4.xsl
endif
endif
# Allows to set a custom publication date
#
ifdef SETDATE
ifdef PROFILE_URN
PROFSTRINGS += --stringparam "pubdate=$(SETDATE)"
.INTERMEDIATE: $(PROFILES)
else
$(warn $(shell ccecho "warn" "Warning: Ignoring --setdate option since $(MAIN) does not include a profiling URN"))
endif
endif
# Also needs a prerequisite on the entity files, since entities are resolved
# during profiling, so profiling needs to be redone whenever the entities
# change.
# The like is also true for the DC file.
#
$(PROFILES):
ifdef TEXTFILES
$(PROFILES): link_txt_files
endif
.PHONY: profile
profile: $(PROFILES)
ifeq "$(MAKECMDGOALS)" "profile"
@ccecho "result" "Profiled sources can be found at\n$(PROFILEDIR)"
endif
# Profiling stringparams
#... are already defined in setfiles.mk
#--------------------------------------------------
# Normal profiling
#
# Creating the profiled xml sources
#
# linking the entity files is not needed when profiling, because the
# entities are already resolved
#
ifeq "$(strip $(SRC_FORMAT))" "xml"
$(PROFILEDIR)/%.xml: $(DOC_DIR)/xml/%.xml $(ENTITIES_DOC) $(DOCCONF) | $(PROFILEDIR)
else
$(PROFILEDIR)/%.xml: $(ADOC_DIR)/%.xml $(ENTITIES_DOC) $(DOCCONF) | $(PROFILEDIR)
endif
ifeq "$(VERBOSITY)" "2"
@(tput el1; echo -en "\r Profiling $<")
endif
$(XSLTPROC) --output $@ $(PROFSTRINGS) $(HROOTSTRING) \
--stringparam "filename=$(notdir $<)" \
--stylesheet $(PROFILE_STYLESHEET) --file $< $(XSLTPROCESSOR)
# Files included with xi:include parse="text" $(TEXTFILES) are linked into
# the profile directory. the profiling stylesheets rewrites all paths to
# these files with just the filename (href="../foo/bar.txt" -> href="bar.txt")
# Since these text files can come from arbitrary locations, it is not possible
# to write a pattern rule for creating the links. We use the
# PHONY link_txt_files to generate them.
#
# "Clean" paths and file:// entries are supported, other protocols not
#
ifdef TEXTFILES
.PHONY: link_txt_files
link_txt_files: | $(PROFILEDIR)
for TF in $(TEXTFILES); do \
TF=$${TF#file://*}; \
if [[ "$${TF:0:1}" != "/" ]]; then \
TF="$(DOC_DIR)/xml/$$TF"; \
(cd $(PROFILEDIR) && ln -sf $$(realpath --relative-to="$(PROFILEDIR)" $$TF)); \
else \
(cd $(PROFILEDIR) && ln -sf $$TF); \
fi; \
done
endif
|