Aurélien Larcher
2018-11-05 11c2e2569bbe562fe5f88c7c1eedf86322885661
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
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
 
#
# Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, Aurelien Larcher. All rights reserved.
#
BUILD_BITS  ?= NO_ARCH
BUILD_STYLE ?= archive
 
include $(WS_MAKE_RULES)/common.mk
 
MKFONTSCALE = mkfontscale
MKFONTDIR = mkfontdir
 
ETCFONTSDIR = $(ETCDIR)/fonts
ETCFONTSCONFDIR = $(ETCFONTSDIR)/conf.avail
USRSHAREFONTSDIR = $(USRSHAREDIR)/fonts
 
#
# Font type macros 
#
 
TTFFONTDIR = TrueType
OTFFONTDIR = OpenType
X11FONTDIR = X11
PKGFONTDIR?= $($(FONT_TYPE)FONTDIR)
 
# For compatibility
USRSHARETTFONTSDIR = $(USRSHAREFONTSDIR)/$(TTFFONTDIR)
USRSHAREOTFONTSDIR = $(USRSHAREFONTSDIR)/$(OTFFONTDIR)
 
TTFFONTSRC = ttf
OTFFONTSRC = otf
X11FONTSRC =
PKGFONTSRC?= $($(FONT_TYPE)FONTSRC)
 
TTFFONTCLS = truetype 
OTFFONTCLS = opentype 
X11FONTCLS = xorg 
PKGFONTCLS?= $($(FONT_TYPE)FONTCLS)
 
TTFFONTEXT = *.ttc *.tte *.ttf
OTFFONTEXT = *.otf *.otc *.ttf *.ttc
X11FONTEXT =
PKGFONTEXT?= $($(FONT_TYPE)FONTEXT)
 
PKGFONTCONFSRC = fontconfig
PKGFONTCONFEXT = *.conf
 
#
# Proto area directories
#
 
PROTOFONTSDIR = $(PROTO_DIR)$(USRSHAREFONTSDIR)
PROTOTTFFONTSDIR = $(PROTO_DIR)$(TTFFONTDIR)
PROTOOTFFONTSDIR = $(PROTO_DIR)$(OTFFONTDIR)
PROTOX11FONTSDIR = $(PROTO_DIR)$(X11FONTDIR)
PROTOPKGFONTSDIR = $(PROTO$(FONT_TYPE)FONTSDIR)
 
PROTOFONTSCONFDIR = $(PROTO_DIR)$(ETCFONTSCONFDIR)
 
#
# Default rules
#
 
COMPONENT_FONT_TYPE = $(PKGFONTCLS)
COMPONENT_FONT_NAME?= $(COMPONENT_NAME)
COMPONENT_FMRI = \
  system/font/$(strip $(COMPONENT_FONT_TYPE))/$(strip $(COMPONENT_FONT_NAME))
COMPONENT_CLASSIFICATION = System/Fonts
 
COMPONENT_FONT_DEST_DIR?= $(USRSHAREFONTSDIR)/$(PKGFONTDIR)/$(COMPONENT_FONT_NAME)
COMPONENT_FONT_SRC_DIR ?= $(PKGFONTSRC)
COMPONENT_FONT_FILES    =
 
COMPONENT_FONTCONF_DEST_DIR?= $(ETCFONTSCONFDIR)
COMPONENT_FONTCONF_SRC_DIR ?= $(PKGFONTCONFSRC)
COMPONENT_FONTCONF_FILES    = $(PKGFONTCONFEXT)
 
ifeq ($(strip $(BUILD_STYLE)),archive)
 
POST_INSTALL_MKFONT?=no 
 
COMPONENT_BUILD_ACTION?= true
ifeq ($(strip $(POST_INSTALL_MKFONT)),no)
COMPONENT_BUILD_ACTION = \
  cd $(@D)/$(COMPONENT_FONT_SRC_DIR); $(MKFONTSCALE); $(MKFONTDIR);
endif
 
$(BUILD_DIR)/%/.built: $(SOURCE_DIR)/.prep
    ($(RM) -rf $(@D) ; $(MKDIR) $(@D))
    $(CLONEY) $(SOURCE_DIR) $(@D)
    $(COMPONENT_PRE_BUILD_ACTION)
    ($(COMPONENT_BUILD_ACTION))
    $(COMPONENT_POST_BUILD_ACTION)
    $(TOUCH) $@
 
build: $(BUILD_$(MK_BITS))
 
COMPONENT_FONT_POST_INSTALL_ACTION = \
  ( $(MKFONTSCALE) $(PROTO_DIR)$(COMPONENT_FONT_DEST_DIR); \
    $(MKFONTDIR) $(PROTO_DIR)$(COMPONENT_FONT_DEST_DIR) )
 
ifeq ($(strip $(POST_INSTALL_MKFONT)),yes)
COMPONENT_POST_INSTALL_ACTION+=$(COMPONENT_FONT_POST_INSTALL_ACTION)
else
COMPONENT_FONT_FILES += fonts.dir
COMPONENT_FONT_FILES += fonts.scale
endif
 
COMPONENT_INSTALL_ACTION = \
  cd $(@D)/$(COMPONENT_FONT_SRC_DIR) && \
    $(INSTALL) -m 0444 $(COMPONENT_FONT_FILES) \
      $(PROTO_DIR)$(COMPONENT_FONT_DEST_DIR) ; \
  if [ -n "$(strip $(COMPONENT_FONTCONF_FILES))" ]; \
  then \
    cd $(@D)/$(COMPONENT_FONTCONF_SRC_DIR) && \
      $(INSTALL) -m 0444 $(COMPONENT_FONTCONF_FILES) \
        $(PROTO_DIR)$(COMPONENT_FONTCONF_DEST_DIR) ; \
  fi;
 
$(BUILD_DIR)/%/.installed: $(BUILD_DIR)/%/.built
    $(MKDIR) $(@D)
    $(COMPONENT_PRE_INSTALL_ACTION)
    -$(RM) -r $(PROTO_DIR)$(COMPONENT_FONT_DEST_DIR)
    $(MKDIR) $(PROTO_DIR)$(COMPONENT_FONT_DEST_DIR)
    $(MKDIR) $(PROTO_DIR)$(COMPONENT_FONTCONF_DEST_DIR)
    ($(COMPONENT_INSTALL_ACTION))
    $(COMPONENT_POST_INSTALL_ACTION)
    $(TOUCH) $@
 
install: $(INSTALL_$(MK_BITS))
 
clean::
    $(RM) -r $(BUILD_DIR) $(PROTO_DIR)
 
endif
 
ifeq ($(strip $(BUILD_STYLE)),configure)
# We don't compress individual font files so that we get better compression
# at higher levels in ZFS & IPS, and so that we aren't constantly replacing
# font files in every build just because the timestamp in the compressed
# version changed.
CONFIGURE_OPTIONS += --without-compression
endif
 
# Add font metadata to packages to make it easier to search for fonts
$(CANONICAL_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.mogrified): PUBLISH_TRANSFORMS += $(@:.mogrified=.font-transforms)
 
$(CANONICAL_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.mogrified): font-transforms
font-transforms: $(CANONICAL_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.font-transforms)
 
$(MANIFEST_BASE)-%.font-transforms: %.p5m
    $(PERL) $(WS_TOOLS)/generate_font_metadata.pl \
    -p $(PROTO_DIR) -m $< > $@ || ( rm $@ ; exit 1 )
 
# Package containing fc-scan used in generate_font_metadata.pl
REQUIRED_PACKAGES    += system/library/fontconfig
# Package containing $(MKFONTSCALE) & $(MKFONTDIR)
REQUIRED_PACKAGES    += x11/font-utilities